UNPKG

fhirbuilder

Version:
39 lines (38 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PatientLinkValidator = PatientLinkValidator; const definitions_1 = require("../base/definitions"); const base_1 = require("../base"); const utils_1 = require("../../../commons/utils"); const models_1 = require("../../../../r4/models"); /** * @description The model fields for the PatientLink model */ const modelFields = (0, definitions_1.createBackboneDefinition)([ { name: 'other', type: 'Reference', isArray: false, isRequired: true, referenceTypes: ['Patient', 'RelatedPerson'] }, { name: 'type', type: 'code', isArray: false, isRequired: true, enumValues: ['replaced-by', 'replaces', 'refer', 'seealso'], }, { name: '_type', type: 'Element', isArray: false, isRequired: false }, ]); /** * @description Validates the PatientLink model * @param dataToValidate - the PatientLink model to validate * @param path - the path to the model * @param errors - the errors array */ function PatientLinkValidator(dataToValidate, path = 'PatientLink', errors = []) { // Ensure that the model fields match the attributes of the model (0, utils_1.AssertModelFieldsMatchAttributes)(modelFields, new models_1.PatientLink()); // Validate the model and add any errors to the errors array (0, base_1.ModelValidator)({ dataToValidate, modelDefinition: modelFields, path, errors, }); }