fhirbuilder
Version:
Another FHIR Tool to build FHIR Resources
44 lines (43 loc) • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PatientContactValidator = PatientContactValidator;
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 PatientContact model
*/
const modelFields = (0, definitions_1.createBackboneDefinition)([
{ name: 'relationship', type: 'CodeableConcept', isArray: true, isRequired: false },
{ name: 'name', type: 'HumanName', isArray: false, isRequired: false },
{ name: 'telecom', type: 'ContactPoint', isArray: true, isRequired: false },
{ name: 'address', type: 'Address', isArray: false, isRequired: false },
{
name: 'gender',
type: 'code',
isArray: false,
isRequired: false,
enumValues: ['male', 'female', 'other', 'unknown'],
},
{ name: '_gender', type: 'Element', isArray: false, isRequired: false },
{ name: 'organization', type: 'Reference', isArray: false, isRequired: false, referenceTypes: ['Organization'] },
{ name: 'period', type: 'Period', isArray: false, isRequired: false },
]);
/**
* @description Validates the PatientContact model
* @param dataToValidate - the PatientContact model to validate
* @param path - the path to the model
* @param errors - the errors array
*/
function PatientContactValidator(dataToValidate, path = 'PatientContact', errors = []) {
// Ensure that the model fields match the attributes of the model
(0, utils_1.AssertModelFieldsMatchAttributes)(modelFields, new models_1.PatientContact());
// Validate the model and add any errors to the errors array
(0, base_1.ModelValidator)({
dataToValidate,
modelDefinition: modelFields,
path,
errors,
});
}