cqm-models 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +2 -2
  3. data/.github/PULL_REQUEST_TEMPLATE.md +3 -0
  4. data/app/assets/javascripts/AdverseEvent.js +3 -1
  5. data/app/assets/javascripts/AllergyIntolerance.js +2 -0
  6. data/app/assets/javascripts/AssessmentPerformed.js +1 -0
  7. data/app/assets/javascripts/AssessmentRecommended.js +2 -0
  8. data/app/assets/javascripts/CareGoal.js +2 -0
  9. data/app/assets/javascripts/CommunicationFromPatientToProvider.js +2 -0
  10. data/app/assets/javascripts/CommunicationFromProviderToPatient.js +2 -0
  11. data/app/assets/javascripts/CommunicationFromProviderToProvider.js +2 -0
  12. data/app/assets/javascripts/Component.js +3 -1
  13. data/app/assets/javascripts/DeviceApplied.js +2 -0
  14. data/app/assets/javascripts/DeviceOrder.js +2 -0
  15. data/app/assets/javascripts/DeviceRecommended.js +2 -0
  16. data/app/assets/javascripts/Diagnosis.js +2 -0
  17. data/app/assets/javascripts/DiagnosticStudyOrder.js +2 -0
  18. data/app/assets/javascripts/DiagnosticStudyPerformed.js +2 -1
  19. data/app/assets/javascripts/DiagnosticStudyRecommended.js +2 -0
  20. data/app/assets/javascripts/EncounterOrder.js +3 -1
  21. data/app/assets/javascripts/EncounterPerformed.js +1 -0
  22. data/app/assets/javascripts/EncounterRecommended.js +3 -1
  23. data/app/assets/javascripts/FacilityLocation.js +3 -1
  24. data/app/assets/javascripts/FamilyHistory.js +2 -0
  25. data/app/assets/javascripts/Id.js +2 -0
  26. data/app/assets/javascripts/ImmunizationAdministered.js +2 -0
  27. data/app/assets/javascripts/ImmunizationOrder.js +2 -0
  28. data/app/assets/javascripts/IndividualResult.js +4 -1
  29. data/app/assets/javascripts/InterventionOrder.js +2 -0
  30. data/app/assets/javascripts/InterventionPerformed.js +2 -0
  31. data/app/assets/javascripts/InterventionRecommended.js +2 -0
  32. data/app/assets/javascripts/LaboratoryTestOrder.js +2 -0
  33. data/app/assets/javascripts/LaboratoryTestPerformed.js +1 -0
  34. data/app/assets/javascripts/LaboratoryTestRecommended.js +2 -0
  35. data/app/assets/javascripts/MedicationActive.js +2 -0
  36. data/app/assets/javascripts/MedicationAdministered.js +2 -0
  37. data/app/assets/javascripts/MedicationDischarge.js +2 -0
  38. data/app/assets/javascripts/MedicationDispensed.js +2 -0
  39. data/app/assets/javascripts/MedicationOrder.js +2 -0
  40. data/app/assets/javascripts/Participation.js +2 -0
  41. data/app/assets/javascripts/Patient.js +22 -10
  42. data/app/assets/javascripts/PatientCareExperience.js +2 -0
  43. data/app/assets/javascripts/PatientCharacteristic.js +2 -0
  44. data/app/assets/javascripts/PatientCharacteristicBirthdate.js +2 -0
  45. data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +2 -0
  46. data/app/assets/javascripts/PatientCharacteristicEthnicity.js +2 -0
  47. data/app/assets/javascripts/PatientCharacteristicExpired.js +2 -0
  48. data/app/assets/javascripts/PatientCharacteristicPayer.js +2 -0
  49. data/app/assets/javascripts/PatientCharacteristicRace.js +2 -0
  50. data/app/assets/javascripts/PatientCharacteristicSex.js +2 -0
  51. data/app/assets/javascripts/PhysicalExamOrder.js +2 -0
  52. data/app/assets/javascripts/PhysicalExamPerformed.js +1 -0
  53. data/app/assets/javascripts/PhysicalExamRecommended.js +2 -0
  54. data/app/assets/javascripts/ProcedureOrder.js +2 -0
  55. data/app/assets/javascripts/ProcedurePerformed.js +2 -2
  56. data/app/assets/javascripts/ProcedureRecommended.js +2 -0
  57. data/app/assets/javascripts/ProviderCareExperience.js +2 -0
  58. data/app/assets/javascripts/ProviderCharacteristic.js +2 -0
  59. data/app/assets/javascripts/Ratio.js +2 -0
  60. data/app/assets/javascripts/ResultComponent.js +2 -0
  61. data/app/assets/javascripts/SubstanceAdministered.js +2 -0
  62. data/app/assets/javascripts/SubstanceOrder.js +2 -0
  63. data/app/assets/javascripts/SubstanceRecommended.js +2 -0
  64. data/app/assets/javascripts/Symptom.js +2 -0
  65. data/app/assets/javascripts/basetypes/Any.js +15 -0
  66. data/app/assets/javascripts/basetypes/Code.js +20 -10
  67. data/app/assets/javascripts/basetypes/DataElement.js +13 -13
  68. data/app/models/qdm/patient.rb +1 -1
  69. data/cqm-models.gemspec +1 -1
  70. data/dist/index.js +527 -231
  71. data/lib/generate_models.rb +6 -0
  72. data/package.json +3 -3
  73. data/templates/models_template.rb.erb +1 -0
  74. data/templates/mongoose_template.js.erb +10 -2
  75. data/templates/patient_extension.rb.erb +12 -1
  76. data/templates/patient_template.js.erb +24 -11
  77. data/yarn.lock +3 -3
  78. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adce07d4828edeec55d0a07a98a55f7cd4ca0e6f
4
- data.tar.gz: fd48e3958c11556440fa984040a426437fb65823
3
+ metadata.gz: f69ba79193a6df18a4a86fc508237fac9b1e9078
4
+ data.tar.gz: 6ddf65c325e26a91823a84ff3a1fdb2b75323110
5
5
  SHA512:
6
- metadata.gz: 34e5edecfca3aebe628265178824100649c0abadce2b6c730acf7ed368f1d6c958606d12e31fa9a1e9a8c1bc0a80bd3a46daa68ab52123604eafea31e8f81010
7
- data.tar.gz: 219d45b6e063aaa360eb8800b6f84fe496fb70625589f5417f0203dc1ad98a64d9253fe1d7592a41502b646ef08e6040dc3de410fa961aba42ba60cdd62f641b
6
+ metadata.gz: b2563e216ff73afed6947a86e68f7467c3091df0a8eb4846df375675e75e63923d353abe79b8304d588e164694e0c21cd53fee4efd6b97f3e174dbdea3622587
7
+ data.tar.gz: 7791447027060f7e426a71214b818877c44b15962f656789f64cffaea55a8a9ecf12be3cbb2975280cd78c3a1e483aceb4e15346ee8a65f296c073ad6fc4ff97
data/.eslintrc.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "extends": "airbnb-base",
3
3
  "rules": {
4
4
  "max-len": ["error", {"code": 200, "ignoreComments": true}],
5
- "no-unused-vars": ["error", { "varsIgnorePattern": "Code|Quantity|Interval|Integer|Array|Float|Time|Number|Date|Mixed|Any" }],
5
+ "no-unused-vars": ["error", { "varsIgnorePattern": "DataElementSchema|ComponentSchema|FacilityLocationSchema|Code|Quantity|Interval|Integer|Array|Float|Time|Number|Date|Mixed|Any" }],
6
6
  "camelcase": "off",
7
7
  "comma-dangle": ["error", {
8
- "arrays": "always-multiline",
8
+ "arrays": "always-multiline",
9
9
  "objects": "always-multiline",
10
10
  "imports": "always-multiline",
11
11
  "exports": "always-multiline",
@@ -9,6 +9,7 @@ Pull requests into cqm-models require the following. Submitter and reviewer shou
9
9
  - [ ] Tests have been run locally and pass
10
10
  - [ ] If there were any JavaScript changes, this PR has updated the `dist` directory using `npm run dist`
11
11
  - [ ] If applicable, the library version number in `package.json` and `cqm-models.gemspec` has been updated
12
+ - [ ] All changes can be reproduced by running the generator script
12
13
 
13
14
  **Bonnie Reviewer:**
14
15
 
@@ -16,6 +17,7 @@ Name:
16
17
  - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
17
18
  - [ ] The tests appropriately test the new code, including edge cases
18
19
  - [ ] You have tried to break the code
20
+ - [ ] You have executed the generator script, and made sure no changes were made that the generator did not reproduce itself
19
21
 
20
22
  **Cypress Reviewer:**
21
23
 
@@ -23,3 +25,4 @@ Name:
23
25
  - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
24
26
  - [ ] The tests appropriately test the new code, including edge cases
25
27
  - [ ] You have tried to break the code
28
+ - [ ] You have executed the generator script, and made sure no changes were made that the generator did not reproduce itself
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -15,7 +17,7 @@ const AdverseEventSchema = DataElementSchema({
15
17
  authorDatetime: DateTime,
16
18
  relevantPeriod: Interval,
17
19
  severity: Code,
18
- facilityLocation: Code,
20
+ facilityLocation: FacilityLocationSchema,
19
21
  type: Code,
20
22
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.120' },
21
23
  category: { type: String, default: 'adverse_event' },
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -5,6 +5,7 @@ const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
7
  const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
8
9
  const Any = require('./basetypes/Any');
9
10
 
10
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -11,7 +13,7 @@ const [Number, String] = [
11
13
  mongoose.Schema.Types.String,
12
14
  ];
13
15
 
14
- const ComponentSchema = DataElementSchema({
16
+ const ComponentSchema = new mongoose.Schema({
15
17
  code: Code,
16
18
  result: Any,
17
19
  qdmVersion: { type: String, default: '5.3' },
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -5,6 +5,7 @@ const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
7
  const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
8
9
  const Any = require('./basetypes/Any');
9
10
 
10
11
  const [Number, String] = [
@@ -20,7 +21,7 @@ const DiagnosticStudyPerformedSchema = DataElementSchema({
20
21
  resultDatetime: DateTime,
21
22
  status: Code,
22
23
  method: Code,
23
- facilityLocation: Code,
24
+ facilityLocation: FacilityLocationSchema,
24
25
  negationRationale: Code,
25
26
  components: [ComponentSchema],
26
27
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.23' },
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -14,7 +16,7 @@ const [Number, String] = [
14
16
  const EncounterOrderSchema = DataElementSchema({
15
17
  authorDatetime: DateTime,
16
18
  reason: Code,
17
- facilityLocation: Code,
19
+ facilityLocation: FacilityLocationSchema,
18
20
  negationRationale: Code,
19
21
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.27' },
20
22
  category: { type: String, default: 'encounter' },
@@ -4,6 +4,7 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
7
8
  const { FacilityLocationSchema } = require('./FacilityLocation');
8
9
  const Any = require('./basetypes/Any');
9
10
 
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -14,7 +16,7 @@ const [Number, String] = [
14
16
  const EncounterRecommendedSchema = DataElementSchema({
15
17
  authorDatetime: DateTime,
16
18
  reason: Code,
17
- facilityLocation: Code,
19
+ facilityLocation: FacilityLocationSchema,
18
20
  negationRationale: Code,
19
21
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.28' },
20
22
  category: { type: String, default: 'encounter' },
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -11,7 +13,7 @@ const [Number, String] = [
11
13
  mongoose.Schema.Types.String,
12
14
  ];
13
15
 
14
- const FacilityLocationSchema = DataElementSchema({
16
+ const FacilityLocationSchema = new mongoose.Schema({
15
17
  code: Code,
16
18
  locationPeriod: Interval,
17
19
  qdmVersion: { type: String, default: '5.3' },
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -29,7 +29,10 @@ const IndividualResultSchema = mongoose.Schema(
29
29
  // This field is for application specific information only. If both Bonnie and
30
30
  // Cypress use a common field, it should be made a field on this model,
31
31
  // and not put into extendedData.
32
- extendedData: {},
32
+ extendedData: {
33
+ type: Mixed,
34
+ default: {},
35
+ },
33
36
 
34
37
  // Calculation State attributes
35
38
  state: {
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -5,6 +5,7 @@ const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
7
  const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
8
9
  const Any = require('./basetypes/Any');
9
10
 
10
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -5,10 +5,11 @@ const Quantity = require('./basetypes/Quantity');
5
5
  const DateTime = require('./basetypes/DateTime');
6
6
  const AllDataElements = require('./AllDataElements');
7
7
 
8
- const [Schema, Number, String] = [
8
+ const [Schema, Number, String, Mixed] = [
9
9
  mongoose.Schema,
10
10
  mongoose.Schema.Types.Number,
11
11
  mongoose.Schema.Types.String,
12
+ mongoose.Schema.Types.Mixed,
12
13
  ];
13
14
 
14
15
  const PatientSchema = new Schema({
@@ -25,7 +26,10 @@ const PatientSchema = new Schema({
25
26
  // This field is for application specific information only. If both Bonnie
26
27
  // Cypress use a common field, it should be made a field on this model,
27
28
  // and not put into extendedData.
28
- extendedData: {},
29
+ extendedData: {
30
+ type: Mixed,
31
+ default: {},
32
+ },
29
33
  }, { id: false });
30
34
 
31
35
  // After initialization of a Patient model, initialize every individual data element
@@ -78,19 +82,27 @@ PatientSchema.methods.getDataElements = function getDataElements(params) {
78
82
  // Returns an array of dataElements that exist on the patient, queried by
79
83
  // QDM profile
80
84
  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}`);
85
+ // If isNegated == true, only return data elements with a negationRationale that is not null.
86
+ // If isNegated == false, only return data elements with a null negationRationale.
87
+ // If isNegated == null, return all matching data elements by type, regardless of negationRationale.
88
+ const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated));
89
+ return results.map((result) => {
90
+ const getCodeFunction = Object.getPrototypeOf(result).getCode;
91
+ const codeFunction = Object.getPrototypeOf(result).code;
92
+ const removedMongooseItems = AllDataElements[profile](result).toObject();
93
+ // toObject() will remove all mongoose functions but also removed the getCode and code functions
94
+ // the execution engine requires the code and getCode functions so we have to add them back
95
+ removedMongooseItems.getCode = getCodeFunction;
96
+ removedMongooseItems.code = codeFunction;
97
+ return removedMongooseItems;
98
+ });
87
99
  };
88
100
 
89
101
  // This method is called by the CQL execution engine on a CQLPatient when
90
102
  // the execution engine wants information on a record. A record could be patient
91
103
  // characteristic information about the patient, or it could be data criteria
92
104
  // that currently exist on this patient (data criteria you drag on a patient
93
- // in Bonnie's patient builder).
105
+ // in Bonnie patient builder).
94
106
  // @param {String} profile - the data criteria requested by the execution engine
95
107
  // @returns {Object}
96
108
  PatientSchema.methods.findRecords = function findRecords(profile) {
@@ -107,7 +119,7 @@ PatientSchema.methods.findRecords = function findRecords(profile) {
107
119
  // Requested something else (probably a QDM data type).
108
120
 
109
121
  // Strip model details from request. The requested profile string contains
110
- // a lot of things we don't need or care about. Example, we might see
122
+ // a lot of things we do not need or care about. Example, we might see
111
123
  // something like:
112
124
  // "{urn:healthit-gov:qdm:v5_0_draft}PatientCharacteristicEthnicity"
113
125
  // Where we only care about: "PatientCharacteristicEthnicity".
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [
@@ -4,6 +4,8 @@ const Code = require('./basetypes/Code');
4
4
  const Interval = require('./basetypes/Interval');
5
5
  const Quantity = require('./basetypes/Quantity');
6
6
  const DateTime = require('./basetypes/DateTime');
7
+ const { ComponentSchema } = require('./Component');
8
+ const { FacilityLocationSchema } = require('./FacilityLocation');
7
9
  const Any = require('./basetypes/Any');
8
10
 
9
11
  const [Number, String] = [