UNPKG

eirenerx-sdk

Version:
24 lines (20 loc) 864 B
var jsonSchema = require('json-schema'); var demographics = require('./schemas/demographics.json'); var allergies = require('./schemas/allergies.json'); module.exports = function(patientData) { // validate demographics // must contain required elements: // - first_name, last_name, home_phone, gender, dob, ssn, address, city, state, zip, identifier // validate allergies // - Allergies must be empty array, // - if not empty, it should match a specific pattern // { allergy: ...., description: ...., onset_date: ....} var demoResults = jsonSchema.validate(patientData.demographics, demographics); var alrResults = jsonSchema.validate(patientData.allergies, allergies); // if patient Data is valid then return null return { valid: demoResults.valid && alrResults.valid, demographics: demoResults, allergies: alrResults }; };