cqm-models 1.0.3 → 1.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.eslintrc.json +10 -2
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +31 -1
- data/README.md +59 -2
- data/app/assets/javascripts/AdverseEvent.js +16 -7
- data/app/assets/javascripts/AllDataElements.js +6 -6
- data/app/assets/javascripts/AllergyIntolerance.js +16 -7
- data/app/assets/javascripts/AssessmentOrder.js +15 -6
- data/app/assets/javascripts/AssessmentPerformed.js +16 -7
- data/app/assets/javascripts/AssessmentRecommended.js +16 -7
- data/app/assets/javascripts/CareGoal.js +16 -7
- data/app/assets/javascripts/CommunicationPerformed.js +15 -6
- data/app/assets/javascripts/DeviceApplied.js +16 -7
- data/app/assets/javascripts/DeviceOrder.js +16 -7
- data/app/assets/javascripts/DeviceRecommended.js +16 -7
- data/app/assets/javascripts/Diagnosis.js +16 -7
- data/app/assets/javascripts/DiagnosticStudyOrder.js +16 -7
- data/app/assets/javascripts/DiagnosticStudyPerformed.js +16 -7
- data/app/assets/javascripts/DiagnosticStudyRecommended.js +16 -7
- data/app/assets/javascripts/EncounterOrder.js +16 -7
- data/app/assets/javascripts/EncounterPerformed.js +16 -7
- data/app/assets/javascripts/EncounterRecommended.js +16 -7
- data/app/assets/javascripts/FamilyHistory.js +16 -7
- data/app/assets/javascripts/Id.js +7 -3
- data/app/assets/javascripts/ImmunizationAdministered.js +16 -7
- data/app/assets/javascripts/ImmunizationOrder.js +16 -7
- data/app/assets/javascripts/IndividualResult.js +7 -2
- data/app/assets/javascripts/InterventionOrder.js +16 -7
- data/app/assets/javascripts/InterventionPerformed.js +16 -7
- data/app/assets/javascripts/InterventionRecommended.js +16 -7
- data/app/assets/javascripts/LaboratoryTestOrder.js +16 -7
- data/app/assets/javascripts/LaboratoryTestPerformed.js +16 -7
- data/app/assets/javascripts/LaboratoryTestRecommended.js +16 -7
- data/app/assets/javascripts/MedicationActive.js +16 -7
- data/app/assets/javascripts/MedicationAdministered.js +16 -7
- data/app/assets/javascripts/MedicationDischarge.js +16 -7
- data/app/assets/javascripts/MedicationDispensed.js +16 -7
- data/app/assets/javascripts/MedicationOrder.js +16 -7
- data/app/assets/javascripts/Participation.js +15 -6
- data/app/assets/javascripts/PatientCareExperience.js +16 -7
- data/app/assets/javascripts/PatientCharacteristic.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicBirthdate.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicEthnicity.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicExpired.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicPayer.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicRace.js +16 -7
- data/app/assets/javascripts/PatientCharacteristicSex.js +16 -7
- data/app/assets/javascripts/PhysicalExamOrder.js +16 -7
- data/app/assets/javascripts/PhysicalExamPerformed.js +16 -7
- data/app/assets/javascripts/PhysicalExamRecommended.js +16 -7
- data/app/assets/javascripts/ProcedureOrder.js +16 -7
- data/app/assets/javascripts/ProcedurePerformed.js +16 -7
- data/app/assets/javascripts/ProcedureRecommended.js +16 -7
- data/app/assets/javascripts/ProviderCareExperience.js +16 -7
- data/app/assets/javascripts/ProviderCharacteristic.js +16 -7
- data/app/assets/javascripts/QDMPatient.js +262 -0
- data/app/assets/javascripts/Result.js +7 -2
- data/app/assets/javascripts/ResultComponent.js +14 -6
- data/app/assets/javascripts/SubstanceAdministered.js +16 -7
- data/app/assets/javascripts/SubstanceOrder.js +16 -7
- data/app/assets/javascripts/SubstanceRecommended.js +16 -7
- data/app/assets/javascripts/Symptom.js +16 -7
- data/app/assets/javascripts/attributes/Component.js +30 -0
- data/app/assets/javascripts/attributes/FacilityLocation.js +30 -0
- data/app/assets/javascripts/basetypes/Any.js +1 -1
- data/app/assets/javascripts/basetypes/Code.js +1 -1
- data/app/assets/javascripts/basetypes/DataElement.js +2 -1
- data/app/assets/javascripts/basetypes/DateTime.js +5 -1
- data/app/assets/javascripts/basetypes/Interval.js +1 -1
- data/app/assets/javascripts/basetypes/Quantity.js +1 -1
- data/app/assets/javascripts/basetypes/Ratio.js +1 -1
- data/app/assets/javascripts/browser.js +3 -0
- data/app/assets/javascripts/cqm/AllCQMModels.js +24 -0
- data/app/assets/javascripts/cqm/CQLLibrary.js +32 -0
- data/app/assets/javascripts/cqm/CQLStatementDependency.js +28 -0
- data/app/assets/javascripts/cqm/Concept.js +17 -0
- data/app/assets/javascripts/cqm/Measure.js +108 -0
- data/app/assets/javascripts/{MeasurePackage.js → cqm/MeasurePackage.js} +9 -3
- data/app/assets/javascripts/cqm/Patient.js +38 -0
- data/app/assets/javascripts/cqm/PopulationSet.js +88 -0
- data/app/assets/javascripts/cqm/Provider.js +44 -0
- data/app/assets/javascripts/cqm/ValueSet.js +26 -0
- data/app/assets/javascripts/index.js +18 -8
- data/app/models/{qdm/tacoma → cqm}/concept.rb +4 -4
- data/app/models/cqm/cql_library.rb +22 -0
- data/app/models/cqm/cql_statement_dependency.rb +24 -0
- data/app/models/cqm/measure.rb +105 -0
- data/app/models/{qdm/tacoma → cqm}/measure_package.rb +2 -2
- data/app/models/cqm/patient.rb +20 -0
- data/app/models/cqm/population_set.rb +86 -0
- data/app/models/cqm/provider.rb +110 -0
- data/app/models/cqm/valueset.rb +15 -0
- data/app/models/hqmfOid_to_datatype_map.json +55 -0
- data/app/models/model_finder.rb +12 -0
- data/app/models/models.rb +18 -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 +1 -0
- data/app/models/qdm/assessment_performed.rb +2 -1
- data/app/models/qdm/assessment_recommended.rb +2 -1
- data/app/models/qdm/attributes/attribute.rb +63 -0
- data/app/models/qdm/{component.rb → attributes/component.rb} +1 -1
- data/app/models/qdm/{facility_location.rb → attributes/facility_location.rb} +1 -1
- data/app/models/qdm/basetypes/data_element.rb +21 -6
- data/app/models/qdm/basetypes/interval.rb +2 -1
- data/app/models/qdm/care_goal.rb +2 -1
- data/app/models/qdm/communication_performed.rb +1 -0
- data/app/models/qdm/device_applied.rb +2 -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 -2
- data/app/models/qdm/diagnostic_study_recommended.rb +2 -1
- data/app/models/qdm/encounter_order.rb +3 -2
- data/app/models/qdm/encounter_performed.rb +2 -1
- data/app/models/qdm/encounter_recommended.rb +3 -2
- data/app/models/qdm/family_history.rb +2 -1
- data/app/models/qdm/immunization_administered.rb +2 -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 +2 -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 +2 -1
- data/app/models/qdm/laboratory_test_recommended.rb +2 -1
- data/app/models/qdm/medication_active.rb +2 -1
- data/app/models/qdm/medication_administered.rb +2 -1
- data/app/models/qdm/medication_discharge.rb +2 -1
- 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 -0
- data/app/models/qdm/patient.rb +7 -4
- data/app/models/qdm/patient_care_experience.rb +2 -1
- data/app/models/qdm/patient_characteristic.rb +2 -1
- data/app/models/qdm/patient_characteristic_birthdate.rb +2 -1
- data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +2 -1
- data/app/models/qdm/patient_characteristic_ethnicity.rb +2 -1
- data/app/models/qdm/patient_characteristic_expired.rb +2 -1
- data/app/models/qdm/patient_characteristic_payer.rb +2 -1
- data/app/models/qdm/patient_characteristic_race.rb +2 -1
- data/app/models/qdm/patient_characteristic_sex.rb +2 -1
- data/app/models/qdm/physical_exam_order.rb +2 -1
- data/app/models/qdm/physical_exam_performed.rb +2 -1
- data/app/models/qdm/physical_exam_recommended.rb +2 -1
- data/app/models/qdm/procedure_order.rb +2 -1
- data/app/models/qdm/procedure_performed.rb +2 -1
- data/app/models/qdm/procedure_recommended.rb +2 -1
- data/app/models/qdm/provider_care_experience.rb +2 -1
- data/app/models/qdm/provider_characteristic.rb +2 -1
- data/app/models/qdm/substance_administered.rb +2 -1
- data/app/models/qdm/substance_order.rb +2 -1
- data/app/models/qdm/substance_recommended.rb +2 -1
- data/app/models/qdm/symptom.rb +2 -1
- data/bin/build_cql_execution.sh +8 -0
- data/bin/validate_browser.sh +17 -0
- data/bin/validate_generator.sh +12 -0
- data/cqm-models.gemspec +5 -2
- data/data/oids_qdm_5.4.json +321 -0
- data/data/{oids.json → oids_unversioned.json} +0 -0
- data/dist/browser.js +102937 -0
- data/dist/index.js +36637 -36540
- data/lib/generate_models.rb +89 -93
- data/lib/generate_patients.rb +125 -0
- data/lib/generate_types.rb +64 -0
- data/lib/generators/custom_mongo/model.rb.tt +20 -0
- data/lib/generators/custom_mongo/model_generator.rb +34 -0
- data/notice.md +9 -0
- data/package.json +12 -6
- data/templates/id_template.js.erb +8 -3
- data/templates/index_template.js.erb +18 -8
- data/templates/models_template.rb.erb +20 -4
- data/templates/mongoose_template.js.erb +23 -15
- data/templates/patient_extension.rb.erb +7 -4
- data/templates/patient_template.js.erb +88 -87
- data/yarn.lock +552 -347
- metadata +86 -19
- data/app/assets/javascripts/Component.js +0 -26
- data/app/assets/javascripts/Concept.js +0 -14
- data/app/assets/javascripts/FacilityLocation.js +0 -26
- data/app/assets/javascripts/Measure.js +0 -78
- data/app/assets/javascripts/Patient.js +0 -262
- data/app/assets/javascripts/ValueSet.js +0 -30
- data/app/models/qdm/tacoma/measure.rb +0 -174
- data/app/models/qdm/tacoma/valueset.rb +0 -68
@@ -0,0 +1,20 @@
|
|
1
|
+
<% module_namespacing do -%>
|
2
|
+
class <%= class_name %><%= " < #{options[:parent].classify}" if options[:parent] %>
|
3
|
+
<% unless options[:parent] -%>
|
4
|
+
include Mongoid::Document
|
5
|
+
<% end -%>
|
6
|
+
<% if options[:timestamps] -%>
|
7
|
+
include Mongoid::Timestamps
|
8
|
+
<% end -%>
|
9
|
+
<% if options[:collection] -%>
|
10
|
+
store_in collection: "<%= options[:collection] %>"
|
11
|
+
<% end -%>
|
12
|
+
<% attributes.reject{|attr| attr.reference?}.each do |attribute| -%>
|
13
|
+
field :<%= attribute.name %>, type: <%= attribute.type_class %><% if attribute.default -%>, default: '<%= attribute.default %>'<% end -%>
|
14
|
+
|
15
|
+
<% end -%>
|
16
|
+
<% attributes.select{|attr| attr.reference? }.each do |attribute| -%>
|
17
|
+
embedded_in :<%= attribute.name%>
|
18
|
+
<% end -%>
|
19
|
+
end
|
20
|
+
<% end -%>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
require 'rails/generators/active_model'
|
3
|
+
require File.join(Gem::Specification.find_by_name('mongoid').gem_dir, 'lib/rails/generators/mongoid/model/model_generator.rb')
|
4
|
+
|
5
|
+
module Rails
|
6
|
+
module Generators
|
7
|
+
# Extend this class to add the "default" field used in the generator.
|
8
|
+
class GeneratedAttribute
|
9
|
+
attr_accessor :default
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module CustomMongo
|
15
|
+
module Generators
|
16
|
+
# Extend this class to add the "default" field.
|
17
|
+
class ModelGenerator < ::Mongoid::Generators::ModelGenerator
|
18
|
+
def initialize(args, *options)
|
19
|
+
custom_attributes = args[1]
|
20
|
+
args = [args[0]] # "super" expects the name as arg[0], then we custom parse the attributes
|
21
|
+
super
|
22
|
+
self.attributes = custom_attributes.map do |attribute|
|
23
|
+
att = Rails::Generators::GeneratedAttribute.new(attribute[:name], attribute[:type].to_sym)
|
24
|
+
att.default = attribute[:default]
|
25
|
+
att
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_model_file
|
30
|
+
template File.join(File.dirname(__FILE__), 'model.rb.tt'), File.join('app/models', class_path, "#{file_name}.rb")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/notice.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
NOTICE
|
2
|
+
======
|
3
|
+
This (software/technical data) was produced for the U. S. Government under Contract Number HHSM-500-2012-00008I, and is subject to Federal Acquisition Regulation Clause 52.227-14, Rights in Data-General.
|
4
|
+
|
5
|
+
No other use other than that granted to the U. S. Government, or to those acting on behalf of the U. S. Government under that Clause is authorized without the express written permission of The MITRE Corporation.
|
6
|
+
|
7
|
+
To the extent necessary MITRE hereby grants express written permission to use, reproduce, distribute, modify, and otherwise leverage this software to the extent permitted by the Apache 2.0 license.
|
8
|
+
|
9
|
+
For further information, please contact The MITRE Corporation, Contracts Management Office, 7515 Colshire Drive, McLean, VA 22102-7539, (703) 983-6000.
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cqm-models",
|
3
|
-
"version": "1.0
|
3
|
+
"version": "1.1.1.0",
|
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": {
|
@@ -11,24 +11,30 @@
|
|
11
11
|
"contributors": [
|
12
12
|
"Louis Ades <lades@mitre.org>",
|
13
13
|
"Michael O'Keefe <mokeefe@mitre.org>",
|
14
|
-
"Adam Holmes <aholmes@mitre.org>"
|
14
|
+
"Adam Holmes <aholmes@mitre.org>",
|
15
|
+
"Chris Hossenlopp <hossenlopp@mitre.org>"
|
15
16
|
],
|
16
17
|
"license": "Apache-2.0",
|
17
18
|
"dependencies": {
|
18
|
-
"cql-execution": "
|
19
|
-
"mongoose": "^5.
|
19
|
+
"cql-execution": "https://github.com/cqframework/cql-execution.git",
|
20
|
+
"mongoose": "^5.4.14"
|
20
21
|
},
|
21
22
|
"devDependencies": {
|
22
23
|
"browserify": "^16.1.0",
|
23
24
|
"eslint": "^4.17.0",
|
24
25
|
"eslint-config-airbnb-base": "^12.1.0",
|
25
26
|
"eslint-plugin-import": "^2.8.0",
|
27
|
+
"istanbul": "^0.4.5",
|
26
28
|
"jasmine": "^2.9.0"
|
27
29
|
},
|
28
30
|
"scripts": {
|
29
|
-
"
|
31
|
+
"prepublish": "./bin/build_cql_execution.sh",
|
32
|
+
"test": "istanbul cover jasmine -x 'spec/**/*'",
|
30
33
|
"lint": "eslint 'app/assets/javascripts/**/*.js'",
|
31
34
|
"dist": "yarn && browserify app/assets/javascripts/index.js > dist/index.js",
|
32
|
-
"
|
35
|
+
"browser": "browserify app/assets/javascripts/browser.js > dist/browser.js",
|
36
|
+
"browser_test": "browserify app/assets/javascripts/browser.js > tmp/dist/browser.js",
|
37
|
+
"dist_test": "browserify app/assets/javascripts/index.js > tmp/dist/index.js",
|
38
|
+
"build-cql": "cd ./node_modules/cql-execution && yarn install && cd ../../"
|
33
39
|
}
|
34
40
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const mongoose = require('mongoose');
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
2
|
|
3
3
|
const [Number, String] = [
|
4
4
|
mongoose.Schema.Types.Number,
|
@@ -7,9 +7,14 @@ const [Number, String] = [
|
|
7
7
|
|
8
8
|
const IdSchema = mongoose.Schema({
|
9
9
|
<%- for attribute in attrs_with_extras -%>
|
10
|
-
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]]
|
10
|
+
<% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %>
|
11
11
|
<%- end %>
|
12
12
|
}, { _id: false, id: false });
|
13
13
|
|
14
14
|
module.exports.IdSchema = IdSchema;
|
15
|
-
|
15
|
+
class Id extends mongoose.Document {
|
16
|
+
constructor(object) {
|
17
|
+
super(object, IdSchema);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
module.exports.Id = Id;
|
@@ -2,13 +2,23 @@ module.exports = require('./AllDataElements.js');
|
|
2
2
|
module.exports.CQL = require('cql-execution');
|
3
3
|
module.exports.Result = require('./Result.js').Result;
|
4
4
|
module.exports.ResultSchema = require('./Result.js').ResultSchema;
|
5
|
-
module.exports.Measure = require('./Measure.js').Measure;
|
6
|
-
module.exports.MeasureSchema = require('./Measure.js').MeasureSchema;
|
7
|
-
module.exports.MeasurePackage = require('./MeasurePackage.js').MeasurePackage;
|
8
|
-
module.exports.MeasurePackageSchema = require('./MeasurePackage.js').MeasurePackageSchema;
|
9
|
-
module.exports.
|
10
|
-
module.exports.
|
11
|
-
module.exports.
|
12
|
-
module.exports.
|
5
|
+
module.exports.Measure = require('./cqm/Measure.js').Measure;
|
6
|
+
module.exports.MeasureSchema = require('./cqm/Measure.js').MeasureSchema;
|
7
|
+
module.exports.MeasurePackage = require('./cqm/MeasurePackage.js').MeasurePackage;
|
8
|
+
module.exports.MeasurePackageSchema = require('./cqm/MeasurePackage.js').MeasurePackageSchema;
|
9
|
+
module.exports.Patient = require('./cqm/Patient.js').Patient;
|
10
|
+
module.exports.PatientSchema = require('./cqm/Patient.js').PatientSchema;
|
11
|
+
module.exports.Provider = require('./cqm/Provider.js').Provider;
|
12
|
+
module.exports.ProviderSchema = require('./cqm/Provider.js').ProviderSchema;
|
13
|
+
module.exports.StatementDependency = require('./cqm/CQLStatementDependency.js').StatementDependency;
|
14
|
+
module.exports.StatementDependencySchema = require('./cqm/CQLStatementDependency.js').StatementDependencySchema;
|
15
|
+
module.exports.PopulationSet = require('./cqm/PopulationSet.js').PopulationSet;
|
16
|
+
module.exports.PopulationSetSchema = require('./cqm/PopulationSet.js').PopulationSetSchema;
|
17
|
+
module.exports.CQLLibrary = require('./cqm/CQLLibrary.js').CQLLibrary;
|
18
|
+
module.exports.CQLLibrarySchema = require('./cqm/CQLLibrary.js').CQLLibrarySchema;
|
19
|
+
module.exports.ValueSet = require('./cqm/ValueSet.js').ValueSet;
|
20
|
+
module.exports.ValueSetSchema = require('./cqm/ValueSet.js').ValueSetSchema;
|
21
|
+
module.exports.Concept = require('./cqm/Concept.js').Concept;
|
22
|
+
module.exports.ConceptSchema = require('./cqm/Concept.js').ConceptSchema;
|
13
23
|
module.exports.IndividualResult = require('./IndividualResult').IndividualResult;
|
14
24
|
module.exports.IndividualResultSchema = require('./IndividualResult').IndividualResultSchema;
|
@@ -3,6 +3,9 @@ module QDM
|
|
3
3
|
end
|
4
4
|
require 'mongoid'
|
5
5
|
|
6
|
+
# ModelFinder
|
7
|
+
require_relative 'model_finder'
|
8
|
+
|
6
9
|
# Generated models that are dependencies for base types
|
7
10
|
require_relative 'qdm/id'
|
8
11
|
|
@@ -12,16 +15,29 @@ require_relative 'qdm/basetypes/data_element'
|
|
12
15
|
require_relative 'qdm/basetypes/interval'
|
13
16
|
require_relative 'qdm/basetypes/quantity'
|
14
17
|
require_relative 'qdm/basetypes/ratio'
|
18
|
+
require_relative 'qdm/attributes/attribute'
|
19
|
+
require_relative 'qdm/attributes/facility_location'
|
20
|
+
require_relative 'qdm/attributes/component'
|
15
21
|
|
16
22
|
# Tacoma-specific models
|
17
|
-
require_relative '
|
18
|
-
require_relative '
|
19
|
-
require_relative '
|
20
|
-
require_relative '
|
23
|
+
require_relative 'cqm/measure'
|
24
|
+
require_relative 'cqm/measure_package'
|
25
|
+
require_relative 'cqm/valueset'
|
26
|
+
require_relative 'cqm/concept'
|
27
|
+
require_relative 'cqm/cql_statement_dependency'
|
28
|
+
require_relative 'cqm/cql_library'
|
29
|
+
require_relative 'cqm/population_set'
|
30
|
+
require_relative 'cqm/patient'
|
31
|
+
require_relative 'cqm/provider'
|
21
32
|
require_relative 'qdm/tacoma/individual_result'
|
22
33
|
|
34
|
+
# Make Patient Generation Available
|
35
|
+
require_relative '../../lib/generate_patients'
|
36
|
+
|
23
37
|
# Generated models
|
24
38
|
<%- datatypes.each_key do |datatype| -%>
|
25
39
|
<%- next if datatype.underscore == 'id' -%>
|
40
|
+
<%- next if datatype.underscore == 'facility_location' -%>
|
41
|
+
<%- next if datatype.underscore == 'component' -%>
|
26
42
|
require_relative 'qdm/<%= datatype.underscore %>'
|
27
43
|
<%- end -%>
|
@@ -1,30 +1,38 @@
|
|
1
|
-
const mongoose = require('mongoose');
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
|
+
<% unless datatype.downcase == 'component' || datatype.downcase == 'facilitylocation' %>
|
3
|
+
<% unless datatype.downcase == 'id' %>const { IdSchema } = require('./Id');<% end %>
|
2
4
|
const { DataElementSchema } = require('./basetypes/DataElement');
|
3
5
|
const Code = require('./basetypes/Code');
|
4
6
|
const Interval = require('./basetypes/Interval');
|
5
7
|
const Quantity = require('./basetypes/Quantity');
|
6
8
|
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 %>
|
9
|
-
<% unless datatype.downcase == 'id' %>const { IdSchema } = require('./Id');<% end %>
|
10
9
|
const Any = require('./basetypes/Any');
|
10
|
+
const { ComponentSchema } = require('./attributes/Component');
|
11
|
+
const { FacilityLocationSchema } = require('./attributes/FacilityLocation');
|
12
|
+
<% else %>
|
13
|
+
const Code = require('../basetypes/Code');
|
14
|
+
const Interval = require('../basetypes/Interval');
|
15
|
+
const Quantity = require('../basetypes/Quantity');
|
16
|
+
const DateTime = require('../basetypes/DateTime');
|
17
|
+
const Any = require('../basetypes/Any');
|
18
|
+
<% end %>
|
11
19
|
|
12
20
|
const [Number, String] = [
|
13
21
|
mongoose.Schema.Types.Number,
|
14
22
|
mongoose.Schema.Types.String,
|
15
23
|
];
|
16
|
-
|
17
|
-
const <%= datatype -%>Schema = DataElementSchema({
|
18
|
-
<%- for attribute in attrs_with_extras -%>
|
19
|
-
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
|
20
|
-
<%- end %>
|
21
|
-
});
|
22
|
-
<% else %>
|
23
|
-
const <%= datatype -%>Schema = new mongoose.Schema({
|
24
|
+
|
25
|
+
const <%= datatype -%>Schema = <% unless datatype == 'Component' || datatype == 'FacilityLocation' %>DataElementSchema<% else %>new mongoose.Schema<%- end %>({
|
24
26
|
<%- for attribute in attrs_with_extras -%>
|
25
|
-
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]]
|
27
|
+
<% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %>
|
26
28
|
<%- end %>
|
27
29
|
});
|
28
|
-
|
30
|
+
|
29
31
|
module.exports.<%= datatype %>Schema = <%= datatype %>Schema;
|
30
|
-
|
32
|
+
class <%= datatype %> extends mongoose.Document {
|
33
|
+
constructor(object) {
|
34
|
+
super(object, <%= datatype %>Schema);
|
35
|
+
this._type = 'QDM::<%= datatype %>';
|
36
|
+
}
|
37
|
+
}
|
38
|
+
module.exports.<%= datatype %> = <%= datatype %>;
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
field :familyName, type: String
|
3
|
-
field :bundleId, type: String
|
1
|
+
embedded_in :tacomaPatient, class_name: 'CQM::Patient'
|
4
2
|
|
5
3
|
# These are the "data criteria", or QDM datatype elements that exist on a
|
6
4
|
# patient.
|
@@ -133,6 +131,11 @@
|
|
133
131
|
get_data_elements('medication')
|
134
132
|
end
|
135
133
|
|
134
|
+
# Helper method; returns patient_characteristic data element types on this patient.
|
135
|
+
def patient_characteristics
|
136
|
+
get_data_elements('patient_characteristic')
|
137
|
+
end
|
138
|
+
|
136
139
|
# Helper method; returns physical_exam data element types on this patient.
|
137
140
|
def physical_exams
|
138
141
|
get_data_elements('physical_exam')
|
@@ -200,6 +203,6 @@
|
|
200
203
|
|
201
204
|
# Include '_type' in any JSON output. This is necessary for deserialization.
|
202
205
|
def to_json(options = nil)
|
203
|
-
serializable_hash(methods: :_type).to_json(options)
|
206
|
+
serializable_hash(methods: :_type, include: :_type).to_json(options)
|
204
207
|
end
|
205
208
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
const mongoose = require('mongoose');
|
1
|
+
const mongoose = require('mongoose/browser');
|
2
2
|
const Code = require('./basetypes/Code');
|
3
3
|
const Interval = require('./basetypes/Interval');
|
4
4
|
const Quantity = require('./basetypes/Quantity');
|
@@ -12,13 +12,10 @@ const [Schema, Number, String, Mixed] = [
|
|
12
12
|
mongoose.Schema.Types.Mixed,
|
13
13
|
];
|
14
14
|
|
15
|
-
const
|
15
|
+
const QDMPatientSchema = new Schema({
|
16
16
|
<%- for attribute in attrs_with_extras -%>
|
17
|
-
<%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]]
|
17
|
+
<% if attribute[:default] %><%= attribute[:name] %>: { type: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>, default: '<%= attribute[:default] %>' },<% else %><%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,<%- end %>
|
18
18
|
<%- end %>
|
19
|
-
givenNames: [String],
|
20
|
-
familyName: String,
|
21
|
-
bundleId: String,
|
22
19
|
// These are the "data criteria", or QDM datatype elements that exist on a
|
23
20
|
// patient.
|
24
21
|
dataElements: [],
|
@@ -33,46 +30,40 @@ const PatientSchema = new Schema({
|
|
33
30
|
|
34
31
|
// After initialization of a Patient model, initialize every individual data element
|
35
32
|
// to its respective Mongoose Model
|
36
|
-
|
33
|
+
QDMPatientSchema.methods.initializeDataElements = function initializeDataElements() {
|
37
34
|
let typeStripped;
|
38
35
|
const dataElementsInit = [];
|
39
36
|
this.dataElements.forEach((element) => {
|
40
37
|
typeStripped = element._type.replace(/QDM::/, '');
|
41
|
-
|
42
|
-
dataElementsInit.push(AllDataElements[typeStripped](element));
|
43
|
-
} else {
|
44
|
-
dataElementsInit.push(element);
|
45
|
-
}
|
38
|
+
dataElementsInit.push(new AllDataElements[typeStripped](element));
|
46
39
|
});
|
47
40
|
this.set({ dataElements: dataElementsInit });
|
48
41
|
};
|
49
42
|
|
50
|
-
|
51
|
-
|
52
|
-
PatientSchema.methods.id = function id() {
|
43
|
+
QDMPatientSchema.methods.id = function id() {
|
53
44
|
return this._id;
|
54
45
|
};
|
55
46
|
|
56
47
|
// Returns an array of elements that exist on this patient, that
|
57
48
|
// match the given HQMF data criteria OID.
|
58
|
-
|
49
|
+
QDMPatientSchema.methods.getByHqmfOid = function getByHqmfOid(hqmfOid) {
|
59
50
|
return this.dataElements.filter(element => element.hqmfOid === hqmfOid);
|
60
51
|
};
|
61
52
|
|
62
53
|
// Returns an array of elements that exist on this patient, that
|
63
54
|
// match the given QRDA data criteria OID.
|
64
|
-
|
55
|
+
QDMPatientSchema.methods.getByQrdaOid = function getByQrdaOid(qrdaOid) {
|
65
56
|
return this.dataElements.filter(element => element.qrdaOid === qrdaOid);
|
66
57
|
};
|
67
58
|
|
68
59
|
// Returns an array of elements that exist on this patient. Optionally
|
69
|
-
// takes a
|
70
|
-
// Example: patient.getDataElements(
|
60
|
+
// takes a qdmCategory, which returns all elements of that QDM qdmCategory.
|
61
|
+
// Example: patient.getDataElements({qdmCategory: 'encounters'}) will return
|
71
62
|
// all Encounter QDM data types active on the patient.
|
72
|
-
|
73
|
-
if (params.qdmCategory && params.qdmStatus) {
|
63
|
+
QDMPatientSchema.methods.getDataElements = function getDataElements(params) {
|
64
|
+
if (params !== undefined && params.qdmCategory !== undefined && params.qdmStatus !== undefined) {
|
74
65
|
return this.dataElements.filter(element => (element.qdmCategory === params.qdmCategory) && (element.qdmStatus === params.qdmStatus));
|
75
|
-
} else if (params.
|
66
|
+
} else if (params !== undefined && params.qdmCategory !== undefined) {
|
76
67
|
return this.dataElements.filter(element => element.qdmCategory === params.qdmCategory);
|
77
68
|
}
|
78
69
|
return this.dataElements;
|
@@ -83,15 +74,15 @@ PatientSchema.methods.getDataElements = function getDataElements(params) {
|
|
83
74
|
// @param {string} profile - the data criteria requested by the execution engine
|
84
75
|
// @param {boolean} isNegated - whether dataElements should be returned based on their negation status
|
85
76
|
// @returns {DataElement[]}
|
86
|
-
|
77
|
+
QDMPatientSchema.methods.getByProfile = function getByProfile(profile, isNegated = null) {
|
87
78
|
// If isNegated == true, only return data elements with a negationRationale that is not null.
|
88
79
|
// If isNegated == false, only return data elements with a null negationRationale.
|
89
80
|
// If isNegated == null, return all matching data elements by type, regardless of negationRationale.
|
90
|
-
const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated));
|
81
|
+
const results = this.dataElements.filter(element => (element._type === `QDM::${profile}` || element._type === profile) && (isNegated === null || !!element.negationRationale === isNegated));
|
91
82
|
return results.map((result) => {
|
92
|
-
const removedMongooseItems = AllDataElements[profile](result).toObject();
|
83
|
+
const removedMongooseItems = new AllDataElements[profile](result).toObject({ virtuals: true });
|
93
84
|
// toObject() will remove all mongoose functions but also remove the schema methods, so we add them back
|
94
|
-
Object.entries(
|
85
|
+
Object.entries(result.schema.methods).forEach(([method_name, method]) => {
|
95
86
|
removedMongooseItems[method_name] = method;
|
96
87
|
});
|
97
88
|
return removedMongooseItems;
|
@@ -105,7 +96,7 @@ PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated =
|
|
105
96
|
// in Bonnie patient builder).
|
106
97
|
// @param {String} profile - the data criteria requested by the execution engine
|
107
98
|
// @returns {Object}
|
108
|
-
|
99
|
+
QDMPatientSchema.methods.findRecords = function findRecords(profile) {
|
109
100
|
let profileStripped;
|
110
101
|
if (profile === 'Patient') {
|
111
102
|
// Requested generic patient info
|
@@ -141,121 +132,131 @@ PatientSchema.methods.findRecords = function findRecords(profile) {
|
|
141
132
|
return [];
|
142
133
|
};
|
143
134
|
|
144
|
-
|
145
|
-
return this.getDataElements({
|
135
|
+
QDMPatientSchema.methods.adverse_events = function adverse_events() {
|
136
|
+
return this.getDataElements({ qdmCategory: 'adverse_event' });
|
146
137
|
};
|
147
138
|
|
148
|
-
|
149
|
-
return this.getDataElements({
|
139
|
+
QDMPatientSchema.methods.allergies = function allergies() {
|
140
|
+
return this.getDataElements({ qdmCategory: 'allergy' });
|
150
141
|
};
|
151
142
|
|
152
|
-
|
153
|
-
return this.getDataElements({
|
143
|
+
QDMPatientSchema.methods.assessments = function assessments() {
|
144
|
+
return this.getDataElements({ qdmCategory: 'assessment' });
|
154
145
|
};
|
155
146
|
|
156
|
-
|
157
|
-
return this.getDataElements({
|
147
|
+
QDMPatientSchema.methods.care_experiences = function care_experiences() {
|
148
|
+
return this.getDataElements({ qdmCategory: 'care_experience' });
|
158
149
|
};
|
159
150
|
|
160
|
-
|
161
|
-
return this.getDataElements({
|
151
|
+
QDMPatientSchema.methods.care_goals = function care_goals() {
|
152
|
+
return this.getDataElements({ qdmCategory: 'care_goal' });
|
162
153
|
};
|
163
154
|
|
164
|
-
|
165
|
-
return this.getDataElements({
|
155
|
+
QDMPatientSchema.methods.communications = function communications() {
|
156
|
+
return this.getDataElements({ qdmCategory: 'communication' });
|
166
157
|
};
|
167
158
|
|
168
|
-
|
169
|
-
return this.getDataElements({
|
159
|
+
QDMPatientSchema.methods.conditions = function conditions() {
|
160
|
+
return this.getDataElements({ qdmCategory: 'condition' });
|
170
161
|
};
|
171
162
|
|
172
|
-
|
173
|
-
return this.getDataElements({
|
163
|
+
QDMPatientSchema.methods.devices = function devices() {
|
164
|
+
return this.getDataElements({ qdmCategory: 'device' });
|
174
165
|
};
|
175
166
|
|
176
|
-
|
177
|
-
return this.getDataElements({
|
167
|
+
QDMPatientSchema.methods.diagnostic_studies = function diagnostic_studies() {
|
168
|
+
return this.getDataElements({ qdmCategory: 'diagnostic_study' });
|
178
169
|
};
|
179
170
|
|
180
|
-
|
181
|
-
return this.getDataElements({
|
171
|
+
QDMPatientSchema.methods.encounters = function encounters() {
|
172
|
+
return this.getDataElements({ qdmCategory: 'encounter' });
|
182
173
|
};
|
183
174
|
|
184
|
-
|
185
|
-
return this.getDataElements({
|
175
|
+
QDMPatientSchema.methods.family_history = function family_history() {
|
176
|
+
return this.getDataElements({ qdmCategory: 'family_history' });
|
186
177
|
};
|
187
178
|
|
188
|
-
|
189
|
-
return this.getDataElements({
|
179
|
+
QDMPatientSchema.methods.functional_statuses = function functional_statuses() {
|
180
|
+
return this.getDataElements({ qdmCategory: 'functional_status' });
|
190
181
|
};
|
191
182
|
|
192
|
-
|
193
|
-
return this.getDataElements({
|
183
|
+
QDMPatientSchema.methods.immunizations = function immunizations() {
|
184
|
+
return this.getDataElements({ qdmCategory: 'immunization' });
|
194
185
|
};
|
195
186
|
|
196
|
-
|
197
|
-
return this.getDataElements({
|
187
|
+
QDMPatientSchema.methods.interventions = function interventions() {
|
188
|
+
return this.getDataElements({ qdmCategory: 'intervention' });
|
198
189
|
};
|
199
190
|
|
200
|
-
|
201
|
-
return this.getDataElements({
|
191
|
+
QDMPatientSchema.methods.laboratory_tests = function laboratory_tests() {
|
192
|
+
return this.getDataElements({ qdmCategory: 'laboratory_test' });
|
202
193
|
};
|
203
194
|
|
204
|
-
|
205
|
-
return this.getDataElements({
|
195
|
+
QDMPatientSchema.methods.medical_equipment = function medical_equipment() {
|
196
|
+
return this.getDataElements({ qdmCategory: 'medical_equipment' });
|
206
197
|
};
|
207
198
|
|
208
|
-
|
209
|
-
return this.getDataElements({
|
199
|
+
QDMPatientSchema.methods.medications = function medications() {
|
200
|
+
return this.getDataElements({ qdmCategory: 'medication' });
|
210
201
|
};
|
211
202
|
|
212
|
-
|
213
|
-
return this.getDataElements({
|
203
|
+
QDMPatientSchema.methods.patient_characteristics = function patient_characteristics() {
|
204
|
+
return this.getDataElements({ qdmCategory: 'patient_characteristic' });
|
214
205
|
};
|
215
206
|
|
216
|
-
|
217
|
-
return this.getDataElements({
|
207
|
+
QDMPatientSchema.methods.physical_exams = function physical_exams() {
|
208
|
+
return this.getDataElements({ qdmCategory: 'physical_exam' });
|
218
209
|
};
|
219
210
|
|
220
|
-
|
221
|
-
return this.getDataElements({
|
211
|
+
QDMPatientSchema.methods.preferences = function preferences() {
|
212
|
+
return this.getDataElements({ qdmCategory: 'preference' });
|
222
213
|
};
|
223
214
|
|
224
|
-
|
225
|
-
return this.getDataElements({
|
215
|
+
QDMPatientSchema.methods.provider_characteristics = function provider_characteristics() {
|
216
|
+
return this.getDataElements({ qdmCategory: 'provider_characteristic' });
|
226
217
|
};
|
227
218
|
|
228
|
-
|
229
|
-
return this.getDataElements({
|
219
|
+
QDMPatientSchema.methods.procedures = function procedures() {
|
220
|
+
return this.getDataElements({ qdmCategory: 'procedure' });
|
230
221
|
};
|
231
222
|
|
232
|
-
|
233
|
-
return this.getDataElements({
|
223
|
+
QDMPatientSchema.methods.results = function results() {
|
224
|
+
return this.getDataElements({ qdmCategory: 'result' });
|
234
225
|
};
|
235
226
|
|
236
|
-
|
237
|
-
return this.getDataElements({
|
227
|
+
QDMPatientSchema.methods.risk_category_assessments = function risk_category_assessments() {
|
228
|
+
return this.getDataElements({ qdmCategory: 'risk_category_assessment' });
|
238
229
|
};
|
239
230
|
|
240
|
-
|
241
|
-
return this.getDataElements({
|
231
|
+
QDMPatientSchema.methods.social_history = function social_history() {
|
232
|
+
return this.getDataElements({ qdmCategory: 'social_history' });
|
242
233
|
};
|
243
234
|
|
244
|
-
|
245
|
-
return this.getDataElements({
|
235
|
+
QDMPatientSchema.methods.substances = function substances() {
|
236
|
+
return this.getDataElements({ qdmCategory: 'substance' });
|
246
237
|
};
|
247
238
|
|
248
|
-
|
249
|
-
return this.getDataElements({
|
239
|
+
QDMPatientSchema.methods.symptoms = function symptoms() {
|
240
|
+
return this.getDataElements({ qdmCategory: 'symptom' });
|
250
241
|
};
|
251
242
|
|
252
|
-
|
253
|
-
return this.getDataElements({
|
243
|
+
QDMPatientSchema.methods.system_characteristics = function system_characteristics() {
|
244
|
+
return this.getDataElements({ qdmCategory: 'system_characteristic' });
|
254
245
|
};
|
255
246
|
|
256
|
-
|
257
|
-
return this.getDataElements({
|
247
|
+
QDMPatientSchema.methods.transfers = function transfers() {
|
248
|
+
return this.getDataElements({ qdmCategory: 'transfer' });
|
258
249
|
};
|
259
250
|
|
260
|
-
|
261
|
-
|
251
|
+
QDMPatientSchema.methods.vital_signs = function vital_signs() {
|
252
|
+
return this.getDataElements({ qdmCategory: 'vital_sign' });
|
253
|
+
};
|
254
|
+
|
255
|
+
module.exports.QDMPatientSchema = QDMPatientSchema;
|
256
|
+
class QDMPatient extends mongoose.Document {
|
257
|
+
constructor(object) {
|
258
|
+
super(object, QDMPatientSchema);
|
259
|
+
this.initializeDataElements();
|
260
|
+
}
|
261
|
+
}
|
262
|
+
module.exports.QDMPatient = QDMPatient;
|