UNPKG

fhirbuilder

Version:
165 lines (164 loc) 5.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrganizationBuilder = 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 Organization * @class OrganizationBuilder * @extends {DomainResourceBuilder} * @implements {IOrganizationBuilder} * @author Roberto Araneda Espinoza */ class OrganizationBuilder extends base_1.DomainResourceBuilder { organization; constructor() { super(); this.organization = new models_1.Organization(); } /** * @description Sets the resource type to Organization * @param json - the json to parse * @returns {this} */ fromJSON(json) { const incomingData = typeof json === 'string' ? JSON.parse(json) : json; Object.assign(this.organization, 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) { const arrayParam = ['_alias']; if (arrayParam.includes(param)) { this.organization[param] = this.organization[param] || []; this.organization[param].push(extension); return this; } const localParam = param; this.organization[localParam] = extension; return this; } /** * @description Builds the model * @returns {Organization} */ build() { return Object.assign(this.organization, super.build()); } /** * @description Adds a value to the identifier array * @description Identifier for the organization that is used to identify the organization across multiple disparate systems. * @param value - the value to add * @returns {this} */ addIdentifier(value) { this.organization.identifier = this.organization.identifier || []; this.organization.identifier.push(value); return this; } /** * @description Sets the active value * @description Whether the organization's record is still in active use. * @param value - the value to set * @returns {this} */ setActive(value) { this.organization.active = value; return this; } /** * @description Adds a value to the type array * @description The kind(s) of organization that this is. * @param value - the value to add * @returns {this} */ addType(value) { this.organization.type = this.organization.type || []; this.organization.type.push(value); return this; } /** * @description Sets the name value * @description A name associated with the organization. * @param value - the value to set * @returns {this} */ setName(value) { this.organization.name = value; return this; } /** * @description Adds a value to the alias array * @description A list of alternate names that the organization is known as, or was known as in the past. * @param value - the value to add * @returns {this} */ addAlias(value) { this.organization.alias = this.organization.alias || []; this.organization.alias.push(value); return this; } /** * @description Adds a value to the telecom array * @description A contact detail for the organization. * @param value - the value to add * @returns {this} */ addTelecom(value) { this.organization.telecom = this.organization.telecom || []; this.organization.telecom.push(value); return this; } /** * @description Adds a value to the address array * @description An address for the organization. * @param value - the value to add * @returns {this} */ addAddress(value) { this.organization.address = this.organization.address || []; this.organization.address.push(value); return this; } /** * @description Sets the partOf value * @description The organization of which this organization forms a part. * @param value - the value to set * @returns {this} */ setPartOf(value) { this.organization.partOf = value; return this; } /** * @description Adds a value to the contact array * @description Contact for the organization for a certain purpose. * @param value - the value to add * @returns {this} */ addContact(value) { this.organization.contact = this.organization.contact || []; this.organization.contact.push(value); return this; } /** * @description Adds a value to the endpoint array * @description Technical endpoints providing access to services operated for the organization. * @param value - the value to add * @returns {this} */ addEndpoint(value) { this.organization.endpoint = this.organization.endpoint || []; this.organization.endpoint.push(value); return this; } } exports.OrganizationBuilder = OrganizationBuilder;