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,27 @@
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 LaboratoryTestOrderSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ reason: Code,
16
+ method: Code,
17
+ negationRationale: Code,
18
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.41' },
19
+ category: { type: String, default: 'laboratory_test' },
20
+ qdmStatus: { type: String, default: 'order' },
21
+ qdmVersion: { type: String, default: '5.3' },
22
+ _type: { type: String, default: 'LaboratoryTestOrder' },
23
+
24
+ });
25
+
26
+ module.exports.LaboratoryTestOrderSchema = LaboratoryTestOrderSchema;
27
+ module.exports.LaboratoryTestOrder = mongoose.model('LaboratoryTestOrder', LaboratoryTestOrderSchema);
@@ -0,0 +1,33 @@
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 LaboratoryTestPerformedSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ relevantPeriod: Interval,
16
+ status: Code,
17
+ method: Code,
18
+ result: {},
19
+ resultDatetime: DateTime,
20
+ reason: Code,
21
+ referenceRange: Interval,
22
+ negationRationale: Code,
23
+ components: [],
24
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.42' },
25
+ category: { type: String, default: 'laboratory_test' },
26
+ qdmStatus: { type: String, default: 'performed' },
27
+ qdmVersion: { type: String, default: '5.3' },
28
+ _type: { type: String, default: 'LaboratoryTestPerformed' },
29
+
30
+ });
31
+
32
+ module.exports.LaboratoryTestPerformedSchema = LaboratoryTestPerformedSchema;
33
+ module.exports.LaboratoryTestPerformed = mongoose.model('LaboratoryTestPerformed', LaboratoryTestPerformedSchema);
@@ -0,0 +1,27 @@
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 LaboratoryTestRecommendedSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ method: Code,
16
+ reason: Code,
17
+ negationRationale: Code,
18
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.43' },
19
+ category: { type: String, default: 'laboratory_test' },
20
+ qdmStatus: { type: String, default: 'recommended' },
21
+ qdmVersion: { type: String, default: '5.3' },
22
+ _type: { type: String, default: 'LaboratoryTestRecommended' },
23
+
24
+ });
25
+
26
+ module.exports.LaboratoryTestRecommendedSchema = LaboratoryTestRecommendedSchema;
27
+ module.exports.LaboratoryTestRecommended = mongoose.model('LaboratoryTestRecommended', LaboratoryTestRecommendedSchema);
@@ -0,0 +1,76 @@
1
+ const mongoose = require('mongoose');
2
+ const Code = require('./basetypes/Code');
3
+ const Interval = require('./basetypes/Interval');
4
+ const Quantity = require('./basetypes/Quantity');
5
+
6
+ const [mNumber, mString, mBoolean, Mixed, ObjectId, mDate] = [
7
+ mongoose.Schema.Types.Number,
8
+ mongoose.Schema.Types.String,
9
+ mongoose.Schema.Types.Boolean,
10
+ mongoose.Schema.Types.Mixed,
11
+ mongoose.Schema.Types.ObjectId,
12
+ mongoose.Schema.Types.Date,
13
+ ];
14
+
15
+ const MeasureSchema = mongoose.Schema(
16
+ {
17
+ // ID/other measure information
18
+ id: mString,
19
+ measure_id: mString,
20
+ hqmf_id: mString,
21
+ hqmf_set_id: mString,
22
+ hqmf_version_number: mNumber,
23
+ cms_id: mString,
24
+ title: mString,
25
+ description: mString,
26
+ type: mString,
27
+ category: { type: mString, default: 'Uncategorized' },
28
+
29
+ // Measure type variables
30
+ episode_of_care: mBoolean,
31
+ continuous_constiable: mBoolean,
32
+ episode_ids: [],
33
+
34
+ // Publishing data (used by Bonnie)
35
+ published: mBoolean,
36
+ publish_date: mDate,
37
+ version: mNumber,
38
+
39
+ // ELM/CQL Measure-logic related data
40
+ elm_annotations: Mixed,
41
+ cql: [mString],
42
+ elm: [Mixed],
43
+ main_cql_library: mString,
44
+ cql_statement_dependencies: Mixed,
45
+
46
+ // HQMF/Tacoma-specific Measure-logic related data
47
+ population_criteria: Mixed,
48
+ data_criteria: Mixed,
49
+ source_data_criteria: Mixed,
50
+ measure_period: Interval,
51
+ measure_attributes: [],
52
+ populations: [Mixed],
53
+ populations_cql_map: Mixed,
54
+ observations: [Mixed],
55
+
56
+ value_sets: [{ type: ObjectId, ref: 'ValueSet' }],
57
+
58
+ complexity: Mixed, // Bonnie-specific?
59
+
60
+ // Relations to other model classes
61
+ user: { type: ObjectId, ref: 'User', index: true }, // Bonnie-specific
62
+ bundle: { type: ObjectId, ref: 'Bundle' }, // Cypress-specific, but used in Bonnie-bundler as well
63
+ package: { type: ObjectId, ref: 'MeasurePackage' }, // Bonnie specific
64
+ },
65
+ // Options
66
+ {
67
+ timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }, // These are the Mongoid conventions for timestamps
68
+ }
69
+ );
70
+
71
+ MeasureSchema.virtual('ALL_POPULATION_CODES').get(() => ['STRAT', 'IPP', 'DENOM', 'DENEX', 'NUMER', 'NUMEX', 'DENEXCEP', 'MSRPOPL', 'OBSERV', 'MSRPOPLEX']);
72
+
73
+ MeasureSchema.virtual('cqlSkipStatements').get(() => ['SDE Ethnicity', 'SDE Payer', 'SDE Race', 'SDE Sex']);
74
+
75
+ module.exports.MeasureSchema = MeasureSchema;
76
+ module.exports.Measure = mongoose.model('measure', MeasureSchema);
@@ -0,0 +1,20 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const [mBuffer, ObjectId] = [
4
+ mongoose.Schema.Types.Buffer,
5
+ mongoose.Schema.Types.ObjectId,
6
+ ];
7
+
8
+ const MeasurePackageSchema = mongoose.Schema(
9
+ {
10
+ file: mBuffer,
11
+ measure: { type: ObjectId, ref: 'Measure' },
12
+ },
13
+ // Options
14
+ {
15
+ timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' },
16
+ }
17
+ );
18
+
19
+ module.exports.MeasurePackageSchema = MeasurePackageSchema;
20
+ module.exports.MeasurePackage = mongoose.model('measure_package', MeasurePackageSchema);
@@ -0,0 +1,28 @@
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 MedicationActiveSchema = DataElementSchema({
14
+ relevantPeriod: Interval,
15
+ dosage: Quantity,
16
+ supply: Quantity,
17
+ frequency: Code,
18
+ route: Code,
19
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.44' },
20
+ category: { type: String, default: 'medication' },
21
+ qdmStatus: { type: String, default: 'active' },
22
+ qdmVersion: { type: String, default: '5.3' },
23
+ _type: { type: String, default: 'MedicationActive' },
24
+
25
+ });
26
+
27
+ module.exports.MedicationActiveSchema = MedicationActiveSchema;
28
+ module.exports.MedicationActive = mongoose.model('MedicationActive', MedicationActiveSchema);
@@ -0,0 +1,31 @@
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 MedicationAdministeredSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ relevantPeriod: Interval,
16
+ dosage: Quantity,
17
+ supply: Quantity,
18
+ frequency: Code,
19
+ route: Code,
20
+ reason: Code,
21
+ negationRationale: Code,
22
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.45' },
23
+ category: { type: String, default: 'medication' },
24
+ qdmStatus: { type: String, default: 'administered' },
25
+ qdmVersion: { type: String, default: '5.3' },
26
+ _type: { type: String, default: 'MedicationAdministered' },
27
+
28
+ });
29
+
30
+ module.exports.MedicationAdministeredSchema = MedicationAdministeredSchema;
31
+ module.exports.MedicationAdministered = mongoose.model('MedicationAdministered', MedicationAdministeredSchema);
@@ -0,0 +1,30 @@
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 MedicationDischargeSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ refills: Number,
16
+ dosage: Quantity,
17
+ supply: Quantity,
18
+ frequency: Code,
19
+ route: Code,
20
+ negationRationale: Code,
21
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.48' },
22
+ category: { type: String, default: 'medication' },
23
+ qdmStatus: { type: String, default: 'discharge' },
24
+ qdmVersion: { type: String, default: '5.3' },
25
+ _type: { type: String, default: 'MedicationDischarge' },
26
+
27
+ });
28
+
29
+ module.exports.MedicationDischargeSchema = MedicationDischargeSchema;
30
+ module.exports.MedicationDischarge = mongoose.model('MedicationDischarge', MedicationDischargeSchema);
@@ -0,0 +1,31 @@
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 MedicationDispensedSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ relevantPeriod: Interval,
16
+ refills: Number,
17
+ dosage: Quantity,
18
+ supply: Quantity,
19
+ frequency: Code,
20
+ route: Code,
21
+ negationRationale: Code,
22
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.49' },
23
+ category: { type: String, default: 'medication' },
24
+ qdmStatus: { type: String, default: 'dispensed' },
25
+ qdmVersion: { type: String, default: '5.3' },
26
+ _type: { type: String, default: 'MedicationDispensed' },
27
+
28
+ });
29
+
30
+ module.exports.MedicationDispensedSchema = MedicationDispensedSchema;
31
+ module.exports.MedicationDispensed = mongoose.model('MedicationDispensed', MedicationDispensedSchema);
@@ -0,0 +1,34 @@
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 MedicationOrderSchema = DataElementSchema({
14
+ activeDatetime: DateTime,
15
+ relevantPeriod: Interval,
16
+ authorDatetime: DateTime,
17
+ refills: Number,
18
+ dosage: Quantity,
19
+ supply: Quantity,
20
+ frequency: Code,
21
+ route: Code,
22
+ method: Code,
23
+ reason: Code,
24
+ negationRationale: Code,
25
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.51' },
26
+ category: { type: String, default: 'medication' },
27
+ qdmStatus: { type: String, default: 'order' },
28
+ qdmVersion: { type: String, default: '5.3' },
29
+ _type: { type: String, default: 'MedicationOrder' },
30
+
31
+ });
32
+
33
+ module.exports.MedicationOrderSchema = MedicationOrderSchema;
34
+ module.exports.MedicationOrder = mongoose.model('MedicationOrder', MedicationOrderSchema);
@@ -0,0 +1,21 @@
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 ParticipationSchema = DataElementSchema({
14
+ participationPeriod: Interval,
15
+ qdmVersion: { type: String, default: '5.3' },
16
+ _type: { type: String, default: 'Participation' },
17
+
18
+ });
19
+
20
+ module.exports.ParticipationSchema = ParticipationSchema;
21
+ module.exports.Participation = mongoose.model('Participation', ParticipationSchema);
@@ -0,0 +1,248 @@
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
+ birthDatetime: DateTime,
16
+ qdmVersion: { type: String, default: '5.3' },
17
+ _type: { type: String, default: 'Patient' },
18
+
19
+ givenNames: [String],
20
+ familyName: String,
21
+ bundleId: String,
22
+ // These are the "data criteria", or QDM datatype elements that exist on a
23
+ // patient.
24
+ dataElements: [],
25
+ // This field is for application specific information only. If both Bonnie
26
+ // Cypress use a common field, it should be made a field on this model,
27
+ // and not put into extendedData.
28
+ extendedData: {},
29
+ }, { id: false });
30
+
31
+ // After initialization of a Patient model, initialize every individual data element
32
+ // to its respective Mongoose Model
33
+ PatientSchema.methods.initializeDataElements = function initializeDataElements() {
34
+ let typeStripped;
35
+ const dataElementsInit = [];
36
+ this.dataElements.forEach((element) => {
37
+ typeStripped = element._type.replace(/QDM::/, '');
38
+ if (typeStripped in AllDataElements) {
39
+ dataElementsInit.push(AllDataElements[typeStripped](element));
40
+ } else {
41
+ dataElementsInit.push(element);
42
+ }
43
+ });
44
+ this.set({ dataElements: dataElementsInit });
45
+ };
46
+
47
+ PatientSchema.queue('initializeDataElements');
48
+
49
+ PatientSchema.methods.id = function id() {
50
+ return this._id;
51
+ };
52
+
53
+ // Returns an array of elements that exist on this patient, that
54
+ // match the given HQMF data criteria OID.
55
+ PatientSchema.methods.getByHqmfOid = function getByHqmfOid(hqmfOid) {
56
+ return this.dataElements.filter(element => element.hqmfOid === hqmfOid);
57
+ };
58
+
59
+ // Returns an array of elements that exist on this patient, that
60
+ // match the given QRDA data criteria OID.
61
+ PatientSchema.methods.getByQrdaOid = function getByQrdaOid(qrdaOid) {
62
+ return this.dataElements.filter(element => element.qrdaOid === qrdaOid);
63
+ };
64
+
65
+ // Returns an array of elements that exist on this patient. Optionally
66
+ // takes a category, which returns all elements of that QDM category.
67
+ // Example: patient.getDataElements(category = 'encounters') will return
68
+ // all Encounter QDM data types active on the patient.
69
+ PatientSchema.methods.getDataElements = function getDataElements(params) {
70
+ if (params.category && params.qdmStatus) {
71
+ return this.dataElements.filter(element => (element.category === params.category) && (element.qdmStatus === params.qdmStatus));
72
+ } else if (params.category) {
73
+ return this.dataElements.filter(element => element.category === params.category);
74
+ }
75
+ return this.dataElements;
76
+ };
77
+
78
+ // Returns an array of dataElements that exist on the patient, queried by
79
+ // QDM profile
80
+ PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated = null) {
81
+ if (isNegated === true) {
82
+ return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale !== 'undefined' && element.negationRationale != null));
83
+ } else if (isNegated === false) {
84
+ return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale === 'undefined' || element.negationRationale == null));
85
+ }
86
+ return this.dataElements.filter(element => element._type === `QDM::${profile}`);
87
+ };
88
+
89
+ // This method is called by the CQL execution engine on a CQLPatient when
90
+ // the execution engine wants information on a record. A record could be patient
91
+ // characteristic information about the patient, or it could be data criteria
92
+ // that currently exist on this patient (data criteria you drag on a patient
93
+ // in Bonnie's patient builder).
94
+ // @param {String} profile - the data criteria requested by the execution engine
95
+ // @returns {Object}
96
+ PatientSchema.methods.findRecords = function findRecords(profile) {
97
+ let profileStripped;
98
+ if (profile === 'Patient') {
99
+ // Requested generic patient info
100
+ return { birthDatetime: this.birthDatetime };
101
+ } else if (/PatientCharacteristic/.test(profile)) {
102
+ // Requested a patient characteristic
103
+ profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
104
+ return this.getByProfile(profileStripped);
105
+ } else if (profile != null) {
106
+ // Requested something else (probably a QDM data type).
107
+
108
+ // Strip model details from request. The requested profile string contains
109
+ // a lot of things we don't need or care about. Example, we might see
110
+ // something like:
111
+ // "{urn:healthit-gov:qdm:v5_0_draft}PatientCharacteristicEthnicity"
112
+ // Where we only care about: "PatientCharacteristicEthnicity".
113
+ profileStripped = profile.replace(/ *\{[^)]*\} */g, '');
114
+
115
+ // Check and handle negation status
116
+ if (/Positive/.test(profileStripped)) {
117
+ profileStripped = profileStripped.replace(/Positive/, '');
118
+ // Since the data criteria is 'Positive', it is not negated.
119
+ return this.getByProfile(profileStripped, false);
120
+ } else if (/Negative/.test(profileStripped)) {
121
+ profileStripped = profileStripped.replace(/Negative/, '');
122
+ // Since the data criteria is 'Negative', it is negated.
123
+ return this.getByProfile(profileStripped, true);
124
+ }
125
+ // No negation status, proceed normally
126
+ return this.getByProfile(profileStripped);
127
+ }
128
+ return [];
129
+ };
130
+
131
+ PatientSchema.methods.adverse_events = function adverse_events() {
132
+ return this.getDataElements({ category: 'adverse_event' });
133
+ };
134
+
135
+ PatientSchema.methods.allergies = function allergies() {
136
+ return this.getDataElements({ category: 'allergy' });
137
+ };
138
+
139
+ PatientSchema.methods.assessments = function assessments() {
140
+ return this.getDataElements({ category: 'assessment' });
141
+ };
142
+
143
+ PatientSchema.methods.care_experiences = function care_experiences() {
144
+ return this.getDataElements({ category: 'care_experience' });
145
+ };
146
+
147
+ PatientSchema.methods.care_goals = function care_goals() {
148
+ return this.getDataElements({ category: 'care_goal' });
149
+ };
150
+
151
+ PatientSchema.methods.communications = function communications() {
152
+ return this.getDataElements({ category: 'communication' });
153
+ };
154
+
155
+ PatientSchema.methods.conditions = function conditions() {
156
+ return this.getDataElements({ category: 'condition' });
157
+ };
158
+
159
+ PatientSchema.methods.devices = function devices() {
160
+ return this.getDataElements({ category: 'device' });
161
+ };
162
+
163
+ PatientSchema.methods.diagnostic_studies = function diagnostic_studies() {
164
+ return this.getDataElements({ category: 'diagnostic_study' });
165
+ };
166
+
167
+ PatientSchema.methods.encounters = function encounters() {
168
+ return this.getDataElements({ category: 'encounter' });
169
+ };
170
+
171
+ PatientSchema.methods.family_history = function family_history() {
172
+ return this.getDataElements({ category: 'family_history' });
173
+ };
174
+
175
+ PatientSchema.methods.functional_statuses = function functional_statuses() {
176
+ return this.getDataElements({ category: 'functional_status' });
177
+ };
178
+
179
+ PatientSchema.methods.immunizations = function immunizations() {
180
+ return this.getDataElements({ category: 'immunization' });
181
+ };
182
+
183
+ PatientSchema.methods.interventions = function interventions() {
184
+ return this.getDataElements({ category: 'intervention' });
185
+ };
186
+
187
+ PatientSchema.methods.laboratory_tests = function laboratory_tests() {
188
+ return this.getDataElements({ category: 'laboratory_test' });
189
+ };
190
+
191
+ PatientSchema.methods.medical_equipment = function medical_equipment() {
192
+ return this.getDataElements({ category: 'medical_equipment' });
193
+ };
194
+
195
+ PatientSchema.methods.medications = function medications() {
196
+ return this.getDataElements({ category: 'medication' });
197
+ };
198
+
199
+ PatientSchema.methods.physical_exams = function physical_exams() {
200
+ return this.getDataElements({ category: 'physical_exam' });
201
+ };
202
+
203
+ PatientSchema.methods.preferences = function preferences() {
204
+ return this.getDataElements({ category: 'preference' });
205
+ };
206
+
207
+ PatientSchema.methods.provider_characteristics = function provider_characteristics() {
208
+ return this.getDataElements({ category: 'provider_characteristic' });
209
+ };
210
+
211
+ PatientSchema.methods.procedures = function procedures() {
212
+ return this.getDataElements({ category: 'procedure' });
213
+ };
214
+
215
+ PatientSchema.methods.results = function results() {
216
+ return this.getDataElements({ category: 'result' });
217
+ };
218
+
219
+ PatientSchema.methods.risk_category_assessments = function risk_category_assessments() {
220
+ return this.getDataElements({ category: 'risk_category_assessment' });
221
+ };
222
+
223
+ PatientSchema.methods.social_history = function social_history() {
224
+ return this.getDataElements({ category: 'social_history' });
225
+ };
226
+
227
+ PatientSchema.methods.substances = function substances() {
228
+ return this.getDataElements({ category: 'substance' });
229
+ };
230
+
231
+ PatientSchema.methods.symptoms = function symptoms() {
232
+ return this.getDataElements({ category: 'symptom' });
233
+ };
234
+
235
+ PatientSchema.methods.system_characteristics = function system_characteristics() {
236
+ return this.getDataElements({ category: 'system_characteristic' });
237
+ };
238
+
239
+ PatientSchema.methods.transfers = function transfers() {
240
+ return this.getDataElements({ category: 'transfer' });
241
+ };
242
+
243
+ PatientSchema.methods.vital_signs = function vital_signs() {
244
+ return this.getDataElements({ category: 'vital_sign' });
245
+ };
246
+
247
+ module.exports.PatientSchema = PatientSchema;
248
+ module.exports.Patient = mongoose.model('Patient', PatientSchema);
@@ -0,0 +1,23 @@
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 PatientCareExperienceSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.52' },
16
+ category: { type: String, default: 'care_experience' },
17
+ qdmVersion: { type: String, default: '5.3' },
18
+ _type: { type: String, default: 'PatientCareExperience' },
19
+
20
+ });
21
+
22
+ module.exports.PatientCareExperienceSchema = PatientCareExperienceSchema;
23
+ module.exports.PatientCareExperience = mongoose.model('PatientCareExperience', PatientCareExperienceSchema);
@@ -0,0 +1,23 @@
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 PatientCharacteristicSchema = DataElementSchema({
14
+ authorDatetime: DateTime,
15
+ hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.53' },
16
+ category: { type: String, default: 'patient_characteristic' },
17
+ qdmVersion: { type: String, default: '5.3' },
18
+ _type: { type: String, default: 'PatientCharacteristic' },
19
+
20
+ });
21
+
22
+ module.exports.PatientCharacteristicSchema = PatientCharacteristicSchema;
23
+ module.exports.PatientCharacteristic = mongoose.model('PatientCharacteristic', PatientCharacteristicSchema);