cqm-models 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,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,21 @@
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
+ <%- datatypes.each_key do |datatype| -%>
20
+ require_relative 'qdm/<%= datatype.underscore %>'
21
+ <%- end -%>
@@ -0,0 +1,20 @@
1
+ const mongoose = require('mongoose');
2
+ const { DataElementSchema } = require('./basetypes/DataElement');
3
+ const Code = require('./basetypes/Code');
4
+ const Interval = require('./basetypes/Interval');
5
+ const Quantity = require('./basetypes/Quantity');
6
+ const DateTime = require('./basetypes/DateTime');
7
+
8
+ const [Number, String] = [
9
+ mongoose.Schema.Types.Number,
10
+ mongoose.Schema.Types.String,
11
+ ];
12
+
13
+ const <%= datatype -%>Schema = DataElementSchema({
14
+ <%- for attribute in attrs_with_extras -%>
15
+ <%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
16
+ <%- end %>
17
+ });
18
+
19
+ module.exports.<%= datatype %>Schema = <%= datatype %>Schema;
20
+ module.exports.<%= datatype %> = mongoose.model('<%= datatype %>', <%= datatype %>Schema);
@@ -0,0 +1,194 @@
1
+ field :givenNames, type: Array
2
+ field :familyName, type: String
3
+ field :bundleId, type: String
4
+
5
+ # These are the "data criteria", or QDM datatype elements that exist on a
6
+ # patient.
7
+ embeds_many :dataElements, class_name: 'QDM::DataElement'
8
+
9
+ # This field is for application specific information only. If both Bonnie
10
+ # Cypress use a common field, it should be made a field on this model,
11
+ # and not put into extendedData.
12
+ field :extendedData, type: Hash
13
+
14
+ # Returns an array of elements that exist on this patient, that
15
+ # match the given HQMF data criteria OID.
16
+ def get_by_hqmf_oid(hqmf_oid)
17
+ dataElements.where(hqmfOid: hqmf_oid) || []
18
+ end
19
+
20
+ # Returns an array of elements that exist on this patient, that
21
+ # match the given QRDA data criteria OID.
22
+ def get_by_qrda_oid(qrda_oid)
23
+ dataElements.where(qrdaOid: qrda_oid) || []
24
+ end
25
+
26
+ # Returns an array of elements that exist on this patient. Optionally
27
+ # takes a category and/or, which returns all elements of that QDM
28
+ # category. Example: patient.get_data_elements('encounters')
29
+ # will return all Encounter QDM data types active on the patient.
30
+ def get_data_elements(category = nil, status = nil)
31
+ if category && status
32
+ dataElements.where(category: category, qdmStatus: status) || []
33
+ elsif category
34
+ dataElements.where(category: category) || []
35
+ else
36
+ dataElements || []
37
+ end
38
+ end
39
+
40
+ # Helper method; returns adverse_event data element types on this patient.
41
+ def adverse_events
42
+ get_data_elements('adverse_event')
43
+ end
44
+
45
+ # Helper method; returns allergy data element types on this patient.
46
+ def allergies
47
+ get_data_elements('allergy')
48
+ end
49
+
50
+ # Helper method; returns assessment data element types on this patient.
51
+ def assessments
52
+ get_data_elements('assessment')
53
+ end
54
+
55
+ # Helper method; returns care_experience data element types on this patient.
56
+ def care_experiences
57
+ get_data_elements('care_experience')
58
+ end
59
+
60
+ # Helper method; returns care_goal data element types on this patient.
61
+ def care_goals
62
+ get_data_elements('care_goal')
63
+ end
64
+
65
+ # Helper method; returns communication data element types on this patient.
66
+ def communications
67
+ get_data_elements('communication')
68
+ end
69
+
70
+ # Helper method; returns condition data element types on this patient.
71
+ def conditions
72
+ get_data_elements('condition')
73
+ end
74
+
75
+ # Helper method; returns device data element types on this patient.
76
+ def devices
77
+ get_data_elements('device')
78
+ end
79
+
80
+ # Helper method; returns diagnostic_study data element types on this patient.
81
+ def diagnostic_studies
82
+ get_data_elements('diagnostic_study')
83
+ end
84
+
85
+ # Helper method; returns encounter data element types on this patient.
86
+ def encounters
87
+ get_data_elements('encounter')
88
+ end
89
+
90
+ # Helper method; returns family_history data element types on this patient.
91
+ def family_history
92
+ get_data_elements('family_history')
93
+ end
94
+
95
+ # Helper method; returns functional_status data element types on this patient.
96
+ def functional_statuses
97
+ get_data_elements('functional_status')
98
+ end
99
+
100
+ # Helper method; returns immunization data element types on this patient.
101
+ def immunizations
102
+ get_data_elements('immunization')
103
+ end
104
+
105
+ # Helper method; returns intervention data element types on this patient.
106
+ def interventions
107
+ get_data_elements('intervention')
108
+ end
109
+
110
+ # Helper method; returns laboratory_test data element types on this patient.
111
+ def laboratory_tests
112
+ get_data_elements('laboratory_test')
113
+ end
114
+
115
+ # Helper method; returns medical_equipment data element types on this patient.
116
+ def medical_equipment
117
+ get_data_elements('medical_equipment')
118
+ end
119
+
120
+ # Helper method; returns medication data element types on this patient.
121
+ def medications
122
+ get_data_elements('medication')
123
+ end
124
+
125
+ # Helper method; returns physical_exam data element types on this patient.
126
+ def physical_exams
127
+ get_data_elements('physical_exam')
128
+ end
129
+
130
+ # Helper method; returns preference data element types on this patient.
131
+ def preferences
132
+ get_data_elements('preference')
133
+ end
134
+
135
+ # Helper method; returns provider_characteristic data element types on this patient.
136
+ def provider_characteristics
137
+ get_data_elements('provider_characteristic')
138
+ end
139
+
140
+ # Helper method; returns procedure data element types on this patient.
141
+ def procedures
142
+ get_data_elements('procedure')
143
+ end
144
+
145
+ # Helper method; returns result data element types on this patient.
146
+ def results
147
+ get_data_elements('result')
148
+ end
149
+
150
+ # Helper method; returns risk_category_assessment data element types on this patient.
151
+ def risk_category_assessments
152
+ get_data_elements('risk_category_assessment')
153
+ end
154
+
155
+ # Helper method; returns social_history data element types on this patient.
156
+ def social_history
157
+ get_data_elements('social_history')
158
+ end
159
+
160
+ # Helper method; returns substance data element types on this patient.
161
+ def substances
162
+ get_data_elements('substance')
163
+ end
164
+
165
+ # Helper method; returns symptom data element types on this patient.
166
+ def symptoms
167
+ get_data_elements('symptom')
168
+ end
169
+
170
+ # Helper method; returns system_characteristic data element types on this patient.
171
+ def system_characteristics
172
+ get_data_elements('system_characteristic')
173
+ end
174
+
175
+ # Helper method; returns transfer data element types on this patient.
176
+ def transfers
177
+ get_data_elements('transfer')
178
+ end
179
+
180
+ # Helper method; returns vital_sign data element types on this patient.
181
+ def vital_signs
182
+ get_data_elements('vital_sign')
183
+ end
184
+
185
+ # Return the Mongo id.
186
+ def id
187
+ _id
188
+ end
189
+
190
+ # Include '_type' in any JSON output. This is necessary for deserialization.
191
+ def to_json(options = nil)
192
+ serializable_hash(methods: :_type).to_json(options)
193
+ end
194
+ end
@@ -0,0 +1,247 @@
1
+ const mongoose = require('mongoose');
2
+ const Code = require('./basetypes/Code');
3
+ const Interval = require('./basetypes/Interval');
4
+ const Quantity = require('./basetypes/Quantity');
5
+ const DateTime = require('./basetypes/DateTime');
6
+ const AllDataElements = require('./AllDataElements');
7
+
8
+ const [Schema, Number, String] = [
9
+ mongoose.Schema,
10
+ mongoose.Schema.Types.Number,
11
+ mongoose.Schema.Types.String,
12
+ ];
13
+
14
+ const PatientSchema = new Schema({
15
+ <%- for attribute in attrs_with_extras -%>
16
+ <%= attribute[:name] %>: <%= TYPE_LOOKUP_JS[attribute[:type]] -%>,
17
+ <%- end %>
18
+ givenNames: [String],
19
+ familyName: String,
20
+ bundleId: String,
21
+ // These are the "data criteria", or QDM datatype elements that exist on a
22
+ // patient.
23
+ dataElements: [],
24
+ // This field is for application specific information only. If both Bonnie
25
+ // Cypress use a common field, it should be made a field on this model,
26
+ // and not put into extendedData.
27
+ extendedData: {},
28
+ }, { id: false });
29
+
30
+ // After initialization of a Patient model, initialize every individual data element
31
+ // to its respective Mongoose Model
32
+ PatientSchema.methods.initializeDataElements = function initializeDataElements() {
33
+ let typeStripped;
34
+ const dataElementsInit = [];
35
+ this.dataElements.forEach((element) => {
36
+ typeStripped = element._type.replace(/QDM::/, '');
37
+ if (typeStripped in AllDataElements) {
38
+ dataElementsInit.push(AllDataElements[typeStripped](element));
39
+ } else {
40
+ dataElementsInit.push(element);
41
+ }
42
+ });
43
+ this.set({ dataElements: dataElementsInit });
44
+ };
45
+
46
+ PatientSchema.queue('initializeDataElements');
47
+
48
+ PatientSchema.methods.id = function id() {
49
+ return this._id;
50
+ };
51
+
52
+ // Returns an array of elements that exist on this patient, that
53
+ // match the given HQMF data criteria OID.
54
+ PatientSchema.methods.getByHqmfOid = function getByHqmfOid(hqmfOid) {
55
+ return this.dataElements.filter(element => element.hqmfOid === hqmfOid);
56
+ };
57
+
58
+ // Returns an array of elements that exist on this patient, that
59
+ // match the given QRDA data criteria OID.
60
+ PatientSchema.methods.getByQrdaOid = function getByQrdaOid(qrdaOid) {
61
+ return this.dataElements.filter(element => element.qrdaOid === qrdaOid);
62
+ };
63
+
64
+ // Returns an array of elements that exist on this patient. Optionally
65
+ // takes a category, which returns all elements of that QDM category.
66
+ // Example: patient.getDataElements(category = 'encounters') will return
67
+ // all Encounter QDM data types active on the patient.
68
+ PatientSchema.methods.getDataElements = function getDataElements(params) {
69
+ if (params.category && params.qdmStatus) {
70
+ return this.dataElements.filter(element => (element.category === params.category) && (element.qdmStatus === params.qdmStatus));
71
+ } else if (params.category) {
72
+ return this.dataElements.filter(element => element.category === params.category);
73
+ }
74
+ return this.dataElements;
75
+ };
76
+
77
+ // Returns an array of dataElements that exist on the patient, queried by
78
+ // QDM profile
79
+ PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated = null) {
80
+ if (isNegated === true) {
81
+ return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale !== 'undefined' && element.negationRationale != null));
82
+ } else if (isNegated === false) {
83
+ return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale === 'undefined' || element.negationRationale == null));
84
+ }
85
+ return this.dataElements.filter(element => element._type === `QDM::${profile}`);
86
+ };
87
+
88
+ // This method is called by the CQL execution engine on a CQLPatient when
89
+ // the execution engine wants information on a record. A record could be patient
90
+ // characteristic information about the patient, or it could be data criteria
91
+ // that currently exist on this patient (data criteria you drag on a patient
92
+ // in Bonnie's patient builder).
93
+ // @param {String} profile - the data criteria requested by the execution engine
94
+ // @returns {Object}
95
+ PatientSchema.methods.findRecords = function findRecords(profile) {
96
+ let profileStripped;
97
+ if (profile === 'Patient') {
98
+ // Requested generic patient info
99
+ return { birthDatetime: this.birthDatetime };
100
+ } else if (/PatientCharacteristic/.test(profile)) {
101
+ // Requested a patient characteristic
102
+ profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
103
+ return this.getByProfile(profileStripped);
104
+ } else if (profile != null) {
105
+ // Requested something else (probably a QDM data type).
106
+
107
+ // Strip model details from request. The requested profile string contains
108
+ // a lot of things we don't need or care about. Example, we might see
109
+ // something like:
110
+ // "{urn:healthit-gov:qdm:v5_0_draft}PatientCharacteristicEthnicity"
111
+ // Where we only care about: "PatientCharacteristicEthnicity".
112
+ profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
113
+
114
+ // Check and handle negation status
115
+ if (/Positive/.test(profileStripped)) {
116
+ profileStripped = profileStripped.replace(/Positive/, '');
117
+ // Since the data criteria is 'Positive', it is not negated.
118
+ return this.getByProfile(profileStripped, false);
119
+ } else if (/Negative/.test(profileStripped)) {
120
+ profileStripped = profileStripped.replace(/Negative/, '');
121
+ // Since the data criteria is 'Negative', it is negated.
122
+ return this.getByProfile(profileStripped, true);
123
+ }
124
+ // No negation status, proceed normally
125
+ return this.getByProfile(profileStripped);
126
+ }
127
+ return [];
128
+ };
129
+
130
+ PatientSchema.methods.adverse_events = function adverse_events() {
131
+ return this.getDataElements({ category: 'adverse_event' });
132
+ };
133
+
134
+ PatientSchema.methods.allergies = function allergies() {
135
+ return this.getDataElements({ category: 'allergy' });
136
+ };
137
+
138
+ PatientSchema.methods.assessments = function assessments() {
139
+ return this.getDataElements({ category: 'assessment' });
140
+ };
141
+
142
+ PatientSchema.methods.care_experiences = function care_experiences() {
143
+ return this.getDataElements({ category: 'care_experience' });
144
+ };
145
+
146
+ PatientSchema.methods.care_goals = function care_goals() {
147
+ return this.getDataElements({ category: 'care_goal' });
148
+ };
149
+
150
+ PatientSchema.methods.communications = function communications() {
151
+ return this.getDataElements({ category: 'communication' });
152
+ };
153
+
154
+ PatientSchema.methods.conditions = function conditions() {
155
+ return this.getDataElements({ category: 'condition' });
156
+ };
157
+
158
+ PatientSchema.methods.devices = function devices() {
159
+ return this.getDataElements({ category: 'device' });
160
+ };
161
+
162
+ PatientSchema.methods.diagnostic_studies = function diagnostic_studies() {
163
+ return this.getDataElements({ category: 'diagnostic_study' });
164
+ };
165
+
166
+ PatientSchema.methods.encounters = function encounters() {
167
+ return this.getDataElements({ category: 'encounter' });
168
+ };
169
+
170
+ PatientSchema.methods.family_history = function family_history() {
171
+ return this.getDataElements({ category: 'family_history' });
172
+ };
173
+
174
+ PatientSchema.methods.functional_statuses = function functional_statuses() {
175
+ return this.getDataElements({ category: 'functional_status' });
176
+ };
177
+
178
+ PatientSchema.methods.immunizations = function immunizations() {
179
+ return this.getDataElements({ category: 'immunization' });
180
+ };
181
+
182
+ PatientSchema.methods.interventions = function interventions() {
183
+ return this.getDataElements({ category: 'intervention' });
184
+ };
185
+
186
+ PatientSchema.methods.laboratory_tests = function laboratory_tests() {
187
+ return this.getDataElements({ category: 'laboratory_test' });
188
+ };
189
+
190
+ PatientSchema.methods.medical_equipment = function medical_equipment() {
191
+ return this.getDataElements({ category: 'medical_equipment' });
192
+ };
193
+
194
+ PatientSchema.methods.medications = function medications() {
195
+ return this.getDataElements({ category: 'medication' });
196
+ };
197
+
198
+ PatientSchema.methods.physical_exams = function physical_exams() {
199
+ return this.getDataElements({ category: 'physical_exam' });
200
+ };
201
+
202
+ PatientSchema.methods.preferences = function preferences() {
203
+ return this.getDataElements({ category: 'preference' });
204
+ };
205
+
206
+ PatientSchema.methods.provider_characteristics = function provider_characteristics() {
207
+ return this.getDataElements({ category: 'provider_characteristic' });
208
+ };
209
+
210
+ PatientSchema.methods.procedures = function procedures() {
211
+ return this.getDataElements({ category: 'procedure' });
212
+ };
213
+
214
+ PatientSchema.methods.results = function results() {
215
+ return this.getDataElements({ category: 'result' });
216
+ };
217
+
218
+ PatientSchema.methods.risk_category_assessments = function risk_category_assessments() {
219
+ return this.getDataElements({ category: 'risk_category_assessment' });
220
+ };
221
+
222
+ PatientSchema.methods.social_history = function social_history() {
223
+ return this.getDataElements({ category: 'social_history' });
224
+ };
225
+
226
+ PatientSchema.methods.substances = function substances() {
227
+ return this.getDataElements({ category: 'substance' });
228
+ };
229
+
230
+ PatientSchema.methods.symptoms = function symptoms() {
231
+ return this.getDataElements({ category: 'symptom' });
232
+ };
233
+
234
+ PatientSchema.methods.system_characteristics = function system_characteristics() {
235
+ return this.getDataElements({ category: 'system_characteristic' });
236
+ };
237
+
238
+ PatientSchema.methods.transfers = function transfers() {
239
+ return this.getDataElements({ category: 'transfer' });
240
+ };
241
+
242
+ PatientSchema.methods.vital_signs = function vital_signs() {
243
+ return this.getDataElements({ category: 'vital_sign' });
244
+ };
245
+
246
+ module.exports.PatientSchema = PatientSchema;
247
+ module.exports.Patient = mongoose.model('Patient', PatientSchema);
data/tmp/.keep ADDED
File without changes