fhirbuilder
Version:
Another FHIR Tool to build FHIR Resources
284 lines (282 loc) • 11.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppointmentBuilder = void 0;
const models_1 = require("../../models");
const base_1 = require("../base");
/**
* @version R4 (v4.0.1)
* @summary FHIR® Specification by HL7®
* @description Class for building a Appointment
* @class AppointmentBuilder
* @extends {DomainResourceBuilder}
* @implements {IAppointmentBuilder}
* @author Roberto Araneda Espinoza
*/
class AppointmentBuilder extends base_1.DomainResourceBuilder {
appointment;
constructor() {
super();
this.appointment = new models_1.Appointment();
}
/**
* @description Sets the resource type to Appointment
* @param json - the json to parse
* @returns {this}
*/
fromJSON(json) {
const incomingData = typeof json === 'string' ? JSON.parse(json) : json;
Object.assign(this.appointment, incomingData);
return this;
}
/**
* @description Adds a primitive extension to the element
* @param param - the field to add the extension to
* @param extension - the extension to add
* @returns {this}
* @example addPrimitiveExtension('_value', { value: 'test' })
*/
addPrimitiveExtension(param, extension) {
this.appointment[param] = extension;
return this;
}
/**
* @description Builds the model
* @returns {Appointment}
*/
build() {
return Object.assign(this.appointment, super.build());
}
/**
* @description Adds a value to the identifier array
* @description This records identifiers associated with this appointment concern that are defined by business processes and/or used to refer to it when a direct URL reference to the resource itself is not appropriate (e.g. in CDA documents, or in written / printed documentation).
* @param value - the value to add
* @returns {this}
*/
addIdentifier(value) {
this.appointment.identifier = this.appointment.identifier || [];
this.appointment.identifier.push(value);
return this;
}
/**
* @description Sets the status value
* @description The overall status of the Appointment. Each of the participants has their own participation status which indicates their involvement in the process, however this status indicates the shared status.
* @param value - the value to set
* @returns {this}
*/
setStatus(value) {
this.appointment.status = value;
return this;
}
/**
* @description Sets the cancelationReason value
* @description The coded reason for the appointment being cancelled. This is often used in reporting/billing/futher processing to determine if further actions are required, or specific fees apply.
* @param value - the value to set
* @returns {this}
*/
setCancelationReason(value) {
this.appointment.cancelationReason = value;
return this;
}
/**
* @description Adds a value to the serviceCategory array
* @description A broad categorization of the service that is to be performed during this appointment.
* @param value - the value to add
* @returns {this}
*/
addServiceCategory(value) {
this.appointment.serviceCategory = this.appointment.serviceCategory || [];
this.appointment.serviceCategory.push(value);
return this;
}
/**
* @description Adds a value to the serviceType array
* @description The specific service that is to be performed during this appointment.
* @param value - the value to add
* @returns {this}
*/
addServiceType(value) {
this.appointment.serviceType = this.appointment.serviceType || [];
this.appointment.serviceType.push(value);
return this;
}
/**
* @description Adds a value to the specialty array
* @description The specialty of a practitioner that would be required to perform the service requested in this appointment.
* @param value - the value to add
* @returns {this}
*/
addSpecialty(value) {
this.appointment.specialty = this.appointment.specialty || [];
this.appointment.specialty.push(value);
return this;
}
/**
* @description Sets the appointmentType value
* @description The style of appointment or patient that has been booked in the slot (not service type).
* @param value - the value to set
* @returns {this}
*/
setAppointmentType(value) {
this.appointment.appointmentType = value;
return this;
}
/**
* @description Adds a value to the reasonCode array
* @description The coded reason that this appointment is being scheduled. This is more clinical than administrative.
* @param value - the value to add
* @returns {this}
*/
addReasonCode(value) {
this.appointment.reasonCode = this.appointment.reasonCode || [];
this.appointment.reasonCode.push(value);
return this;
}
/**
* @description Adds a value to the reasonReference array
* @description Reason the appointment has been scheduled to take place, as specified using information from another resource. When the patient arrives and the encounter begins it may be used as the admission diagnosis. The indication will typically be a Condition (with other resources referenced in the evidence.detail), or a Procedure.
* @param value - the value to add
* @returns {this}
*/
addReasonReference(value) {
this.appointment.reasonReference = this.appointment.reasonReference || [];
this.appointment.reasonReference.push(value);
return this;
}
/**
* @description Sets the priority value
* @description The priority of the appointment. Can be used to make informed decisions if needing to re-prioritize appointments. (The iCal Standard specifies 0 as undefined, 1 as highest, 9 as lowest priority).
* @param value - the value to set
* @returns {this}
*/
setPriority(value) {
this.appointment.priority = value;
return this;
}
/**
* @description Sets the description value
* @description The brief description of the appointment as would be shown on a subject line in a meeting request, or appointment list. Detailed or expanded information should be put in the comment field.
* @param value - the value to set
* @returns {this}
*/
setDescription(value) {
this.appointment.description = value;
return this;
}
/**
* @description Adds a value to the supportingInformation array
* @description Additional information to support the appointment provided when making the appointment.
* @param value - the value to add
* @returns {this}
*/
addSupportingInformation(value) {
this.appointment.supportingInformation = this.appointment.supportingInformation || [];
this.appointment.supportingInformation.push(value);
return this;
}
/**
* @description Sets the start value
* @description Date/Time that the appointment is to take place.
* @param value - the value to set
* @returns {this}
*/
setStart(value) {
this.appointment.start = value;
return this;
}
/**
* @description Sets the end value
* @description Date/Time that the appointment is to conclude.
* @param value - the value to set
* @returns {this}
*/
setEnd(value) {
this.appointment.end = value;
return this;
}
/**
* @description Sets the minutesDuration value
* @description Number of minutes that the appointment is to take. This can be less than the duration between the start and end times. For example, where the actual time of appointment is only an estimate or if a 30 minute appointment is being requested, but any time would work. Also, if there is, for example, a planned 15 minute break in the middle of a long appointment, the duration may be 15 minutes less than the difference between the start and end.
* @param value - the value to set
* @returns {this}
*/
setMinutesDuration(value) {
this.appointment.minutesDuration = value;
return this;
}
/**
* @description Adds a value to the slot array
* @description The slots from the participants' schedules that will be filled by the appointment.
* @param value - the value to add
* @returns {this}
*/
addSlot(value) {
this.appointment.slot = this.appointment.slot || [];
this.appointment.slot.push(value);
return this;
}
/**
* @description Sets the created value
* @description The date that this appointment was initially created. This could be different to the meta.lastModified value on the initial entry, as this could have been before the resource was created on the FHIR server, and should remain unchanged over the lifespan of the appointment.
* @param value - the value to set
* @returns {this}
*/
setCreated(value) {
this.appointment.created = value;
return this;
}
/**
* @description Sets the comment value
* @description Additional comments about the appointment.
* @param value - the value to set
* @returns {this}
*/
setComment(value) {
this.appointment.comment = value;
return this;
}
/**
* @description Sets the patientInstruction value
* @description While Appointment.comment contains information for internal use, Appointment.patientInstructions is used to capture patient facing information about the Appointment (e.g. please bring your referral or fast from 8pm night before).
* @param value - the value to set
* @returns {this}
*/
setPatientInstruction(value) {
this.appointment.patientInstruction = value;
return this;
}
/**
* @description Adds a value to the basedOn array
* @description The service request this appointment is allocated to assess (e.g. incoming referral or procedure request).
* @param value - the value to add
* @returns {this}
*/
addBasedOn(value) {
this.appointment.basedOn = this.appointment.basedOn || [];
this.appointment.basedOn.push(value);
return this;
}
/**
* @description Adds a value to the participant array
* @description List of participants involved in the appointment.
* @param value - the value to add
* @returns {this}
*/
addParticipant(value) {
this.appointment.participant = this.appointment.participant || [];
this.appointment.participant.push(value);
return this;
}
/**
* @description Adds a value to the requestedPeriod array
* @description A set of date ranges (potentially including times) that the appointment is preferred to be scheduled within.
The duration (usually in minutes) could also be provided to indicate the length of the appointment to fill and populate the start/end times for the actual allocated time. However, in other situations the duration may be calculated by the scheduling system.
* @param value - the value to add
* @returns {this}
*/
addRequestedPeriod(value) {
this.appointment.requestedPeriod = this.appointment.requestedPeriod || [];
this.appointment.requestedPeriod.push(value);
return this;
}
}
exports.AppointmentBuilder = AppointmentBuilder;