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
data/dist/index.js CHANGED
@@ -5,6 +5,8 @@ const Code = require('./basetypes/Code');
5
5
  const Interval = require('./basetypes/Interval');
6
6
  const Quantity = require('./basetypes/Quantity');
7
7
  const DateTime = require('./basetypes/DateTime');
8
+ const { ComponentSchema } = require('./Component');
9
+ const { FacilityLocationSchema } = require('./FacilityLocation');
8
10
  const Any = require('./basetypes/Any');
9
11
 
10
12
  const [Number, String] = [
@@ -16,7 +18,7 @@ const AdverseEventSchema = DataElementSchema({
16
18
  authorDatetime: DateTime,
17
19
  relevantPeriod: Interval,
18
20
  severity: Code,
19
- facilityLocation: Code,
21
+ facilityLocation: FacilityLocationSchema,
20
22
  type: Code,
21
23
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.120' },
22
24
  category: { type: String, default: 'adverse_event' },
@@ -28,7 +30,7 @@ const AdverseEventSchema = DataElementSchema({
28
30
  module.exports.AdverseEventSchema = AdverseEventSchema;
29
31
  module.exports.AdverseEvent = mongoose.model('AdverseEvent', AdverseEventSchema);
30
32
 
31
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],2:[function(require,module,exports){
33
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],2:[function(require,module,exports){
32
34
  module.exports.Patient = require('./Patient.js').Patient;
33
35
  module.exports.PatientSchema = require('./Patient.js').PatientSchema;
34
36
  module.exports.Id = require('./Id.js').Id;
@@ -157,6 +159,8 @@ const Code = require('./basetypes/Code');
157
159
  const Interval = require('./basetypes/Interval');
158
160
  const Quantity = require('./basetypes/Quantity');
159
161
  const DateTime = require('./basetypes/DateTime');
162
+ const { ComponentSchema } = require('./Component');
163
+ const { FacilityLocationSchema } = require('./FacilityLocation');
160
164
  const Any = require('./basetypes/Any');
161
165
 
162
166
  const [Number, String] = [
@@ -180,7 +184,7 @@ const AllergyIntoleranceSchema = DataElementSchema({
180
184
  module.exports.AllergyIntoleranceSchema = AllergyIntoleranceSchema;
181
185
  module.exports.AllergyIntolerance = mongoose.model('AllergyIntolerance', AllergyIntoleranceSchema);
182
186
 
183
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],4:[function(require,module,exports){
187
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],4:[function(require,module,exports){
184
188
  const mongoose = require('mongoose');
185
189
  const { DataElementSchema } = require('./basetypes/DataElement');
186
190
  const Code = require('./basetypes/Code');
@@ -188,6 +192,7 @@ const Interval = require('./basetypes/Interval');
188
192
  const Quantity = require('./basetypes/Quantity');
189
193
  const DateTime = require('./basetypes/DateTime');
190
194
  const { ComponentSchema } = require('./Component');
195
+ const { FacilityLocationSchema } = require('./FacilityLocation');
191
196
  const Any = require('./basetypes/Any');
192
197
 
193
198
  const [Number, String] = [
@@ -214,13 +219,15 @@ const AssessmentPerformedSchema = DataElementSchema({
214
219
  module.exports.AssessmentPerformedSchema = AssessmentPerformedSchema;
215
220
  module.exports.AssessmentPerformed = mongoose.model('AssessmentPerformed', AssessmentPerformedSchema);
216
221
 
217
- },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],5:[function(require,module,exports){
222
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],5:[function(require,module,exports){
218
223
  const mongoose = require('mongoose');
219
224
  const { DataElementSchema } = require('./basetypes/DataElement');
220
225
  const Code = require('./basetypes/Code');
221
226
  const Interval = require('./basetypes/Interval');
222
227
  const Quantity = require('./basetypes/Quantity');
223
228
  const DateTime = require('./basetypes/DateTime');
229
+ const { ComponentSchema } = require('./Component');
230
+ const { FacilityLocationSchema } = require('./FacilityLocation');
224
231
  const Any = require('./basetypes/Any');
225
232
 
226
233
  const [Number, String] = [
@@ -244,13 +251,15 @@ const AssessmentRecommendedSchema = DataElementSchema({
244
251
  module.exports.AssessmentRecommendedSchema = AssessmentRecommendedSchema;
245
252
  module.exports.AssessmentRecommended = mongoose.model('AssessmentRecommended', AssessmentRecommendedSchema);
246
253
 
247
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],6:[function(require,module,exports){
254
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],6:[function(require,module,exports){
248
255
  const mongoose = require('mongoose');
249
256
  const { DataElementSchema } = require('./basetypes/DataElement');
250
257
  const Code = require('./basetypes/Code');
251
258
  const Interval = require('./basetypes/Interval');
252
259
  const Quantity = require('./basetypes/Quantity');
253
260
  const DateTime = require('./basetypes/DateTime');
261
+ const { ComponentSchema } = require('./Component');
262
+ const { FacilityLocationSchema } = require('./FacilityLocation');
254
263
  const Any = require('./basetypes/Any');
255
264
 
256
265
  const [Number, String] = [
@@ -272,13 +281,15 @@ const CareGoalSchema = DataElementSchema({
272
281
  module.exports.CareGoalSchema = CareGoalSchema;
273
282
  module.exports.CareGoal = mongoose.model('CareGoal', CareGoalSchema);
274
283
 
275
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],7:[function(require,module,exports){
284
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],7:[function(require,module,exports){
276
285
  const mongoose = require('mongoose');
277
286
  const { DataElementSchema } = require('./basetypes/DataElement');
278
287
  const Code = require('./basetypes/Code');
279
288
  const Interval = require('./basetypes/Interval');
280
289
  const Quantity = require('./basetypes/Quantity');
281
290
  const DateTime = require('./basetypes/DateTime');
291
+ const { ComponentSchema } = require('./Component');
292
+ const { FacilityLocationSchema } = require('./FacilityLocation');
282
293
  const Any = require('./basetypes/Any');
283
294
 
284
295
  const [Number, String] = [
@@ -301,13 +312,15 @@ const CommunicationFromPatientToProviderSchema = DataElementSchema({
301
312
  module.exports.CommunicationFromPatientToProviderSchema = CommunicationFromPatientToProviderSchema;
302
313
  module.exports.CommunicationFromPatientToProvider = mongoose.model('CommunicationFromPatientToProvider', CommunicationFromPatientToProviderSchema);
303
314
 
304
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],8:[function(require,module,exports){
315
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],8:[function(require,module,exports){
305
316
  const mongoose = require('mongoose');
306
317
  const { DataElementSchema } = require('./basetypes/DataElement');
307
318
  const Code = require('./basetypes/Code');
308
319
  const Interval = require('./basetypes/Interval');
309
320
  const Quantity = require('./basetypes/Quantity');
310
321
  const DateTime = require('./basetypes/DateTime');
322
+ const { ComponentSchema } = require('./Component');
323
+ const { FacilityLocationSchema } = require('./FacilityLocation');
311
324
  const Any = require('./basetypes/Any');
312
325
 
313
326
  const [Number, String] = [
@@ -330,13 +343,15 @@ const CommunicationFromProviderToPatientSchema = DataElementSchema({
330
343
  module.exports.CommunicationFromProviderToPatientSchema = CommunicationFromProviderToPatientSchema;
331
344
  module.exports.CommunicationFromProviderToPatient = mongoose.model('CommunicationFromProviderToPatient', CommunicationFromProviderToPatientSchema);
332
345
 
333
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],9:[function(require,module,exports){
346
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],9:[function(require,module,exports){
334
347
  const mongoose = require('mongoose');
335
348
  const { DataElementSchema } = require('./basetypes/DataElement');
336
349
  const Code = require('./basetypes/Code');
337
350
  const Interval = require('./basetypes/Interval');
338
351
  const Quantity = require('./basetypes/Quantity');
339
352
  const DateTime = require('./basetypes/DateTime');
353
+ const { ComponentSchema } = require('./Component');
354
+ const { FacilityLocationSchema } = require('./FacilityLocation');
340
355
  const Any = require('./basetypes/Any');
341
356
 
342
357
  const [Number, String] = [
@@ -359,13 +374,15 @@ const CommunicationFromProviderToProviderSchema = DataElementSchema({
359
374
  module.exports.CommunicationFromProviderToProviderSchema = CommunicationFromProviderToProviderSchema;
360
375
  module.exports.CommunicationFromProviderToProvider = mongoose.model('CommunicationFromProviderToProvider', CommunicationFromProviderToProviderSchema);
361
376
 
362
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],10:[function(require,module,exports){
377
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],10:[function(require,module,exports){
363
378
  const mongoose = require('mongoose');
364
379
  const { DataElementSchema } = require('./basetypes/DataElement');
365
380
  const Code = require('./basetypes/Code');
366
381
  const Interval = require('./basetypes/Interval');
367
382
  const Quantity = require('./basetypes/Quantity');
368
383
  const DateTime = require('./basetypes/DateTime');
384
+
385
+ const { FacilityLocationSchema } = require('./FacilityLocation');
369
386
  const Any = require('./basetypes/Any');
370
387
 
371
388
  const [Number, String] = [
@@ -373,7 +390,7 @@ const [Number, String] = [
373
390
  mongoose.Schema.Types.String,
374
391
  ];
375
392
 
376
- const ComponentSchema = DataElementSchema({
393
+ const ComponentSchema = new mongoose.Schema({
377
394
  code: Code,
378
395
  result: Any,
379
396
  qdmVersion: { type: String, default: '5.3' },
@@ -384,7 +401,7 @@ const ComponentSchema = DataElementSchema({
384
401
  module.exports.ComponentSchema = ComponentSchema;
385
402
  module.exports.Component = mongoose.model('Component', ComponentSchema);
386
403
 
387
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],11:[function(require,module,exports){
404
+ },{"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],11:[function(require,module,exports){
388
405
  const mongoose = require('mongoose');
389
406
 
390
407
  const mString = mongoose.Schema.Types.String;
@@ -407,6 +424,8 @@ const Code = require('./basetypes/Code');
407
424
  const Interval = require('./basetypes/Interval');
408
425
  const Quantity = require('./basetypes/Quantity');
409
426
  const DateTime = require('./basetypes/DateTime');
427
+ const { ComponentSchema } = require('./Component');
428
+ const { FacilityLocationSchema } = require('./FacilityLocation');
410
429
  const Any = require('./basetypes/Any');
411
430
 
412
431
  const [Number, String] = [
@@ -432,13 +451,15 @@ const DeviceAppliedSchema = DataElementSchema({
432
451
  module.exports.DeviceAppliedSchema = DeviceAppliedSchema;
433
452
  module.exports.DeviceApplied = mongoose.model('DeviceApplied', DeviceAppliedSchema);
434
453
 
435
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],13:[function(require,module,exports){
454
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],13:[function(require,module,exports){
436
455
  const mongoose = require('mongoose');
437
456
  const { DataElementSchema } = require('./basetypes/DataElement');
438
457
  const Code = require('./basetypes/Code');
439
458
  const Interval = require('./basetypes/Interval');
440
459
  const Quantity = require('./basetypes/Quantity');
441
460
  const DateTime = require('./basetypes/DateTime');
461
+ const { ComponentSchema } = require('./Component');
462
+ const { FacilityLocationSchema } = require('./FacilityLocation');
442
463
  const Any = require('./basetypes/Any');
443
464
 
444
465
  const [Number, String] = [
@@ -461,13 +482,15 @@ const DeviceOrderSchema = DataElementSchema({
461
482
  module.exports.DeviceOrderSchema = DeviceOrderSchema;
462
483
  module.exports.DeviceOrder = mongoose.model('DeviceOrder', DeviceOrderSchema);
463
484
 
464
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],14:[function(require,module,exports){
485
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],14:[function(require,module,exports){
465
486
  const mongoose = require('mongoose');
466
487
  const { DataElementSchema } = require('./basetypes/DataElement');
467
488
  const Code = require('./basetypes/Code');
468
489
  const Interval = require('./basetypes/Interval');
469
490
  const Quantity = require('./basetypes/Quantity');
470
491
  const DateTime = require('./basetypes/DateTime');
492
+ const { ComponentSchema } = require('./Component');
493
+ const { FacilityLocationSchema } = require('./FacilityLocation');
471
494
  const Any = require('./basetypes/Any');
472
495
 
473
496
  const [Number, String] = [
@@ -490,13 +513,15 @@ const DeviceRecommendedSchema = DataElementSchema({
490
513
  module.exports.DeviceRecommendedSchema = DeviceRecommendedSchema;
491
514
  module.exports.DeviceRecommended = mongoose.model('DeviceRecommended', DeviceRecommendedSchema);
492
515
 
493
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],15:[function(require,module,exports){
516
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],15:[function(require,module,exports){
494
517
  const mongoose = require('mongoose');
495
518
  const { DataElementSchema } = require('./basetypes/DataElement');
496
519
  const Code = require('./basetypes/Code');
497
520
  const Interval = require('./basetypes/Interval');
498
521
  const Quantity = require('./basetypes/Quantity');
499
522
  const DateTime = require('./basetypes/DateTime');
523
+ const { ComponentSchema } = require('./Component');
524
+ const { FacilityLocationSchema } = require('./FacilityLocation');
500
525
  const Any = require('./basetypes/Any');
501
526
 
502
527
  const [Number, String] = [
@@ -520,13 +545,15 @@ const DiagnosisSchema = DataElementSchema({
520
545
  module.exports.DiagnosisSchema = DiagnosisSchema;
521
546
  module.exports.Diagnosis = mongoose.model('Diagnosis', DiagnosisSchema);
522
547
 
523
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],16:[function(require,module,exports){
548
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],16:[function(require,module,exports){
524
549
  const mongoose = require('mongoose');
525
550
  const { DataElementSchema } = require('./basetypes/DataElement');
526
551
  const Code = require('./basetypes/Code');
527
552
  const Interval = require('./basetypes/Interval');
528
553
  const Quantity = require('./basetypes/Quantity');
529
554
  const DateTime = require('./basetypes/DateTime');
555
+ const { ComponentSchema } = require('./Component');
556
+ const { FacilityLocationSchema } = require('./FacilityLocation');
530
557
  const Any = require('./basetypes/Any');
531
558
 
532
559
  const [Number, String] = [
@@ -550,7 +577,7 @@ const DiagnosticStudyOrderSchema = DataElementSchema({
550
577
  module.exports.DiagnosticStudyOrderSchema = DiagnosticStudyOrderSchema;
551
578
  module.exports.DiagnosticStudyOrder = mongoose.model('DiagnosticStudyOrder', DiagnosticStudyOrderSchema);
552
579
 
553
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],17:[function(require,module,exports){
580
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],17:[function(require,module,exports){
554
581
  const mongoose = require('mongoose');
555
582
  const { DataElementSchema } = require('./basetypes/DataElement');
556
583
  const Code = require('./basetypes/Code');
@@ -558,6 +585,7 @@ const Interval = require('./basetypes/Interval');
558
585
  const Quantity = require('./basetypes/Quantity');
559
586
  const DateTime = require('./basetypes/DateTime');
560
587
  const { ComponentSchema } = require('./Component');
588
+ const { FacilityLocationSchema } = require('./FacilityLocation');
561
589
  const Any = require('./basetypes/Any');
562
590
 
563
591
  const [Number, String] = [
@@ -573,7 +601,7 @@ const DiagnosticStudyPerformedSchema = DataElementSchema({
573
601
  resultDatetime: DateTime,
574
602
  status: Code,
575
603
  method: Code,
576
- facilityLocation: Code,
604
+ facilityLocation: FacilityLocationSchema,
577
605
  negationRationale: Code,
578
606
  components: [ComponentSchema],
579
607
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.23' },
@@ -587,13 +615,15 @@ const DiagnosticStudyPerformedSchema = DataElementSchema({
587
615
  module.exports.DiagnosticStudyPerformedSchema = DiagnosticStudyPerformedSchema;
588
616
  module.exports.DiagnosticStudyPerformed = mongoose.model('DiagnosticStudyPerformed', DiagnosticStudyPerformedSchema);
589
617
 
590
- },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],18:[function(require,module,exports){
618
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],18:[function(require,module,exports){
591
619
  const mongoose = require('mongoose');
592
620
  const { DataElementSchema } = require('./basetypes/DataElement');
593
621
  const Code = require('./basetypes/Code');
594
622
  const Interval = require('./basetypes/Interval');
595
623
  const Quantity = require('./basetypes/Quantity');
596
624
  const DateTime = require('./basetypes/DateTime');
625
+ const { ComponentSchema } = require('./Component');
626
+ const { FacilityLocationSchema } = require('./FacilityLocation');
597
627
  const Any = require('./basetypes/Any');
598
628
 
599
629
  const [Number, String] = [
@@ -617,13 +647,15 @@ const DiagnosticStudyRecommendedSchema = DataElementSchema({
617
647
  module.exports.DiagnosticStudyRecommendedSchema = DiagnosticStudyRecommendedSchema;
618
648
  module.exports.DiagnosticStudyRecommended = mongoose.model('DiagnosticStudyRecommended', DiagnosticStudyRecommendedSchema);
619
649
 
620
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],19:[function(require,module,exports){
650
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],19:[function(require,module,exports){
621
651
  const mongoose = require('mongoose');
622
652
  const { DataElementSchema } = require('./basetypes/DataElement');
623
653
  const Code = require('./basetypes/Code');
624
654
  const Interval = require('./basetypes/Interval');
625
655
  const Quantity = require('./basetypes/Quantity');
626
656
  const DateTime = require('./basetypes/DateTime');
657
+ const { ComponentSchema } = require('./Component');
658
+ const { FacilityLocationSchema } = require('./FacilityLocation');
627
659
  const Any = require('./basetypes/Any');
628
660
 
629
661
  const [Number, String] = [
@@ -634,7 +666,7 @@ const [Number, String] = [
634
666
  const EncounterOrderSchema = DataElementSchema({
635
667
  authorDatetime: DateTime,
636
668
  reason: Code,
637
- facilityLocation: Code,
669
+ facilityLocation: FacilityLocationSchema,
638
670
  negationRationale: Code,
639
671
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.27' },
640
672
  category: { type: String, default: 'encounter' },
@@ -647,13 +679,14 @@ const EncounterOrderSchema = DataElementSchema({
647
679
  module.exports.EncounterOrderSchema = EncounterOrderSchema;
648
680
  module.exports.EncounterOrder = mongoose.model('EncounterOrder', EncounterOrderSchema);
649
681
 
650
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],20:[function(require,module,exports){
682
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],20:[function(require,module,exports){
651
683
  const mongoose = require('mongoose');
652
684
  const { DataElementSchema } = require('./basetypes/DataElement');
653
685
  const Code = require('./basetypes/Code');
654
686
  const Interval = require('./basetypes/Interval');
655
687
  const Quantity = require('./basetypes/Quantity');
656
688
  const DateTime = require('./basetypes/DateTime');
689
+ const { ComponentSchema } = require('./Component');
657
690
  const { FacilityLocationSchema } = require('./FacilityLocation');
658
691
  const Any = require('./basetypes/Any');
659
692
 
@@ -683,13 +716,15 @@ const EncounterPerformedSchema = DataElementSchema({
683
716
  module.exports.EncounterPerformedSchema = EncounterPerformedSchema;
684
717
  module.exports.EncounterPerformed = mongoose.model('EncounterPerformed', EncounterPerformedSchema);
685
718
 
686
- },{"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],21:[function(require,module,exports){
719
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],21:[function(require,module,exports){
687
720
  const mongoose = require('mongoose');
688
721
  const { DataElementSchema } = require('./basetypes/DataElement');
689
722
  const Code = require('./basetypes/Code');
690
723
  const Interval = require('./basetypes/Interval');
691
724
  const Quantity = require('./basetypes/Quantity');
692
725
  const DateTime = require('./basetypes/DateTime');
726
+ const { ComponentSchema } = require('./Component');
727
+ const { FacilityLocationSchema } = require('./FacilityLocation');
693
728
  const Any = require('./basetypes/Any');
694
729
 
695
730
  const [Number, String] = [
@@ -700,7 +735,7 @@ const [Number, String] = [
700
735
  const EncounterRecommendedSchema = DataElementSchema({
701
736
  authorDatetime: DateTime,
702
737
  reason: Code,
703
- facilityLocation: Code,
738
+ facilityLocation: FacilityLocationSchema,
704
739
  negationRationale: Code,
705
740
  hqmfOid: { type: String, default: '2.16.840.1.113883.10.20.28.3.28' },
706
741
  category: { type: String, default: 'encounter' },
@@ -713,13 +748,15 @@ const EncounterRecommendedSchema = DataElementSchema({
713
748
  module.exports.EncounterRecommendedSchema = EncounterRecommendedSchema;
714
749
  module.exports.EncounterRecommended = mongoose.model('EncounterRecommended', EncounterRecommendedSchema);
715
750
 
716
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],22:[function(require,module,exports){
751
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],22:[function(require,module,exports){
717
752
  const mongoose = require('mongoose');
718
753
  const { DataElementSchema } = require('./basetypes/DataElement');
719
754
  const Code = require('./basetypes/Code');
720
755
  const Interval = require('./basetypes/Interval');
721
756
  const Quantity = require('./basetypes/Quantity');
722
757
  const DateTime = require('./basetypes/DateTime');
758
+ const { ComponentSchema } = require('./Component');
759
+
723
760
  const Any = require('./basetypes/Any');
724
761
 
725
762
  const [Number, String] = [
@@ -727,7 +764,7 @@ const [Number, String] = [
727
764
  mongoose.Schema.Types.String,
728
765
  ];
729
766
 
730
- const FacilityLocationSchema = DataElementSchema({
767
+ const FacilityLocationSchema = new mongoose.Schema({
731
768
  code: Code,
732
769
  locationPeriod: Interval,
733
770
  qdmVersion: { type: String, default: '5.3' },
@@ -738,13 +775,15 @@ const FacilityLocationSchema = DataElementSchema({
738
775
  module.exports.FacilityLocationSchema = FacilityLocationSchema;
739
776
  module.exports.FacilityLocation = mongoose.model('FacilityLocation', FacilityLocationSchema);
740
777
 
741
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],23:[function(require,module,exports){
778
+ },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],23:[function(require,module,exports){
742
779
  const mongoose = require('mongoose');
743
780
  const { DataElementSchema } = require('./basetypes/DataElement');
744
781
  const Code = require('./basetypes/Code');
745
782
  const Interval = require('./basetypes/Interval');
746
783
  const Quantity = require('./basetypes/Quantity');
747
784
  const DateTime = require('./basetypes/DateTime');
785
+ const { ComponentSchema } = require('./Component');
786
+ const { FacilityLocationSchema } = require('./FacilityLocation');
748
787
  const Any = require('./basetypes/Any');
749
788
 
750
789
  const [Number, String] = [
@@ -766,13 +805,15 @@ const FamilyHistorySchema = DataElementSchema({
766
805
  module.exports.FamilyHistorySchema = FamilyHistorySchema;
767
806
  module.exports.FamilyHistory = mongoose.model('FamilyHistory', FamilyHistorySchema);
768
807
 
769
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],24:[function(require,module,exports){
808
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],24:[function(require,module,exports){
770
809
  const mongoose = require('mongoose');
771
810
  const { DataElementSchema } = require('./basetypes/DataElement');
772
811
  const Code = require('./basetypes/Code');
773
812
  const Interval = require('./basetypes/Interval');
774
813
  const Quantity = require('./basetypes/Quantity');
775
814
  const DateTime = require('./basetypes/DateTime');
815
+ const { ComponentSchema } = require('./Component');
816
+ const { FacilityLocationSchema } = require('./FacilityLocation');
776
817
  const Any = require('./basetypes/Any');
777
818
 
778
819
  const [Number, String] = [
@@ -791,13 +832,15 @@ const IdSchema = DataElementSchema({
791
832
  module.exports.IdSchema = IdSchema;
792
833
  module.exports.Id = mongoose.model('Id', IdSchema);
793
834
 
794
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],25:[function(require,module,exports){
835
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],25:[function(require,module,exports){
795
836
  const mongoose = require('mongoose');
796
837
  const { DataElementSchema } = require('./basetypes/DataElement');
797
838
  const Code = require('./basetypes/Code');
798
839
  const Interval = require('./basetypes/Interval');
799
840
  const Quantity = require('./basetypes/Quantity');
800
841
  const DateTime = require('./basetypes/DateTime');
842
+ const { ComponentSchema } = require('./Component');
843
+ const { FacilityLocationSchema } = require('./FacilityLocation');
801
844
  const Any = require('./basetypes/Any');
802
845
 
803
846
  const [Number, String] = [
@@ -824,13 +867,15 @@ const ImmunizationAdministeredSchema = DataElementSchema({
824
867
  module.exports.ImmunizationAdministeredSchema = ImmunizationAdministeredSchema;
825
868
  module.exports.ImmunizationAdministered = mongoose.model('ImmunizationAdministered', ImmunizationAdministeredSchema);
826
869
 
827
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],26:[function(require,module,exports){
870
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],26:[function(require,module,exports){
828
871
  const mongoose = require('mongoose');
829
872
  const { DataElementSchema } = require('./basetypes/DataElement');
830
873
  const Code = require('./basetypes/Code');
831
874
  const Interval = require('./basetypes/Interval');
832
875
  const Quantity = require('./basetypes/Quantity');
833
876
  const DateTime = require('./basetypes/DateTime');
877
+ const { ComponentSchema } = require('./Component');
878
+ const { FacilityLocationSchema } = require('./FacilityLocation');
834
879
  const Any = require('./basetypes/Any');
835
880
 
836
881
  const [Number, String] = [
@@ -857,7 +902,7 @@ const ImmunizationOrderSchema = DataElementSchema({
857
902
  module.exports.ImmunizationOrderSchema = ImmunizationOrderSchema;
858
903
  module.exports.ImmunizationOrder = mongoose.model('ImmunizationOrder', ImmunizationOrderSchema);
859
904
 
860
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],27:[function(require,module,exports){
905
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],27:[function(require,module,exports){
861
906
  const mongoose = require('mongoose');
862
907
 
863
908
  const [Number, String, Mixed, ObjectId] = [
@@ -889,7 +934,10 @@ const IndividualResultSchema = mongoose.Schema(
889
934
  // This field is for application specific information only. If both Bonnie and
890
935
  // Cypress use a common field, it should be made a field on this model,
891
936
  // and not put into extendedData.
892
- extendedData: {},
937
+ extendedData: {
938
+ type: Mixed,
939
+ default: {},
940
+ },
893
941
 
894
942
  // Calculation State attributes
895
943
  state: {
@@ -920,6 +968,8 @@ const Code = require('./basetypes/Code');
920
968
  const Interval = require('./basetypes/Interval');
921
969
  const Quantity = require('./basetypes/Quantity');
922
970
  const DateTime = require('./basetypes/DateTime');
971
+ const { ComponentSchema } = require('./Component');
972
+ const { FacilityLocationSchema } = require('./FacilityLocation');
923
973
  const Any = require('./basetypes/Any');
924
974
 
925
975
  const [Number, String] = [
@@ -942,13 +992,15 @@ const InterventionOrderSchema = DataElementSchema({
942
992
  module.exports.InterventionOrderSchema = InterventionOrderSchema;
943
993
  module.exports.InterventionOrder = mongoose.model('InterventionOrder', InterventionOrderSchema);
944
994
 
945
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],29:[function(require,module,exports){
995
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],29:[function(require,module,exports){
946
996
  const mongoose = require('mongoose');
947
997
  const { DataElementSchema } = require('./basetypes/DataElement');
948
998
  const Code = require('./basetypes/Code');
949
999
  const Interval = require('./basetypes/Interval');
950
1000
  const Quantity = require('./basetypes/Quantity');
951
1001
  const DateTime = require('./basetypes/DateTime');
1002
+ const { ComponentSchema } = require('./Component');
1003
+ const { FacilityLocationSchema } = require('./FacilityLocation');
952
1004
  const Any = require('./basetypes/Any');
953
1005
 
954
1006
  const [Number, String] = [
@@ -974,13 +1026,15 @@ const InterventionPerformedSchema = DataElementSchema({
974
1026
  module.exports.InterventionPerformedSchema = InterventionPerformedSchema;
975
1027
  module.exports.InterventionPerformed = mongoose.model('InterventionPerformed', InterventionPerformedSchema);
976
1028
 
977
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],30:[function(require,module,exports){
1029
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],30:[function(require,module,exports){
978
1030
  const mongoose = require('mongoose');
979
1031
  const { DataElementSchema } = require('./basetypes/DataElement');
980
1032
  const Code = require('./basetypes/Code');
981
1033
  const Interval = require('./basetypes/Interval');
982
1034
  const Quantity = require('./basetypes/Quantity');
983
1035
  const DateTime = require('./basetypes/DateTime');
1036
+ const { ComponentSchema } = require('./Component');
1037
+ const { FacilityLocationSchema } = require('./FacilityLocation');
984
1038
  const Any = require('./basetypes/Any');
985
1039
 
986
1040
  const [Number, String] = [
@@ -1003,13 +1057,15 @@ const InterventionRecommendedSchema = DataElementSchema({
1003
1057
  module.exports.InterventionRecommendedSchema = InterventionRecommendedSchema;
1004
1058
  module.exports.InterventionRecommended = mongoose.model('InterventionRecommended', InterventionRecommendedSchema);
1005
1059
 
1006
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],31:[function(require,module,exports){
1060
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],31:[function(require,module,exports){
1007
1061
  const mongoose = require('mongoose');
1008
1062
  const { DataElementSchema } = require('./basetypes/DataElement');
1009
1063
  const Code = require('./basetypes/Code');
1010
1064
  const Interval = require('./basetypes/Interval');
1011
1065
  const Quantity = require('./basetypes/Quantity');
1012
1066
  const DateTime = require('./basetypes/DateTime');
1067
+ const { ComponentSchema } = require('./Component');
1068
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1013
1069
  const Any = require('./basetypes/Any');
1014
1070
 
1015
1071
  const [Number, String] = [
@@ -1033,7 +1089,7 @@ const LaboratoryTestOrderSchema = DataElementSchema({
1033
1089
  module.exports.LaboratoryTestOrderSchema = LaboratoryTestOrderSchema;
1034
1090
  module.exports.LaboratoryTestOrder = mongoose.model('LaboratoryTestOrder', LaboratoryTestOrderSchema);
1035
1091
 
1036
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],32:[function(require,module,exports){
1092
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],32:[function(require,module,exports){
1037
1093
  const mongoose = require('mongoose');
1038
1094
  const { DataElementSchema } = require('./basetypes/DataElement');
1039
1095
  const Code = require('./basetypes/Code');
@@ -1041,6 +1097,7 @@ const Interval = require('./basetypes/Interval');
1041
1097
  const Quantity = require('./basetypes/Quantity');
1042
1098
  const DateTime = require('./basetypes/DateTime');
1043
1099
  const { ComponentSchema } = require('./Component');
1100
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1044
1101
  const Any = require('./basetypes/Any');
1045
1102
 
1046
1103
  const [Number, String] = [
@@ -1070,13 +1127,15 @@ const LaboratoryTestPerformedSchema = DataElementSchema({
1070
1127
  module.exports.LaboratoryTestPerformedSchema = LaboratoryTestPerformedSchema;
1071
1128
  module.exports.LaboratoryTestPerformed = mongoose.model('LaboratoryTestPerformed', LaboratoryTestPerformedSchema);
1072
1129
 
1073
- },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],33:[function(require,module,exports){
1130
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],33:[function(require,module,exports){
1074
1131
  const mongoose = require('mongoose');
1075
1132
  const { DataElementSchema } = require('./basetypes/DataElement');
1076
1133
  const Code = require('./basetypes/Code');
1077
1134
  const Interval = require('./basetypes/Interval');
1078
1135
  const Quantity = require('./basetypes/Quantity');
1079
1136
  const DateTime = require('./basetypes/DateTime');
1137
+ const { ComponentSchema } = require('./Component');
1138
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1080
1139
  const Any = require('./basetypes/Any');
1081
1140
 
1082
1141
  const [Number, String] = [
@@ -1100,7 +1159,7 @@ const LaboratoryTestRecommendedSchema = DataElementSchema({
1100
1159
  module.exports.LaboratoryTestRecommendedSchema = LaboratoryTestRecommendedSchema;
1101
1160
  module.exports.LaboratoryTestRecommended = mongoose.model('LaboratoryTestRecommended', LaboratoryTestRecommendedSchema);
1102
1161
 
1103
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],34:[function(require,module,exports){
1162
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],34:[function(require,module,exports){
1104
1163
  const mongoose = require('mongoose');
1105
1164
  const Code = require('./basetypes/Code');
1106
1165
  const Interval = require('./basetypes/Interval');
@@ -1209,6 +1268,8 @@ const Code = require('./basetypes/Code');
1209
1268
  const Interval = require('./basetypes/Interval');
1210
1269
  const Quantity = require('./basetypes/Quantity');
1211
1270
  const DateTime = require('./basetypes/DateTime');
1271
+ const { ComponentSchema } = require('./Component');
1272
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1212
1273
  const Any = require('./basetypes/Any');
1213
1274
 
1214
1275
  const [Number, String] = [
@@ -1233,13 +1294,15 @@ const MedicationActiveSchema = DataElementSchema({
1233
1294
  module.exports.MedicationActiveSchema = MedicationActiveSchema;
1234
1295
  module.exports.MedicationActive = mongoose.model('MedicationActive', MedicationActiveSchema);
1235
1296
 
1236
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],37:[function(require,module,exports){
1297
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],37:[function(require,module,exports){
1237
1298
  const mongoose = require('mongoose');
1238
1299
  const { DataElementSchema } = require('./basetypes/DataElement');
1239
1300
  const Code = require('./basetypes/Code');
1240
1301
  const Interval = require('./basetypes/Interval');
1241
1302
  const Quantity = require('./basetypes/Quantity');
1242
1303
  const DateTime = require('./basetypes/DateTime');
1304
+ const { ComponentSchema } = require('./Component');
1305
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1243
1306
  const Any = require('./basetypes/Any');
1244
1307
 
1245
1308
  const [Number, String] = [
@@ -1267,13 +1330,15 @@ const MedicationAdministeredSchema = DataElementSchema({
1267
1330
  module.exports.MedicationAdministeredSchema = MedicationAdministeredSchema;
1268
1331
  module.exports.MedicationAdministered = mongoose.model('MedicationAdministered', MedicationAdministeredSchema);
1269
1332
 
1270
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],38:[function(require,module,exports){
1333
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],38:[function(require,module,exports){
1271
1334
  const mongoose = require('mongoose');
1272
1335
  const { DataElementSchema } = require('./basetypes/DataElement');
1273
1336
  const Code = require('./basetypes/Code');
1274
1337
  const Interval = require('./basetypes/Interval');
1275
1338
  const Quantity = require('./basetypes/Quantity');
1276
1339
  const DateTime = require('./basetypes/DateTime');
1340
+ const { ComponentSchema } = require('./Component');
1341
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1277
1342
  const Any = require('./basetypes/Any');
1278
1343
 
1279
1344
  const [Number, String] = [
@@ -1300,13 +1365,15 @@ const MedicationDischargeSchema = DataElementSchema({
1300
1365
  module.exports.MedicationDischargeSchema = MedicationDischargeSchema;
1301
1366
  module.exports.MedicationDischarge = mongoose.model('MedicationDischarge', MedicationDischargeSchema);
1302
1367
 
1303
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],39:[function(require,module,exports){
1368
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],39:[function(require,module,exports){
1304
1369
  const mongoose = require('mongoose');
1305
1370
  const { DataElementSchema } = require('./basetypes/DataElement');
1306
1371
  const Code = require('./basetypes/Code');
1307
1372
  const Interval = require('./basetypes/Interval');
1308
1373
  const Quantity = require('./basetypes/Quantity');
1309
1374
  const DateTime = require('./basetypes/DateTime');
1375
+ const { ComponentSchema } = require('./Component');
1376
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1310
1377
  const Any = require('./basetypes/Any');
1311
1378
 
1312
1379
  const [Number, String] = [
@@ -1334,13 +1401,15 @@ const MedicationDispensedSchema = DataElementSchema({
1334
1401
  module.exports.MedicationDispensedSchema = MedicationDispensedSchema;
1335
1402
  module.exports.MedicationDispensed = mongoose.model('MedicationDispensed', MedicationDispensedSchema);
1336
1403
 
1337
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],40:[function(require,module,exports){
1404
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],40:[function(require,module,exports){
1338
1405
  const mongoose = require('mongoose');
1339
1406
  const { DataElementSchema } = require('./basetypes/DataElement');
1340
1407
  const Code = require('./basetypes/Code');
1341
1408
  const Interval = require('./basetypes/Interval');
1342
1409
  const Quantity = require('./basetypes/Quantity');
1343
1410
  const DateTime = require('./basetypes/DateTime');
1411
+ const { ComponentSchema } = require('./Component');
1412
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1344
1413
  const Any = require('./basetypes/Any');
1345
1414
 
1346
1415
  const [Number, String] = [
@@ -1371,13 +1440,15 @@ const MedicationOrderSchema = DataElementSchema({
1371
1440
  module.exports.MedicationOrderSchema = MedicationOrderSchema;
1372
1441
  module.exports.MedicationOrder = mongoose.model('MedicationOrder', MedicationOrderSchema);
1373
1442
 
1374
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],41:[function(require,module,exports){
1443
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],41:[function(require,module,exports){
1375
1444
  const mongoose = require('mongoose');
1376
1445
  const { DataElementSchema } = require('./basetypes/DataElement');
1377
1446
  const Code = require('./basetypes/Code');
1378
1447
  const Interval = require('./basetypes/Interval');
1379
1448
  const Quantity = require('./basetypes/Quantity');
1380
1449
  const DateTime = require('./basetypes/DateTime');
1450
+ const { ComponentSchema } = require('./Component');
1451
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1381
1452
  const Any = require('./basetypes/Any');
1382
1453
 
1383
1454
  const [Number, String] = [
@@ -1397,7 +1468,7 @@ const ParticipationSchema = DataElementSchema({
1397
1468
  module.exports.ParticipationSchema = ParticipationSchema;
1398
1469
  module.exports.Participation = mongoose.model('Participation', ParticipationSchema);
1399
1470
 
1400
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],42:[function(require,module,exports){
1471
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],42:[function(require,module,exports){
1401
1472
  const mongoose = require('mongoose');
1402
1473
  const Code = require('./basetypes/Code');
1403
1474
  const Interval = require('./basetypes/Interval');
@@ -1405,10 +1476,11 @@ const Quantity = require('./basetypes/Quantity');
1405
1476
  const DateTime = require('./basetypes/DateTime');
1406
1477
  const AllDataElements = require('./AllDataElements');
1407
1478
 
1408
- const [Schema, Number, String] = [
1479
+ const [Schema, Number, String, Mixed] = [
1409
1480
  mongoose.Schema,
1410
1481
  mongoose.Schema.Types.Number,
1411
1482
  mongoose.Schema.Types.String,
1483
+ mongoose.Schema.Types.Mixed,
1412
1484
  ];
1413
1485
 
1414
1486
  const PatientSchema = new Schema({
@@ -1425,7 +1497,10 @@ const PatientSchema = new Schema({
1425
1497
  // This field is for application specific information only. If both Bonnie
1426
1498
  // Cypress use a common field, it should be made a field on this model,
1427
1499
  // and not put into extendedData.
1428
- extendedData: {},
1500
+ extendedData: {
1501
+ type: Mixed,
1502
+ default: {},
1503
+ },
1429
1504
  }, { id: false });
1430
1505
 
1431
1506
  // After initialization of a Patient model, initialize every individual data element
@@ -1478,19 +1553,27 @@ PatientSchema.methods.getDataElements = function getDataElements(params) {
1478
1553
  // Returns an array of dataElements that exist on the patient, queried by
1479
1554
  // QDM profile
1480
1555
  PatientSchema.methods.getByProfile = function getByProfile(profile, isNegated = null) {
1481
- if (isNegated === true) {
1482
- return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale !== 'undefined' && element.negationRationale != null));
1483
- } else if (isNegated === false) {
1484
- return this.dataElements.filter(element => element._type === `QDM::${profile}` && (typeof element.negationRationale === 'undefined' || element.negationRationale == null));
1485
- }
1486
- return this.dataElements.filter(element => element._type === `QDM::${profile}`);
1556
+ // If isNegated == true, only return data elements with a negationRationale that is not null.
1557
+ // If isNegated == false, only return data elements with a null negationRationale.
1558
+ // If isNegated == null, return all matching data elements by type, regardless of negationRationale.
1559
+ const results = this.dataElements.filter(element => element._type === `QDM::${profile}` && (isNegated === null || !!element.negationRationale === isNegated));
1560
+ return results.map((result) => {
1561
+ const getCodeFunction = Object.getPrototypeOf(result).getCode;
1562
+ const codeFunction = Object.getPrototypeOf(result).code;
1563
+ const removedMongooseItems = AllDataElements[profile](result).toObject();
1564
+ // toObject() will remove all mongoose functions but also removed the getCode and code functions
1565
+ // the execution engine requires the code and getCode functions so we have to add them back
1566
+ removedMongooseItems.getCode = getCodeFunction;
1567
+ removedMongooseItems.code = codeFunction;
1568
+ return removedMongooseItems;
1569
+ });
1487
1570
  };
1488
1571
 
1489
1572
  // This method is called by the CQL execution engine on a CQLPatient when
1490
1573
  // the execution engine wants information on a record. A record could be patient
1491
1574
  // characteristic information about the patient, or it could be data criteria
1492
1575
  // that currently exist on this patient (data criteria you drag on a patient
1493
- // in Bonnie's patient builder).
1576
+ // in Bonnie patient builder).
1494
1577
  // @param {String} profile - the data criteria requested by the execution engine
1495
1578
  // @returns {Object}
1496
1579
  PatientSchema.methods.findRecords = function findRecords(profile) {
@@ -1507,7 +1590,7 @@ PatientSchema.methods.findRecords = function findRecords(profile) {
1507
1590
  // Requested something else (probably a QDM data type).
1508
1591
 
1509
1592
  // Strip model details from request. The requested profile string contains
1510
- // a lot of things we don't need or care about. Example, we might see
1593
+ // a lot of things we do not need or care about. Example, we might see
1511
1594
  // something like:
1512
1595
  // "{urn:healthit-gov:qdm:v5_0_draft}PatientCharacteristicEthnicity"
1513
1596
  // Where we only care about: "PatientCharacteristicEthnicity".
@@ -1655,6 +1738,8 @@ const Code = require('./basetypes/Code');
1655
1738
  const Interval = require('./basetypes/Interval');
1656
1739
  const Quantity = require('./basetypes/Quantity');
1657
1740
  const DateTime = require('./basetypes/DateTime');
1741
+ const { ComponentSchema } = require('./Component');
1742
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1658
1743
  const Any = require('./basetypes/Any');
1659
1744
 
1660
1745
  const [Number, String] = [
@@ -1674,13 +1759,15 @@ const PatientCareExperienceSchema = DataElementSchema({
1674
1759
  module.exports.PatientCareExperienceSchema = PatientCareExperienceSchema;
1675
1760
  module.exports.PatientCareExperience = mongoose.model('PatientCareExperience', PatientCareExperienceSchema);
1676
1761
 
1677
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],44:[function(require,module,exports){
1762
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],44:[function(require,module,exports){
1678
1763
  const mongoose = require('mongoose');
1679
1764
  const { DataElementSchema } = require('./basetypes/DataElement');
1680
1765
  const Code = require('./basetypes/Code');
1681
1766
  const Interval = require('./basetypes/Interval');
1682
1767
  const Quantity = require('./basetypes/Quantity');
1683
1768
  const DateTime = require('./basetypes/DateTime');
1769
+ const { ComponentSchema } = require('./Component');
1770
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1684
1771
  const Any = require('./basetypes/Any');
1685
1772
 
1686
1773
  const [Number, String] = [
@@ -1700,13 +1787,15 @@ const PatientCharacteristicSchema = DataElementSchema({
1700
1787
  module.exports.PatientCharacteristicSchema = PatientCharacteristicSchema;
1701
1788
  module.exports.PatientCharacteristic = mongoose.model('PatientCharacteristic', PatientCharacteristicSchema);
1702
1789
 
1703
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],45:[function(require,module,exports){
1790
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],45:[function(require,module,exports){
1704
1791
  const mongoose = require('mongoose');
1705
1792
  const { DataElementSchema } = require('./basetypes/DataElement');
1706
1793
  const Code = require('./basetypes/Code');
1707
1794
  const Interval = require('./basetypes/Interval');
1708
1795
  const Quantity = require('./basetypes/Quantity');
1709
1796
  const DateTime = require('./basetypes/DateTime');
1797
+ const { ComponentSchema } = require('./Component');
1798
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1710
1799
  const Any = require('./basetypes/Any');
1711
1800
 
1712
1801
  const [Number, String] = [
@@ -1727,13 +1816,15 @@ const PatientCharacteristicBirthdateSchema = DataElementSchema({
1727
1816
  module.exports.PatientCharacteristicBirthdateSchema = PatientCharacteristicBirthdateSchema;
1728
1817
  module.exports.PatientCharacteristicBirthdate = mongoose.model('PatientCharacteristicBirthdate', PatientCharacteristicBirthdateSchema);
1729
1818
 
1730
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],46:[function(require,module,exports){
1819
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],46:[function(require,module,exports){
1731
1820
  const mongoose = require('mongoose');
1732
1821
  const { DataElementSchema } = require('./basetypes/DataElement');
1733
1822
  const Code = require('./basetypes/Code');
1734
1823
  const Interval = require('./basetypes/Interval');
1735
1824
  const Quantity = require('./basetypes/Quantity');
1736
1825
  const DateTime = require('./basetypes/DateTime');
1826
+ const { ComponentSchema } = require('./Component');
1827
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1737
1828
  const Any = require('./basetypes/Any');
1738
1829
 
1739
1830
  const [Number, String] = [
@@ -1756,13 +1847,15 @@ const PatientCharacteristicClinicalTrialParticipantSchema = DataElementSchema({
1756
1847
  module.exports.PatientCharacteristicClinicalTrialParticipantSchema = PatientCharacteristicClinicalTrialParticipantSchema;
1757
1848
  module.exports.PatientCharacteristicClinicalTrialParticipant = mongoose.model('PatientCharacteristicClinicalTrialParticipant', PatientCharacteristicClinicalTrialParticipantSchema);
1758
1849
 
1759
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],47:[function(require,module,exports){
1850
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],47:[function(require,module,exports){
1760
1851
  const mongoose = require('mongoose');
1761
1852
  const { DataElementSchema } = require('./basetypes/DataElement');
1762
1853
  const Code = require('./basetypes/Code');
1763
1854
  const Interval = require('./basetypes/Interval');
1764
1855
  const Quantity = require('./basetypes/Quantity');
1765
1856
  const DateTime = require('./basetypes/DateTime');
1857
+ const { ComponentSchema } = require('./Component');
1858
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1766
1859
  const Any = require('./basetypes/Any');
1767
1860
 
1768
1861
  const [Number, String] = [
@@ -1782,13 +1875,15 @@ const PatientCharacteristicEthnicitySchema = DataElementSchema({
1782
1875
  module.exports.PatientCharacteristicEthnicitySchema = PatientCharacteristicEthnicitySchema;
1783
1876
  module.exports.PatientCharacteristicEthnicity = mongoose.model('PatientCharacteristicEthnicity', PatientCharacteristicEthnicitySchema);
1784
1877
 
1785
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],48:[function(require,module,exports){
1878
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],48:[function(require,module,exports){
1786
1879
  const mongoose = require('mongoose');
1787
1880
  const { DataElementSchema } = require('./basetypes/DataElement');
1788
1881
  const Code = require('./basetypes/Code');
1789
1882
  const Interval = require('./basetypes/Interval');
1790
1883
  const Quantity = require('./basetypes/Quantity');
1791
1884
  const DateTime = require('./basetypes/DateTime');
1885
+ const { ComponentSchema } = require('./Component');
1886
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1792
1887
  const Any = require('./basetypes/Any');
1793
1888
 
1794
1889
  const [Number, String] = [
@@ -1810,13 +1905,15 @@ const PatientCharacteristicExpiredSchema = DataElementSchema({
1810
1905
  module.exports.PatientCharacteristicExpiredSchema = PatientCharacteristicExpiredSchema;
1811
1906
  module.exports.PatientCharacteristicExpired = mongoose.model('PatientCharacteristicExpired', PatientCharacteristicExpiredSchema);
1812
1907
 
1813
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],49:[function(require,module,exports){
1908
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],49:[function(require,module,exports){
1814
1909
  const mongoose = require('mongoose');
1815
1910
  const { DataElementSchema } = require('./basetypes/DataElement');
1816
1911
  const Code = require('./basetypes/Code');
1817
1912
  const Interval = require('./basetypes/Interval');
1818
1913
  const Quantity = require('./basetypes/Quantity');
1819
1914
  const DateTime = require('./basetypes/DateTime');
1915
+ const { ComponentSchema } = require('./Component');
1916
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1820
1917
  const Any = require('./basetypes/Any');
1821
1918
 
1822
1919
  const [Number, String] = [
@@ -1837,13 +1934,15 @@ const PatientCharacteristicPayerSchema = DataElementSchema({
1837
1934
  module.exports.PatientCharacteristicPayerSchema = PatientCharacteristicPayerSchema;
1838
1935
  module.exports.PatientCharacteristicPayer = mongoose.model('PatientCharacteristicPayer', PatientCharacteristicPayerSchema);
1839
1936
 
1840
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],50:[function(require,module,exports){
1937
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],50:[function(require,module,exports){
1841
1938
  const mongoose = require('mongoose');
1842
1939
  const { DataElementSchema } = require('./basetypes/DataElement');
1843
1940
  const Code = require('./basetypes/Code');
1844
1941
  const Interval = require('./basetypes/Interval');
1845
1942
  const Quantity = require('./basetypes/Quantity');
1846
1943
  const DateTime = require('./basetypes/DateTime');
1944
+ const { ComponentSchema } = require('./Component');
1945
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1847
1946
  const Any = require('./basetypes/Any');
1848
1947
 
1849
1948
  const [Number, String] = [
@@ -1863,13 +1962,15 @@ const PatientCharacteristicRaceSchema = DataElementSchema({
1863
1962
  module.exports.PatientCharacteristicRaceSchema = PatientCharacteristicRaceSchema;
1864
1963
  module.exports.PatientCharacteristicRace = mongoose.model('PatientCharacteristicRace', PatientCharacteristicRaceSchema);
1865
1964
 
1866
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],51:[function(require,module,exports){
1965
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],51:[function(require,module,exports){
1867
1966
  const mongoose = require('mongoose');
1868
1967
  const { DataElementSchema } = require('./basetypes/DataElement');
1869
1968
  const Code = require('./basetypes/Code');
1870
1969
  const Interval = require('./basetypes/Interval');
1871
1970
  const Quantity = require('./basetypes/Quantity');
1872
1971
  const DateTime = require('./basetypes/DateTime');
1972
+ const { ComponentSchema } = require('./Component');
1973
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1873
1974
  const Any = require('./basetypes/Any');
1874
1975
 
1875
1976
  const [Number, String] = [
@@ -1889,13 +1990,15 @@ const PatientCharacteristicSexSchema = DataElementSchema({
1889
1990
  module.exports.PatientCharacteristicSexSchema = PatientCharacteristicSexSchema;
1890
1991
  module.exports.PatientCharacteristicSex = mongoose.model('PatientCharacteristicSex', PatientCharacteristicSexSchema);
1891
1992
 
1892
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],52:[function(require,module,exports){
1993
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],52:[function(require,module,exports){
1893
1994
  const mongoose = require('mongoose');
1894
1995
  const { DataElementSchema } = require('./basetypes/DataElement');
1895
1996
  const Code = require('./basetypes/Code');
1896
1997
  const Interval = require('./basetypes/Interval');
1897
1998
  const Quantity = require('./basetypes/Quantity');
1898
1999
  const DateTime = require('./basetypes/DateTime');
2000
+ const { ComponentSchema } = require('./Component');
2001
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1899
2002
  const Any = require('./basetypes/Any');
1900
2003
 
1901
2004
  const [Number, String] = [
@@ -1920,7 +2023,7 @@ const PhysicalExamOrderSchema = DataElementSchema({
1920
2023
  module.exports.PhysicalExamOrderSchema = PhysicalExamOrderSchema;
1921
2024
  module.exports.PhysicalExamOrder = mongoose.model('PhysicalExamOrder', PhysicalExamOrderSchema);
1922
2025
 
1923
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],53:[function(require,module,exports){
2026
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],53:[function(require,module,exports){
1924
2027
  const mongoose = require('mongoose');
1925
2028
  const { DataElementSchema } = require('./basetypes/DataElement');
1926
2029
  const Code = require('./basetypes/Code');
@@ -1928,6 +2031,7 @@ const Interval = require('./basetypes/Interval');
1928
2031
  const Quantity = require('./basetypes/Quantity');
1929
2032
  const DateTime = require('./basetypes/DateTime');
1930
2033
  const { ComponentSchema } = require('./Component');
2034
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1931
2035
  const Any = require('./basetypes/Any');
1932
2036
 
1933
2037
  const [Number, String] = [
@@ -1955,13 +2059,15 @@ const PhysicalExamPerformedSchema = DataElementSchema({
1955
2059
  module.exports.PhysicalExamPerformedSchema = PhysicalExamPerformedSchema;
1956
2060
  module.exports.PhysicalExamPerformed = mongoose.model('PhysicalExamPerformed', PhysicalExamPerformedSchema);
1957
2061
 
1958
- },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],54:[function(require,module,exports){
2062
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],54:[function(require,module,exports){
1959
2063
  const mongoose = require('mongoose');
1960
2064
  const { DataElementSchema } = require('./basetypes/DataElement');
1961
2065
  const Code = require('./basetypes/Code');
1962
2066
  const Interval = require('./basetypes/Interval');
1963
2067
  const Quantity = require('./basetypes/Quantity');
1964
2068
  const DateTime = require('./basetypes/DateTime');
2069
+ const { ComponentSchema } = require('./Component');
2070
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1965
2071
  const Any = require('./basetypes/Any');
1966
2072
 
1967
2073
  const [Number, String] = [
@@ -1986,13 +2092,15 @@ const PhysicalExamRecommendedSchema = DataElementSchema({
1986
2092
  module.exports.PhysicalExamRecommendedSchema = PhysicalExamRecommendedSchema;
1987
2093
  module.exports.PhysicalExamRecommended = mongoose.model('PhysicalExamRecommended', PhysicalExamRecommendedSchema);
1988
2094
 
1989
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],55:[function(require,module,exports){
2095
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],55:[function(require,module,exports){
1990
2096
  const mongoose = require('mongoose');
1991
2097
  const { DataElementSchema } = require('./basetypes/DataElement');
1992
2098
  const Code = require('./basetypes/Code');
1993
2099
  const Interval = require('./basetypes/Interval');
1994
2100
  const Quantity = require('./basetypes/Quantity');
1995
2101
  const DateTime = require('./basetypes/DateTime');
2102
+ const { ComponentSchema } = require('./Component');
2103
+ const { FacilityLocationSchema } = require('./FacilityLocation');
1996
2104
  const Any = require('./basetypes/Any');
1997
2105
 
1998
2106
  const [Number, String] = [
@@ -2019,16 +2127,16 @@ const ProcedureOrderSchema = DataElementSchema({
2019
2127
  module.exports.ProcedureOrderSchema = ProcedureOrderSchema;
2020
2128
  module.exports.ProcedureOrder = mongoose.model('ProcedureOrder', ProcedureOrderSchema);
2021
2129
 
2022
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],56:[function(require,module,exports){
2130
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],56:[function(require,module,exports){
2023
2131
  const mongoose = require('mongoose');
2024
2132
  const { DataElementSchema } = require('./basetypes/DataElement');
2025
2133
  const Code = require('./basetypes/Code');
2026
2134
  const Interval = require('./basetypes/Interval');
2027
2135
  const Quantity = require('./basetypes/Quantity');
2028
2136
  const DateTime = require('./basetypes/DateTime');
2029
- const Any = require('./basetypes/Any');
2030
-
2031
2137
  const { ComponentSchema } = require('./Component');
2138
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2139
+ const Any = require('./basetypes/Any');
2032
2140
 
2033
2141
  const [Number, String] = [
2034
2142
  mongoose.Schema.Types.Number,
@@ -2059,13 +2167,15 @@ const ProcedurePerformedSchema = DataElementSchema({
2059
2167
  module.exports.ProcedurePerformedSchema = ProcedurePerformedSchema;
2060
2168
  module.exports.ProcedurePerformed = mongoose.model('ProcedurePerformed', ProcedurePerformedSchema);
2061
2169
 
2062
- },{"./Component":10,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],57:[function(require,module,exports){
2170
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],57:[function(require,module,exports){
2063
2171
  const mongoose = require('mongoose');
2064
2172
  const { DataElementSchema } = require('./basetypes/DataElement');
2065
2173
  const Code = require('./basetypes/Code');
2066
2174
  const Interval = require('./basetypes/Interval');
2067
2175
  const Quantity = require('./basetypes/Quantity');
2068
2176
  const DateTime = require('./basetypes/DateTime');
2177
+ const { ComponentSchema } = require('./Component');
2178
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2069
2179
  const Any = require('./basetypes/Any');
2070
2180
 
2071
2181
  const [Number, String] = [
@@ -2092,13 +2202,15 @@ const ProcedureRecommendedSchema = DataElementSchema({
2092
2202
  module.exports.ProcedureRecommendedSchema = ProcedureRecommendedSchema;
2093
2203
  module.exports.ProcedureRecommended = mongoose.model('ProcedureRecommended', ProcedureRecommendedSchema);
2094
2204
 
2095
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],58:[function(require,module,exports){
2205
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],58:[function(require,module,exports){
2096
2206
  const mongoose = require('mongoose');
2097
2207
  const { DataElementSchema } = require('./basetypes/DataElement');
2098
2208
  const Code = require('./basetypes/Code');
2099
2209
  const Interval = require('./basetypes/Interval');
2100
2210
  const Quantity = require('./basetypes/Quantity');
2101
2211
  const DateTime = require('./basetypes/DateTime');
2212
+ const { ComponentSchema } = require('./Component');
2213
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2102
2214
  const Any = require('./basetypes/Any');
2103
2215
 
2104
2216
  const [Number, String] = [
@@ -2118,13 +2230,15 @@ const ProviderCareExperienceSchema = DataElementSchema({
2118
2230
  module.exports.ProviderCareExperienceSchema = ProviderCareExperienceSchema;
2119
2231
  module.exports.ProviderCareExperience = mongoose.model('ProviderCareExperience', ProviderCareExperienceSchema);
2120
2232
 
2121
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],59:[function(require,module,exports){
2233
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],59:[function(require,module,exports){
2122
2234
  const mongoose = require('mongoose');
2123
2235
  const { DataElementSchema } = require('./basetypes/DataElement');
2124
2236
  const Code = require('./basetypes/Code');
2125
2237
  const Interval = require('./basetypes/Interval');
2126
2238
  const Quantity = require('./basetypes/Quantity');
2127
2239
  const DateTime = require('./basetypes/DateTime');
2240
+ const { ComponentSchema } = require('./Component');
2241
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2128
2242
  const Any = require('./basetypes/Any');
2129
2243
 
2130
2244
  const [Number, String] = [
@@ -2144,13 +2258,15 @@ const ProviderCharacteristicSchema = DataElementSchema({
2144
2258
  module.exports.ProviderCharacteristicSchema = ProviderCharacteristicSchema;
2145
2259
  module.exports.ProviderCharacteristic = mongoose.model('ProviderCharacteristic', ProviderCharacteristicSchema);
2146
2260
 
2147
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],60:[function(require,module,exports){
2261
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],60:[function(require,module,exports){
2148
2262
  const mongoose = require('mongoose');
2149
2263
  const { DataElementSchema } = require('./basetypes/DataElement');
2150
2264
  const Code = require('./basetypes/Code');
2151
2265
  const Interval = require('./basetypes/Interval');
2152
2266
  const Quantity = require('./basetypes/Quantity');
2153
2267
  const DateTime = require('./basetypes/DateTime');
2268
+ const { ComponentSchema } = require('./Component');
2269
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2154
2270
  const Any = require('./basetypes/Any');
2155
2271
 
2156
2272
  const [Number, String] = [
@@ -2169,7 +2285,7 @@ const RatioSchema = DataElementSchema({
2169
2285
  module.exports.RatioSchema = RatioSchema;
2170
2286
  module.exports.Ratio = mongoose.model('Ratio', RatioSchema);
2171
2287
 
2172
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],61:[function(require,module,exports){
2288
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],61:[function(require,module,exports){
2173
2289
  const mongoose = require('mongoose');
2174
2290
 
2175
2291
  const PlaceholderResultSchema = mongoose.Schema({
@@ -2206,6 +2322,8 @@ const Code = require('./basetypes/Code');
2206
2322
  const Interval = require('./basetypes/Interval');
2207
2323
  const Quantity = require('./basetypes/Quantity');
2208
2324
  const DateTime = require('./basetypes/DateTime');
2325
+
2326
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2209
2327
  const Any = require('./basetypes/Any');
2210
2328
 
2211
2329
  const [Number, String] = [
@@ -2223,13 +2341,15 @@ const ResultComponentSchema = DataElementSchema({
2223
2341
  module.exports.ResultComponentSchema = ResultComponentSchema;
2224
2342
  module.exports.ResultComponent = mongoose.model('ResultComponent', ResultComponentSchema);
2225
2343
 
2226
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],63:[function(require,module,exports){
2344
+ },{"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],63:[function(require,module,exports){
2227
2345
  const mongoose = require('mongoose');
2228
2346
  const { DataElementSchema } = require('./basetypes/DataElement');
2229
2347
  const Code = require('./basetypes/Code');
2230
2348
  const Interval = require('./basetypes/Interval');
2231
2349
  const Quantity = require('./basetypes/Quantity');
2232
2350
  const DateTime = require('./basetypes/DateTime');
2351
+ const { ComponentSchema } = require('./Component');
2352
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2233
2353
  const Any = require('./basetypes/Any');
2234
2354
 
2235
2355
  const [Number, String] = [
@@ -2256,13 +2376,15 @@ const SubstanceAdministeredSchema = DataElementSchema({
2256
2376
  module.exports.SubstanceAdministeredSchema = SubstanceAdministeredSchema;
2257
2377
  module.exports.SubstanceAdministered = mongoose.model('SubstanceAdministered', SubstanceAdministeredSchema);
2258
2378
 
2259
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],64:[function(require,module,exports){
2379
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],64:[function(require,module,exports){
2260
2380
  const mongoose = require('mongoose');
2261
2381
  const { DataElementSchema } = require('./basetypes/DataElement');
2262
2382
  const Code = require('./basetypes/Code');
2263
2383
  const Interval = require('./basetypes/Interval');
2264
2384
  const Quantity = require('./basetypes/Quantity');
2265
2385
  const DateTime = require('./basetypes/DateTime');
2386
+ const { ComponentSchema } = require('./Component');
2387
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2266
2388
  const Any = require('./basetypes/Any');
2267
2389
 
2268
2390
  const [Number, String] = [
@@ -2291,13 +2413,15 @@ const SubstanceOrderSchema = DataElementSchema({
2291
2413
  module.exports.SubstanceOrderSchema = SubstanceOrderSchema;
2292
2414
  module.exports.SubstanceOrder = mongoose.model('SubstanceOrder', SubstanceOrderSchema);
2293
2415
 
2294
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],65:[function(require,module,exports){
2416
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],65:[function(require,module,exports){
2295
2417
  const mongoose = require('mongoose');
2296
2418
  const { DataElementSchema } = require('./basetypes/DataElement');
2297
2419
  const Code = require('./basetypes/Code');
2298
2420
  const Interval = require('./basetypes/Interval');
2299
2421
  const Quantity = require('./basetypes/Quantity');
2300
2422
  const DateTime = require('./basetypes/DateTime');
2423
+ const { ComponentSchema } = require('./Component');
2424
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2301
2425
  const Any = require('./basetypes/Any');
2302
2426
 
2303
2427
  const [Number, String] = [
@@ -2326,13 +2450,15 @@ const SubstanceRecommendedSchema = DataElementSchema({
2326
2450
  module.exports.SubstanceRecommendedSchema = SubstanceRecommendedSchema;
2327
2451
  module.exports.SubstanceRecommended = mongoose.model('SubstanceRecommended', SubstanceRecommendedSchema);
2328
2452
 
2329
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],66:[function(require,module,exports){
2453
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],66:[function(require,module,exports){
2330
2454
  const mongoose = require('mongoose');
2331
2455
  const { DataElementSchema } = require('./basetypes/DataElement');
2332
2456
  const Code = require('./basetypes/Code');
2333
2457
  const Interval = require('./basetypes/Interval');
2334
2458
  const Quantity = require('./basetypes/Quantity');
2335
2459
  const DateTime = require('./basetypes/DateTime');
2460
+ const { ComponentSchema } = require('./Component');
2461
+ const { FacilityLocationSchema } = require('./FacilityLocation');
2336
2462
  const Any = require('./basetypes/Any');
2337
2463
 
2338
2464
  const [Number, String] = [
@@ -2354,7 +2480,7 @@ const SymptomSchema = DataElementSchema({
2354
2480
  module.exports.SymptomSchema = SymptomSchema;
2355
2481
  module.exports.Symptom = mongoose.model('Symptom', SymptomSchema);
2356
2482
 
2357
- },{"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],67:[function(require,module,exports){
2483
+ },{"./Component":10,"./FacilityLocation":22,"./basetypes/Any":68,"./basetypes/Code":69,"./basetypes/DataElement":70,"./basetypes/DateTime":71,"./basetypes/Interval":72,"./basetypes/Quantity":73,"mongoose":402}],67:[function(require,module,exports){
2358
2484
  const mongoose = require('mongoose');
2359
2485
  const Concept = require('./Concept.js');
2360
2486
 
@@ -2399,6 +2525,21 @@ function RecursiveCast(any) {
2399
2525
  if (any && any.value && any.unit) {
2400
2526
  return new cql.Quantity(any);
2401
2527
  }
2528
+ if (any && any.code && any.codeSystem) {
2529
+ if (typeof any.code === 'undefined') {
2530
+ throw new Error(`Code: ${any} does not have a code`);
2531
+ } else if (typeof any.codeSystem === 'undefined') {
2532
+ throw new Error(`Code: ${any} does not have a codeSystem`);
2533
+ }
2534
+
2535
+ const val = { code: any.code, codeSystem: any.codeSystem };
2536
+
2537
+ val.descriptor = (typeof any.descriptor !== 'undefined') ? any.descriptor : null;
2538
+ val.codeSystemOid = (typeof any.codeSystemOid !== 'undefined') ? any.codeSystemOid : null;
2539
+ val.version = (typeof any.version !== 'undefined') ? any.version : null;
2540
+
2541
+ return new cql.Code(val.code, val.codeSystem, val.version, val.descriptor);
2542
+ }
2402
2543
  if (any && any.low) {
2403
2544
  const casted = new cql.Interval(any.low, any.high, any.lowClosed, any.highClosed);
2404
2545
 
@@ -2443,6 +2584,7 @@ module.exports = Any;
2443
2584
 
2444
2585
  },{"cql-execution":151,"mongoose":402}],69:[function(require,module,exports){
2445
2586
  const mongoose = require('mongoose');
2587
+ const cql = require('cql-execution');
2446
2588
 
2447
2589
  function Code(key, options) {
2448
2590
  mongoose.SchemaType.call(this, key, options, 'Code');
@@ -2450,33 +2592,43 @@ function Code(key, options) {
2450
2592
  Code.prototype = Object.create(mongoose.SchemaType.prototype);
2451
2593
 
2452
2594
  Code.prototype.cast = (code) => {
2453
- if (typeof code.code === 'undefined') {
2454
- throw new Error(`Code: ${code} does not have a code`);
2455
- } else if (typeof code.codeSystem === 'undefined') {
2456
- throw new Error(`Code: ${code} does not have a codeSystem`);
2457
- }
2595
+ if (code != null) {
2596
+ // handles codes that have not yet been cast to a code and those that have already been cast to a code
2597
+ if (code.code && (code.codeSystem || code.system)) {
2598
+ if (typeof code.code === 'undefined') {
2599
+ throw new Error(`Code: ${code} does not have a code`);
2600
+ } else if (typeof code.codeSystem === 'undefined' && typeof code.system === 'undefined') {
2601
+ throw new Error(`Code: ${code} does not have a system`);
2602
+ }
2458
2603
 
2459
- const val = { code: code.code, codeSystem: code.codeSystem };
2604
+ const val = { code: code.code, codeSystem: code.codeSystem || code.system };
2460
2605
 
2461
- val.descriptor = (typeof code.descriptor !== 'undefined') ? code.descriptor : null;
2462
- val.codeSystemOid = (typeof code.codeSystemOid !== 'undefined') ? code.codeSystemOid : null;
2463
- val.version = (typeof code.version !== 'undefined') ? code.version : null;
2606
+ val.descriptor = (typeof code.descriptor !== 'undefined') ? code.descriptor : null;
2607
+ val.codeSystemOid = (typeof code.codeSystemOid !== 'undefined') ? code.codeSystemOid : null;
2608
+ val.version = (typeof code.version !== 'undefined') ? code.version : null;
2464
2609
 
2465
- return val;
2610
+ return new cql.Code(val.code, val.codeSystem, val.version, val.descriptor);
2611
+ }
2612
+ throw new Error(`Expected a code. Received ${code}.`);
2613
+ } else {
2614
+ // returns a null or undefined if what is passed in is null or undefined
2615
+ return code;
2616
+ }
2466
2617
  };
2467
2618
 
2468
2619
  mongoose.Schema.Types.Code = Code;
2469
2620
  module.exports = Code;
2470
2621
 
2471
- },{"mongoose":402}],70:[function(require,module,exports){
2622
+ },{"cql-execution":151,"mongoose":402}],70:[function(require,module,exports){
2472
2623
  const mongoose = require('mongoose');
2473
2624
  const Code = require('./Code.js');
2625
+ const cql = require('cql-execution');
2474
2626
 
2475
2627
  const [Schema] = [mongoose.Schema];
2476
2628
 
2477
2629
  function DataElementSchema(add, options) {
2478
2630
  const extended = new Schema({
2479
- dataElementCodes: { type: [Code] },
2631
+ dataElementCodes: { type: [] },
2480
2632
  description: { type: String },
2481
2633
  }, options);
2482
2634
 
@@ -2484,21 +2636,20 @@ function DataElementSchema(add, options) {
2484
2636
  extended.add(add);
2485
2637
  }
2486
2638
 
2487
- // Returns all of the codes on this data element
2488
- // in a format usable by the cql-execution framework
2639
+ // Returns all of the codes on this data element in a format usable by
2640
+ // the cql-execution framework.
2489
2641
  extended.methods.getCode = function getCode() {
2490
- return this.dataElementCodes.map((code) => {
2491
- const result = {};
2492
- result.code = code.code;
2493
- result.system = code.code_system;
2494
- return result;
2495
- });
2642
+ return this.dataElementCodes.map(code => new cql.Code(code.code, code.codeSystem, code.version, code.descriptor));
2496
2643
  };
2497
2644
 
2498
- // Returns all of the codes on this data element
2499
- // in their normal form.
2500
- extended.methods.codes = function getCodes() {
2501
- return this.dataElementCodes;
2645
+ // Return the first code on this data element in a format usable by
2646
+ // the cql-execution framework.
2647
+ extended.methods.code = function code() {
2648
+ if (this.dataElementCodes && this.dataElementCodes[0]) {
2649
+ const qdmCode = this.dataElementCodes[0];
2650
+ return new cql.Code(qdmCode.code, qdmCode.codeSystem, qdmCode.version, qdmCode.descriptor);
2651
+ }
2652
+ return null;
2502
2653
  };
2503
2654
 
2504
2655
  return extended;
@@ -2506,7 +2657,7 @@ function DataElementSchema(add, options) {
2506
2657
 
2507
2658
  module.exports.DataElementSchema = DataElementSchema;
2508
2659
 
2509
- },{"./Code.js":69,"mongoose":402}],71:[function(require,module,exports){
2660
+ },{"./Code.js":69,"cql-execution":151,"mongoose":402}],71:[function(require,module,exports){
2510
2661
  const mongoose = require('mongoose');
2511
2662
  const cql = require('cql-execution');
2512
2663
 
@@ -25836,7 +25987,7 @@ function objectToString(o) {
25836
25987
  },{"./clinical":152,"./datetime":154,"./interval":156,"./logic":157,"./uncertainty":158}],154:[function(require,module,exports){
25837
25988
  // Generated by CoffeeScript 1.12.7
25838
25989
  (function() {
25839
- var DateTime, Uncertainty, moment;
25990
+ var DateTime, Uncertainty, cqlFormatStringToMomentFormatString, getTimezoneSeparatorFromString, isValidDateTimeStringFormat, moment, normalizeMillisecondsField, normalizeMillisecondsFieldInString;
25840
25991
 
25841
25992
  Uncertainty = require('./uncertainty').Uncertainty;
25842
25993
 
@@ -25857,36 +26008,51 @@ function objectToString(o) {
25857
26008
  DateTime.FIELDS = [DateTime.Unit.YEAR, DateTime.Unit.MONTH, DateTime.Unit.DAY, DateTime.Unit.HOUR, DateTime.Unit.MINUTE, DateTime.Unit.SECOND, DateTime.Unit.MILLISECOND];
25858
26009
 
25859
26010
  DateTime.parse = function(string) {
25860
- var arg, args, match, num, regex;
25861
- match = regex = /(\d{4})(-(\d{2}))?(-(\d{2}))?(T((\d{2})(\:(\d{2})(\:(\d{2})(\.(\d+))?)?)?)?(Z|(([+-])(\d{2})(\:?(\d{2}))?))?)?/.exec(string);
25862
- if ((match != null ? match[0] : void 0) === string) {
25863
- args = [match[1], match[3], match[5], match[8], match[10], match[12], match[14]];
25864
- if (args[6] != null) {
25865
- args[6] = (args[6] + "00").substring(0, 3);
25866
- }
25867
- args = (function() {
25868
- var i, len, results;
25869
- results = [];
25870
- for (i = 0, len = args.length; i < len; i++) {
25871
- arg = args[i];
25872
- results.push(arg != null ? parseInt(arg, 10) : void 0);
25873
- }
25874
- return results;
25875
- })();
25876
- if (match[18] != null) {
25877
- num = parseInt(match[18], 10) + (match[20] != null ? parseInt(match[20], 10) / 60 : 0);
25878
- args.push(match[17] === '+' ? num : num * -1);
25879
- } else if (match[15] === 'Z') {
25880
- args.push(0);
25881
- }
25882
- return (function(func, args, ctor) {
25883
- ctor.prototype = func.prototype;
25884
- var child = new ctor, result = func.apply(child, args);
25885
- return Object(result) === result ? result : child;
25886
- })(DateTime, args, function(){});
25887
- } else {
26011
+ var arg, args, days, hours, matches, milliseconds, minutes, months, num, seconds, years;
26012
+ if (string === null) {
25888
26013
  return null;
25889
26014
  }
26015
+ matches = /(\d{4})(-(\d{2}))?(-(\d{2}))?(T((\d{2})(\:(\d{2})(\:(\d{2})(\.(\d+))?)?)?)?(Z|(([+-])(\d{2})(\:?(\d{2}))?))?)?/.exec(string);
26016
+ if (matches == null) {
26017
+ throw new Error('Invalid DateTime String: ' + string);
26018
+ }
26019
+ years = matches[1];
26020
+ months = matches[3];
26021
+ days = matches[5];
26022
+ hours = matches[8];
26023
+ minutes = matches[10];
26024
+ seconds = matches[12];
26025
+ milliseconds = matches[14];
26026
+ if (milliseconds != null) {
26027
+ milliseconds = normalizeMillisecondsField(milliseconds);
26028
+ }
26029
+ if (milliseconds != null) {
26030
+ string = normalizeMillisecondsFieldInString(string, matches);
26031
+ }
26032
+ if (!isValidDateTimeStringFormat(string)) {
26033
+ throw new Error('Invalid DateTime String: ' + string);
26034
+ }
26035
+ args = [years, months, days, hours, minutes, seconds, milliseconds];
26036
+ args = (function() {
26037
+ var i, len, results;
26038
+ results = [];
26039
+ for (i = 0, len = args.length; i < len; i++) {
26040
+ arg = args[i];
26041
+ results.push(arg != null ? parseInt(arg, 10) : void 0);
26042
+ }
26043
+ return results;
26044
+ })();
26045
+ if (matches[18] != null) {
26046
+ num = parseInt(matches[18], 10) + (matches[20] != null ? parseInt(matches[20], 10) / 60 : 0);
26047
+ args.push(matches[17] === '+' ? num : num * -1);
26048
+ } else if (matches[15] === 'Z') {
26049
+ args.push(0);
26050
+ }
26051
+ return (function(func, args, ctor) {
26052
+ ctor.prototype = func.prototype;
26053
+ var child = new ctor, result = func.apply(child, args);
26054
+ return Object(result) === result ? result : child;
26055
+ })(DateTime, args, function(){});
25890
26056
  };
25891
26057
 
25892
26058
  DateTime.fromDate = function(date, timezoneOffset) {
@@ -26399,6 +26565,72 @@ function objectToString(o) {
26399
26565
 
26400
26566
  })();
26401
26567
 
26568
+ normalizeMillisecondsFieldInString = function(string, matches) {
26569
+ var beforeMs, msAndAfter, msString, ref, timezoneField, timezoneSeparator;
26570
+ msString = matches[14];
26571
+ msString = normalizeMillisecondsField(msString);
26572
+ ref = string.split('.'), beforeMs = ref[0], msAndAfter = ref[1];
26573
+ timezoneSeparator = getTimezoneSeparatorFromString(msAndAfter);
26574
+ if (!!timezoneSeparator) {
26575
+ timezoneField = msAndAfter != null ? msAndAfter.split(timezoneSeparator)[1] : void 0;
26576
+ }
26577
+ if (timezoneField == null) {
26578
+ timezoneField = '';
26579
+ }
26580
+ return string = beforeMs + '.' + msString + timezoneSeparator + timezoneField;
26581
+ };
26582
+
26583
+ normalizeMillisecondsField = function(msString) {
26584
+ return msString = (msString + "00").substring(0, 3);
26585
+ };
26586
+
26587
+ isValidDateTimeStringFormat = function(string) {
26588
+ var cqlFormatStringWithLength, cqlFormats, format, i, len, strict;
26589
+ if (typeof string !== 'string') {
26590
+ return false;
26591
+ }
26592
+ cqlFormats = ['YYYY', 'YYYY-MM', 'YYYY-MM-DD', 'YYYY-MM-DDTZ', 'YYYY-MM-DDT+hh', 'YYYY-MM-DDT+hh:mm', 'YYYY-MM-DDT-hh', 'YYYY-MM-DDT-hh:mm', 'YYYY-MM-DDThh', 'YYYY-MM-DDThhZ', 'YYYY-MM-DDThh+hh', 'YYYY-MM-DDThh+hh:mm', 'YYYY-MM-DDThh-hh', 'YYYY-MM-DDThh-hh:mm', 'YYYY-MM-DDThh:mm', 'YYYY-MM-DDThh:mmZ', 'YYYY-MM-DDThh:mm+hh', 'YYYY-MM-DDThh:mm+hh:mm', 'YYYY-MM-DDThh:mm-hh', 'YYYY-MM-DDThh:mm-hh:mm', 'YYYY-MM-DDThh:mm:ss', 'YYYY-MM-DDThh:mm:ssZ', 'YYYY-MM-DDThh:mm:ss+hh', 'YYYY-MM-DDThh:mm:ss+hh:mm', 'YYYY-MM-DDThh:mm:ss-hh', 'YYYY-MM-DDThh:mm:ss-hh:mm', 'YYYY-MM-DDThh:mm:ss.fff', 'YYYY-MM-DDThh:mm:ss.fffZ', 'YYYY-MM-DDThh:mm:ss.fff+hh', 'YYYY-MM-DDThh:mm:ss.fff+hh:mm', 'YYYY-MM-DDThh:mm:ss.fff-hh', 'YYYY-MM-DDThh:mm:ss.fff-hh:mm'];
26593
+ cqlFormatStringWithLength = {};
26594
+ for (i = 0, len = cqlFormats.length; i < len; i++) {
26595
+ format = cqlFormats[i];
26596
+ cqlFormatStringWithLength[format.length] = format;
26597
+ }
26598
+ if (cqlFormatStringWithLength[string.length] == null) {
26599
+ return false;
26600
+ }
26601
+ strict = false;
26602
+ return moment(string, cqlFormatStringToMomentFormatString(cqlFormatStringWithLength[string.length]), strict).isValid();
26603
+ };
26604
+
26605
+ cqlFormatStringToMomentFormatString = function(string) {
26606
+ var momentString, ref, timeAndTimeZoneOffset, timezoneSeparator, yearMonthDay;
26607
+ ref = string.split('T'), yearMonthDay = ref[0], timeAndTimeZoneOffset = ref[1];
26608
+ if (timeAndTimeZoneOffset != null) {
26609
+ timezoneSeparator = getTimezoneSeparatorFromString(timeAndTimeZoneOffset);
26610
+ }
26611
+ momentString = yearMonthDay;
26612
+ if (string.match(/T/) != null) {
26613
+ momentString += '[T]';
26614
+ }
26615
+ if (!!timezoneSeparator) {
26616
+ momentString += timeAndTimeZoneOffset.substring(0, timeAndTimeZoneOffset.search(timezoneSeparator)) + '[Z]';
26617
+ } else {
26618
+ momentString += timeAndTimeZoneOffset;
26619
+ }
26620
+ return momentString = momentString.replace(/f/g, 'S');
26621
+ };
26622
+
26623
+ getTimezoneSeparatorFromString = function(string) {
26624
+ var ref, ref1, timezoneSeparator;
26625
+ if ((string != null ? (ref = string.match(/-/)) != null ? ref.length : void 0 : void 0) === 1) {
26626
+ return timezoneSeparator = '-';
26627
+ } else if ((string != null ? (ref1 = string.match(/\+/)) != null ? ref1.length : void 0 : void 0) === 1) {
26628
+ return timezoneSeparator = '+';
26629
+ } else {
26630
+ return timezoneSeparator = '';
26631
+ }
26632
+ };
26633
+
26402
26634
  }).call(this);
26403
26635
 
26404
26636
 
@@ -28216,20 +28448,14 @@ function objectToString(o) {
28216
28448
  }
28217
28449
 
28218
28450
  Less.prototype.exec = function(ctx) {
28219
- var args, error;
28451
+ var args;
28220
28452
  args = this.execArgs(ctx).map(function(x) {
28221
28453
  return Uncertainty.from(x);
28222
28454
  });
28223
- try {
28224
- return args[0].lessThan(args[1]);
28225
- } catch (error1) {
28226
- error = error1;
28227
- if (error instanceof IncompatibleTypesException) {
28228
- return null;
28229
- } else {
28230
- throw error;
28231
- }
28455
+ if (!((args[0] != null) && (args[1] != null))) {
28456
+ return null;
28232
28457
  }
28458
+ return args[0].lessThan(args[1]);
28233
28459
  };
28234
28460
 
28235
28461
  return Less;
@@ -28244,20 +28470,14 @@ function objectToString(o) {
28244
28470
  }
28245
28471
 
28246
28472
  LessOrEqual.prototype.exec = function(ctx) {
28247
- var args, error;
28473
+ var args;
28248
28474
  args = this.execArgs(ctx).map(function(x) {
28249
28475
  return Uncertainty.from(x);
28250
28476
  });
28251
- try {
28252
- return args[0].lessThanOrEquals(args[1]);
28253
- } catch (error1) {
28254
- error = error1;
28255
- if (error instanceof IncompatibleTypesException) {
28256
- return null;
28257
- } else {
28258
- throw error;
28259
- }
28477
+ if (!((args[0] != null) && (args[1] != null))) {
28478
+ return null;
28260
28479
  }
28480
+ return args[0].lessThanOrEquals(args[1]);
28261
28481
  };
28262
28482
 
28263
28483
  return LessOrEqual;
@@ -28272,20 +28492,14 @@ function objectToString(o) {
28272
28492
  }
28273
28493
 
28274
28494
  Greater.prototype.exec = function(ctx) {
28275
- var args, error;
28495
+ var args;
28276
28496
  args = this.execArgs(ctx).map(function(x) {
28277
28497
  return Uncertainty.from(x);
28278
28498
  });
28279
- try {
28280
- return args[0].greaterThan(args[1]);
28281
- } catch (error1) {
28282
- error = error1;
28283
- if (error instanceof IncompatibleTypesException) {
28284
- return null;
28285
- } else {
28286
- throw error;
28287
- }
28499
+ if (!((args[0] != null) && (args[1] != null))) {
28500
+ return null;
28288
28501
  }
28502
+ return args[0].greaterThan(args[1]);
28289
28503
  };
28290
28504
 
28291
28505
  return Greater;
@@ -28300,20 +28514,14 @@ function objectToString(o) {
28300
28514
  }
28301
28515
 
28302
28516
  GreaterOrEqual.prototype.exec = function(ctx) {
28303
- var args, error;
28517
+ var args;
28304
28518
  args = this.execArgs(ctx).map(function(x) {
28305
28519
  return Uncertainty.from(x);
28306
28520
  });
28307
- try {
28308
- return args[0].greaterThanOrEquals(args[1]);
28309
- } catch (error1) {
28310
- error = error1;
28311
- if (error instanceof IncompatibleTypesException) {
28312
- return null;
28313
- } else {
28314
- throw error;
28315
- }
28521
+ if (!((args[0] != null) && (args[1] != null))) {
28522
+ return null;
28316
28523
  }
28524
+ return args[0].greaterThanOrEquals(args[1]);
28317
28525
  };
28318
28526
 
28319
28527
  return GreaterOrEqual;
@@ -30350,17 +30558,12 @@ function objectToString(o) {
30350
30558
  }
30351
30559
 
30352
30560
  Equal.prototype.exec = function(ctx) {
30353
- var error;
30354
- try {
30355
- return equals.apply(null, this.execArgs(ctx));
30356
- } catch (error1) {
30357
- error = error1;
30358
- if (error instanceof IncompatibleTypesException) {
30359
- return null;
30360
- } else {
30361
- throw error;
30362
- }
30561
+ var args;
30562
+ args = this.execArgs(ctx);
30563
+ if (!((args[0] != null) && (args[1] != null))) {
30564
+ return null;
30363
30565
  }
30566
+ return equals.apply(null, this.execArgs(ctx));
30364
30567
  };
30365
30568
 
30366
30569
  return Equal;
@@ -30398,17 +30601,12 @@ function objectToString(o) {
30398
30601
  }
30399
30602
 
30400
30603
  NotEqual.prototype.exec = function(ctx) {
30401
- var error;
30402
- try {
30403
- return ThreeValuedLogic.not(equals.apply(null, this.execArgs(ctx)));
30404
- } catch (error1) {
30405
- error = error1;
30406
- if (error instanceof IncompatibleTypesException) {
30407
- return null;
30408
- } else {
30409
- throw error;
30410
- }
30604
+ var args;
30605
+ args = this.execArgs(ctx);
30606
+ if (!((args[0] != null) && (args[1] != null))) {
30607
+ return null;
30411
30608
  }
30609
+ return ThreeValuedLogic.not(equals.apply(null, this.execArgs(ctx)));
30412
30610
  };
30413
30611
 
30414
30612
  return NotEqual;
@@ -30849,7 +31047,7 @@ function objectToString(o) {
30849
31047
  },{"./builder":161,"./expression":167}],179:[function(require,module,exports){
30850
31048
  // Generated by CoffeeScript 1.12.7
30851
31049
  (function() {
30852
- var Code, Exception, Expression, FunctionRef, IncompatibleTypesException, Quantity, ValueSet, build, clean_unit, convert_value, createQuantity, decimalAdjust, is_valid_ucum_unit, ref, ucum, ucum_multiply, ucum_time_units, ucum_to_cql_units, ucum_unit, unitValidityCache, units_to_string,
31050
+ var Code, Exception, Expression, FunctionRef, IncompatibleTypesException, Quantity, ValueSet, build, clean_unit, convert_value, createQuantity, decimalAdjust, isValidDecimal, is_valid_ucum_unit, ref, ref1, ucum, ucum_multiply, ucum_time_units, ucum_to_cql_units, ucum_unit, unitValidityCache, units_to_string,
30853
31051
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
30854
31052
  hasProp = {}.hasOwnProperty;
30855
31053
 
@@ -30857,9 +31055,9 @@ function objectToString(o) {
30857
31055
 
30858
31056
  FunctionRef = require('./reusable').FunctionRef;
30859
31057
 
30860
- decimalAdjust = require('../util/math').decimalAdjust;
31058
+ ref = require('../util/math'), decimalAdjust = ref.decimalAdjust, isValidDecimal = ref.isValidDecimal;
30861
31059
 
30862
- ref = require('../datatypes/datatypes'), ValueSet = ref.ValueSet, Code = ref.Code;
31060
+ ref1 = require('../datatypes/datatypes'), ValueSet = ref1.ValueSet, Code = ref1.Code;
30863
31061
 
30864
31062
  Exception = require('../datatypes/exception').Exception;
30865
31063
 
@@ -30886,8 +31084,13 @@ function objectToString(o) {
30886
31084
  function Quantity(json) {
30887
31085
  Quantity.__super__.constructor.apply(this, arguments);
30888
31086
  this.unit = json.unit;
30889
- this.value = parseFloat(json.value);
30890
- if (!is_valid_ucum_unit(this.unit)) {
31087
+ if (json.value == null) {
31088
+ this.value = null;
31089
+ } else {
31090
+ this.value = parseFloat(json.value);
31091
+ isValidDecimal(this.value);
31092
+ }
31093
+ if ((this.unit != null) && !is_valid_ucum_unit(this.unit)) {
30891
31094
  throw new Error("\'" + this.unit + "\' is not a valid UCUM unit.");
30892
31095
  }
30893
31096
  }
@@ -31105,15 +31308,15 @@ function objectToString(o) {
31105
31308
  module.exports.convert_value = convert_value;
31106
31309
 
31107
31310
  units_to_string = function(units) {
31108
- var denom, i, key, len, numer, pow, ref1, str, unit_string, v;
31311
+ var denom, i, key, len, numer, pow, ref2, str, unit_string, v;
31109
31312
  if (units == null) {
31110
31313
  units = {};
31111
31314
  }
31112
31315
  numer = [];
31113
31316
  denom = [];
31114
- ref1 = Object.keys(units);
31115
- for (i = 0, len = ref1.length; i < len; i++) {
31116
- key = ref1[i];
31317
+ ref2 = Object.keys(units);
31318
+ for (i = 0, len = ref2.length; i < len; i++) {
31319
+ key = ref2[i];
31117
31320
  v = units[key];
31118
31321
  pow = Math.abs(v);
31119
31322
  str = pow === 1 ? key : key + pow;
@@ -31136,7 +31339,7 @@ function objectToString(o) {
31136
31339
  };
31137
31340
 
31138
31341
  ucum_multiply = function(t, ms) {
31139
- var b, i, k, len, mterm, ref1, ret, sign, v;
31342
+ var b, i, k, len, mterm, ref2, ret, sign, v;
31140
31343
  if (ms == null) {
31141
31344
  ms = [];
31142
31345
  }
@@ -31149,9 +31352,9 @@ function objectToString(o) {
31149
31352
  sign = mterm[0] === '.' ? 1 : -1;
31150
31353
  b = mterm[1];
31151
31354
  ret.value *= Math.pow(b.value, sign);
31152
- ref1 = b.units;
31153
- for (k in ref1) {
31154
- v = ref1[k];
31355
+ ref2 = b.units;
31356
+ for (k in ref2) {
31357
+ v = ref2[k];
31155
31358
  ret.units[k] = ret.units[k] || 0;
31156
31359
  ret.units[k] = ret.units[k] + sign * v;
31157
31360
  if (ret.units[k] === 0) {
@@ -31171,16 +31374,23 @@ function objectToString(o) {
31171
31374
 
31172
31375
  module.exports.parseQuantity = function(str) {
31173
31376
  var components, unit, value;
31174
- components = /([+|-]?\d+\.?\d*)\s*'(.+)'/.exec(str);
31175
- if ((components != null) && (components[1] != null) && (components[2] != null)) {
31377
+ components = /([+|-]?\d+\.?\d*)\s*('(.+)')?/.exec(str);
31378
+ if ((components != null) && (components[1] != null)) {
31176
31379
  value = parseFloat(components[1]);
31177
- unit = components[2].trim();
31380
+ if (!isValidDecimal(value)) {
31381
+ return null;
31382
+ }
31383
+ if (components[3] != null) {
31384
+ unit = components[3].trim();
31385
+ } else {
31386
+ unit = "";
31387
+ }
31178
31388
  return new Quantity({
31179
31389
  value: value,
31180
31390
  unit: unit
31181
31391
  });
31182
31392
  } else {
31183
- return null;
31393
+ throw new Error("Unable to parse Quantity");
31184
31394
  }
31185
31395
  };
31186
31396
 
@@ -32133,7 +32343,7 @@ function objectToString(o) {
32133
32343
  },{"./builder":161,"./expression":167}],184:[function(require,module,exports){
32134
32344
  // Generated by CoffeeScript 1.12.7
32135
32345
  (function() {
32136
- var As, Concept, Convert, DateTime, Expression, FunctionRef, IntervalTypeSpecifier, Is, ListTypeSpecifier, NamedTypeSpecifier, ToBoolean, ToConcept, ToDateTime, ToDecimal, ToInteger, ToQuantity, ToString, ToTime, TupleTypeSpecifier, UnimplementedExpression, parseQuantity, ref,
32346
+ var As, Concept, Convert, DateTime, Expression, FunctionRef, IntervalTypeSpecifier, Is, ListTypeSpecifier, NamedTypeSpecifier, ToBoolean, ToConcept, ToDateTime, ToDecimal, ToInteger, ToQuantity, ToString, ToTime, TupleTypeSpecifier, UnimplementedExpression, isValidDecimal, isValidInteger, limitDecimalPrecision, parseQuantity, ref, ref1,
32137
32347
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
32138
32348
  hasProp = {}.hasOwnProperty;
32139
32349
 
@@ -32147,15 +32357,17 @@ function objectToString(o) {
32147
32357
 
32148
32358
  parseQuantity = require('./quantity').parseQuantity;
32149
32359
 
32360
+ ref1 = require('../util/math'), isValidDecimal = ref1.isValidDecimal, isValidInteger = ref1.isValidInteger, limitDecimalPrecision = ref1.limitDecimalPrecision;
32361
+
32150
32362
  module.exports.As = As = (function(superClass) {
32151
32363
  extend(As, superClass);
32152
32364
 
32153
32365
  function As(json) {
32154
- var ref1;
32366
+ var ref2;
32155
32367
  As.__super__.constructor.apply(this, arguments);
32156
32368
  this.asType = json.asType;
32157
32369
  this.asTypeSpecifier = json.asTypeSpecifier;
32158
- this.strict = (ref1 = json.strict) != null ? ref1 : false;
32370
+ this.strict = (ref2 = json.strict) != null ? ref2 : false;
32159
32371
  }
32160
32372
 
32161
32373
  As.prototype.exec = function(ctx) {
@@ -32244,10 +32456,14 @@ function objectToString(o) {
32244
32456
  }
32245
32457
 
32246
32458
  ToDecimal.prototype.exec = function(ctx) {
32247
- var arg;
32459
+ var arg, decimal;
32248
32460
  arg = this.execArgs(ctx);
32249
32461
  if ((arg != null) && typeof arg !== 'undefined') {
32250
- return parseFloat(arg.toString());
32462
+ decimal = parseFloat(arg.toString());
32463
+ decimal = limitDecimalPrecision(decimal);
32464
+ if (isValidDecimal(decimal)) {
32465
+ return decimal;
32466
+ }
32251
32467
  } else {
32252
32468
  return null;
32253
32469
  }
@@ -32265,10 +32481,13 @@ function objectToString(o) {
32265
32481
  }
32266
32482
 
32267
32483
  ToInteger.prototype.exec = function(ctx) {
32268
- var arg;
32484
+ var arg, integer;
32269
32485
  arg = this.execArgs(ctx);
32270
32486
  if ((arg != null) && typeof arg !== 'undefined') {
32271
- return parseInt(arg.toString());
32487
+ integer = parseInt(arg.toString());
32488
+ if (isValidInteger(integer)) {
32489
+ return integer;
32490
+ }
32272
32491
  } else {
32273
32492
  return null;
32274
32493
  }
@@ -32286,10 +32505,11 @@ function objectToString(o) {
32286
32505
  }
32287
32506
 
32288
32507
  ToQuantity.prototype.exec = function(ctx) {
32289
- var arg;
32508
+ var arg, quantity;
32290
32509
  arg = this.execArgs(ctx);
32291
32510
  if ((arg != null) && typeof arg !== 'undefined') {
32292
- return parseQuantity(arg.toString());
32511
+ quantity = parseQuantity(arg.toString());
32512
+ return quantity;
32293
32513
  } else {
32294
32514
  return null;
32295
32515
  }
@@ -32465,7 +32685,7 @@ function objectToString(o) {
32465
32685
 
32466
32686
 
32467
32687
 
32468
- },{"../datatypes/clinical":152,"../datatypes/datetime":154,"./expression":167,"./quantity":179,"./reusable":181}],185:[function(require,module,exports){
32688
+ },{"../datatypes/clinical":152,"../datatypes/datetime":154,"../util/math":280,"./expression":167,"./quantity":179,"./reusable":181}],185:[function(require,module,exports){
32469
32689
  // Generated by CoffeeScript 1.12.7
32470
32690
  (function() {
32471
32691
  var Address, Alert, Attachment, BackboneElement, CORE, CodeableConcept, Coding, ContactPoint, DT, DomainResource, Element, ElementDefinition, Extension, HumanName, Identifier, Narrative, Parameters, Period, Quantity, Range, Ratio, Reference, Resource, SampledData, Timing,
@@ -68731,7 +68951,11 @@ function objectToString(o) {
68731
68951
 
68732
68952
  Context.prototype.supportLibraryLocalIds = function(lib, localIdResults) {
68733
68953
  var ref, results, supportLib, supportLibName;
68734
- localIdResults[lib.library.source.library.identifier.id] = lib.localId_context;
68954
+ if (localIdResults[lib.library.source.library.identifier.id] != null) {
68955
+ this.mergeLibraryLocalIdResults(localIdResults, lib.library.source.library.identifier.id, lib.localId_context);
68956
+ } else {
68957
+ localIdResults[lib.library.source.library.identifier.id] = lib.localId_context;
68958
+ }
68735
68959
  ref = lib.library_context;
68736
68960
  results = [];
68737
68961
  for (supportLibName in ref) {
@@ -68741,6 +68965,21 @@ function objectToString(o) {
68741
68965
  return results;
68742
68966
  };
68743
68967
 
68968
+ Context.prototype.mergeLibraryLocalIdResults = function(localIdResults, libraryId, libraryResults) {
68969
+ var existingResult, localId, localIdResult, results;
68970
+ results = [];
68971
+ for (localId in libraryResults) {
68972
+ localIdResult = libraryResults[localId];
68973
+ existingResult = localIdResults[libraryId][localId];
68974
+ if (existingResult === false || existingResult === null || existingResult === void 0 || existingResult.length === 0) {
68975
+ results.push(localIdResults[libraryId][localId] = localIdResult);
68976
+ } else {
68977
+ results.push(void 0);
68978
+ }
68979
+ }
68980
+ return results;
68981
+ };
68982
+
68744
68983
  Context.prototype.checkParameters = function(params) {
68745
68984
  var pDef, pName, pVal;
68746
68985
  for (pName in params) {
@@ -69115,7 +69354,7 @@ function objectToString(o) {
69115
69354
  },{}],279:[function(require,module,exports){
69116
69355
  // Generated by CoffeeScript 1.12.7
69117
69356
  (function() {
69118
- var DateTime, Uncertainty, areDateTimesOrQuantities, areNumbers, classesEqual, codesAreEquivalent, compareEveryItemInArrays, compareObjects, deepCompareKeysAndValues, equals, equivalent, getClassOfObjects, getKeysFromObject, isCode, isUncertainty;
69357
+ var DateTime, Uncertainty, areDateTimesOrQuantities, areNumbers, classesEqual, codesAreEquivalent, compareEveryItemInArrays, compareObjects, deepCompareKeysAndValues, equals, equivalent, getClassOfObjects, getKeysFromObject, isCode, isFunction, isUncertainty;
69119
69358
 
69120
69359
  DateTime = require('../datatypes/datetime').DateTime;
69121
69360
 
@@ -69266,19 +69505,30 @@ function objectToString(o) {
69266
69505
  };
69267
69506
 
69268
69507
  deepCompareKeysAndValues = function(a, b, comparisonFunction) {
69269
- var aKeys, bKeys;
69508
+ var aKeys, bKeys, finalComparisonResult, shouldReturnNull;
69270
69509
  aKeys = getKeysFromObject(a);
69271
69510
  bKeys = getKeysFromObject(b);
69272
- return aKeys.length === bKeys.length && aKeys.every(function(key) {
69273
- return comparisonFunction(a[key], b[key]);
69511
+ shouldReturnNull = false;
69512
+ finalComparisonResult = aKeys.length === bKeys.length && aKeys.every(function(key) {
69513
+ var comparisonResult;
69514
+ comparisonResult = comparisonFunction(a[key], b[key]);
69515
+ if (comparisonResult === null) {
69516
+ shouldReturnNull = true;
69517
+ }
69518
+ return comparisonResult;
69274
69519
  });
69520
+ if (shouldReturnNull) {
69521
+ return null;
69522
+ }
69523
+ return finalComparisonResult;
69275
69524
  };
69276
69525
 
69277
69526
  getKeysFromObject = function(object) {
69278
- var key;
69527
+ var key, objectClass;
69528
+ objectClass = {}.toString.call(object);
69279
69529
  return ((function() {
69280
69530
  var results;
69281
- if (typeof key !== 'function') {
69531
+ if (!isFunction(key)) {
69282
69532
  results = [];
69283
69533
  for (key in object) {
69284
69534
  results.push(key);
@@ -69288,6 +69538,10 @@ function objectToString(o) {
69288
69538
  })());
69289
69539
  };
69290
69540
 
69541
+ isFunction = function(input) {
69542
+ return input instanceof Function || {}.toString.call(input) === '[object Function]';
69543
+ };
69544
+
69291
69545
  module.exports.equals = equals = function(a, b) {
69292
69546
  var aClass, bClass, ref;
69293
69547
  if (!((a != null) && (b != null))) {
@@ -69304,8 +69558,8 @@ function objectToString(o) {
69304
69558
  if (typeof a.equals === 'function') {
69305
69559
  return a.equals(b);
69306
69560
  }
69307
- if (a === b) {
69308
- return true;
69561
+ if (typeof a === typeof b && typeof a === 'string' || typeof a === 'number' || typeof a === 'boolean') {
69562
+ return a === b;
69309
69563
  }
69310
69564
  ref = getClassOfObjects(a, b), aClass = ref[0], bClass = ref[1];
69311
69565
  if (aClass !== bClass) {
@@ -69319,12 +69573,14 @@ function objectToString(o) {
69319
69573
  return a[p] === b[p];
69320
69574
  });
69321
69575
  case '[object Array]':
69322
- if (a.includes(null) || a.includes(void 0) || b.includes(null) || b.includes(void 0)) {
69576
+ if (a.indexOf(null) >= 0 || a.indexOf(void 0) >= 0 || b.indexOf(null) >= 0 || b.indexOf(void 0) >= 0) {
69323
69577
  return null;
69324
69578
  }
69325
69579
  return compareEveryItemInArrays(a, b, equals);
69326
69580
  case '[object Object]':
69327
69581
  return compareObjects(a, b, equals);
69582
+ case '[object Function]':
69583
+ return a === b;
69328
69584
  }
69329
69585
  return false;
69330
69586
  };
@@ -69336,7 +69592,7 @@ function objectToString(o) {
69336
69592
  },{"../datatypes/datetime":154,"../datatypes/uncertainty":158}],280:[function(require,module,exports){
69337
69593
  // Generated by CoffeeScript 1.12.7
69338
69594
  (function() {
69339
- var DateTime, Exception, MAX_DATE_VALUE, MAX_FLOAT_VALUE, MAX_INT_VALUE, MAX_TIME_VALUE, MIN_DATE_VALUE, MIN_FLOAT_PRECISION_VALUE, MIN_FLOAT_VALUE, MIN_INT_VALUE, OverFlowException, Uncertainty, predecessor, successor,
69595
+ var DateTime, Exception, MAX_DATE_VALUE, MAX_FLOAT_VALUE, MAX_INT_VALUE, MAX_TIME_VALUE, MIN_DATE_VALUE, MIN_FLOAT_PRECISION_VALUE, MIN_FLOAT_VALUE, MIN_INT_VALUE, MIN_TIME_VALUE, OverFlowException, Uncertainty, isValidDecimal, isValidInteger, predecessor, successor,
69340
69596
  extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
69341
69597
  hasProp = {}.hasOwnProperty;
69342
69598
 
@@ -69360,10 +69616,50 @@ function objectToString(o) {
69360
69616
 
69361
69617
  module.exports.MAX_DATE_VALUE = MAX_DATE_VALUE = DateTime.parse("9999-12-31T23:59:59.999");
69362
69618
 
69363
- module.exports.MIN_TIME_VALUE = MAX_TIME_VALUE = DateTime.parse("0000-01-01T00:00:00.000");
69619
+ module.exports.MIN_TIME_VALUE = MIN_TIME_VALUE = DateTime.parse("0000-01-01T00:00:00.000");
69364
69620
 
69365
69621
  module.exports.MAX_TIME_VALUE = MAX_TIME_VALUE = DateTime.parse("0000-01-01T23:59:59.999");
69366
69622
 
69623
+ module.exports.isValidInteger = isValidInteger = function(integer) {
69624
+ if (isNaN(integer)) {
69625
+ throw new Error("Unable to parse Integer");
69626
+ }
69627
+ if (integer > MAX_INT_VALUE) {
69628
+ throw new Error("Maximum Integer value exceeded");
69629
+ }
69630
+ if (integer < MIN_INT_VALUE) {
69631
+ throw new Error("Minimum Integer value exceeded");
69632
+ }
69633
+ return true;
69634
+ };
69635
+
69636
+ module.exports.isValidDecimal = isValidDecimal = function(decimal) {
69637
+ if (isNaN(decimal)) {
69638
+ throw new Error("Unable to parse Decimal");
69639
+ }
69640
+ if (decimal > MAX_FLOAT_VALUE) {
69641
+ throw new Error("Maximum Decimal value exceeded");
69642
+ }
69643
+ if (decimal < MIN_FLOAT_VALUE) {
69644
+ throw new Error("Minimum Decimal value exceeded");
69645
+ }
69646
+ return true;
69647
+ };
69648
+
69649
+ module.exports.limitDecimalPrecision = function(decimal) {
69650
+ var decimalPoints, decimalString, splitDecimalString;
69651
+ decimalString = decimal.toString();
69652
+ if (decimalString.indexOf('e') !== -1) {
69653
+ return decimal;
69654
+ }
69655
+ splitDecimalString = decimalString.split('.');
69656
+ decimalPoints = splitDecimalString[1];
69657
+ if ((decimalPoints != null) && decimalPoints.length > 8) {
69658
+ decimalString = splitDecimalString[0] + '.' + splitDecimalString[1].substring(0, 8);
69659
+ }
69660
+ return parseFloat(decimalString);
69661
+ };
69662
+
69367
69663
  module.exports.OverFlowException = OverFlowException = OverFlowException = (function(superClass) {
69368
69664
  extend(OverFlowException, superClass);
69369
69665