cqm-models 0.8.0 → 0.8.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 +2 -2
- data/.github/PULL_REQUEST_TEMPLATE.md +3 -0
- data/app/assets/javascripts/AdverseEvent.js +3 -1
- data/app/assets/javascripts/AllergyIntolerance.js +2 -0
- data/app/assets/javascripts/AssessmentPerformed.js +1 -0
- data/app/assets/javascripts/AssessmentRecommended.js +2 -0
- data/app/assets/javascripts/CareGoal.js +2 -0
- data/app/assets/javascripts/CommunicationFromPatientToProvider.js +2 -0
- data/app/assets/javascripts/CommunicationFromProviderToPatient.js +2 -0
- data/app/assets/javascripts/CommunicationFromProviderToProvider.js +2 -0
- data/app/assets/javascripts/Component.js +3 -1
- data/app/assets/javascripts/DeviceApplied.js +2 -0
- data/app/assets/javascripts/DeviceOrder.js +2 -0
- data/app/assets/javascripts/DeviceRecommended.js +2 -0
- data/app/assets/javascripts/Diagnosis.js +2 -0
- data/app/assets/javascripts/DiagnosticStudyOrder.js +2 -0
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +2 -1
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +2 -0
- data/app/assets/javascripts/EncounterOrder.js +3 -1
- data/app/assets/javascripts/EncounterPerformed.js +1 -0
- data/app/assets/javascripts/EncounterRecommended.js +3 -1
- data/app/assets/javascripts/FacilityLocation.js +3 -1
- data/app/assets/javascripts/FamilyHistory.js +2 -0
- data/app/assets/javascripts/Id.js +2 -0
- data/app/assets/javascripts/ImmunizationAdministered.js +2 -0
- data/app/assets/javascripts/ImmunizationOrder.js +2 -0
- data/app/assets/javascripts/IndividualResult.js +4 -1
- data/app/assets/javascripts/InterventionOrder.js +2 -0
- data/app/assets/javascripts/InterventionPerformed.js +2 -0
- data/app/assets/javascripts/InterventionRecommended.js +2 -0
- data/app/assets/javascripts/LaboratoryTestOrder.js +2 -0
- data/app/assets/javascripts/LaboratoryTestPerformed.js +1 -0
- data/app/assets/javascripts/LaboratoryTestRecommended.js +2 -0
- data/app/assets/javascripts/MedicationActive.js +2 -0
- data/app/assets/javascripts/MedicationAdministered.js +2 -0
- data/app/assets/javascripts/MedicationDischarge.js +2 -0
- data/app/assets/javascripts/MedicationDispensed.js +2 -0
- data/app/assets/javascripts/MedicationOrder.js +2 -0
- data/app/assets/javascripts/Participation.js +2 -0
- data/app/assets/javascripts/Patient.js +22 -10
- data/app/assets/javascripts/PatientCareExperience.js +2 -0
- data/app/assets/javascripts/PatientCharacteristic.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicExpired.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicPayer.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicRace.js +2 -0
- data/app/assets/javascripts/PatientCharacteristicSex.js +2 -0
- data/app/assets/javascripts/PhysicalExamOrder.js +2 -0
- data/app/assets/javascripts/PhysicalExamPerformed.js +1 -0
- data/app/assets/javascripts/PhysicalExamRecommended.js +2 -0
- data/app/assets/javascripts/ProcedureOrder.js +2 -0
- data/app/assets/javascripts/ProcedurePerformed.js +2 -2
- data/app/assets/javascripts/ProcedureRecommended.js +2 -0
- data/app/assets/javascripts/ProviderCareExperience.js +2 -0
- data/app/assets/javascripts/ProviderCharacteristic.js +2 -0
- data/app/assets/javascripts/Ratio.js +2 -0
- data/app/assets/javascripts/ResultComponent.js +2 -0
- data/app/assets/javascripts/SubstanceAdministered.js +2 -0
- data/app/assets/javascripts/SubstanceOrder.js +2 -0
- data/app/assets/javascripts/SubstanceRecommended.js +2 -0
- data/app/assets/javascripts/Symptom.js +2 -0
- data/app/assets/javascripts/basetypes/Any.js +15 -0
- data/app/assets/javascripts/basetypes/Code.js +20 -10
- data/app/assets/javascripts/basetypes/DataElement.js +13 -13
- data/app/models/qdm/patient.rb +1 -1
- data/cqm-models.gemspec +1 -1
- data/dist/index.js +527 -231
- data/lib/generate_models.rb +6 -0
- data/package.json +3 -3
- data/templates/models_template.rb.erb +1 -0
- data/templates/mongoose_template.js.erb +10 -2
- data/templates/patient_extension.rb.erb +12 -1
- data/templates/patient_template.js.erb +24 -11
- data/yarn.lock +3 -3
- metadata +3 -3
data/lib/generate_models.rb
CHANGED
@@ -284,6 +284,12 @@ files = Dir.glob(js_models_path + '*.js').each do |file_name|
|
|
284
284
|
# Add class
|
285
285
|
contents.gsub!(/ _type: String,\n/, " _type: { type: String, default: '#{dc_name.camelize}' },\n")
|
286
286
|
|
287
|
+
# Component and Facility types
|
288
|
+
contents.gsub!(/facilityLocations: \[\]/, 'facilityLocations: [FacilityLocationSchema]')
|
289
|
+
contents.gsub!(/facilityLocation: Code/, 'facilityLocation: FacilityLocationSchema')
|
290
|
+
contents.gsub!(/components: \[\]/, 'components: [ComponentSchema]')
|
291
|
+
contents.gsub!(/component: Code/, 'component: ComponentSchema')
|
292
|
+
|
287
293
|
File.open(file_name, 'w') { |file| file.puts contents }
|
288
294
|
end
|
289
295
|
|
data/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "cqm-models",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.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": {
|
7
7
|
"index.js": "dist/index.js"
|
8
8
|
},
|
9
9
|
"repository": "https://github.com/projecttacoma/cqm-models.git",
|
10
|
-
"homepage": "https://github.com/
|
10
|
+
"homepage": "https://github.com/projecttacoma/cqm-models#readme",
|
11
11
|
"contributors": [
|
12
12
|
"Louis Ades <lades@mitre.org>",
|
13
13
|
"Michael O'Keefe <mokeefe@mitre.org>",
|
@@ -15,7 +15,7 @@
|
|
15
15
|
],
|
16
16
|
"license": "Apache-2.0",
|
17
17
|
"dependencies": {
|
18
|
-
"cql-execution": "1.2.
|
18
|
+
"cql-execution": "1.2.2",
|
19
19
|
"mongoose": "^5.0.7"
|
20
20
|
},
|
21
21
|
"devDependencies": {
|
@@ -14,6 +14,7 @@ require_relative 'qdm/tacoma/measure'
|
|
14
14
|
require_relative 'qdm/tacoma/measure_package'
|
15
15
|
require_relative 'qdm/tacoma/valueset'
|
16
16
|
require_relative 'qdm/tacoma/concept'
|
17
|
+
require_relative 'qdm/tacoma/individual_result'
|
17
18
|
|
18
19
|
# Generated models
|
19
20
|
<%- datatypes.each_key do |datatype| -%>
|
@@ -4,18 +4,26 @@ const Code = require('./basetypes/Code');
|
|
4
4
|
const Interval = require('./basetypes/Interval');
|
5
5
|
const Quantity = require('./basetypes/Quantity');
|
6
6
|
const DateTime = require('./basetypes/DateTime');
|
7
|
+
<% unless datatype.downcase.include? 'component' %>const { ComponentSchema } = require('./Component');<% end %>
|
8
|
+
<% unless datatype.downcase.include? 'facilitylocation' %>const { FacilityLocationSchema } = require('./FacilityLocation');<% end %>
|
7
9
|
const Any = require('./basetypes/Any');
|
8
10
|
|
9
11
|
const [Number, String] = [
|
10
12
|
mongoose.Schema.Types.Number,
|
11
13
|
mongoose.Schema.Types.String,
|
12
14
|
];
|
13
|
-
|
15
|
+
<% unless datatype == 'Component' || datatype == 'FacilityLocation' %>
|
14
16
|
const <%= datatype -%>Schema = DataElementSchema({
|
15
17
|
<%- for attribute in attrs_with_extras -%>
|
16
18
|
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
|
17
19
|
<%- end %>
|
18
20
|
});
|
19
|
-
|
21
|
+
<% else %>
|
22
|
+
const <%= datatype -%>Schema = new mongoose.Schema({
|
23
|
+
<%- for attribute in attrs_with_extras -%>
|
24
|
+
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
|
25
|
+
<%- end %>
|
26
|
+
});
|
27
|
+
<% end %>
|
20
28
|
module.exports.<%= datatype %>Schema = <%= datatype %>Schema;
|
21
29
|
module.exports.<%= datatype %> = mongoose.model('<%= datatype %>', <%= datatype %>Schema);
|
@@ -23,6 +23,17 @@
|
|
23
23
|
dataElements.where(qrdaOid: qrda_oid) || []
|
24
24
|
end
|
25
25
|
|
26
|
+
# Shift all data element fields that deal with dates by the given value.
|
27
|
+
# Given value should be in seconds. Positive values shift forward, negative
|
28
|
+
# values shift backwards.
|
29
|
+
#
|
30
|
+
# Note: This will shift dates of the birthdate and
|
31
|
+
# dates on the data elements that exist on the patient.
|
32
|
+
def shift_dates(seconds)
|
33
|
+
self.birthDatetime = (birthDatetime.utc.to_time + seconds.seconds).to_datetime
|
34
|
+
dataElements.each { |element| element.shift_dates(seconds) }
|
35
|
+
end
|
36
|
+
|
26
37
|
# Returns an array of elements that exist on this patient. Optionally
|
27
38
|
# takes a category and/or, which returns all elements of that QDM
|
28
39
|
# category. Example: patient.get_data_elements('encounters')
|
@@ -191,4 +202,4 @@
|
|
191
202
|
def to_json(options = nil)
|
192
203
|
serializable_hash(methods: :_type).to_json(options)
|
193
204
|
end
|
194
|
-
end
|
205
|
+
end
|
@@ -5,10 +5,11 @@ const Quantity = require('./basetypes/Quantity');
|
|
5
5
|
const DateTime = require('./basetypes/DateTime');
|
6
6
|
const AllDataElements = require('./AllDataElements');
|
7
7
|
|
8
|
-
const [Schema, Number, String] = [
|
8
|
+
const [Schema, Number, String, Mixed] = [
|
9
9
|
mongoose.Schema,
|
10
10
|
mongoose.Schema.Types.Number,
|
11
11
|
mongoose.Schema.Types.String,
|
12
|
+
mongoose.Schema.Types.Mixed,
|
12
13
|
];
|
13
14
|
|
14
15
|
const PatientSchema = new Schema({
|
@@ -24,7 +25,10 @@ const PatientSchema = new Schema({
|
|
24
25
|
// This field is for application specific information only. If both Bonnie
|
25
26
|
// Cypress use a common field, it should be made a field on this model,
|
26
27
|
// and not put into extendedData.
|
27
|
-
extendedData: {
|
28
|
+
extendedData: {
|
29
|
+
type: Mixed,
|
30
|
+
default: {},
|
31
|
+
},
|
28
32
|
}, { id: false });
|
29
33
|
|
30
34
|
// After initialization of a Patient model, initialize every individual data element
|
@@ -77,26 +81,35 @@ PatientSchema.methods.getDataElements = function getDataElements(params) {
|
|
77
81
|
// Returns an array of dataElements that exist on the patient, queried by
|
78
82
|
// QDM profile
|
79
83
|
PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated = null) {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
// If isNegated == true, only return data elements with a negationRationale that is not null.
|
85
|
+
// If isNegated == false, only return data elements with a null negationRationale.
|
86
|
+
// If isNegated == null, return all matching data elements by type, regardless of negationRationale.
|
87
|
+
const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated));
|
88
|
+
return results.map((result) => {
|
89
|
+
const getCodeFunction = Object.getPrototypeOf(result).getCode;
|
90
|
+
const codeFunction = Object.getPrototypeOf(result).code;
|
91
|
+
const removedMongooseItems = AllDataElements[profile](result).toObject();
|
92
|
+
// toObject() will remove all mongoose functions but also removed the getCode and code functions
|
93
|
+
// the execution engine requires the code and getCode functions so we have to add them back
|
94
|
+
removedMongooseItems.getCode = getCodeFunction;
|
95
|
+
removedMongooseItems.code = codeFunction;
|
96
|
+
return removedMongooseItems;
|
97
|
+
});
|
86
98
|
};
|
87
99
|
|
88
100
|
// This method is called by the CQL execution engine on a CQLPatient when
|
89
101
|
// the execution engine wants information on a record. A record could be patient
|
90
102
|
// characteristic information about the patient, or it could be data criteria
|
91
103
|
// that currently exist on this patient (data criteria you drag on a patient
|
92
|
-
// in Bonnie
|
104
|
+
// in Bonnie patient builder).
|
93
105
|
// @param {String} profile - the data criteria requested by the execution engine
|
94
106
|
// @returns {Object}
|
95
107
|
PatientSchema.methods.findRecords = function findRecords(profile) {
|
96
108
|
let profileStripped;
|
97
109
|
if (profile === 'Patient') {
|
98
110
|
// Requested generic patient info
|
99
|
-
|
111
|
+
const info = { birthDatetime: this.birthDatetime };
|
112
|
+
return [info];
|
100
113
|
} else if (/PatientCharacteristic/.test(profile)) {
|
101
114
|
// Requested a patient characteristic
|
102
115
|
profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
|
@@ -105,7 +118,7 @@ PatientSchema.methods.findRecords = function findRecords(profile) {
|
|
105
118
|
// Requested something else (probably a QDM data type).
|
106
119
|
|
107
120
|
// Strip model details from request. The requested profile string contains
|
108
|
-
// a lot of things we
|
121
|
+
// a lot of things we do not need or care about. Example, we might see
|
109
122
|
// something like:
|
110
123
|
// "{urn:healthit-gov:qdm:v5_0_draft}PatientCharacteristicEthnicity"
|
111
124
|
// Where we only care about: "PatientCharacteristicEthnicity".
|
data/yarn.lock
CHANGED
@@ -442,9 +442,9 @@ core-util-is@~1.0.0:
|
|
442
442
|
version "1.0.2"
|
443
443
|
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
444
444
|
|
445
|
-
cql-execution@1.2.
|
446
|
-
version "1.2.
|
447
|
-
resolved "https://registry.yarnpkg.com/cql-execution/-/cql-execution-1.2.
|
445
|
+
cql-execution@1.2.2:
|
446
|
+
version "1.2.2"
|
447
|
+
resolved "https://registry.yarnpkg.com/cql-execution/-/cql-execution-1.2.2.tgz#2d8933e96edc2c0ff04992444fc8d79e3cb556bb"
|
448
448
|
dependencies:
|
449
449
|
moment "^2.20.1"
|
450
450
|
ucum "0.0.7"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cqm-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aholmes@mitre.org
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-07-
|
13
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
318
|
rubyforge_project:
|
319
|
-
rubygems_version: 2.6.
|
319
|
+
rubygems_version: 2.6.12
|
320
320
|
signing_key:
|
321
321
|
specification_version: 4
|
322
322
|
summary: Mongo models that correspond to the QDM specification.
|