UNPKG

fhirbuilder

Version:
40 lines (39 loc) 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AllergyIntoleranceReactionValidator = AllergyIntoleranceReactionValidator; 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 AllergyIntoleranceReaction model */ const modelFields = (0, definitions_1.createBackboneDefinition)([ { name: 'substance', type: 'CodeableConcept', isArray: false, isRequired: false }, { name: 'manifestation', type: 'CodeableConcept', isArray: true, isRequired: true }, { name: 'description', type: 'string', isArray: false, isRequired: false }, { name: '_description', type: 'Element', isArray: false, isRequired: false }, { name: 'onset', type: 'dateTime', isArray: false, isRequired: false }, { name: '_onset', type: 'Element', isArray: false, isRequired: false }, { name: 'severity', type: 'code', isArray: false, isRequired: false, enumValues: ['mild', 'moderate', 'severe'] }, { name: '_severity', type: 'Element', isArray: false, isRequired: false }, { name: 'exposureRoute', type: 'CodeableConcept', isArray: false, isRequired: false }, { name: 'note', type: 'Annotation', isArray: true, isRequired: false }, ]); /** * @description Validates the AllergyIntoleranceReaction model * @param dataToValidate - the AllergyIntoleranceReaction model to validate * @param path - the path to the model * @param errors - the errors array */ function AllergyIntoleranceReactionValidator(dataToValidate, path = 'AllergyIntoleranceReaction', errors = []) { // Ensure that the model fields match the attributes of the model (0, utils_1.AssertModelFieldsMatchAttributes)(modelFields, new models_1.AllergyIntoleranceReaction()); // Validate the model and add any errors to the errors array (0, base_1.ModelValidator)({ dataToValidate, modelDefinition: modelFields, path, errors, }); }