cqm-models 1.1.1.0 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +1 -1
- data/.github/workflows/gitleaks_github_actions.yml +28 -0
- data/.travis.yml +3 -3
- data/README.md +12 -9
- data/app/assets/javascripts/AdverseEvent.js +9 -3
- data/app/assets/javascripts/AllDataElements.js +18 -6
- data/app/assets/javascripts/AllergyIntolerance.js +8 -2
- data/app/assets/javascripts/AssessmentOrder.js +8 -2
- data/app/assets/javascripts/AssessmentPerformed.js +11 -3
- data/app/assets/javascripts/AssessmentRecommended.js +8 -2
- data/app/assets/javascripts/CareGoal.js +10 -3
- data/app/assets/javascripts/CommunicationPerformed.js +12 -6
- data/app/assets/javascripts/DeviceApplied.js +9 -2
- data/app/assets/javascripts/DeviceOrder.js +8 -2
- data/app/assets/javascripts/DeviceRecommended.js +8 -2
- data/app/assets/javascripts/Diagnosis.js +8 -2
- data/app/assets/javascripts/DiagnosticStudyOrder.js +8 -2
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +9 -2
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +8 -2
- data/app/assets/javascripts/EncounterOrder.js +9 -2
- data/app/assets/javascripts/EncounterPerformed.js +11 -5
- data/app/assets/javascripts/EncounterRecommended.js +8 -2
- data/app/assets/javascripts/FamilyHistory.js +8 -2
- data/app/assets/javascripts/ImmunizationAdministered.js +9 -2
- data/app/assets/javascripts/ImmunizationOrder.js +8 -2
- data/app/assets/javascripts/InterventionOrder.js +8 -2
- data/app/assets/javascripts/InterventionPerformed.js +9 -2
- data/app/assets/javascripts/InterventionRecommended.js +8 -2
- data/app/assets/javascripts/LaboratoryTestOrder.js +8 -2
- data/app/assets/javascripts/LaboratoryTestPerformed.js +9 -2
- data/app/assets/javascripts/LaboratoryTestRecommended.js +8 -2
- data/app/assets/javascripts/MedicationActive.js +9 -2
- data/app/assets/javascripts/MedicationAdministered.js +9 -2
- data/app/assets/javascripts/MedicationDischarge.js +9 -2
- data/app/assets/javascripts/MedicationDispensed.js +10 -4
- data/app/assets/javascripts/MedicationOrder.js +9 -4
- data/app/assets/javascripts/Participation.js +8 -2
- data/app/assets/javascripts/PatientCareExperience.js +8 -2
- data/app/assets/javascripts/PatientCharacteristic.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicExpired.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicPayer.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicRace.js +7 -2
- data/app/assets/javascripts/PatientCharacteristicSex.js +7 -2
- data/app/assets/javascripts/PhysicalExamOrder.js +8 -2
- data/app/assets/javascripts/PhysicalExamPerformed.js +9 -2
- data/app/assets/javascripts/PhysicalExamRecommended.js +8 -2
- data/app/assets/javascripts/ProcedureOrder.js +10 -3
- data/app/assets/javascripts/ProcedurePerformed.js +11 -3
- data/app/assets/javascripts/ProcedureRecommended.js +9 -3
- data/app/assets/javascripts/ProviderCareExperience.js +8 -2
- data/app/assets/javascripts/QDMPatient.js +25 -9
- data/app/assets/javascripts/RelatedPerson.js +42 -0
- data/app/assets/javascripts/SubstanceAdministered.js +9 -2
- data/app/assets/javascripts/SubstanceOrder.js +9 -2
- data/app/assets/javascripts/SubstanceRecommended.js +8 -2
- data/app/assets/javascripts/Symptom.js +8 -2
- data/app/assets/javascripts/attributes/CarePartner.js +33 -0
- data/app/assets/javascripts/attributes/Component.js +22 -1
- data/app/assets/javascripts/attributes/DiagnosisComponent.js +34 -0
- data/app/assets/javascripts/attributes/Entity.js +58 -0
- data/app/assets/javascripts/attributes/FacilityLocation.js +4 -1
- data/app/assets/javascripts/attributes/Identifier.js +23 -0
- data/app/assets/javascripts/attributes/Organization.js +33 -0
- data/app/assets/javascripts/attributes/PatientEntity.js +32 -0
- data/app/assets/javascripts/attributes/Practitioner.js +35 -0
- data/app/assets/javascripts/attributes/ResultComponent.js +31 -0
- data/app/assets/javascripts/basetypes/Any.js +24 -15
- data/app/assets/javascripts/basetypes/AnyEntity.js +44 -0
- data/app/assets/javascripts/basetypes/Code.js +8 -12
- data/app/assets/javascripts/basetypes/DataElement.js +17 -6
- data/app/assets/javascripts/basetypes/Interval.js +10 -8
- data/app/assets/javascripts/basetypes/QDMDate.js +36 -0
- data/app/assets/javascripts/basetypes/Quantity.js +1 -1
- data/app/assets/javascripts/basetypes/Ratio.js +1 -1
- data/app/assets/javascripts/cqm/AllCQMModels.js +2 -0
- data/app/assets/javascripts/cqm/ClauseResult.js +28 -0
- data/app/assets/javascripts/{IndividualResult.js → cqm/IndividualResult.js} +28 -2
- data/app/assets/javascripts/cqm/Measure.js +1 -1
- data/app/assets/javascripts/cqm/Provider.js +0 -2
- data/app/assets/javascripts/cqm/StatementResult.js +41 -0
- data/app/assets/javascripts/index.js +6 -2
- data/app/models/cqm/clause_result.rb +21 -0
- data/app/models/{qdm/tacoma → cqm}/individual_result.rb +24 -3
- data/app/models/cqm/measure.rb +2 -0
- data/app/models/cqm/patient.rb +1 -0
- data/app/models/cqm/provider.rb +4 -4
- data/app/models/cqm/statement_result.rb +27 -0
- data/app/models/hqmfOid_to_datatype_map.json +5 -1
- data/app/models/model_finder.rb +1 -0
- data/app/models/models.rb +15 -6
- data/app/models/qdm/adverse_event.rb +3 -2
- data/app/models/qdm/allergy_intolerance.rb +2 -1
- data/app/models/qdm/assessment_order.rb +2 -1
- data/app/models/qdm/assessment_performed.rb +5 -2
- data/app/models/qdm/assessment_recommended.rb +2 -1
- data/app/models/qdm/attributes/attribute.rb +1 -0
- data/app/models/qdm/attributes/care_partner.rb +10 -0
- data/app/models/qdm/attributes/component.rb +1 -1
- data/app/models/qdm/attributes/diagnosis_component.rb +10 -0
- data/app/models/qdm/attributes/entity.rb +15 -0
- data/app/models/qdm/attributes/facility_location.rb +1 -1
- data/app/models/qdm/{id.rb → attributes/identifier.rb} +3 -4
- data/app/models/qdm/attributes/organization.rb +10 -0
- data/app/models/qdm/attributes/patient_entity.rb +9 -0
- data/app/models/qdm/attributes/practitioner.rb +12 -0
- data/app/models/qdm/{result_component.rb → attributes/result_component.rb} +1 -3
- data/app/models/qdm/basetypes/code.rb +9 -10
- data/app/models/qdm/basetypes/data_element.rb +64 -12
- data/app/models/qdm/basetypes/date.rb +39 -0
- data/app/models/qdm/basetypes/interval.rb +26 -3
- data/app/models/qdm/basetypes/quantity.rb +1 -0
- data/app/models/qdm/basetypes/ratio.rb +1 -0
- data/app/models/qdm/care_goal.rb +4 -2
- data/app/models/qdm/communication_performed.rb +6 -5
- data/app/models/qdm/device_applied.rb +3 -1
- data/app/models/qdm/device_order.rb +2 -1
- data/app/models/qdm/device_recommended.rb +2 -1
- data/app/models/qdm/diagnosis.rb +2 -1
- data/app/models/qdm/diagnostic_study_order.rb +2 -1
- data/app/models/qdm/diagnostic_study_performed.rb +3 -1
- data/app/models/qdm/diagnostic_study_recommended.rb +2 -1
- data/app/models/qdm/encounter_order.rb +3 -1
- data/app/models/qdm/encounter_performed.rb +3 -2
- data/app/models/qdm/encounter_recommended.rb +2 -1
- data/app/models/qdm/family_history.rb +2 -1
- data/app/models/qdm/immunization_administered.rb +3 -1
- data/app/models/qdm/immunization_order.rb +2 -1
- data/app/models/qdm/intervention_order.rb +2 -1
- data/app/models/qdm/intervention_performed.rb +3 -1
- data/app/models/qdm/intervention_recommended.rb +2 -1
- data/app/models/qdm/laboratory_test_order.rb +2 -1
- data/app/models/qdm/laboratory_test_performed.rb +3 -1
- data/app/models/qdm/laboratory_test_recommended.rb +2 -1
- data/app/models/qdm/medication_active.rb +3 -1
- data/app/models/qdm/medication_administered.rb +3 -1
- data/app/models/qdm/medication_discharge.rb +3 -1
- data/app/models/qdm/medication_dispensed.rb +4 -3
- data/app/models/qdm/medication_order.rb +3 -3
- data/app/models/qdm/participation.rb +2 -1
- data/app/models/qdm/patient.rb +2 -2
- data/app/models/qdm/patient_care_experience.rb +2 -1
- data/app/models/qdm/patient_characteristic.rb +1 -1
- data/app/models/qdm/patient_characteristic_birthdate.rb +1 -1
- data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +1 -1
- data/app/models/qdm/patient_characteristic_ethnicity.rb +1 -1
- data/app/models/qdm/patient_characteristic_expired.rb +1 -1
- data/app/models/qdm/patient_characteristic_payer.rb +1 -1
- data/app/models/qdm/patient_characteristic_race.rb +1 -1
- data/app/models/qdm/patient_characteristic_sex.rb +1 -1
- data/app/models/qdm/physical_exam_order.rb +2 -1
- data/app/models/qdm/physical_exam_performed.rb +3 -1
- data/app/models/qdm/physical_exam_recommended.rb +2 -1
- data/app/models/qdm/procedure_order.rb +4 -2
- data/app/models/qdm/procedure_performed.rb +5 -2
- data/app/models/qdm/procedure_recommended.rb +3 -2
- data/app/models/qdm/provider_care_experience.rb +2 -1
- data/app/models/qdm/related_person.rb +13 -0
- data/app/models/qdm/substance_administered.rb +3 -1
- data/app/models/qdm/substance_order.rb +3 -1
- data/app/models/qdm/substance_recommended.rb +2 -1
- data/app/models/qdm/symptom.rb +2 -1
- data/bin/validate_generator.sh +1 -1
- data/cqm-models.gemspec +5 -5
- data/data/oids_qdm_5.5.json +337 -0
- data/dist/browser.js +41069 -34668
- data/dist/index.js +41068 -34667
- data/lib/generate_entities.rb +56 -0
- data/lib/generate_models.rb +77 -39
- data/lib/generate_patients.rb +20 -14
- data/lib/generate_types.rb +54 -14
- data/lib/generator_helpers.rb +14 -0
- data/modelinfo/qdm-modelinfo-5.5.xml +982 -0
- data/package.json +4 -4
- data/templates/entity_extension.rb.erb +6 -0
- data/templates/identifier_extension.rb.erb +58 -0
- data/templates/{id_template.js.erb → identifier_template.js.erb} +6 -5
- data/templates/index_template.js.erb +6 -2
- data/templates/models_template.rb.erb +22 -5
- data/templates/mongoose_template.js.erb +86 -12
- data/templates/patient_extension.rb.erb +1 -1
- data/templates/patient_template.js.erb +0 -4
- data/yarn.lock +525 -391
- metadata +46 -21
- data/app/assets/javascripts/Id.js +0 -21
- data/app/assets/javascripts/ProviderCharacteristic.js +0 -36
- data/app/assets/javascripts/ResultComponent.js +0 -33
- data/app/models/qdm/provider_characteristic.rb +0 -12
@@ -0,0 +1,31 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const { ComponentSchemaFunction } = require('./Component');
|
4
|
+
const Code = require('../basetypes/Code');
|
5
|
+
const Interval = require('../basetypes/Interval');
|
6
|
+
const Quantity = require('../basetypes/Quantity');
|
7
|
+
const DateTime = require('../basetypes/DateTime');
|
8
|
+
const QDMDate = require('../basetypes/QDMDate');
|
9
|
+
const Any = require('../basetypes/Any');
|
10
|
+
|
11
|
+
const [Number, String] = [
|
12
|
+
mongoose.Schema.Types.Number,
|
13
|
+
mongoose.Schema.Types.String,
|
14
|
+
];
|
15
|
+
|
16
|
+
const ResultComponentSchema = ComponentSchemaFunction({
|
17
|
+
referenceRange: Interval,
|
18
|
+
_type: { type: String, default: 'QDM::ResultComponent' },
|
19
|
+
|
20
|
+
});
|
21
|
+
|
22
|
+
module.exports.ResultComponentSchema = ResultComponentSchema;
|
23
|
+
class ResultComponent extends mongoose.Document {
|
24
|
+
constructor(object) {
|
25
|
+
super(object, ResultComponentSchema);
|
26
|
+
this._type = 'QDM::ResultComponent';
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
module.exports.ResultComponent = ResultComponent;
|
31
|
+
|
@@ -8,31 +8,31 @@ Any.prototype = Object.create(mongoose.SchemaType.prototype);
|
|
8
8
|
|
9
9
|
function RecursiveCast(any) {
|
10
10
|
if (any && any.value && any.unit) {
|
11
|
-
return new cql.Quantity(any);
|
11
|
+
return new cql.Quantity(any.value, any.unit);
|
12
12
|
}
|
13
|
-
if (any && any.code && any.codeSystem) {
|
14
|
-
if (typeof any.code === 'undefined') {
|
15
|
-
throw new Error(`Code: ${any} does not have a code`);
|
16
|
-
} else if (typeof any.codeSystem === 'undefined') {
|
17
|
-
throw new Error(`Code: ${any} does not have a codeSystem`);
|
18
|
-
}
|
19
13
|
|
20
|
-
|
14
|
+
if (any.isCode || any.isConcept || any.isValueSet || any.isList ||
|
15
|
+
any.isDateTime || any.isDate || any.isRatio || any.isQuantiy ||
|
16
|
+
any.isInterval || any.isBooleanLiteral || any.isIntegerLiteral ||
|
17
|
+
any.isDecimalLiteral || any.isStringLiteral || any.isTuple) {
|
18
|
+
return any;
|
19
|
+
}
|
21
20
|
|
22
|
-
|
23
|
-
val
|
21
|
+
if (any && any.code && any.system) {
|
22
|
+
const val = { code: any.code, system: any.system };
|
23
|
+
val.display = (typeof any.display !== 'undefined') ? any.display : null;
|
24
24
|
val.version = (typeof any.version !== 'undefined') ? any.version : null;
|
25
25
|
|
26
|
-
return new cql.Code(val.code, val.
|
26
|
+
return new cql.Code(val.code, val.system, val.version, val.display);
|
27
27
|
}
|
28
28
|
if (any && any.low) {
|
29
29
|
const casted = new cql.Interval(any.low, any.high, any.lowClosed, any.highClosed);
|
30
30
|
|
31
31
|
// Cast Low and High values to Quantities if it is a quantity
|
32
32
|
if (casted.low && casted.low.unit && casted.low.value) {
|
33
|
-
casted.low = new cql.Quantity(casted.low);
|
33
|
+
casted.low = new cql.Quantity(casted.low.value, casted.low.unit);
|
34
34
|
if (casted.high && casted.high.unit && casted.high.value) {
|
35
|
-
casted.high = new cql.Quantity(casted.high);
|
35
|
+
casted.high = new cql.Quantity(casted.high.value, casted.high.unit);
|
36
36
|
}
|
37
37
|
return casted;
|
38
38
|
}
|
@@ -56,8 +56,17 @@ function RecursiveCast(any) {
|
|
56
56
|
if (Number.isFinite(any)) {
|
57
57
|
return any;
|
58
58
|
}
|
59
|
-
if (Date.parse(any)) {
|
60
|
-
|
59
|
+
if (Date.parse(any) || Date.parse(`1984-01-01T${any}`)) {
|
60
|
+
if (any.match(/T/) || any.match(/\+/)) {
|
61
|
+
// If it has a T or a timezoneoffset, it must be a DateTime
|
62
|
+
return cql.DateTime.fromJSDate(new Date(any), 0);
|
63
|
+
}
|
64
|
+
if (any.match(/:/)) {
|
65
|
+
// If it has a : but no T or timezoneoffset, it must be a Time
|
66
|
+
return cql.DateTime.fromJSDate(new Date(`1984-01-01T${any}`), 0).getTime();
|
67
|
+
}
|
68
|
+
// Must be a Date
|
69
|
+
return cql.DateTime.fromJSDate(new Date(any), 0).getDate();
|
61
70
|
}
|
62
71
|
return any;
|
63
72
|
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
const { PatientEntity } = require('../attributes/PatientEntity');
|
3
|
+
const { Practitioner } = require('../attributes/Practitioner');
|
4
|
+
const { CarePartner } = require('../attributes/CarePartner');
|
5
|
+
const { Organization } = require('../attributes/Organization');
|
6
|
+
|
7
|
+
function AnyEntity(key, options) {
|
8
|
+
mongoose.SchemaType.call(this, key, options, 'AnyEntity');
|
9
|
+
}
|
10
|
+
AnyEntity.prototype = Object.create(mongoose.SchemaType.prototype);
|
11
|
+
|
12
|
+
AnyEntity.prototype.cast = (entity) => {
|
13
|
+
if (entity == null) {
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
if (entity instanceof PatientEntity || entity instanceof Practitioner || entity instanceof CarePartner || entity instanceof Organization) {
|
18
|
+
return entity;
|
19
|
+
}
|
20
|
+
|
21
|
+
if (entity._type != null) {
|
22
|
+
// copy _id to id if it isn't defined
|
23
|
+
if (entity.id == null && entity._id != null) {
|
24
|
+
entity.id = entity._id;
|
25
|
+
}
|
26
|
+
switch (entity._type) {
|
27
|
+
case 'QDM::PatientEntity':
|
28
|
+
return new PatientEntity(entity);
|
29
|
+
case 'QDM::Practitioner':
|
30
|
+
return new Practitioner(entity);
|
31
|
+
case 'QDM::CarePartner':
|
32
|
+
return new CarePartner(entity);
|
33
|
+
case 'QDM::Organization':
|
34
|
+
return new Organization(entity);
|
35
|
+
default:
|
36
|
+
throw new Error(`Could not find entity type "${entity._type}".`);
|
37
|
+
}
|
38
|
+
} else {
|
39
|
+
throw new Error('Could not find _type indicator for entity.');
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
43
|
+
mongoose.Schema.Types.AnyEntity = AnyEntity;
|
44
|
+
module.exports = AnyEntity;
|
@@ -8,21 +8,17 @@ Code.prototype = Object.create(mongoose.SchemaType.prototype);
|
|
8
8
|
|
9
9
|
Code.prototype.cast = (code) => {
|
10
10
|
if (code != null) {
|
11
|
+
// return code if it doesn't even need casting
|
12
|
+
if (code.isCode) {
|
13
|
+
return code;
|
14
|
+
}
|
11
15
|
// handles codes that have not yet been cast to a code and those that have already been cast to a code
|
12
|
-
if (code.code &&
|
13
|
-
|
14
|
-
|
15
|
-
} else if (typeof code.codeSystem === 'undefined' && typeof code.system === 'undefined') {
|
16
|
-
throw new Error(`Code: ${code} does not have a system`);
|
17
|
-
}
|
18
|
-
|
19
|
-
const val = { code: code.code, codeSystem: code.codeSystem || code.system };
|
20
|
-
|
21
|
-
val.descriptor = (typeof code.descriptor !== 'undefined') ? code.descriptor : null;
|
22
|
-
val.codeSystemOid = (typeof code.codeSystemOid !== 'undefined') ? code.codeSystemOid : null;
|
16
|
+
if (code.code && code.system) {
|
17
|
+
const val = { code: code.code, system: code.system };
|
18
|
+
val.display = (typeof code.display !== 'undefined') ? code.display : null;
|
23
19
|
val.version = (typeof code.version !== 'undefined') ? code.version : null;
|
24
20
|
|
25
|
-
return new cql.Code(val.code, val.
|
21
|
+
return new cql.Code(val.code, val.system, val.version, val.display);
|
26
22
|
}
|
27
23
|
throw new Error(`Expected a code. Received ${code}.`);
|
28
24
|
} else {
|
@@ -1,19 +1,19 @@
|
|
1
1
|
const mongoose = require('mongoose/browser');
|
2
2
|
const Code = require('./Code.js');
|
3
3
|
const cql = require('cql-execution');
|
4
|
-
const
|
4
|
+
const Identifier = require('../attributes/Identifier');
|
5
5
|
|
6
6
|
const [Schema] = [mongoose.Schema];
|
7
7
|
|
8
8
|
function DataElementSchema(add, options) {
|
9
9
|
const extended = new Schema({
|
10
|
-
dataElementCodes: { type: [] },
|
10
|
+
dataElementCodes: { type: [Code] },
|
11
11
|
description: { type: String },
|
12
12
|
codeListId: { type: String },
|
13
13
|
id: {
|
14
|
-
type:
|
14
|
+
type: String,
|
15
15
|
default() {
|
16
|
-
return
|
16
|
+
return this._id ? this._id.toString() : mongoose.Types.ObjectId().toString();
|
17
17
|
},
|
18
18
|
},
|
19
19
|
}, options);
|
@@ -25,7 +25,15 @@ function DataElementSchema(add, options) {
|
|
25
25
|
// Returns all of the codes on this data element in a format usable by
|
26
26
|
// the cql-execution framework.
|
27
27
|
extended.methods.getCode = function getCode() {
|
28
|
-
|
28
|
+
if (this.dataElementCodes) {
|
29
|
+
return this.dataElementCodes.map((code) => {
|
30
|
+
if (code.isCode) {
|
31
|
+
return code;
|
32
|
+
}
|
33
|
+
return new cql.Code(code.code, code.system, code.version, code.display);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
return null;
|
29
37
|
};
|
30
38
|
|
31
39
|
// Return the first code on this data element in a format usable by
|
@@ -33,7 +41,10 @@ function DataElementSchema(add, options) {
|
|
33
41
|
extended.methods.code = function code() {
|
34
42
|
if (this.dataElementCodes && this.dataElementCodes[0]) {
|
35
43
|
const qdmCode = this.dataElementCodes[0];
|
36
|
-
|
44
|
+
if (qdmCode.isCode) {
|
45
|
+
return qdmCode;
|
46
|
+
}
|
47
|
+
return new cql.Code(qdmCode.code, qdmCode.system, qdmCode.version, qdmCode.display);
|
37
48
|
}
|
38
49
|
return null;
|
39
50
|
};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
const mongoose = require('mongoose/browser');
|
2
2
|
const cql = require('cql-execution');
|
3
|
+
const DateTime = require('./DateTime');
|
3
4
|
|
4
5
|
function Interval(key, options) {
|
5
6
|
mongoose.SchemaType.call(this, key, options, 'Interval');
|
@@ -7,26 +8,27 @@ function Interval(key, options) {
|
|
7
8
|
Interval.prototype = Object.create(mongoose.SchemaType.prototype);
|
8
9
|
|
9
10
|
Interval.prototype.cast = (interval) => {
|
10
|
-
if (
|
11
|
-
|
11
|
+
if (interval.isInterval) {
|
12
|
+
return interval;
|
12
13
|
}
|
13
14
|
const casted = new cql.Interval(interval.low, interval.high, interval.lowClosed, interval.highClosed);
|
14
15
|
|
15
16
|
// Cast Low and High values to Quantities if it is a quantity
|
16
17
|
if (casted.low && casted.low.unit && casted.low.value) {
|
17
|
-
casted.low = new cql.Quantity(casted.low);
|
18
|
+
casted.low = new cql.Quantity(casted.low.value, casted.low.unit);
|
18
19
|
if (casted.high && casted.high.unit && casted.high.value) {
|
19
|
-
casted.high = new cql.Quantity(casted.high);
|
20
|
+
casted.high = new cql.Quantity(casted.high.value, casted.high.unit);
|
20
21
|
}
|
21
22
|
return casted;
|
22
23
|
}
|
23
24
|
|
24
25
|
// Cast to DateTime if it is a string representing a DateTime
|
25
|
-
if (casted.low
|
26
|
-
casted.low =
|
26
|
+
if (casted.low) {
|
27
|
+
casted.low = DateTime.prototype.cast(casted.low);
|
27
28
|
}
|
28
|
-
|
29
|
-
|
29
|
+
|
30
|
+
if (casted.high) {
|
31
|
+
casted.high = DateTime.prototype.cast(casted.high);
|
30
32
|
}
|
31
33
|
return casted;
|
32
34
|
};
|
@@ -0,0 +1,36 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
const cql = require('cql-execution');
|
3
|
+
|
4
|
+
function QDMDate(key, options) {
|
5
|
+
mongoose.SchemaType.call(this, key, options, 'Date');
|
6
|
+
}
|
7
|
+
QDMDate.prototype = Object.create(mongoose.SchemaType.prototype);
|
8
|
+
|
9
|
+
QDMDate.prototype.cast = (date) => {
|
10
|
+
if (date == null) {
|
11
|
+
return date;
|
12
|
+
}
|
13
|
+
|
14
|
+
// Already a CQL Date
|
15
|
+
if (date.isDate) {
|
16
|
+
return date;
|
17
|
+
}
|
18
|
+
|
19
|
+
// Object
|
20
|
+
if (typeof date === 'object') {
|
21
|
+
const keys = Object.keys(date);
|
22
|
+
if (keys.includes('year') && keys.includes('month') && keys.includes('day')) {
|
23
|
+
return new cql.Date(date.year, date.month, date.day);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
// Date String
|
28
|
+
if (!cql.Date.parse(date)) {
|
29
|
+
throw new Error(`Date: ${date} is not a valid Date`);
|
30
|
+
} else {
|
31
|
+
return cql.Date.parse(date);
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
mongoose.Schema.Types.QDMDate = QDMDate;
|
36
|
+
module.exports = QDMDate;
|
@@ -13,7 +13,7 @@ Quantity.prototype.cast = (quantity) => {
|
|
13
13
|
throw new Error(`Quantity: ${quantity} does not have a unit`);
|
14
14
|
}
|
15
15
|
|
16
|
-
return new cql.Quantity(quantity);
|
16
|
+
return new cql.Quantity(quantity.value, quantity.unit);
|
17
17
|
};
|
18
18
|
|
19
19
|
mongoose.Schema.Types.Quantity = Quantity;
|
@@ -22,3 +22,5 @@ module.exports.Patient = require('./Patient.js').Patient;
|
|
22
22
|
module.exports.PatientSchema = require('./Patient.js').PatientSchema;
|
23
23
|
module.exports.Provider = require('./Provider.js').Provider;
|
24
24
|
module.exports.ProviderSchema = require('./Provider.js').ProviderSchema;
|
25
|
+
module.exports.IndividualResult = require('./IndividualResult.js').IndividualResult;
|
26
|
+
module.exports.IndividualResultSchema = require('./IndividualResult.js').IndividualResultSchema;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const [String, Mixed] = [
|
4
|
+
mongoose.Schema.Types.String,
|
5
|
+
mongoose.Schema.Types.Mixed,
|
6
|
+
];
|
7
|
+
|
8
|
+
const ClauseResultSchema = mongoose.Schema({
|
9
|
+
// Library the clause this result is for is in
|
10
|
+
library_name: String,
|
11
|
+
// Statement the clause this result is for is in
|
12
|
+
statement_name: String,
|
13
|
+
// LocalId of the clause this result is for
|
14
|
+
localId: String,
|
15
|
+
// Final, processed result of raw calculation
|
16
|
+
final: String,
|
17
|
+
// Raw result of clause calculation
|
18
|
+
raw: Mixed,
|
19
|
+
});
|
20
|
+
|
21
|
+
|
22
|
+
module.exports.ClauseResultSchema = ClauseResultSchema;
|
23
|
+
class ClauseResult extends mongoose.Document {
|
24
|
+
constructor(object) {
|
25
|
+
super(object, ClauseResultSchema);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
module.exports.ClauseResult = ClauseResult;
|
@@ -1,4 +1,6 @@
|
|
1
1
|
const mongoose = require('mongoose/browser');
|
2
|
+
const { ClauseResultSchema } = require('./ClauseResult');
|
3
|
+
const { StatementResultSchema } = require('./StatementResult');
|
2
4
|
|
3
5
|
const [Number, String, Mixed, ObjectId] = [
|
4
6
|
mongoose.Schema.Types.Number,
|
@@ -22,9 +24,11 @@ const IndividualResultSchema = mongoose.Schema(
|
|
22
24
|
MSRPOPLEX: Number,
|
23
25
|
|
24
26
|
// Result Attributes
|
25
|
-
clause_results:
|
27
|
+
clause_results: [ClauseResultSchema],
|
28
|
+
statement_results: [StatementResultSchema],
|
29
|
+
population_relevance: Mixed,
|
26
30
|
episode_results: Mixed,
|
27
|
-
|
31
|
+
observation_values: [Number],
|
28
32
|
|
29
33
|
// This field is for application specific information only. If both Bonnie and
|
30
34
|
// Cypress use a common field, it should be made a field on this model,
|
@@ -53,6 +57,28 @@ const IndividualResultSchema = mongoose.Schema(
|
|
53
57
|
}
|
54
58
|
);
|
55
59
|
|
60
|
+
IndividualResultSchema.methods.clause_results_by_clause = function clause_results_by_clause() {
|
61
|
+
const clause_results_hash = {};
|
62
|
+
this.clause_results.forEach((result) => {
|
63
|
+
if (!clause_results_hash[result.library_name]) {
|
64
|
+
clause_results_hash[result.library_name] = {};
|
65
|
+
}
|
66
|
+
clause_results_hash[result.library_name][result.localId] = result;
|
67
|
+
});
|
68
|
+
return clause_results_hash;
|
69
|
+
};
|
70
|
+
|
71
|
+
IndividualResultSchema.methods.statement_results_by_statement = function statement_results_by_statement() {
|
72
|
+
const statement_results_hash = {};
|
73
|
+
this.statement_results.forEach((result) => {
|
74
|
+
if (!statement_results_hash[result.library_name]) {
|
75
|
+
statement_results_hash[result.library_name] = {};
|
76
|
+
}
|
77
|
+
statement_results_hash[result.library_name][result.statement_name] = result;
|
78
|
+
});
|
79
|
+
return statement_results_hash;
|
80
|
+
};
|
81
|
+
|
56
82
|
module.exports.IndividualResultSchema = IndividualResultSchema;
|
57
83
|
class IndividualResult extends mongoose.Document {
|
58
84
|
constructor(object) {
|
@@ -64,7 +64,7 @@ const MeasureSchema = new mongoose.Schema(
|
|
64
64
|
// HQMF/Tacoma-specific Measure-logic related data
|
65
65
|
population_criteria: Mixed,
|
66
66
|
source_data_criteria: [],
|
67
|
-
measure_period:
|
67
|
+
measure_period: Mixed,
|
68
68
|
measure_attributes: [],
|
69
69
|
|
70
70
|
population_sets: [PopulationSetSchema],
|
@@ -1,5 +1,4 @@
|
|
1
1
|
const mongoose = require('mongoose/browser');
|
2
|
-
const Id = require('../Id');
|
3
2
|
|
4
3
|
const [Schema, String, Boolean] = [
|
5
4
|
mongoose.Schema,
|
@@ -31,7 +30,6 @@ const ProviderSchema = new Schema({
|
|
31
30
|
title: String,
|
32
31
|
addresses: [AddressSchema],
|
33
32
|
telecoms: [TelecomSchema],
|
34
|
-
ids: [Id.IdSchema],
|
35
33
|
|
36
34
|
}, { id: false });
|
37
35
|
|
@@ -0,0 +1,41 @@
|
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
|
3
|
+
const [String, Mixed] = [
|
4
|
+
mongoose.Schema.Types.String,
|
5
|
+
mongoose.Schema.Types.Mixed,
|
6
|
+
];
|
7
|
+
|
8
|
+
const StatementResultSchema = mongoose.Schema({
|
9
|
+
// Library the statement this result is for is in
|
10
|
+
library_name: String,
|
11
|
+
// Statement this result is for is in
|
12
|
+
statement_name: String,
|
13
|
+
// Result, processed for display, of the statement this result is for
|
14
|
+
pretty: String,
|
15
|
+
// Final, processed result of raw calculation
|
16
|
+
final: String,
|
17
|
+
// Raw result of clause calculation
|
18
|
+
raw: Mixed,
|
19
|
+
/*
|
20
|
+
* 'NA' - Not applicable. This statement is not relevant to any population calculation in this population_set. Common
|
21
|
+
* for unused library statements or statements only used for other population sets.
|
22
|
+
*
|
23
|
+
* 'FALSE' - This statement is not relevant to any of this patient's population inclusion calculations.
|
24
|
+
*
|
25
|
+
* 'TRUE' - This statement is relevant for one or more of the population inclusion calculations.
|
26
|
+
*/
|
27
|
+
relevance: {
|
28
|
+
type: String,
|
29
|
+
enum: ['NA', 'TRUE', 'FALSE'],
|
30
|
+
default: 'NA',
|
31
|
+
},
|
32
|
+
});
|
33
|
+
|
34
|
+
|
35
|
+
module.exports.StatementResultSchema = StatementResultSchema;
|
36
|
+
class StatementResult extends mongoose.Document {
|
37
|
+
constructor(object) {
|
38
|
+
super(object, StatementResultSchema);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
module.exports.StatementResult = StatementResult;
|