UNPKG

fhirbuilder

Version:
112 lines (111 loc) 3.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SignatureBuilder = 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 Signature * @class SignatureBuilder * @extends {Builder} * @implements {ISignatureBuilder} * @author Roberto Araneda Espinoza */ class SignatureBuilder extends base_1.ElementBuilder { signature; constructor() { super(); this.signature = new models_1.Signature(); } /** * @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.signature[param] = extension; return this; } /** * @description Builds the model * @returns {Signature} */ build() { return Object.assign(this.signature, super.build()); } /** * @description Adds a value to the type array * @description An indication of the reason that the entity signed this document. This may be explicitly included as part of the signature information and can be used when determining accountability for various actions concerning the document. * @param value - the value to add * @returns {this} */ addType(value) { this.signature.type = this.signature.type || []; this.signature.type.push(value); return this; } /** * @description Sets the when value * @description When the digital signature was signed. * @param value - the value to set * @returns {this} */ setWhen(value) { this.signature.when = value; return this; } /** * @description Sets the who value * @description A reference to an application-usable description of the identity that signed (e.g. the signature used their private key). * @param value - the value to set * @returns {this} */ setWho(value) { this.signature.who = value; return this; } /** * @description Sets the onBehalfOf value * @description A reference to an application-usable description of the identity that is represented by the signature. * @param value - the value to set * @returns {this} */ setOnBehalfOf(value) { this.signature.onBehalfOf = value; return this; } /** * @description Sets the targetFormat value * @description A mime type that indicates the technical format of the target resources signed by the signature. * @param value - the value to set * @returns {this} */ setTargetFormat(value) { this.signature.targetFormat = value; return this; } /** * @description Sets the sigFormat value * @description A mime type that indicates the technical format of the signature. Important mime types are application/signature+xml for X ML DigSig, application/jose for JWS, and image/* for a graphical image of a signature, etc. * @param value - the value to set * @returns {this} */ setSigFormat(value) { this.signature.sigFormat = value; return this; } /** * @description Sets the data value * @description The base64 encoding of the Signature content. When signature is not recorded electronically this element would be empty. * @param value - the value to set * @returns {this} */ setData(value) { this.signature.data = value; return this; } } exports.SignatureBuilder = SignatureBuilder;