cqm-models 0.8.3 → 0.8.4
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/app/assets/javascripts/AdverseEvent.js +1 -0
- data/app/assets/javascripts/AllergyIntolerance.js +1 -0
- data/app/assets/javascripts/AssessmentPerformed.js +2 -1
- data/app/assets/javascripts/AssessmentRecommended.js +1 -0
- data/app/assets/javascripts/CareGoal.js +2 -1
- data/app/assets/javascripts/CommunicationFromPatientToProvider.js +2 -1
- data/app/assets/javascripts/CommunicationFromProviderToPatient.js +2 -1
- data/app/assets/javascripts/CommunicationFromProviderToProvider.js +2 -1
- data/app/assets/javascripts/Component.js +1 -0
- data/app/assets/javascripts/DeviceApplied.js +1 -0
- data/app/assets/javascripts/DeviceOrder.js +1 -0
- data/app/assets/javascripts/DeviceRecommended.js +1 -0
- data/app/assets/javascripts/Diagnosis.js +1 -0
- data/app/assets/javascripts/DiagnosticStudyOrder.js +1 -0
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +1 -0
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +1 -0
- data/app/assets/javascripts/EncounterOrder.js +1 -0
- data/app/assets/javascripts/EncounterPerformed.js +1 -0
- data/app/assets/javascripts/EncounterRecommended.js +1 -0
- data/app/assets/javascripts/FacilityLocation.js +1 -0
- data/app/assets/javascripts/FamilyHistory.js +1 -0
- data/app/assets/javascripts/Id.js +2 -10
- data/app/assets/javascripts/ImmunizationAdministered.js +1 -0
- data/app/assets/javascripts/ImmunizationOrder.js +1 -0
- data/app/assets/javascripts/InterventionOrder.js +1 -0
- data/app/assets/javascripts/InterventionPerformed.js +1 -0
- data/app/assets/javascripts/InterventionRecommended.js +1 -0
- data/app/assets/javascripts/LaboratoryTestOrder.js +1 -0
- data/app/assets/javascripts/LaboratoryTestPerformed.js +1 -0
- data/app/assets/javascripts/LaboratoryTestRecommended.js +1 -0
- data/app/assets/javascripts/MedicationActive.js +1 -0
- data/app/assets/javascripts/MedicationAdministered.js +1 -0
- data/app/assets/javascripts/MedicationDischarge.js +1 -0
- data/app/assets/javascripts/MedicationDispensed.js +1 -0
- data/app/assets/javascripts/MedicationOrder.js +1 -0
- data/app/assets/javascripts/Participation.js +1 -0
- data/app/assets/javascripts/Patient.js +4 -8
- data/app/assets/javascripts/PatientCareExperience.js +1 -0
- data/app/assets/javascripts/PatientCharacteristic.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicExpired.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicPayer.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicRace.js +1 -0
- data/app/assets/javascripts/PatientCharacteristicSex.js +1 -0
- data/app/assets/javascripts/PhysicalExamOrder.js +1 -0
- data/app/assets/javascripts/PhysicalExamPerformed.js +1 -0
- data/app/assets/javascripts/PhysicalExamRecommended.js +1 -0
- data/app/assets/javascripts/ProcedureOrder.js +1 -0
- data/app/assets/javascripts/ProcedurePerformed.js +1 -0
- data/app/assets/javascripts/ProcedureRecommended.js +1 -0
- data/app/assets/javascripts/ProviderCareExperience.js +1 -0
- data/app/assets/javascripts/ProviderCharacteristic.js +1 -0
- data/app/assets/javascripts/Ratio.js +1 -0
- data/app/assets/javascripts/ResultComponent.js +1 -0
- data/app/assets/javascripts/SubstanceAdministered.js +1 -0
- data/app/assets/javascripts/SubstanceOrder.js +1 -0
- data/app/assets/javascripts/SubstanceRecommended.js +1 -0
- data/app/assets/javascripts/Symptom.js +1 -0
- data/app/assets/javascripts/basetypes/Any.js +1 -1
- data/app/assets/javascripts/basetypes/DataElement.js +7 -0
- data/app/models/models.rb +3 -1
- data/app/models/qdm/assessment_performed.rb +1 -1
- data/app/models/qdm/basetypes/data_element.rb +8 -5
- data/app/models/qdm/care_goal.rb +1 -1
- data/app/models/qdm/communication_from_patient_to_provider.rb +1 -1
- data/app/models/qdm/communication_from_provider_to_patient.rb +1 -1
- data/app/models/qdm/communication_from_provider_to_provider.rb +1 -1
- data/app/models/qdm/component.rb +0 -1
- data/app/models/qdm/facility_location.rb +0 -1
- data/app/models/qdm/id.rb +2 -2
- data/cqm-models.gemspec +1 -1
- data/dist/index.js +137 -84
- data/lib/generate_models.rb +27 -19
- data/package.json +1 -1
- data/templates/id_template.js.erb +15 -0
- data/templates/models_template.rb.erb +4 -0
- data/templates/mongoose_template.js.erb +1 -0
- data/templates/patient_template.js.erb +4 -8
- metadata +4 -3
data/lib/generate_models.rb
CHANGED
@@ -25,7 +25,6 @@ TYPE_LOOKUP_RB = {
|
|
25
25
|
'list<QDM.ResultComponent>': 'Array',
|
26
26
|
'list<QDM.FacilityLocation>': 'Array',
|
27
27
|
'list<System.Code>': 'Array',
|
28
|
-
'QDM.Id': 'String',
|
29
28
|
'System.Decimal': 'Float',
|
30
29
|
'System.Time': 'Time',
|
31
30
|
'System.Concept': 'Any'
|
@@ -42,11 +41,10 @@ TYPE_LOOKUP_JS = {
|
|
42
41
|
'interval<System.Quantity>': 'Interval',
|
43
42
|
'list<QDM.Component>': '[]',
|
44
43
|
'System.String': 'String',
|
45
|
-
'list<QDM.Id>': '[
|
44
|
+
'list<QDM.Id>': '[]',
|
46
45
|
'list<QDM.ResultComponent>': '[]',
|
47
46
|
'list<QDM.FacilityLocation>': '[]',
|
48
47
|
'list<System.Code>': '[Code]',
|
49
|
-
'QDM.Id': 'String',
|
50
48
|
'System.Decimal': 'Number',
|
51
49
|
'System.Time': 'DateTime',
|
52
50
|
'System.Concept': '{}'
|
@@ -151,7 +149,7 @@ puts 'Generating JavaScript models...'
|
|
151
149
|
|
152
150
|
# Create JavaScript models
|
153
151
|
template = File.read('templates/mongoose_template.js.erb')
|
154
|
-
|
152
|
+
default_renderer = ERB.new(template, nil, '-')
|
155
153
|
file_path = 'app/assets/javascripts/'
|
156
154
|
file_path = 'tmp/' if IS_TEST
|
157
155
|
extra_fields_js = [
|
@@ -162,19 +160,19 @@ extra_fields_js = [
|
|
162
160
|
{ name: 'qdmVersion', type: 'System.String' },
|
163
161
|
{ name: '_type', type: 'System.String' }
|
164
162
|
]
|
163
|
+
datatype_custom_templates = {
|
164
|
+
Patient: 'templates/patient_template.js.erb',
|
165
|
+
Id: 'templates/id_template.js.erb'
|
166
|
+
}
|
165
167
|
datatypes.each do |datatype, attributes|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
attrs_with_extras = attributes + extra_fields_js
|
171
|
-
puts ' ' + file_path + datatype + '.js'
|
172
|
-
File.open(file_path + datatype + '.js', 'w') { |file| file.puts patient_renderer.result(binding) }
|
173
|
-
else
|
174
|
-
attrs_with_extras = attributes + extra_fields_js
|
175
|
-
puts ' ' + file_path + datatype + '.js'
|
176
|
-
File.open(file_path + datatype + '.js', 'w') { |file| file.puts renderer.result(binding) }
|
168
|
+
renderer = default_renderer
|
169
|
+
if datatype_custom_templates.key?(datatype.to_sym)
|
170
|
+
puts "using custom template for #{datatype}"
|
171
|
+
renderer = ERB.new(File.read(datatype_custom_templates[datatype.to_sym]), nil, '-')
|
177
172
|
end
|
173
|
+
attrs_with_extras = attributes + extra_fields_js # this field gets used in the template
|
174
|
+
puts ' ' + file_path + datatype + '.js'
|
175
|
+
File.open(file_path + datatype + '.js', 'w') { |file| file.puts renderer.result(binding) }
|
178
176
|
end
|
179
177
|
|
180
178
|
# Create require file (if not in test mode)
|
@@ -240,6 +238,9 @@ Dir.glob(ruby_models_path + '*.rb').each do |file_name|
|
|
240
238
|
contents.gsub!(/ field :qdmStatus, type: String\n/, '') # Don't include this field
|
241
239
|
end
|
242
240
|
|
241
|
+
# Make relatedTo embeds_many instead of field
|
242
|
+
contents.gsub!(/ field :relatedTo, type: Array\n/, " embeds_many :relatedTo, class_name: 'QDM::Id'\n")
|
243
|
+
|
243
244
|
File.open(file_name, 'w') { |file| file.puts contents }
|
244
245
|
end
|
245
246
|
|
@@ -287,11 +288,12 @@ files = Dir.glob(js_models_path + '*.js').each do |file_name|
|
|
287
288
|
# Add class
|
288
289
|
contents.gsub!(/ _type: String,\n/, " _type: { type: String, default: '#{dc_name.camelize}' },\n")
|
289
290
|
|
290
|
-
# Component and
|
291
|
+
# Component, Facility, and Id types
|
291
292
|
contents.gsub!(/facilityLocations: \[\]/, 'facilityLocations: [FacilityLocationSchema]')
|
292
293
|
contents.gsub!(/facilityLocation: Code/, 'facilityLocation: FacilityLocationSchema')
|
293
294
|
contents.gsub!(/components: \[\]/, 'components: [ComponentSchema]')
|
294
295
|
contents.gsub!(/component: Code/, 'component: ComponentSchema')
|
296
|
+
contents.gsub!(/relatedTo: \[\]/, 'relatedTo: [IdSchema]')
|
295
297
|
|
296
298
|
File.open(file_name, 'w') { |file| file.puts contents }
|
297
299
|
end
|
@@ -318,8 +320,14 @@ end
|
|
318
320
|
# Set embedded in for datatypes
|
319
321
|
Dir.glob(ruby_models_path + '*.rb').each do |file_name|
|
320
322
|
contents = File.read(file_name)
|
321
|
-
|
322
|
-
|
323
|
+
# TODO: Might be able to make this list by finding baseType="System.Any" in model info file instead of hard-coding.
|
324
|
+
if File.basename(file_name) == 'id.rb'
|
325
|
+
contents.gsub!(/ include Mongoid::Document\n/, " include Mongoid::Document\n embedded_in :data_element\n")
|
326
|
+
else
|
327
|
+
not_embedded_in_patient_files = ['patient.rb', 'component.rb', 'facility_location.rb']
|
328
|
+
next if not_embedded_in_patient_files.include?(File.basename(file_name))
|
329
|
+
contents.gsub!(/ include Mongoid::Document\n/, " include Mongoid::Document\n embedded_in :patient\n")
|
330
|
+
end
|
323
331
|
File.open(file_name, 'w') { |file| file.puts contents }
|
324
332
|
end
|
325
333
|
|
@@ -327,7 +335,7 @@ end
|
|
327
335
|
Dir.glob(ruby_models_path + '*.rb').each do |file_name|
|
328
336
|
contents = ''
|
329
337
|
File.open(file_name).each_line.with_index do |line, index|
|
330
|
-
line.gsub!("\n", " < DataElement\n") if index.zero? && !file_name.include?('/patient.rb')
|
338
|
+
line.gsub!("\n", " < DataElement\n") if index.zero? && !file_name.include?('/patient.rb') && !file_name.include?('/id.rb')
|
331
339
|
contents += "module QDM\n # #{file_name}\n #{line.gsub('QDM::', '')}" if index.zero?
|
332
340
|
contents += ' ' unless index.zero? || line.blank?
|
333
341
|
contents += line unless index.zero?
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cqm-models",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.4",
|
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": {
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const mongoose = require('mongoose');
|
2
|
+
|
3
|
+
const [Number, String] = [
|
4
|
+
mongoose.Schema.Types.Number,
|
5
|
+
mongoose.Schema.Types.String,
|
6
|
+
];
|
7
|
+
|
8
|
+
const IdSchema = mongoose.Schema({
|
9
|
+
<%- for attribute in attrs_with_extras -%>
|
10
|
+
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
|
11
|
+
<%- end %>
|
12
|
+
}, { _id: false, id: false });
|
13
|
+
|
14
|
+
module.exports.IdSchema = IdSchema;
|
15
|
+
module.exports.Id = mongoose.model('Id', IdSchema);
|
@@ -3,6 +3,9 @@ module QDM
|
|
3
3
|
end
|
4
4
|
require 'mongoid'
|
5
5
|
|
6
|
+
# Generated models that are dependencies for base types
|
7
|
+
require_relative 'qdm/id'
|
8
|
+
|
6
9
|
# base types
|
7
10
|
require_relative 'qdm/basetypes/code'
|
8
11
|
require_relative 'qdm/basetypes/interval'
|
@@ -18,5 +21,6 @@ require_relative 'qdm/tacoma/individual_result'
|
|
18
21
|
|
19
22
|
# Generated models
|
20
23
|
<%- datatypes.each_key do |datatype| -%>
|
24
|
+
<%- next if datatype.underscore == 'id' -%>
|
21
25
|
require_relative 'qdm/<%= datatype.underscore %>'
|
22
26
|
<%- end -%>
|
@@ -6,6 +6,7 @@ const Quantity = require('./basetypes/Quantity');
|
|
6
6
|
const DateTime = require('./basetypes/DateTime');
|
7
7
|
<% unless datatype.downcase.include? 'component' %>const { ComponentSchema } = require('./Component');<% end %>
|
8
8
|
<% unless datatype.downcase.include? 'facilitylocation' %>const { FacilityLocationSchema } = require('./FacilityLocation');<% end %>
|
9
|
+
<% unless datatype.downcase == 'id' %>const { IdSchema } = require('./Id');<% end %>
|
9
10
|
const Any = require('./basetypes/Any');
|
10
11
|
|
11
12
|
const [Number, String] = [
|
@@ -89,15 +89,11 @@ PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated =
|
|
89
89
|
// If isNegated == null, return all matching data elements by type, regardless of negationRationale.
|
90
90
|
const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated));
|
91
91
|
return results.map((result) => {
|
92
|
-
const getCodeFunction = Object.getPrototypeOf(result).getCode;
|
93
|
-
const codeFunction = Object.getPrototypeOf(result).code;
|
94
|
-
const idField = result.id;
|
95
92
|
const removedMongooseItems = AllDataElements[profile](result).toObject();
|
96
|
-
// toObject() will remove all mongoose functions but also
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
removedMongooseItems.id = idField;
|
93
|
+
// toObject() will remove all mongoose functions but also remove the schema methods, so we add them back
|
94
|
+
Object.entries(Object.getPrototypeOf(result).schema.methods).forEach(([method_name, method]) => {
|
95
|
+
removedMongooseItems[method_name] = method;
|
96
|
+
});
|
101
97
|
return removedMongooseItems;
|
102
98
|
});
|
103
99
|
};
|
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.4
|
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-08-
|
13
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -289,6 +289,7 @@ files:
|
|
289
289
|
- modelinfo/qdm-modelinfo-5.3.xml
|
290
290
|
- package.json
|
291
291
|
- templates/all_data_elements_template.js.erb
|
292
|
+
- templates/id_template.js.erb
|
292
293
|
- templates/index_template.js.erb
|
293
294
|
- templates/models_template.rb.erb
|
294
295
|
- templates/mongoose_template.js.erb
|
@@ -316,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
317
|
version: '0'
|
317
318
|
requirements: []
|
318
319
|
rubyforge_project:
|
319
|
-
rubygems_version: 2.6.
|
320
|
+
rubygems_version: 2.6.14
|
320
321
|
signing_key:
|
321
322
|
specification_version: 4
|
322
323
|
summary: Mongo models that correspond to the QDM specification.
|