cqm-models 3.0.6 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc.json +6 -0
- data/.github/workflows/ci.yml +56 -0
- data/README.md +3 -2
- data/app/assets/javascripts/AdverseEvent.js +2 -2
- data/app/assets/javascripts/AllDataElements.js +2 -2
- data/app/assets/javascripts/AllergyIntolerance.js +2 -2
- data/app/assets/javascripts/AssessmentOrder.js +2 -2
- data/app/assets/javascripts/AssessmentPerformed.js +3 -2
- data/app/assets/javascripts/AssessmentRecommended.js +2 -2
- data/app/assets/javascripts/CareGoal.js +2 -2
- data/app/assets/javascripts/CommunicationPerformed.js +3 -3
- data/app/assets/javascripts/DeviceOrder.js +2 -2
- data/app/assets/javascripts/DeviceRecommended.js +2 -2
- data/app/assets/javascripts/Diagnosis.js +2 -2
- data/app/assets/javascripts/DiagnosticStudyOrder.js +2 -2
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +4 -2
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +2 -2
- data/app/assets/javascripts/EncounterOrder.js +2 -2
- data/app/assets/javascripts/EncounterPerformed.js +7 -3
- data/app/assets/javascripts/EncounterRecommended.js +2 -2
- data/app/assets/javascripts/FamilyHistory.js +2 -2
- data/app/assets/javascripts/ImmunizationAdministered.js +2 -2
- data/app/assets/javascripts/ImmunizationOrder.js +2 -2
- data/app/assets/javascripts/InterventionOrder.js +2 -2
- data/app/assets/javascripts/InterventionPerformed.js +3 -2
- data/app/assets/javascripts/InterventionRecommended.js +2 -2
- data/app/assets/javascripts/LaboratoryTestOrder.js +2 -2
- data/app/assets/javascripts/LaboratoryTestPerformed.js +4 -2
- data/app/assets/javascripts/LaboratoryTestRecommended.js +2 -2
- data/app/assets/javascripts/MedicationActive.js +2 -2
- data/app/assets/javascripts/MedicationAdministered.js +2 -2
- data/app/assets/javascripts/MedicationDischarge.js +3 -3
- data/app/assets/javascripts/MedicationDispensed.js +4 -3
- data/app/assets/javascripts/MedicationOrder.js +3 -2
- data/app/assets/javascripts/Participation.js +1 -2
- data/app/assets/javascripts/PatientCareExperience.js +2 -2
- data/app/assets/javascripts/PatientCharacteristic.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicExpired.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicPayer.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicRace.js +1 -1
- data/app/assets/javascripts/PatientCharacteristicSex.js +1 -1
- data/app/assets/javascripts/PhysicalExamOrder.js +2 -2
- data/app/assets/javascripts/PhysicalExamPerformed.js +3 -2
- data/app/assets/javascripts/PhysicalExamRecommended.js +2 -2
- data/app/assets/javascripts/ProcedureOrder.js +2 -2
- data/app/assets/javascripts/ProcedurePerformed.js +3 -3
- data/app/assets/javascripts/ProcedureRecommended.js +2 -2
- data/app/assets/javascripts/ProviderCareExperience.js +2 -2
- data/app/assets/javascripts/QDMPatient.js +25 -1
- data/app/assets/javascripts/RelatedPerson.js +1 -1
- data/app/assets/javascripts/SubstanceAdministered.js +2 -2
- data/app/assets/javascripts/SubstanceOrder.js +2 -2
- data/app/assets/javascripts/SubstanceRecommended.js +2 -2
- data/app/assets/javascripts/Symptom.js +2 -2
- data/app/assets/javascripts/attributes/Component.js +2 -2
- data/app/assets/javascripts/attributes/DiagnosisComponent.js +1 -1
- data/app/assets/javascripts/attributes/Entity.js +2 -2
- data/app/assets/javascripts/attributes/FacilityLocation.js +1 -1
- data/app/assets/javascripts/attributes/Identifier.js +1 -1
- data/app/assets/javascripts/attributes/Location.js +32 -0
- data/app/assets/javascripts/attributes/Organization.js +1 -1
- data/app/assets/javascripts/basetypes/AnyEntity.js +3 -0
- data/app/assets/javascripts/basetypes/DataElement.js +25 -1
- data/app/models/hqmfOid_to_datatype_map.json +1 -1
- data/app/models/models.rb +2 -2
- data/app/models/qdm/adverse_event.rb +2 -2
- data/app/models/qdm/allergy_intolerance.rb +2 -2
- data/app/models/qdm/assessment_order.rb +2 -2
- data/app/models/qdm/assessment_performed.rb +3 -2
- data/app/models/qdm/assessment_recommended.rb +2 -2
- data/app/models/qdm/attributes/component.rb +1 -1
- data/app/models/qdm/attributes/diagnosis_component.rb +1 -1
- data/app/models/qdm/attributes/entity.rb +1 -1
- data/app/models/qdm/attributes/facility_location.rb +1 -1
- data/app/models/qdm/attributes/identifier.rb +1 -1
- data/app/models/qdm/attributes/location.rb +9 -0
- data/app/models/qdm/attributes/organization.rb +1 -1
- data/app/models/qdm/basetypes/data_element.rb +5 -0
- data/app/models/qdm/care_goal.rb +2 -2
- data/app/models/qdm/communication_performed.rb +3 -3
- data/app/models/qdm/device_order.rb +2 -2
- data/app/models/qdm/device_recommended.rb +2 -2
- data/app/models/qdm/diagnosis.rb +2 -2
- data/app/models/qdm/diagnostic_study_order.rb +2 -2
- data/app/models/qdm/diagnostic_study_performed.rb +4 -2
- data/app/models/qdm/diagnostic_study_recommended.rb +2 -2
- data/app/models/qdm/encounter_order.rb +2 -2
- data/app/models/qdm/encounter_performed.rb +4 -3
- data/app/models/qdm/encounter_recommended.rb +2 -2
- data/app/models/qdm/family_history.rb +2 -2
- data/app/models/qdm/immunization_administered.rb +2 -2
- data/app/models/qdm/immunization_order.rb +2 -2
- data/app/models/qdm/intervention_order.rb +2 -2
- data/app/models/qdm/intervention_performed.rb +3 -2
- data/app/models/qdm/intervention_recommended.rb +2 -2
- data/app/models/qdm/laboratory_test_order.rb +2 -2
- data/app/models/qdm/laboratory_test_performed.rb +4 -2
- data/app/models/qdm/laboratory_test_recommended.rb +2 -2
- data/app/models/qdm/medication_active.rb +2 -2
- data/app/models/qdm/medication_administered.rb +2 -2
- data/app/models/qdm/medication_discharge.rb +3 -3
- data/app/models/qdm/medication_dispensed.rb +4 -3
- data/app/models/qdm/medication_order.rb +3 -2
- data/app/models/qdm/participation.rb +1 -2
- data/app/models/qdm/patient.rb +1 -1
- data/app/models/qdm/patient_care_experience.rb +2 -2
- 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 -2
- data/app/models/qdm/physical_exam_performed.rb +3 -2
- data/app/models/qdm/physical_exam_recommended.rb +2 -2
- data/app/models/qdm/procedure_order.rb +2 -2
- data/app/models/qdm/procedure_performed.rb +3 -3
- data/app/models/qdm/procedure_recommended.rb +2 -2
- data/app/models/qdm/provider_care_experience.rb +2 -2
- data/app/models/qdm/related_person.rb +1 -1
- data/app/models/qdm/substance_administered.rb +2 -2
- data/app/models/qdm/substance_order.rb +2 -2
- data/app/models/qdm/substance_recommended.rb +2 -2
- data/app/models/qdm/symptom.rb +2 -2
- data/bin/validate_generator.sh +2 -2
- data/cqm-models.gemspec +1 -1
- data/data/oids_qdm_5.6.json +335 -0
- data/dist/browser.js +61618 -94314
- data/dist/index.js +61618 -94314
- data/lib/generate_entities.rb +18 -10
- data/lib/generate_models.rb +28 -20
- data/lib/generate_patients.rb +1 -1
- data/modelinfo/qdm-modelinfo-5.6.xml +1102 -0
- data/package.json +5 -5
- data/templates/models_template.rb.erb +3 -1
- data/templates/mongoose_template.js.erb +9 -2
- data/templates/patient_template.js.erb +48 -4
- data/yarn.lock +1019 -827
- metadata +12 -10
- data/.travis.yml +0 -52
- data/app/assets/javascripts/DeviceApplied.js +0 -48
- data/app/models/qdm/device_applied.rb +0 -19
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cqm-models",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.1",
|
4
4
|
"description": "This library contains auto generated Mongo (Mongoose.js) models that correspond to the QDM (Quality Data Model) specification.",
|
5
5
|
"main": "app/assets/javascripts/index.js",
|
6
6
|
"browser": {
|
@@ -16,13 +16,13 @@
|
|
16
16
|
],
|
17
17
|
"license": "Apache-2.0",
|
18
18
|
"dependencies": {
|
19
|
-
"cql-execution": "~
|
20
|
-
"mongoose": "^5.
|
19
|
+
"cql-execution": "~2.3.3",
|
20
|
+
"mongoose": "^5.13.12"
|
21
21
|
},
|
22
22
|
"devDependencies": {
|
23
23
|
"browserify": "^16.1.0",
|
24
|
-
"eslint": "^
|
25
|
-
"eslint-config-airbnb-base": "^
|
24
|
+
"eslint": "^7.0.0",
|
25
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
26
26
|
"eslint-plugin-import": "^2.8.0",
|
27
27
|
"istanbul": "^0.4.5",
|
28
28
|
"jasmine": "^2.9.0"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Base QDM module (generated from lib/generate_models.rb) for QDM 5.
|
1
|
+
# Base QDM module (generated from lib/generate_models.rb) for QDM 5.6
|
2
2
|
module QDM
|
3
3
|
end
|
4
4
|
require 'mongoid'
|
@@ -25,6 +25,7 @@ require_relative 'qdm/attributes/diagnosis_component'
|
|
25
25
|
require_relative 'qdm/attributes/organization'
|
26
26
|
require_relative 'qdm/attributes/patient_entity'
|
27
27
|
require_relative 'qdm/attributes/practitioner'
|
28
|
+
require_relative 'qdm/attributes/location'
|
28
29
|
require_relative 'qdm/attributes/result_component'
|
29
30
|
|
30
31
|
# Tacoma-specific models
|
@@ -55,6 +56,7 @@ require_relative '../../lib/generate_patients'
|
|
55
56
|
<%- next if datatype.underscore == 'organization' -%>
|
56
57
|
<%- next if datatype.underscore == 'patient_entity' -%>
|
57
58
|
<%- next if datatype.underscore == 'practitioner' -%>
|
59
|
+
<%- next if datatype.underscore == 'location' -%>
|
58
60
|
<%- next if datatype.underscore == 'result_component' -%>
|
59
61
|
require_relative 'qdm/<%= datatype.underscore %>'
|
60
62
|
<%- end -%>
|
@@ -26,7 +26,7 @@ const QDMDate = require('../basetypes/QDMDate');
|
|
26
26
|
const Any = require('../basetypes/Any');
|
27
27
|
|
28
28
|
const [Schema] = [mongoose.Schema];
|
29
|
-
<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity'%>
|
29
|
+
<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity' || datatype.downcase == 'location'%>
|
30
30
|
const { EntitySchemaFunction } = require('./Entity');
|
31
31
|
const Code = require('../basetypes/Code');
|
32
32
|
const Interval = require('../basetypes/Interval');
|
@@ -65,7 +65,7 @@ const <%= datatype -%>Schema = ComponentSchemaFunction({
|
|
65
65
|
<% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %>
|
66
66
|
<%- end %>
|
67
67
|
});
|
68
|
-
<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity'%>
|
68
|
+
<% elsif datatype.downcase == 'carepartner' || datatype.downcase == 'organization' || datatype.downcase == 'practitioner' || datatype.downcase == 'patiententity' || datatype.downcase == 'location'%>
|
69
69
|
const <%= datatype -%>Schema = EntitySchemaFunction({
|
70
70
|
<%- for attribute in attrs_with_extras -%>
|
71
71
|
<% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %>
|
@@ -83,6 +83,13 @@ class <%= datatype %> extends mongoose.Document {
|
|
83
83
|
constructor(object) {
|
84
84
|
super(object, <%= datatype %>Schema);
|
85
85
|
this._type = 'QDM::<%= datatype %>';
|
86
|
+
<%- for attribute in attrs_with_extras -%>
|
87
|
+
<%- if RESERVED_WORDS[attribute[:name].to_s] -%>
|
88
|
+
if (object && object.<%= RESERVED_WORDS[attribute[:name].to_s] %>) {
|
89
|
+
this.<%= attribute[:name] %> = object.<%= RESERVED_WORDS[attribute[:name].to_s] %>;
|
90
|
+
}
|
91
|
+
<%- end -%>
|
92
|
+
<%- end -%>
|
86
93
|
}
|
87
94
|
}
|
88
95
|
<% if datatype.downcase == 'entity' || datatype.downcase == 'component'%>
|
@@ -56,6 +56,30 @@ QDMPatientSchema.methods.getByQrdaOid = function getByQrdaOid(qrdaOid) {
|
|
56
56
|
return this.dataElements.filter(element => element.qrdaOid === qrdaOid);
|
57
57
|
};
|
58
58
|
|
59
|
+
// cql-execution prefers getId() over id() because some data models may have an id property
|
60
|
+
QDMPatientSchema.methods.getId = function getId() {
|
61
|
+
return this._id;
|
62
|
+
};
|
63
|
+
|
64
|
+
/* eslint no-underscore-dangle: 0 */
|
65
|
+
QDMPatientSchema.methods._is = function _is(typeSpecifier) {
|
66
|
+
return this._typeHierarchy().some(
|
67
|
+
t => t.type === typeSpecifier.type && t.name === typeSpecifier.name
|
68
|
+
);
|
69
|
+
};
|
70
|
+
|
71
|
+
/* eslint no-underscore-dangle: 0 */
|
72
|
+
QDMPatientSchema.methods._typeHierarchy = function _typeHierarchy() {
|
73
|
+
const ver = this.qdmVersion.replace('.', '_');
|
74
|
+
return [
|
75
|
+
{
|
76
|
+
name: `{urn:healthit-gov:qdm:v${ver}}Patient`,
|
77
|
+
type: 'NamedTypeSpecifier',
|
78
|
+
},
|
79
|
+
{ name: '{urn:hl7-org:elm-types:r1}Any', type: 'NamedTypeSpecifier' },
|
80
|
+
];
|
81
|
+
};
|
82
|
+
|
59
83
|
// Returns an array of elements that exist on this patient. Optionally
|
60
84
|
// takes a qdmCategory, which returns all elements of that QDM qdmCategory.
|
61
85
|
// Example: patient.getDataElements({qdmCategory: 'encounters'}) will return
|
@@ -97,15 +121,27 @@ QDMPatientSchema.methods.getByProfile = function getByProfile(profile, isNegated
|
|
97
121
|
// @param {String} profile - the data criteria requested by the execution engine
|
98
122
|
// @returns {Object}
|
99
123
|
QDMPatientSchema.methods.findRecords = function findRecords(profile) {
|
124
|
+
// Clear profile cache for this patient if there is no cache or the patient has changed
|
125
|
+
if (QDMPatientSchema.dataElementCache == null
|
126
|
+
|| QDMPatientSchema.dataElementCachePatientId !== this._id) {
|
127
|
+
QDMPatientSchema.dataElementCache = {};
|
128
|
+
QDMPatientSchema.dataElementCachePatientId = this._id;
|
129
|
+
}
|
130
|
+
// If there is a cache 'hit', return it
|
131
|
+
if (Object.prototype.hasOwnProperty.call(QDMPatientSchema.dataElementCache, profile)) {
|
132
|
+
return QDMPatientSchema.dataElementCache[profile];
|
133
|
+
}
|
100
134
|
let profileStripped;
|
101
135
|
if (profile === 'Patient') {
|
102
136
|
// Requested generic patient info
|
103
137
|
const info = { birthDatetime: this.birthDatetime };
|
138
|
+
QDMPatientSchema.dataElementCache[profile] = [info];
|
104
139
|
return [info];
|
105
140
|
} else if (/PatientCharacteristic/.test(profile)) {
|
106
141
|
// Requested a patient characteristic
|
107
142
|
profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
|
108
|
-
|
143
|
+
QDMPatientSchema.dataElementCache[profile] = this.getByProfile(profileStripped);
|
144
|
+
return QDMPatientSchema.dataElementCache[profile];
|
109
145
|
} else if (profile != null) {
|
110
146
|
// Requested something else (probably a QDM data type).
|
111
147
|
|
@@ -120,14 +156,17 @@ QDMPatientSchema.methods.findRecords = function findRecords(profile) {
|
|
120
156
|
if (/Positive/.test(profileStripped)) {
|
121
157
|
profileStripped = profileStripped.replace(/Positive/, '');
|
122
158
|
// Since the data criteria is 'Positive', it is not negated.
|
123
|
-
|
159
|
+
QDMPatientSchema.dataElementCache[profile] = this.getByProfile(profileStripped, false);
|
160
|
+
return QDMPatientSchema.dataElementCache[profile];
|
124
161
|
} else if (/Negative/.test(profileStripped)) {
|
125
162
|
profileStripped = profileStripped.replace(/Negative/, '');
|
126
163
|
// Since the data criteria is 'Negative', it is negated.
|
127
|
-
|
164
|
+
QDMPatientSchema.dataElementCache[profile] = this.getByProfile(profileStripped, true);
|
165
|
+
return QDMPatientSchema.dataElementCache[profile];
|
128
166
|
}
|
129
167
|
// No negation status, proceed normally
|
130
|
-
|
168
|
+
QDMPatientSchema.dataElementCache[profile] = this.getByProfile(profileStripped);
|
169
|
+
return QDMPatientSchema.dataElementCache[profile];
|
131
170
|
}
|
132
171
|
return [];
|
133
172
|
};
|
@@ -248,6 +287,11 @@ QDMPatientSchema.methods.vital_signs = function vital_signs() {
|
|
248
287
|
return this.getDataElements({ qdmCategory: 'vital_sign' });
|
249
288
|
};
|
250
289
|
|
290
|
+
QDMPatientSchema.clearDataElementCache = function clearDataElementCache() {
|
291
|
+
QDMPatientSchema.dataElementCachePatientId = null;
|
292
|
+
QDMPatientSchema.dataElementCache = null;
|
293
|
+
};
|
294
|
+
|
251
295
|
module.exports.QDMPatientSchema = QDMPatientSchema;
|
252
296
|
class QDMPatient extends mongoose.Document {
|
253
297
|
constructor(object) {
|