cqm-models 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. checksums.yaml +7 -0
  2. data/.eslintignore +1 -0
  3. data/.eslintrc.json +26 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +32 -0
  5. data/.gitignore +21 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +42 -0
  8. data/.travis.yml +21 -0
  9. data/Gemfile +5 -0
  10. data/LICENSE.txt +201 -0
  11. data/README.md +26 -0
  12. data/Rakefile +12 -0
  13. data/app/assets/javascripts/AdverseEvent.js +27 -0
  14. data/app/assets/javascripts/AllDataElements.js +120 -0
  15. data/app/assets/javascripts/AllergyIntolerance.js +27 -0
  16. data/app/assets/javascripts/AssessmentPerformed.js +30 -0
  17. data/app/assets/javascripts/AssessmentRecommended.js +27 -0
  18. data/app/assets/javascripts/CareGoal.js +25 -0
  19. data/app/assets/javascripts/CommunicationFromPatientToProvider.js +26 -0
  20. data/app/assets/javascripts/CommunicationFromProviderToPatient.js +26 -0
  21. data/app/assets/javascripts/CommunicationFromProviderToProvider.js +26 -0
  22. data/app/assets/javascripts/Component.js +22 -0
  23. data/app/assets/javascripts/Concept.js +14 -0
  24. data/app/assets/javascripts/DeviceApplied.js +29 -0
  25. data/app/assets/javascripts/DeviceOrder.js +26 -0
  26. data/app/assets/javascripts/DeviceRecommended.js +26 -0
  27. data/app/assets/javascripts/Diagnosis.js +27 -0
  28. data/app/assets/javascripts/DiagnosticStudyOrder.js +27 -0
  29. data/app/assets/javascripts/DiagnosticStudyPerformed.js +33 -0
  30. data/app/assets/javascripts/DiagnosticStudyRecommended.js +27 -0
  31. data/app/assets/javascripts/EncounterOrder.js +27 -0
  32. data/app/assets/javascripts/EncounterPerformed.js +32 -0
  33. data/app/assets/javascripts/EncounterRecommended.js +27 -0
  34. data/app/assets/javascripts/FacilityLocation.js +22 -0
  35. data/app/assets/javascripts/FamilyHistory.js +25 -0
  36. data/app/assets/javascripts/Id.js +22 -0
  37. data/app/assets/javascripts/ImmunizationAdministered.js +30 -0
  38. data/app/assets/javascripts/ImmunizationOrder.js +30 -0
  39. data/app/assets/javascripts/InterventionOrder.js +26 -0
  40. data/app/assets/javascripts/InterventionPerformed.js +29 -0
  41. data/app/assets/javascripts/InterventionRecommended.js +26 -0
  42. data/app/assets/javascripts/LaboratoryTestOrder.js +27 -0
  43. data/app/assets/javascripts/LaboratoryTestPerformed.js +33 -0
  44. data/app/assets/javascripts/LaboratoryTestRecommended.js +27 -0
  45. data/app/assets/javascripts/Measure.js +76 -0
  46. data/app/assets/javascripts/MeasurePackage.js +20 -0
  47. data/app/assets/javascripts/MedicationActive.js +28 -0
  48. data/app/assets/javascripts/MedicationAdministered.js +31 -0
  49. data/app/assets/javascripts/MedicationDischarge.js +30 -0
  50. data/app/assets/javascripts/MedicationDispensed.js +31 -0
  51. data/app/assets/javascripts/MedicationOrder.js +34 -0
  52. data/app/assets/javascripts/Participation.js +21 -0
  53. data/app/assets/javascripts/Patient.js +248 -0
  54. data/app/assets/javascripts/PatientCareExperience.js +23 -0
  55. data/app/assets/javascripts/PatientCharacteristic.js +23 -0
  56. data/app/assets/javascripts/PatientCharacteristicBirthdate.js +24 -0
  57. data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +26 -0
  58. data/app/assets/javascripts/PatientCharacteristicEthnicity.js +23 -0
  59. data/app/assets/javascripts/PatientCharacteristicExpired.js +25 -0
  60. data/app/assets/javascripts/PatientCharacteristicPayer.js +24 -0
  61. data/app/assets/javascripts/PatientCharacteristicRace.js +23 -0
  62. data/app/assets/javascripts/PatientCharacteristicSex.js +23 -0
  63. data/app/assets/javascripts/PhysicalExamOrder.js +28 -0
  64. data/app/assets/javascripts/PhysicalExamPerformed.js +31 -0
  65. data/app/assets/javascripts/PhysicalExamRecommended.js +28 -0
  66. data/app/assets/javascripts/ProcedureOrder.js +30 -0
  67. data/app/assets/javascripts/ProcedurePerformed.js +35 -0
  68. data/app/assets/javascripts/ProcedureRecommended.js +30 -0
  69. data/app/assets/javascripts/ProviderCareExperience.js +23 -0
  70. data/app/assets/javascripts/ProviderCharacteristic.js +23 -0
  71. data/app/assets/javascripts/Ratio.js +22 -0
  72. data/app/assets/javascripts/Result.js +28 -0
  73. data/app/assets/javascripts/ResultComponent.js +21 -0
  74. data/app/assets/javascripts/SubstanceAdministered.js +30 -0
  75. data/app/assets/javascripts/SubstanceOrder.js +32 -0
  76. data/app/assets/javascripts/SubstanceRecommended.js +32 -0
  77. data/app/assets/javascripts/Symptom.js +25 -0
  78. data/app/assets/javascripts/ValueSet.js +30 -0
  79. data/app/assets/javascripts/basetypes/Code.js +25 -0
  80. data/app/assets/javascripts/basetypes/DataElement.js +36 -0
  81. data/app/assets/javascripts/basetypes/DateTime.js +18 -0
  82. data/app/assets/javascripts/basetypes/Interval.js +35 -0
  83. data/app/assets/javascripts/basetypes/Quantity.js +20 -0
  84. data/app/assets/javascripts/index.js +12 -0
  85. data/app/models/models.rb +78 -0
  86. data/app/models/qdm/adverse_event.rb +15 -0
  87. data/app/models/qdm/allergy_intolerance.rb +15 -0
  88. data/app/models/qdm/assessment_performed.rb +18 -0
  89. data/app/models/qdm/assessment_recommended.rb +15 -0
  90. data/app/models/qdm/basetypes/code.rb +56 -0
  91. data/app/models/qdm/basetypes/data_element.rb +42 -0
  92. data/app/models/qdm/basetypes/interval.rb +54 -0
  93. data/app/models/qdm/basetypes/quantity.rb +52 -0
  94. data/app/models/qdm/care_goal.rb +13 -0
  95. data/app/models/qdm/communication_from_patient_to_provider.rb +14 -0
  96. data/app/models/qdm/communication_from_provider_to_patient.rb +14 -0
  97. data/app/models/qdm/communication_from_provider_to_provider.rb +14 -0
  98. data/app/models/qdm/component.rb +10 -0
  99. data/app/models/qdm/device_applied.rb +17 -0
  100. data/app/models/qdm/device_order.rb +14 -0
  101. data/app/models/qdm/device_recommended.rb +14 -0
  102. data/app/models/qdm/diagnosis.rb +15 -0
  103. data/app/models/qdm/diagnostic_study_order.rb +15 -0
  104. data/app/models/qdm/diagnostic_study_performed.rb +21 -0
  105. data/app/models/qdm/diagnostic_study_recommended.rb +15 -0
  106. data/app/models/qdm/encounter_order.rb +15 -0
  107. data/app/models/qdm/encounter_performed.rb +20 -0
  108. data/app/models/qdm/encounter_recommended.rb +15 -0
  109. data/app/models/qdm/facility_location.rb +10 -0
  110. data/app/models/qdm/family_history.rb +13 -0
  111. data/app/models/qdm/id.rb +10 -0
  112. data/app/models/qdm/immunization_administered.rb +18 -0
  113. data/app/models/qdm/immunization_order.rb +18 -0
  114. data/app/models/qdm/intervention_order.rb +14 -0
  115. data/app/models/qdm/intervention_performed.rb +17 -0
  116. data/app/models/qdm/intervention_recommended.rb +14 -0
  117. data/app/models/qdm/laboratory_test_order.rb +15 -0
  118. data/app/models/qdm/laboratory_test_performed.rb +21 -0
  119. data/app/models/qdm/laboratory_test_recommended.rb +15 -0
  120. data/app/models/qdm/medication_active.rb +16 -0
  121. data/app/models/qdm/medication_administered.rb +19 -0
  122. data/app/models/qdm/medication_discharge.rb +18 -0
  123. data/app/models/qdm/medication_dispensed.rb +19 -0
  124. data/app/models/qdm/medication_order.rb +22 -0
  125. data/app/models/qdm/participation.rb +9 -0
  126. data/app/models/qdm/patient.rb +201 -0
  127. data/app/models/qdm/patient_care_experience.rb +11 -0
  128. data/app/models/qdm/patient_characteristic.rb +11 -0
  129. data/app/models/qdm/patient_characteristic_birthdate.rb +12 -0
  130. data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +14 -0
  131. data/app/models/qdm/patient_characteristic_ethnicity.rb +11 -0
  132. data/app/models/qdm/patient_characteristic_expired.rb +13 -0
  133. data/app/models/qdm/patient_characteristic_payer.rb +12 -0
  134. data/app/models/qdm/patient_characteristic_race.rb +11 -0
  135. data/app/models/qdm/patient_characteristic_sex.rb +11 -0
  136. data/app/models/qdm/physical_exam_order.rb +16 -0
  137. data/app/models/qdm/physical_exam_performed.rb +19 -0
  138. data/app/models/qdm/physical_exam_recommended.rb +16 -0
  139. data/app/models/qdm/procedure_order.rb +18 -0
  140. data/app/models/qdm/procedure_performed.rb +23 -0
  141. data/app/models/qdm/procedure_recommended.rb +18 -0
  142. data/app/models/qdm/provider_care_experience.rb +11 -0
  143. data/app/models/qdm/provider_characteristic.rb +11 -0
  144. data/app/models/qdm/ratio.rb +10 -0
  145. data/app/models/qdm/result_component.rb +9 -0
  146. data/app/models/qdm/substance_administered.rb +18 -0
  147. data/app/models/qdm/substance_order.rb +20 -0
  148. data/app/models/qdm/substance_recommended.rb +20 -0
  149. data/app/models/qdm/symptom.rb +13 -0
  150. data/app/models/qdm/tacoma/concept.rb +14 -0
  151. data/app/models/qdm/tacoma/measure.rb +172 -0
  152. data/app/models/qdm/tacoma/measure_package.rb +10 -0
  153. data/app/models/qdm/tacoma/valueset.rb +68 -0
  154. data/bin/console +14 -0
  155. data/bin/setup +8 -0
  156. data/bin/validate_dist.sh +17 -0
  157. data/config/mongoid.yml +6 -0
  158. data/cqm-models.gemspec +29 -0
  159. data/data/oids.json +584 -0
  160. data/dist/index.js +157647 -0
  161. data/lib/cqm/models.rb +1 -0
  162. data/lib/generate_models.rb +330 -0
  163. data/modelinfo/qdm-modelinfo-4.2.xml +515 -0
  164. data/modelinfo/qdm-modelinfo-4.3.xml +521 -0
  165. data/modelinfo/qdm-modelinfo-5.0.1.xml +436 -0
  166. data/modelinfo/qdm-modelinfo-5.0.2.xml +445 -0
  167. data/modelinfo/qdm-modelinfo-5.0.xml +429 -0
  168. data/modelinfo/qdm-modelinfo-5.3.xml +524 -0
  169. data/package.json +34 -0
  170. data/templates/all_data_elements_template.js.erb +4 -0
  171. data/templates/index_template.js.erb +12 -0
  172. data/templates/models_template.rb.erb +21 -0
  173. data/templates/mongoose_template.js.erb +20 -0
  174. data/templates/patient_extension.rb.erb +194 -0
  175. data/templates/patient_template.js.erb +247 -0
  176. data/tmp/.keep +0 -0
  177. data/yarn.lock +1901 -0
  178. metadata +320 -0
@@ -0,0 +1,25 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ function Code(key, options) {
4
+ mongoose.SchemaType.call(this, key, options, 'Code');
5
+ }
6
+ Code.prototype = Object.create(mongoose.SchemaType.prototype);
7
+
8
+ Code.prototype.cast = (code) => {
9
+ if (typeof code.code === 'undefined') {
10
+ throw new Error(`Code: ${code} does not have a code`);
11
+ } else if (typeof code.codeSystem === 'undefined') {
12
+ throw new Error(`Code: ${code} does not have a codeSystem`);
13
+ }
14
+
15
+ const val = { code: code.code, codeSystem: code.codeSystem };
16
+
17
+ val.descriptor = (typeof code.descriptor !== 'undefined') ? code.descriptor : null;
18
+ val.codeSystemOid = (typeof code.codeSystemOid !== 'undefined') ? code.codeSystemOid : null;
19
+ val.version = (typeof code.version !== 'undefined') ? code.version : null;
20
+
21
+ return val;
22
+ };
23
+
24
+ mongoose.Schema.Types.Code = Code;
25
+ module.exports = Code;
@@ -0,0 +1,36 @@
1
+ const mongoose = require('mongoose');
2
+ const Code = require('./Code.js');
3
+
4
+ const [Schema] = [mongoose.Schema];
5
+
6
+ function DataElementSchema(add, options) {
7
+ const extended = new Schema({
8
+ dataElementCodes: { type: [Code] },
9
+ description: { type: String },
10
+ }, options);
11
+
12
+ if (add) {
13
+ extended.add(add);
14
+ }
15
+
16
+ // Returns all of the codes on this data element
17
+ // in a format usable by the cql-execution framework
18
+ extended.methods.getCode = function getCode() {
19
+ return this.dataElementCodes.map((code) => {
20
+ const result = {};
21
+ result.code = code.code;
22
+ result.system = code.code_system;
23
+ return result;
24
+ });
25
+ };
26
+
27
+ // Returns all of the codes on this data element
28
+ // in their normal form.
29
+ extended.methods.codes = function getCodes() {
30
+ return this.dataElementCodes;
31
+ };
32
+
33
+ return extended;
34
+ }
35
+
36
+ module.exports.DataElementSchema = DataElementSchema;
@@ -0,0 +1,18 @@
1
+ const mongoose = require('mongoose');
2
+ const cql = require('cql-execution');
3
+
4
+ function DateTime(key, options) {
5
+ mongoose.SchemaType.call(this, key, options, 'DateTime');
6
+ }
7
+ DateTime.prototype = Object.create(mongoose.SchemaType.prototype);
8
+
9
+ DateTime.prototype.cast = (dateTime) => {
10
+ if (!Date.parse(dateTime)) {
11
+ throw new Error(`DateTime: ${dateTime} is not a valid DateTime`);
12
+ }
13
+
14
+ return cql.DateTime.fromDate(new Date(dateTime), 0);
15
+ };
16
+
17
+ mongoose.Schema.Types.DateTime = DateTime;
18
+ module.exports = DateTime;
@@ -0,0 +1,35 @@
1
+ const mongoose = require('mongoose');
2
+ const cql = require('cql-execution');
3
+
4
+ function Interval(key, options) {
5
+ mongoose.SchemaType.call(this, key, options, 'Interval');
6
+ }
7
+ Interval.prototype = Object.create(mongoose.SchemaType.prototype);
8
+
9
+ Interval.prototype.cast = (interval) => {
10
+ if (typeof interval.low === 'undefined' || interval.low === null) {
11
+ throw new Error(`Interval: ${interval} does not have a low value`);
12
+ }
13
+ const casted = new cql.Interval(interval.low, interval.high, interval.lowClosed, interval.highClosed);
14
+
15
+ // Cast Low and High values to Quantities if it is a quantity
16
+ if (casted.low && casted.low.unit && casted.low.value) {
17
+ casted.low = new cql.Quantity(casted.low);
18
+ if (casted.high && casted.high.unit && casted.high.value) {
19
+ casted.high = new cql.Quantity(casted.high);
20
+ }
21
+ return casted;
22
+ }
23
+
24
+ // Cast to DateTime if it is a string representing a DateTime
25
+ if (casted.low && Date.parse(casted.low)) {
26
+ casted.low = cql.DateTime.fromDate(new Date(casted.low), 0);
27
+ }
28
+ if (casted.high && Date.parse(casted.high)) {
29
+ casted.high = cql.DateTime.fromDate(new Date(casted.high), 0);
30
+ }
31
+ return casted;
32
+ };
33
+
34
+ mongoose.Schema.Types.Interval = Interval;
35
+ module.exports = Interval;
@@ -0,0 +1,20 @@
1
+ const mongoose = require('mongoose');
2
+ const cql = require('cql-execution');
3
+
4
+ function Quantity(key, options) {
5
+ mongoose.SchemaType.call(this, key, options, 'Quantity');
6
+ }
7
+ Quantity.prototype = Object.create(mongoose.SchemaType.prototype);
8
+
9
+ Quantity.prototype.cast = (quantity) => {
10
+ if (typeof quantity.value === 'undefined') {
11
+ throw new Error(`Quantity: ${quantity} does not have a value`);
12
+ } else if (typeof quantity.unit === 'undefined') {
13
+ throw new Error(`Quantity: ${quantity} does not have a unit`);
14
+ }
15
+
16
+ return new cql.Quantity(quantity);
17
+ };
18
+
19
+ mongoose.Schema.Types.Quantity = Quantity;
20
+ module.exports = Quantity;
@@ -0,0 +1,12 @@
1
+ module.exports = require('./AllDataElements.js');
2
+ module.exports.CQL = require('cql-execution');
3
+ module.exports.Result = require('./Result.js').Result;
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.ValueSet = require('./ValueSet.js').ValueSet;
10
+ module.exports.ValueSetSchema = require('./ValueSet.js').ValueSetSchema;
11
+ module.exports.Concept = require('./Concept.js').Concept;
12
+ module.exports.ConceptSchema = require('./Concept.js').ConceptSchema;
@@ -0,0 +1,78 @@
1
+ # Base QDM module (generated from lib/generate_models.rb) for QDM 5.3
2
+ module QDM
3
+ end
4
+ require 'mongoid'
5
+
6
+ # base types
7
+ require_relative 'qdm/basetypes/code'
8
+ require_relative 'qdm/basetypes/interval'
9
+ require_relative 'qdm/basetypes/quantity'
10
+ require_relative 'qdm/basetypes/data_element'
11
+
12
+ # Tacoma-specific models
13
+ require_relative 'qdm/tacoma/measure'
14
+ require_relative 'qdm/tacoma/measure_package'
15
+ require_relative 'qdm/tacoma/valueset'
16
+ require_relative 'qdm/tacoma/concept'
17
+
18
+ # Generated models
19
+ require_relative 'qdm/patient'
20
+ require_relative 'qdm/id'
21
+ require_relative 'qdm/ratio'
22
+ require_relative 'qdm/physical_exam_order'
23
+ require_relative 'qdm/participation'
24
+ require_relative 'qdm/patient_characteristic_sex'
25
+ require_relative 'qdm/care_goal'
26
+ require_relative 'qdm/patient_characteristic'
27
+ require_relative 'qdm/patient_characteristic_ethnicity'
28
+ require_relative 'qdm/patient_characteristic_race'
29
+ require_relative 'qdm/laboratory_test_performed'
30
+ require_relative 'qdm/symptom'
31
+ require_relative 'qdm/medication_administered'
32
+ require_relative 'qdm/procedure_recommended'
33
+ require_relative 'qdm/encounter_performed'
34
+ require_relative 'qdm/diagnosis'
35
+ require_relative 'qdm/communication_from_provider_to_patient'
36
+ require_relative 'qdm/assessment_performed'
37
+ require_relative 'qdm/patient_characteristic_clinical_trial_participant'
38
+ require_relative 'qdm/device_order'
39
+ require_relative 'qdm/diagnostic_study_performed'
40
+ require_relative 'qdm/intervention_order'
41
+ require_relative 'qdm/family_history'
42
+ require_relative 'qdm/component'
43
+ require_relative 'qdm/result_component'
44
+ require_relative 'qdm/facility_location'
45
+ require_relative 'qdm/communication_from_provider_to_provider'
46
+ require_relative 'qdm/medication_active'
47
+ require_relative 'qdm/laboratory_test_order'
48
+ require_relative 'qdm/diagnostic_study_order'
49
+ require_relative 'qdm/substance_order'
50
+ require_relative 'qdm/patient_characteristic_payer'
51
+ require_relative 'qdm/patient_characteristic_expired'
52
+ require_relative 'qdm/assessment_recommended'
53
+ require_relative 'qdm/immunization_administered'
54
+ require_relative 'qdm/substance_administered'
55
+ require_relative 'qdm/encounter_order'
56
+ require_relative 'qdm/encounter_recommended'
57
+ require_relative 'qdm/procedure_performed'
58
+ require_relative 'qdm/allergy_intolerance'
59
+ require_relative 'qdm/provider_characteristic'
60
+ require_relative 'qdm/physical_exam_recommended'
61
+ require_relative 'qdm/patient_characteristic_birthdate'
62
+ require_relative 'qdm/adverse_event'
63
+ require_relative 'qdm/communication_from_patient_to_provider'
64
+ require_relative 'qdm/device_recommended'
65
+ require_relative 'qdm/device_applied'
66
+ require_relative 'qdm/medication_discharge'
67
+ require_relative 'qdm/intervention_performed'
68
+ require_relative 'qdm/laboratory_test_recommended'
69
+ require_relative 'qdm/medication_dispensed'
70
+ require_relative 'qdm/diagnostic_study_recommended'
71
+ require_relative 'qdm/immunization_order'
72
+ require_relative 'qdm/patient_care_experience'
73
+ require_relative 'qdm/provider_care_experience'
74
+ require_relative 'qdm/procedure_order'
75
+ require_relative 'qdm/medication_order'
76
+ require_relative 'qdm/substance_recommended'
77
+ require_relative 'qdm/intervention_recommended'
78
+ require_relative 'qdm/physical_exam_performed'
@@ -0,0 +1,15 @@
1
+ module QDM
2
+ # app/models/qdm/adverse_event.rb
3
+ class AdverseEvent < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :relevantPeriod, type: QDM::Interval
8
+ field :severity, type: QDM::Code
9
+ field :facilityLocation, type: QDM::Code
10
+ field :type, type: QDM::Code
11
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.120'
12
+ field :category, type: String, default: 'adverse_event'
13
+ field :qdmVersion, type: String, default: '5.3'
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module QDM
2
+ # app/models/qdm/allergy_intolerance.rb
3
+ class AllergyIntolerance < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :prevalencePeriod, type: QDM::Interval
8
+ field :type, type: QDM::Code
9
+ field :severity, type: QDM::Code
10
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.119'
11
+ field :category, type: String, default: 'allergy'
12
+ field :qdmStatus, type: String, default: 'intolerance'
13
+ field :qdmVersion, type: String, default: '5.3'
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module QDM
2
+ # app/models/qdm/assessment_performed.rb
3
+ class AssessmentPerformed < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :negationRationale, type: QDM::Code
8
+ field :reason, type: QDM::Code
9
+ field :method, type: QDM::Code
10
+ field :result
11
+ field :components, type: Array
12
+ field :relatedTo, type: Array
13
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.117'
14
+ field :category, type: String, default: 'assessment'
15
+ field :qdmStatus, type: String, default: 'performed'
16
+ field :qdmVersion, type: String, default: '5.3'
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ module QDM
2
+ # app/models/qdm/assessment_recommended.rb
3
+ class AssessmentRecommended < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :negationRationale, type: QDM::Code
8
+ field :reason, type: QDM::Code
9
+ field :method, type: QDM::Code
10
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.118'
11
+ field :category, type: String, default: 'assessment'
12
+ field :qdmStatus, type: String, default: 'recommended'
13
+ field :qdmVersion, type: String, default: '5.3'
14
+ end
15
+ end
@@ -0,0 +1,56 @@
1
+ module QDM
2
+ # Represents a Code
3
+ class Code
4
+ attr_reader :code, :codeSystem, :descriptor, :codeSystemOid, :version
5
+
6
+ # Code and code system are required (at minimum).
7
+ def initialize(code, codeSystem, descriptor = nil, codeSystemOid = nil, version = nil)
8
+ @code = code
9
+ @codeSystem = codeSystem
10
+ @descriptor = descriptor
11
+ @codeSystemOid = codeSystemOid
12
+ @version = version
13
+ end
14
+
15
+ # Converts an object of this instance into a database friendly value.
16
+ def mongoize
17
+ { code: @code, codeSystem: @codeSystem, descriptor: @descriptor, codeSystemOid: @codeSystemOid, version: @version }
18
+ end
19
+
20
+ class << self
21
+ # Get the object as it was stored in the database, and instantiate
22
+ # this custom class from it.
23
+ #
24
+ # The array elements in demongoize are the same 5 elements used in mongoize, i.e.
25
+ # [ code, codeSystem, descriptor, codeSystemOid, version ].
26
+ def demongoize(object)
27
+ return nil unless object
28
+ object = object.symbolize_keys
29
+ QDM::Code.new(object[:code], object[:codeSystem], object[:descriptor], object[:codeSystemOid], object[:version])
30
+ end
31
+
32
+ # Takes any possible object and converts it to how it would be
33
+ # stored in the database.
34
+ def mongoize(object)
35
+ case object
36
+ when nil then nil
37
+ when QDM::Code then object.mongoize
38
+ when Hash
39
+ object = object.symbolize_keys
40
+ codeSystem = object[:system] ? object[:system] : object[:codeSystem]
41
+ QDM::Code.new(object[:code], codeSystem, object[:descriptor], object[:codeSystemOid], object[:version]).mongoize
42
+ else object
43
+ end
44
+ end
45
+
46
+ # Converts the object that was supplied to a criteria and converts it
47
+ # into a database friendly form.
48
+ def evolve(object)
49
+ case object
50
+ when QDM::Code then object.mongoize
51
+ else object
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,42 @@
1
+ module QDM
2
+ # Represents QDM datatype (parent class of all generated QDM datatype models)
3
+ class DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+
7
+ # Codes that describe this datatype.
8
+ field :dataElementCodes, type: Array, default: []
9
+
10
+ # Optional description.
11
+ field :description, type: String
12
+
13
+ # Returns the attribute requested on the datatype.
14
+ def get(attribute)
15
+ send(attribute) if has_attribute?(attribute)
16
+ end
17
+
18
+ # Returns all of the codes on this datatype in a way that is typical
19
+ # to the CQL execution engine.
20
+ def code_system_pairs
21
+ codes.collect do |code|
22
+ { code: code.code, system: code.codeSystem }
23
+ end
24
+ end
25
+
26
+ # Helper method that returns the codes on this data element as QDM::Code
27
+ # objects.
28
+ def codes
29
+ dataElementCodes.collect { |code| QDM::Code.demongoize(code) }
30
+ end
31
+
32
+ # Return the Mongo id for this datatype.
33
+ def id
34
+ _id
35
+ end
36
+
37
+ # Include '_type' in any JSON output. This is necessary for deserialization.
38
+ def to_json(options = nil)
39
+ serializable_hash(methods: :_type).to_json(options)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,54 @@
1
+ module QDM
2
+ # Represents an Interval
3
+ class Interval
4
+ attr_reader :low, :high
5
+
6
+ # Low and high are required (at minimum).
7
+ def initialize(low, high, lowClosed = true, highClosed = true)
8
+ @low = low
9
+ @high = high
10
+ @lowClosed = lowClosed
11
+ @highClosed = highClosed
12
+ end
13
+
14
+ # Converts an object of this instance into a database friendly value.
15
+ def mongoize
16
+ { low: @low, high: @high, lowClosed: @lowClosed, highClosed: @highClosed }
17
+ end
18
+
19
+ class << self
20
+ # Get the object as it was stored in the database, and instantiate
21
+ # this custom class from it.
22
+ #
23
+ # The array elements in demongoize are the same 5 elements used in mongoize, i.e.
24
+ # [ low, high ].
25
+ def demongoize(object)
26
+ return nil unless object
27
+ object = object.symbolize_keys
28
+ QDM::Interval.new(object[:low], object[:high], object[:lowClosed], object[:highClosed]) if object.is_a?(Hash)
29
+ end
30
+
31
+ # Takes any possible object and converts it to how it would be
32
+ # stored in the database.
33
+ def mongoize(object)
34
+ case object
35
+ when nil then nil
36
+ when QDM::Interval then object.mongoize
37
+ when Hash
38
+ object = object.symbolize_keys
39
+ QDM::Interval.new(object[:low], object[:high], object[:lowClosed], object[:highClosed]).mongoize
40
+ else object
41
+ end
42
+ end
43
+
44
+ # Converts the object that was supplied to a criteria and converts it
45
+ # into a database friendly form.
46
+ def evolve(object)
47
+ case object
48
+ when QDM::Interval then object.mongoize
49
+ else object
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,52 @@
1
+ module QDM
2
+ # Represents a Quantity
3
+ class Quantity
4
+ attr_reader :value, :unit
5
+
6
+ # Value and unit are required.
7
+ def initialize(value, unit)
8
+ @value = value
9
+ @unit = unit
10
+ end
11
+
12
+ # Converts an object of this instance into a database friendly value.
13
+ def mongoize
14
+ { value: @value, unit: @unit }
15
+ end
16
+
17
+ class << self
18
+ # Get the object as it was stored in the database, and instantiate
19
+ # this custom class from it.
20
+ #
21
+ # The array elements in demongoize are the same 5 elements used in mongoize, i.e.
22
+ # [ value, unit ].
23
+ def demongoize(object)
24
+ return nil unless object
25
+ object = object.symbolize_keys
26
+ QDM::Quantity.new(object[:value], object[:unit]) if object.is_a?(Hash)
27
+ end
28
+
29
+ # Takes any possible object and converts it to how it would be
30
+ # stored in the database.
31
+ def mongoize(object)
32
+ case object
33
+ when nil then nil
34
+ when QDM::Quantity then object.mongoize
35
+ when Hash
36
+ object = object.symbolize_keys
37
+ QDM::Quantity.new(object[:value], object[:unit]).mongoize
38
+ else object
39
+ end
40
+ end
41
+
42
+ # Converts the object that was supplied to a criteria and converts it
43
+ # into a database friendly form.
44
+ def evolve(object)
45
+ case object
46
+ when QDM::Quantity then object.mongoize
47
+ else object
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ module QDM
2
+ # app/models/qdm/care_goal.rb
3
+ class CareGoal < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :relevantPeriod, type: QDM::Interval
7
+ field :relatedTo, type: Array
8
+ field :targetOutcome
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.7'
10
+ field :category, type: String, default: 'care_goal'
11
+ field :qdmVersion, type: String, default: '5.3'
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module QDM
2
+ # app/models/qdm/communication_from_patient_to_provider.rb
3
+ class CommunicationFromPatientToProvider < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :relatedTo, type: Array
8
+ field :negationRationale, type: QDM::Code
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.8'
10
+ field :category, type: String, default: 'communication'
11
+ field :qdmStatus, type: String, default: 'from_patient_to_provider'
12
+ field :qdmVersion, type: String, default: '5.3'
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module QDM
2
+ # app/models/qdm/communication_from_provider_to_patient.rb
3
+ class CommunicationFromProviderToPatient < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :relatedTo, type: Array
8
+ field :negationRationale, type: QDM::Code
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.9'
10
+ field :category, type: String, default: 'communication'
11
+ field :qdmStatus, type: String, default: 'from_provider_to_patient'
12
+ field :qdmVersion, type: String, default: '5.3'
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module QDM
2
+ # app/models/qdm/communication_from_provider_to_provider.rb
3
+ class CommunicationFromProviderToProvider < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :relatedTo, type: Array
8
+ field :negationRationale, type: QDM::Code
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.10'
10
+ field :category, type: String, default: 'communication'
11
+ field :qdmStatus, type: String, default: 'from_provider_to_provider'
12
+ field :qdmVersion, type: String, default: '5.3'
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module QDM
2
+ # app/models/qdm/component.rb
3
+ class Component < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :code, type: QDM::Code
7
+ field :result
8
+ field :qdmVersion, type: String, default: '5.3'
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module QDM
2
+ # app/models/qdm/device_applied.rb
3
+ class DeviceApplied < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :relevantPeriod, type: QDM::Interval
8
+ field :negationRationale, type: QDM::Code
9
+ field :reason, type: QDM::Code
10
+ field :anatomicalLocationSite, type: QDM::Code
11
+ field :anatomicalApproachSite, type: QDM::Code
12
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.13'
13
+ field :category, type: String, default: 'device'
14
+ field :qdmStatus, type: String, default: 'applied'
15
+ field :qdmVersion, type: String, default: '5.3'
16
+ end
17
+ end
@@ -0,0 +1,14 @@
1
+ module QDM
2
+ # app/models/qdm/device_order.rb
3
+ class DeviceOrder < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :negationRationale, type: QDM::Code
8
+ field :reason, type: QDM::Code
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.15'
10
+ field :category, type: String, default: 'device'
11
+ field :qdmStatus, type: String, default: 'order'
12
+ field :qdmVersion, type: String, default: '5.3'
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module QDM
2
+ # app/models/qdm/device_recommended.rb
3
+ class DeviceRecommended < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :negationRationale, type: QDM::Code
8
+ field :reason, type: QDM::Code
9
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.16'
10
+ field :category, type: String, default: 'device'
11
+ field :qdmStatus, type: String, default: 'recommended'
12
+ field :qdmVersion, type: String, default: '5.3'
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module QDM
2
+ # app/models/qdm/diagnosis.rb
3
+ class Diagnosis < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :prevalencePeriod, type: QDM::Interval
8
+ field :anatomicalLocationSite, type: QDM::Code
9
+ field :severity, type: QDM::Code
10
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.110'
11
+ field :qrdaOid, type: String, default: '2.16.840.1.113883.10.20.24.3.135'
12
+ field :category, type: String, default: 'condition'
13
+ field :qdmVersion, type: String, default: '5.3'
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module QDM
2
+ # app/models/qdm/diagnostic_study_order.rb
3
+ class DiagnosticStudyOrder < DataElement
4
+ include Mongoid::Document
5
+ embedded_in :patient
6
+ field :authorDatetime, type: DateTime
7
+ field :reason, type: QDM::Code
8
+ field :method, type: QDM::Code
9
+ field :negationRationale, type: QDM::Code
10
+ field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.3.22'
11
+ field :category, type: String, default: 'diagnostic_study'
12
+ field :qdmStatus, type: String, default: 'order'
13
+ field :qdmVersion, type: String, default: '5.3'
14
+ end
15
+ end