cqm-models 1.0.3 → 1.1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +5 -5
  2. data/.eslintrc.json +10 -2
  3. data/.github/PULL_REQUEST_TEMPLATE.md +0 -4
  4. data/.rubocop.yml +3 -0
  5. data/.travis.yml +31 -1
  6. data/README.md +59 -2
  7. data/app/assets/javascripts/AdverseEvent.js +16 -7
  8. data/app/assets/javascripts/AllDataElements.js +6 -6
  9. data/app/assets/javascripts/AllergyIntolerance.js +16 -7
  10. data/app/assets/javascripts/AssessmentOrder.js +15 -6
  11. data/app/assets/javascripts/AssessmentPerformed.js +16 -7
  12. data/app/assets/javascripts/AssessmentRecommended.js +16 -7
  13. data/app/assets/javascripts/CareGoal.js +16 -7
  14. data/app/assets/javascripts/CommunicationPerformed.js +15 -6
  15. data/app/assets/javascripts/DeviceApplied.js +16 -7
  16. data/app/assets/javascripts/DeviceOrder.js +16 -7
  17. data/app/assets/javascripts/DeviceRecommended.js +16 -7
  18. data/app/assets/javascripts/Diagnosis.js +16 -7
  19. data/app/assets/javascripts/DiagnosticStudyOrder.js +16 -7
  20. data/app/assets/javascripts/DiagnosticStudyPerformed.js +16 -7
  21. data/app/assets/javascripts/DiagnosticStudyRecommended.js +16 -7
  22. data/app/assets/javascripts/EncounterOrder.js +16 -7
  23. data/app/assets/javascripts/EncounterPerformed.js +16 -7
  24. data/app/assets/javascripts/EncounterRecommended.js +16 -7
  25. data/app/assets/javascripts/FamilyHistory.js +16 -7
  26. data/app/assets/javascripts/Id.js +7 -3
  27. data/app/assets/javascripts/ImmunizationAdministered.js +16 -7
  28. data/app/assets/javascripts/ImmunizationOrder.js +16 -7
  29. data/app/assets/javascripts/IndividualResult.js +7 -2
  30. data/app/assets/javascripts/InterventionOrder.js +16 -7
  31. data/app/assets/javascripts/InterventionPerformed.js +16 -7
  32. data/app/assets/javascripts/InterventionRecommended.js +16 -7
  33. data/app/assets/javascripts/LaboratoryTestOrder.js +16 -7
  34. data/app/assets/javascripts/LaboratoryTestPerformed.js +16 -7
  35. data/app/assets/javascripts/LaboratoryTestRecommended.js +16 -7
  36. data/app/assets/javascripts/MedicationActive.js +16 -7
  37. data/app/assets/javascripts/MedicationAdministered.js +16 -7
  38. data/app/assets/javascripts/MedicationDischarge.js +16 -7
  39. data/app/assets/javascripts/MedicationDispensed.js +16 -7
  40. data/app/assets/javascripts/MedicationOrder.js +16 -7
  41. data/app/assets/javascripts/Participation.js +15 -6
  42. data/app/assets/javascripts/PatientCareExperience.js +16 -7
  43. data/app/assets/javascripts/PatientCharacteristic.js +16 -7
  44. data/app/assets/javascripts/PatientCharacteristicBirthdate.js +16 -7
  45. data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +16 -7
  46. data/app/assets/javascripts/PatientCharacteristicEthnicity.js +16 -7
  47. data/app/assets/javascripts/PatientCharacteristicExpired.js +16 -7
  48. data/app/assets/javascripts/PatientCharacteristicPayer.js +16 -7
  49. data/app/assets/javascripts/PatientCharacteristicRace.js +16 -7
  50. data/app/assets/javascripts/PatientCharacteristicSex.js +16 -7
  51. data/app/assets/javascripts/PhysicalExamOrder.js +16 -7
  52. data/app/assets/javascripts/PhysicalExamPerformed.js +16 -7
  53. data/app/assets/javascripts/PhysicalExamRecommended.js +16 -7
  54. data/app/assets/javascripts/ProcedureOrder.js +16 -7
  55. data/app/assets/javascripts/ProcedurePerformed.js +16 -7
  56. data/app/assets/javascripts/ProcedureRecommended.js +16 -7
  57. data/app/assets/javascripts/ProviderCareExperience.js +16 -7
  58. data/app/assets/javascripts/ProviderCharacteristic.js +16 -7
  59. data/app/assets/javascripts/QDMPatient.js +262 -0
  60. data/app/assets/javascripts/Result.js +7 -2
  61. data/app/assets/javascripts/ResultComponent.js +14 -6
  62. data/app/assets/javascripts/SubstanceAdministered.js +16 -7
  63. data/app/assets/javascripts/SubstanceOrder.js +16 -7
  64. data/app/assets/javascripts/SubstanceRecommended.js +16 -7
  65. data/app/assets/javascripts/Symptom.js +16 -7
  66. data/app/assets/javascripts/attributes/Component.js +30 -0
  67. data/app/assets/javascripts/attributes/FacilityLocation.js +30 -0
  68. data/app/assets/javascripts/basetypes/Any.js +1 -1
  69. data/app/assets/javascripts/basetypes/Code.js +1 -1
  70. data/app/assets/javascripts/basetypes/DataElement.js +2 -1
  71. data/app/assets/javascripts/basetypes/DateTime.js +5 -1
  72. data/app/assets/javascripts/basetypes/Interval.js +1 -1
  73. data/app/assets/javascripts/basetypes/Quantity.js +1 -1
  74. data/app/assets/javascripts/basetypes/Ratio.js +1 -1
  75. data/app/assets/javascripts/browser.js +3 -0
  76. data/app/assets/javascripts/cqm/AllCQMModels.js +24 -0
  77. data/app/assets/javascripts/cqm/CQLLibrary.js +32 -0
  78. data/app/assets/javascripts/cqm/CQLStatementDependency.js +28 -0
  79. data/app/assets/javascripts/cqm/Concept.js +17 -0
  80. data/app/assets/javascripts/cqm/Measure.js +108 -0
  81. data/app/assets/javascripts/{MeasurePackage.js → cqm/MeasurePackage.js} +9 -3
  82. data/app/assets/javascripts/cqm/Patient.js +38 -0
  83. data/app/assets/javascripts/cqm/PopulationSet.js +88 -0
  84. data/app/assets/javascripts/cqm/Provider.js +44 -0
  85. data/app/assets/javascripts/cqm/ValueSet.js +26 -0
  86. data/app/assets/javascripts/index.js +18 -8
  87. data/app/models/{qdm/tacoma → cqm}/concept.rb +4 -4
  88. data/app/models/cqm/cql_library.rb +22 -0
  89. data/app/models/cqm/cql_statement_dependency.rb +24 -0
  90. data/app/models/cqm/measure.rb +105 -0
  91. data/app/models/{qdm/tacoma → cqm}/measure_package.rb +2 -2
  92. data/app/models/cqm/patient.rb +20 -0
  93. data/app/models/cqm/population_set.rb +86 -0
  94. data/app/models/cqm/provider.rb +110 -0
  95. data/app/models/cqm/valueset.rb +15 -0
  96. data/app/models/hqmfOid_to_datatype_map.json +55 -0
  97. data/app/models/model_finder.rb +12 -0
  98. data/app/models/models.rb +18 -6
  99. data/app/models/qdm/adverse_event.rb +3 -2
  100. data/app/models/qdm/allergy_intolerance.rb +2 -1
  101. data/app/models/qdm/assessment_order.rb +1 -0
  102. data/app/models/qdm/assessment_performed.rb +2 -1
  103. data/app/models/qdm/assessment_recommended.rb +2 -1
  104. data/app/models/qdm/attributes/attribute.rb +63 -0
  105. data/app/models/qdm/{component.rb → attributes/component.rb} +1 -1
  106. data/app/models/qdm/{facility_location.rb → attributes/facility_location.rb} +1 -1
  107. data/app/models/qdm/basetypes/data_element.rb +21 -6
  108. data/app/models/qdm/basetypes/interval.rb +2 -1
  109. data/app/models/qdm/care_goal.rb +2 -1
  110. data/app/models/qdm/communication_performed.rb +1 -0
  111. data/app/models/qdm/device_applied.rb +2 -1
  112. data/app/models/qdm/device_order.rb +2 -1
  113. data/app/models/qdm/device_recommended.rb +2 -1
  114. data/app/models/qdm/diagnosis.rb +2 -1
  115. data/app/models/qdm/diagnostic_study_order.rb +2 -1
  116. data/app/models/qdm/diagnostic_study_performed.rb +3 -2
  117. data/app/models/qdm/diagnostic_study_recommended.rb +2 -1
  118. data/app/models/qdm/encounter_order.rb +3 -2
  119. data/app/models/qdm/encounter_performed.rb +2 -1
  120. data/app/models/qdm/encounter_recommended.rb +3 -2
  121. data/app/models/qdm/family_history.rb +2 -1
  122. data/app/models/qdm/immunization_administered.rb +2 -1
  123. data/app/models/qdm/immunization_order.rb +2 -1
  124. data/app/models/qdm/intervention_order.rb +2 -1
  125. data/app/models/qdm/intervention_performed.rb +2 -1
  126. data/app/models/qdm/intervention_recommended.rb +2 -1
  127. data/app/models/qdm/laboratory_test_order.rb +2 -1
  128. data/app/models/qdm/laboratory_test_performed.rb +2 -1
  129. data/app/models/qdm/laboratory_test_recommended.rb +2 -1
  130. data/app/models/qdm/medication_active.rb +2 -1
  131. data/app/models/qdm/medication_administered.rb +2 -1
  132. data/app/models/qdm/medication_discharge.rb +2 -1
  133. data/app/models/qdm/medication_dispensed.rb +4 -3
  134. data/app/models/qdm/medication_order.rb +3 -2
  135. data/app/models/qdm/participation.rb +1 -0
  136. data/app/models/qdm/patient.rb +7 -4
  137. data/app/models/qdm/patient_care_experience.rb +2 -1
  138. data/app/models/qdm/patient_characteristic.rb +2 -1
  139. data/app/models/qdm/patient_characteristic_birthdate.rb +2 -1
  140. data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +2 -1
  141. data/app/models/qdm/patient_characteristic_ethnicity.rb +2 -1
  142. data/app/models/qdm/patient_characteristic_expired.rb +2 -1
  143. data/app/models/qdm/patient_characteristic_payer.rb +2 -1
  144. data/app/models/qdm/patient_characteristic_race.rb +2 -1
  145. data/app/models/qdm/patient_characteristic_sex.rb +2 -1
  146. data/app/models/qdm/physical_exam_order.rb +2 -1
  147. data/app/models/qdm/physical_exam_performed.rb +2 -1
  148. data/app/models/qdm/physical_exam_recommended.rb +2 -1
  149. data/app/models/qdm/procedure_order.rb +2 -1
  150. data/app/models/qdm/procedure_performed.rb +2 -1
  151. data/app/models/qdm/procedure_recommended.rb +2 -1
  152. data/app/models/qdm/provider_care_experience.rb +2 -1
  153. data/app/models/qdm/provider_characteristic.rb +2 -1
  154. data/app/models/qdm/substance_administered.rb +2 -1
  155. data/app/models/qdm/substance_order.rb +2 -1
  156. data/app/models/qdm/substance_recommended.rb +2 -1
  157. data/app/models/qdm/symptom.rb +2 -1
  158. data/bin/build_cql_execution.sh +8 -0
  159. data/bin/validate_browser.sh +17 -0
  160. data/bin/validate_generator.sh +12 -0
  161. data/cqm-models.gemspec +5 -2
  162. data/data/oids_qdm_5.4.json +321 -0
  163. data/data/{oids.json → oids_unversioned.json} +0 -0
  164. data/dist/browser.js +102937 -0
  165. data/dist/index.js +36637 -36540
  166. data/lib/generate_models.rb +89 -93
  167. data/lib/generate_patients.rb +125 -0
  168. data/lib/generate_types.rb +64 -0
  169. data/lib/generators/custom_mongo/model.rb.tt +20 -0
  170. data/lib/generators/custom_mongo/model_generator.rb +34 -0
  171. data/notice.md +9 -0
  172. data/package.json +12 -6
  173. data/templates/id_template.js.erb +8 -3
  174. data/templates/index_template.js.erb +18 -8
  175. data/templates/models_template.rb.erb +20 -4
  176. data/templates/mongoose_template.js.erb +23 -15
  177. data/templates/patient_extension.rb.erb +7 -4
  178. data/templates/patient_template.js.erb +88 -87
  179. data/yarn.lock +552 -347
  180. metadata +86 -19
  181. data/app/assets/javascripts/Component.js +0 -26
  182. data/app/assets/javascripts/Concept.js +0 -14
  183. data/app/assets/javascripts/FacilityLocation.js +0 -26
  184. data/app/assets/javascripts/Measure.js +0 -78
  185. data/app/assets/javascripts/Patient.js +0 -262
  186. data/app/assets/javascripts/ValueSet.js +0 -30
  187. data/app/models/qdm/tacoma/measure.rb +0 -174
  188. data/app/models/qdm/tacoma/valueset.rb +0 -68
@@ -0,0 +1,30 @@
1
+ const mongoose = require('mongoose/browser');
2
+
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
+ const Any = require('../basetypes/Any');
8
+
9
+
10
+ const [Number, String] = [
11
+ mongoose.Schema.Types.Number,
12
+ mongoose.Schema.Types.String,
13
+ ];
14
+
15
+ const ComponentSchema = new mongoose.Schema({
16
+ code: Code,
17
+ result: Any,
18
+ qdmVersion: { type: String, default: '5.4' },
19
+ _type: { type: String, default: 'QDM::Component' },
20
+
21
+ });
22
+
23
+ module.exports.ComponentSchema = ComponentSchema;
24
+ class Component extends mongoose.Document {
25
+ constructor(object) {
26
+ super(object, ComponentSchema);
27
+ this._type = 'QDM::Component';
28
+ }
29
+ }
30
+ module.exports.Component = Component;
@@ -0,0 +1,30 @@
1
+ const mongoose = require('mongoose/browser');
2
+
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
+ const Any = require('../basetypes/Any');
8
+
9
+
10
+ const [Number, String] = [
11
+ mongoose.Schema.Types.Number,
12
+ mongoose.Schema.Types.String,
13
+ ];
14
+
15
+ const FacilityLocationSchema = new mongoose.Schema({
16
+ code: Code,
17
+ locationPeriod: Interval,
18
+ qdmVersion: { type: String, default: '5.4' },
19
+ _type: { type: String, default: 'QDM::FacilityLocation' },
20
+
21
+ });
22
+
23
+ module.exports.FacilityLocationSchema = FacilityLocationSchema;
24
+ class FacilityLocation extends mongoose.Document {
25
+ constructor(object) {
26
+ super(object, FacilityLocationSchema);
27
+ this._type = 'QDM::FacilityLocation';
28
+ }
29
+ }
30
+ module.exports.FacilityLocation = FacilityLocation;
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function Any(key, options) {
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function Code(key, options) {
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const Code = require('./Code.js');
3
3
  const cql = require('cql-execution');
4
4
  const Id = require('../Id');
@@ -9,6 +9,7 @@ function DataElementSchema(add, options) {
9
9
  const extended = new Schema({
10
10
  dataElementCodes: { type: [] },
11
11
  description: { type: String },
12
+ codeListId: { type: String },
12
13
  id: {
13
14
  type: Id.IdSchema,
14
15
  default() {
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function DateTime(key, options) {
@@ -7,6 +7,10 @@ function DateTime(key, options) {
7
7
  DateTime.prototype = Object.create(mongoose.SchemaType.prototype);
8
8
 
9
9
  DateTime.prototype.cast = (dateTime) => {
10
+ if (dateTime.isDateTime) {
11
+ return dateTime;
12
+ }
13
+
10
14
  if (!Date.parse(dateTime)) {
11
15
  throw new Error(`DateTime: ${dateTime} is not a valid DateTime`);
12
16
  }
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function Interval(key, options) {
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function Quantity(key, options) {
@@ -1,4 +1,4 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
  const cql = require('cql-execution');
3
3
 
4
4
  function Ratio(key, options) {
@@ -0,0 +1,3 @@
1
+ window.cqm = window.cqm || {};
2
+ window.cqm.models = require('./index');
3
+
@@ -0,0 +1,24 @@
1
+ module.exports.Measure = require('./Measure.js').Measure;
2
+ module.exports.MeasureSchema = require('./Measure.js').MeasureSchema;
3
+ module.exports.MeasurePackage = require('./MeasurePackage.js').MeasurePackage;
4
+ module.exports.MeasurePackageSchema = require('./MeasurePackage.js').MeasurePackageSchema;
5
+ module.exports.StatementDependency = require('./CQLStatementDependency.js').StatementDependency;
6
+ module.exports.StatementDependencySchema = require('./CQLStatementDependency.js').StatementDependencySchema;
7
+ module.exports.StatementReference = require('./CQLStatementDependency.js').StatementReference;
8
+ module.exports.StatementReferenceSchema = require('./CQLStatementDependency.js').StatementReferenceSchema;
9
+ module.exports.CQLLibrary = require('./CQLLibrary.js').CQLLibrary;
10
+ module.exports.CQLLibrarySchema = require('./CQLLibrary.js').CQLLibrarySchema;
11
+ module.exports.ValueSet = require('./ValueSet.js').ValueSet;
12
+ module.exports.ValueSetSchema = require('./ValueSet.js').ValueSetSchema;
13
+ module.exports.Concept = require('./Concept.js').Concept;
14
+ module.exports.ConceptSchema = require('./Concept.js').ConceptSchema;
15
+ module.exports.PopulationSet = require('./PopulationSet.js').PopulationSet;
16
+ module.exports.PopulationSetSchema = require('./PopulationSet.js').PopulationSetSchema;
17
+ module.exports.PopulationMap = require('./PopulationSet.js').PopulationMap;
18
+ module.exports.PopulationMapSchema = require('./PopulationSet.js').PopulationMapSchema;
19
+ module.exports.Stratification = require('./PopulationSet.js').Stratification;
20
+ module.exports.StratificationSchema = require('./PopulationSet.js').StratificationSchema;
21
+ module.exports.Patient = require('./Patient.js').Patient;
22
+ module.exports.PatientSchema = require('./Patient.js').PatientSchema;
23
+ module.exports.Provider = require('./Provider.js').Provider;
24
+ module.exports.ProviderSchema = require('./Provider.js').ProviderSchema;
@@ -0,0 +1,32 @@
1
+ const mongoose = require('mongoose/browser');
2
+ const { StatementDependencySchema } = require('./CQLStatementDependency');
3
+
4
+ const [Mixed, mDate] = [
5
+ mongoose.Schema.Types.Mixed,
6
+ mongoose.Schema.Types.Date,
7
+ ];
8
+
9
+ const CQLLibrarySchema = new mongoose.Schema(
10
+ {
11
+ library_name: String,
12
+ library_version: String,
13
+ cql: String,
14
+ elm: Mixed,
15
+ elm_annotations: Mixed,
16
+ is_main_library: { type: Boolean, default: false },
17
+ is_top_level: { type: Boolean, default: true },
18
+ statement_dependencies: [StatementDependencySchema],
19
+ },
20
+ // Options
21
+ {
22
+ timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }, // These are the Mongoid conventions for timestamps
23
+ }
24
+ );
25
+
26
+ module.exports.CQLLibrarySchema = CQLLibrarySchema;
27
+ class CQLLibrary extends mongoose.Document {
28
+ constructor(object) {
29
+ super(object, CQLLibrarySchema);
30
+ }
31
+ }
32
+ module.exports.CQLLibrary = CQLLibrary;
@@ -0,0 +1,28 @@
1
+ const mongoose = require('mongoose/browser');
2
+
3
+ const StatementReferenceSchema = new mongoose.Schema({
4
+ library_name: String,
5
+ statement_name: String,
6
+ hqmf_id: String,
7
+ });
8
+
9
+ const StatementDependencySchema = new mongoose.Schema({
10
+ statement_name: String,
11
+ statement_references: [StatementReferenceSchema],
12
+ });
13
+
14
+ module.exports.StatementReferenceSchema = StatementReferenceSchema;
15
+ class StatementReference extends mongoose.Document {
16
+ constructor(object) {
17
+ super(object, StatementReferenceSchema);
18
+ }
19
+ }
20
+ module.exports.StatementReference = StatementReference;
21
+
22
+ module.exports.StatementDependencySchema = StatementDependencySchema;
23
+ class StatementDependency extends mongoose.Document {
24
+ constructor(object) {
25
+ super(object, StatementDependencySchema);
26
+ }
27
+ }
28
+ module.exports.StatementDependency = StatementDependency;
@@ -0,0 +1,17 @@
1
+ const mongoose = require('mongoose/browser');
2
+
3
+ const ConceptSchema = new mongoose.Schema({
4
+ code: String,
5
+ code_system_oid: String,
6
+ code_system_name: String,
7
+ code_system_version: String,
8
+ display_name: String,
9
+ });
10
+
11
+ module.exports.ConceptSchema = ConceptSchema;
12
+ class Concept extends mongoose.Document {
13
+ constructor(object) {
14
+ super(object, ConceptSchema);
15
+ }
16
+ }
17
+ module.exports.Concept = Concept;
@@ -0,0 +1,108 @@
1
+ const mongoose = require('mongoose/browser');
2
+ const Code = require('../basetypes/Code');
3
+ const Interval = require('../basetypes/Interval');
4
+ const Quantity = require('../basetypes/Quantity');
5
+ const DataElementSchema = require('../basetypes/DataElement').DataElementSchema();
6
+ const AllDataElements = require('../AllDataElements');
7
+ const { CQLLibrarySchema } = require('./CQLLibrary');
8
+ const { PopulationSetSchema } = require('./PopulationSet');
9
+
10
+ const [Number, String, Boolean, Mixed, ObjectId, Date] = [
11
+ mongoose.Schema.Types.Number,
12
+ mongoose.Schema.Types.String,
13
+ mongoose.Schema.Types.Boolean,
14
+ mongoose.Schema.Types.Mixed,
15
+ mongoose.Schema.Types.ObjectId,
16
+ mongoose.Schema.Types.Date,
17
+ ];
18
+
19
+ const MeasureSchema = new mongoose.Schema(
20
+ {
21
+ // A version-specific UUID for the measure
22
+ hqmf_id: String,
23
+ // A version-neutral UUID for the measure
24
+ hqmf_set_id: String,
25
+ // A Semantic Version-compliant string (e.g. "2.3.4") for the measure
26
+ hqmf_version_number: String,
27
+ // A CMS-style string (e.g. "CMS2v4") for the measure
28
+ cms_id: String,
29
+ title: String,
30
+ description: String,
31
+
32
+ // Composite/component measure fields
33
+ composite: {
34
+ type: Boolean,
35
+ default: false,
36
+ },
37
+ component: {
38
+ type: Boolean,
39
+ default: false,
40
+ },
41
+ component_hqmf_set_ids: [String],
42
+ composite_hqmf_set_id: String,
43
+
44
+ // Measure type variables
45
+ measure_scoring: {
46
+ type: String,
47
+ enum: ['PROPORTION', 'RATIO', 'CONTINUOUS_VARIABLE', 'COHORT'],
48
+ default: 'PROPORTION',
49
+ },
50
+ calculation_method: {
51
+ type: String,
52
+ enum: ['PATIENT', 'EPISODE_OF_CARE'],
53
+ default: 'PATIENT',
54
+ },
55
+ calculate_sdes: Boolean,
56
+
57
+ // ELM/CQL Measure-logic related data encapsulated in CQLLibrarySchema
58
+ // Field name changed from 'cql' to 'cql_libraries' because the semantics of
59
+ // embeds_many: cqls (on the Ruby side) sounded weird,
60
+ // and we wanted to keep the API consistent
61
+ cql_libraries: [CQLLibrarySchema],
62
+ main_cql_library: String,
63
+
64
+ // HQMF/Tacoma-specific Measure-logic related data
65
+ population_criteria: Mixed,
66
+ source_data_criteria: [],
67
+ measure_period: Interval,
68
+ measure_attributes: [],
69
+
70
+ population_sets: [PopulationSetSchema],
71
+
72
+ // Relations to other model classes
73
+ bundle: { type: ObjectId, ref: 'Bundle' }, // Cypress-specific, until we migrate the Bundle into cqm-models
74
+ package: { type: ObjectId, ref: 'MeasurePackage' }, // Bonnie-specific
75
+ patients: [{ type: ObjectId, ref: 'Patient', index: true }],
76
+
77
+ value_sets: [{ type: ObjectId, ref: 'ValueSet' }],
78
+ },
79
+ // Options
80
+ {
81
+ timestamps: { createdAt: 'created_at', updatedAt: 'updated_at' }, // These are the Mongoid conventions for timestamps
82
+ }
83
+ );
84
+
85
+ // After initialization of a Measure model, initialize every individual data element
86
+ // to its respective Mongoose Model
87
+ MeasureSchema.methods.initializeDataElements = function initializeDataElements() {
88
+ let typeStripped;
89
+ const sourceDataCriteriaInit = [];
90
+ this.source_data_criteria.forEach((element) => {
91
+ typeStripped = element._type.replace(/QDM::/, '');
92
+ sourceDataCriteriaInit.push(new AllDataElements[typeStripped](element));
93
+ });
94
+ this.set('source_data_criteria', sourceDataCriteriaInit);
95
+ };
96
+
97
+ MeasureSchema.methods.all_stratifications = function all_stratifications() {
98
+ return this.population_sets.flatMap(ps => ps.stratifications);
99
+ };
100
+
101
+ module.exports.MeasureSchema = MeasureSchema;
102
+ class Measure extends mongoose.Document {
103
+ constructor(object) {
104
+ super(object, MeasureSchema);
105
+ this.initializeDataElements();
106
+ }
107
+ }
108
+ module.exports.Measure = Measure;
@@ -1,11 +1,12 @@
1
- const mongoose = require('mongoose');
1
+ const mongoose = require('mongoose/browser');
2
2
 
3
+ // using mBuffer to not conflict with system Buffer
3
4
  const [mBuffer, ObjectId] = [
4
5
  mongoose.Schema.Types.Buffer,
5
6
  mongoose.Schema.Types.ObjectId,
6
7
  ];
7
8
 
8
- const MeasurePackageSchema = mongoose.Schema(
9
+ const MeasurePackageSchema = new mongoose.Schema(
9
10
  {
10
11
  file: mBuffer,
11
12
  measure: { type: ObjectId, ref: 'Measure' },
@@ -17,4 +18,9 @@ const MeasurePackageSchema = mongoose.Schema(
17
18
  );
18
19
 
19
20
  module.exports.MeasurePackageSchema = MeasurePackageSchema;
20
- module.exports.MeasurePackage = mongoose.model('measure_package', MeasurePackageSchema);
21
+ class MeasurePackage extends mongoose.Document {
22
+ constructor(object) {
23
+ super(object, MeasurePackageSchema);
24
+ }
25
+ }
26
+ module.exports.MeasurePackage = MeasurePackage;
@@ -0,0 +1,38 @@
1
+ const mongoose = require('mongoose/browser');
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 { QDMPatientSchema, QDMPatient } = require('../QDMPatient');
7
+ const { ProviderSchema } = require('./Provider');
8
+
9
+ const [Schema, Number, String, Mixed] = [
10
+ mongoose.Schema,
11
+ mongoose.Schema.Types.Number,
12
+ mongoose.Schema.Types.String,
13
+ mongoose.Schema.Types.Mixed,
14
+ ];
15
+
16
+ const PatientSchema = new Schema({
17
+
18
+ givenNames: [String],
19
+ familyName: String,
20
+ bundleId: String,
21
+ expectedValues: [],
22
+ notes: String,
23
+ qdmPatient: QDMPatientSchema,
24
+ providers: [ProviderSchema],
25
+ measure_ids: [String],
26
+
27
+ }, { id: false });
28
+
29
+ module.exports.PatientSchema = PatientSchema;
30
+ class Patient extends mongoose.Document {
31
+ constructor(object) {
32
+ super(object, PatientSchema);
33
+ if (this.qdmPatient) {
34
+ this.qdmPatient = new QDMPatient(this.qdmPatient.toJSON());
35
+ }
36
+ }
37
+ }
38
+ module.exports.Patient = Patient;
@@ -0,0 +1,88 @@
1
+ /* eslint-disable no-unused-vars, no-param-reassign */
2
+ const mongoose = require('mongoose/browser');
3
+ const { StatementReferenceSchema } = require('./CQLStatementDependency');
4
+
5
+ const [Mixed] = [
6
+ mongoose.Schema.Types.Mixed,
7
+ ];
8
+
9
+ // TODO: figure out if there is a better way to handle inheritance like mongoid.
10
+ // _type is how mongoid stores the specific type of the embedded document.
11
+ const PopulationMapSchema = new mongoose.Schema({
12
+ _type: String,
13
+ IPP: StatementReferenceSchema,
14
+ DENOM: StatementReferenceSchema,
15
+ NUMER: StatementReferenceSchema,
16
+ NUMEX: StatementReferenceSchema,
17
+ DENEX: StatementReferenceSchema,
18
+ DENEXCEP: StatementReferenceSchema,
19
+ MSRPOPL: StatementReferenceSchema,
20
+ MSRPOPLEX: StatementReferenceSchema,
21
+ // STRAT is only here so cqm-execution can handle stratification results compliation with the current approach.
22
+ STRAT: StatementReferenceSchema,
23
+ });
24
+
25
+ if (!PopulationMapSchema.options.toObject) PopulationMapSchema.options.toObject = {};
26
+ PopulationMapSchema.options.toObject.transform = function transform(doc, ret, options) {
27
+ // remove the _id and _type of every document before returning the result
28
+ delete ret._id;
29
+ delete ret._type;
30
+ return ret;
31
+ };
32
+
33
+
34
+ const StratificationSchema = new mongoose.Schema({
35
+ title: String,
36
+ stratification_id: String,
37
+ hqmf_id: String,
38
+ statement: StatementReferenceSchema,
39
+ });
40
+
41
+ const ObservationSchema = new mongoose.Schema({
42
+ title: String,
43
+ observation_function: StatementReferenceSchema,
44
+ observation_parameter: StatementReferenceSchema,
45
+ aggregation_type: String,
46
+ hqmf_id: String,
47
+ });
48
+
49
+ const PopulationSetSchema = new mongoose.Schema({
50
+ title: String,
51
+ population_set_id: String,
52
+ populations: PopulationMapSchema,
53
+ stratifications: [StratificationSchema],
54
+ supplemental_data_elements: [StatementReferenceSchema],
55
+ observations: [ObservationSchema],
56
+ });
57
+
58
+ module.exports.StratificationSchema = StratificationSchema;
59
+ class Stratification extends mongoose.Document {
60
+ constructor(object) {
61
+ super(object, StratificationSchema);
62
+ }
63
+ }
64
+ module.exports.Stratification = Stratification;
65
+
66
+ module.exports.ObservationSchema = ObservationSchema;
67
+ class Observation extends mongoose.Document {
68
+ constructor(object) {
69
+ super(object, ObservationSchema);
70
+ }
71
+ }
72
+ module.exports.Observation = Observation;
73
+
74
+ module.exports.PopulationMapSchema = PopulationMapSchema;
75
+ class PopulationMap extends mongoose.Document {
76
+ constructor(object) {
77
+ super(object, PopulationMapSchema);
78
+ }
79
+ }
80
+ module.exports.PopulationMap = PopulationMap;
81
+
82
+ module.exports.PopulationSetSchema = PopulationSetSchema;
83
+ class PopulationSet extends mongoose.Document {
84
+ constructor(object) {
85
+ super(object, PopulationSetSchema);
86
+ }
87
+ }
88
+ module.exports.PopulationSet = PopulationSet;