UNPKG

fhirbuilder

Version:
42 lines (41 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ElementBuilder = void 0; /** * @description Base Element Builder * @see {@link https://www.hl7.org/fhir/datatypes.html#Element} * @implements {IElementBuilder} * @author Roberto Araneda */ class ElementBuilder { element; constructor() { this.element = {}; } /** * @description Unique id for inter-element referencing * @param id * @returns {this} */ setId(id) { this.element.id = id; return this; } /** * @description Additional content defined by implementations * @param extension * @returns {this} */ addExtension(extension) { this.element.extension = this.element.extension || []; this.element.extension.push(extension); return this; } /** * @description Returns the element */ build() { return JSON.parse(JSON.stringify(this.element)); } } exports.ElementBuilder = ElementBuilder;