@medplum/mock 0.5.2 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -346,14 +346,17 @@
346
346
  valueQuantity: {
347
347
  value: 50,
348
348
  unit: 'x',
349
+ comparator: '>',
349
350
  },
350
351
  referenceRange: [
351
352
  {
352
353
  low: {
353
354
  value: 10,
355
+ unit: 'x',
354
356
  },
355
357
  high: {
356
358
  value: 50,
359
+ unit: 'x',
357
360
  },
358
361
  },
359
362
  ],
@@ -399,6 +402,13 @@
399
402
  },
400
403
  ],
401
404
  };
405
+ const HomerSimpsonSpecimen = {
406
+ resourceType: 'Specimen',
407
+ subject: core.createReference(HomerSimpson),
408
+ collection: {
409
+ collectedDateTime: '2020-01-01T12:00:00Z',
410
+ },
411
+ };
402
412
  const HomerServiceRequest = {
403
413
  resourceType: 'ServiceRequest',
404
414
  id: '123',
@@ -433,6 +443,8 @@
433
443
  text: 'ORDERED',
434
444
  },
435
445
  ],
446
+ specimen: [core.createReference(HomerSimpsonSpecimen)],
447
+ authoredOn: '2020-01-01T12:00:00Z',
436
448
  };
437
449
  const BartSimpson = {
438
450
  resourceType: 'Patient',
@@ -5548,262 +5560,927 @@
5548
5560
  }
5549
5561
  ]
5550
5562
  }
5551
- }
5552
- ];
5553
-
5554
- const PatientSearchParameters = [
5555
- {
5556
- resourceType: 'SearchParameter',
5557
- id: 'Patient-name',
5558
- base: ['Patient'],
5559
- code: 'name',
5560
- name: 'name',
5561
- type: 'string',
5562
- expression: 'Patient.name',
5563
- },
5564
- {
5565
- resourceType: 'SearchParameter',
5566
- id: 'Patient-birthdate',
5567
- base: ['Patient'],
5568
- code: 'birthdate',
5569
- name: 'birthdate',
5570
- type: 'date',
5571
- expression: 'Patient.birthDate',
5572
- },
5573
- {
5574
- resourceType: 'SearchParameter',
5575
- id: 'Patient-organization',
5576
- base: ['Patient'],
5577
- code: 'organization',
5578
- name: 'organization',
5579
- type: 'reference',
5580
- expression: 'Patient.managingOrganization',
5581
- target: ['Organization'],
5582
- },
5583
- {
5584
- resourceType: 'SearchParameter',
5585
- id: 'Patient-active',
5586
- base: ['Patient'],
5587
- code: 'active',
5588
- name: 'active',
5589
- type: 'token',
5590
- expression: 'Patient.active',
5591
- },
5592
- {
5593
- resourceType: 'SearchParameter',
5594
- id: 'individual-telecom',
5595
- base: ['Patient', 'Practitioner'],
5596
- code: 'telecom',
5597
- name: 'telecom',
5598
- type: 'token',
5599
- expression: 'Patient.telecom | Practitioner.telecom',
5600
- },
5601
- {
5602
- resourceType: 'SearchParameter',
5603
- id: 'individual-email',
5604
- base: ['Patient', 'Practitioner'],
5605
- code: 'email',
5606
- name: 'email',
5607
- type: 'token',
5608
- expression: "Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')",
5609
- },
5610
- {
5611
- resourceType: 'SearchParameter',
5612
- id: 'individual-phone',
5613
- base: ['Patient', 'Practitioner'],
5614
- code: 'phone',
5615
- name: 'phone',
5616
- type: 'token',
5617
- expression: "Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')",
5618
- },
5619
- {
5620
- resourceType: 'SearchParameter',
5621
- id: 'individual-address-city',
5622
- base: ['Patient', 'Practitioner'],
5623
- code: 'address-city',
5624
- name: 'address-city',
5625
- type: 'token',
5626
- expression: 'Patient.address.city | Practitioner.address.city',
5627
- },
5628
- {
5629
- resourceType: 'SearchParameter',
5630
- id: 'individual-address-state',
5631
- base: ['Patient', 'Practitioner'],
5632
- code: 'address-state',
5633
- name: 'address-state',
5634
- type: 'token',
5635
- expression: 'Patient.address.state | Practitioner.address.state',
5636
- },
5637
- {
5638
- resourceType: 'SearchParameter',
5639
- id: 'ServiceRequest-subject',
5640
- code: 'subject',
5641
- base: ['ServiceRequest'],
5642
- type: 'reference',
5643
- expression: 'ServiceRequest.subject',
5644
- target: ['Group', 'Device', 'Patient', 'Location'],
5645
- },
5646
- {
5647
- resourceType: 'SearchParameter',
5648
- id: 'Observation-value-quantity',
5649
- code: 'value-quantity',
5650
- base: ['Observation'],
5651
- type: 'quantity',
5652
- expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',
5653
- },
5654
- {
5655
- resourceType: 'SearchParameter',
5656
- id: 'Encounter-length',
5657
- code: 'length',
5658
- base: ['Encounter'],
5659
- type: 'quantity',
5660
- expression: 'Encounter.length',
5661
- },
5662
- ];
5663
- const GraphQLSchemaResponse = {
5664
- data: {
5665
- StructureDefinitionList,
5666
- SearchParameterList: [...PatientSearchParameters],
5667
- },
5668
- };
5669
-
5670
- const exampleValueSet = {
5671
- resourceType: 'ValueSet',
5672
- expansion: {
5673
- contains: [
5674
- {
5675
- system: 'x',
5676
- code: 'test-code',
5677
- display: 'Test Display',
5678
- },
5679
- ],
5680
- },
5681
- };
5682
-
5683
- /*! *****************************************************************************
5684
- Copyright (c) Microsoft Corporation.
5685
-
5686
- Permission to use, copy, modify, and/or distribute this software for any
5687
- purpose with or without fee is hereby granted.
5688
-
5689
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5690
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5691
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5692
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5693
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5694
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5695
- PERFORMANCE OF THIS SOFTWARE.
5696
- ***************************************************************************** */
5697
-
5698
- function __classPrivateFieldGet$1(receiver, state, kind, f) {
5699
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5700
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5701
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5702
- }
5703
-
5704
- function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
5705
- if (kind === "m") throw new TypeError("Private method is not writable");
5706
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5707
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5708
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5709
- }
5710
-
5711
- /*! *****************************************************************************
5712
- Copyright (c) Microsoft Corporation.
5713
-
5714
- Permission to use, copy, modify, and/or distribute this software for any
5715
- purpose with or without fee is hereby granted.
5716
-
5717
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5718
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5719
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5720
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5721
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5722
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5723
- PERFORMANCE OF THIS SOFTWARE.
5724
- ***************************************************************************** */
5725
-
5726
- function __classPrivateFieldGet(receiver, state, kind, f) {
5727
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5728
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5729
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5730
- }
5731
-
5732
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
5733
- if (kind === "m") throw new TypeError("Private method is not writable");
5734
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5735
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5736
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5737
- }
5738
-
5739
- /**
5740
- * Ensures that the value is wrapped in an array.
5741
- * @param input The input as a an array or a value.
5742
- * @returns The input as an array.
5743
- */
5744
- function ensureArray(input) {
5745
- if (input === null || input === undefined) {
5746
- return [];
5747
- }
5748
- return Array.isArray(input) ? input : [input];
5749
- }
5750
- /**
5751
- * Applies a function to single value or an array of values.
5752
- * @param context The context which will be passed to the function.
5753
- * @param fn The function to apply.
5754
- * @returns The result of the function.
5755
- */
5756
- function applyMaybeArray(context, fn) {
5757
- if (context === undefined) {
5758
- return undefined;
5759
- }
5760
- if (Array.isArray(context)) {
5761
- return context
5762
- .map((e) => fn(e))
5763
- .filter((e) => !!e)
5764
- .flat();
5765
- }
5766
- else {
5767
- return fn(context);
5768
- }
5769
- }
5770
- /**
5771
- * Determines if the input is an empty array.
5772
- * @param obj Any value or array of values.
5773
- * @returns True if the input is an empty array.
5774
- */
5775
- function isEmptyArray(obj) {
5776
- return Array.isArray(obj) && obj.length === 0;
5777
- }
5778
- function isFalsy(obj) {
5779
- return !obj || isEmptyArray(obj);
5780
- }
5781
- /**
5782
- * Converts unknown object into a JavaScript boolean.
5783
- * Note that this is different than the FHIRPath "toBoolean",
5784
- * which has particular semantics around arrays, empty arrays, and type conversions.
5785
- * @param obj Any value or array of values.
5786
- * @returns The converted boolean value according to FHIRPath rules.
5787
- */
5788
- function toJsBoolean(obj) {
5789
- if (Array.isArray(obj)) {
5790
- return obj.length === 0 ? false : !!obj[0];
5791
- }
5792
- return !!obj;
5793
- }
5794
- /**
5795
- * Removes duplicates in array using FHIRPath equality rules.
5796
- * @param arr The input array.
5797
- * @returns The result array with duplicates removed.
5798
- */
5799
- function removeDuplicates(arr) {
5800
- const result = [];
5801
- for (const i of arr) {
5802
- let found = false;
5803
- for (const j of result) {
5804
- if (fhirPathEquals(i, j)) {
5805
- found = true;
5806
- break;
5563
+ },
5564
+ {
5565
+ resourceType: "StructureDefinition",
5566
+ id: "Specimen",
5567
+ name: "Specimen",
5568
+ description: "A sample to be used for analysis.",
5569
+ type: "Specimen",
5570
+ snapshot: {
5571
+ element: [
5572
+ {
5573
+ id: "Specimen",
5574
+ path: "Specimen",
5575
+ definition: "A sample to be used for analysis.",
5576
+ min: 0,
5577
+ max: "*"
5578
+ },
5579
+ {
5580
+ id: "Specimen.id",
5581
+ path: "Specimen.id",
5582
+ definition: "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.",
5583
+ min: 0,
5584
+ max: "1",
5585
+ type: [
5586
+ {
5587
+ code: "http://hl7.org/fhirpath/System.String"
5588
+ }
5589
+ ]
5590
+ },
5591
+ {
5592
+ id: "Specimen.meta",
5593
+ path: "Specimen.meta",
5594
+ definition: "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.",
5595
+ min: 0,
5596
+ max: "1",
5597
+ type: [
5598
+ {
5599
+ code: "Meta"
5600
+ }
5601
+ ]
5602
+ },
5603
+ {
5604
+ id: "Specimen.implicitRules",
5605
+ path: "Specimen.implicitRules",
5606
+ definition: "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.",
5607
+ min: 0,
5608
+ max: "1",
5609
+ type: [
5610
+ {
5611
+ code: "uri"
5612
+ }
5613
+ ]
5614
+ },
5615
+ {
5616
+ id: "Specimen.language",
5617
+ path: "Specimen.language",
5618
+ definition: "The base language in which the resource is written.",
5619
+ min: 0,
5620
+ max: "1",
5621
+ type: [
5622
+ {
5623
+ code: "code"
5624
+ }
5625
+ ],
5626
+ binding: {
5627
+ description: "A human language.",
5628
+ valueSet: "http://hl7.org/fhir/ValueSet/languages"
5629
+ }
5630
+ },
5631
+ {
5632
+ id: "Specimen.text",
5633
+ path: "Specimen.text",
5634
+ definition: "A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.",
5635
+ min: 0,
5636
+ max: "1",
5637
+ type: [
5638
+ {
5639
+ code: "Narrative"
5640
+ }
5641
+ ]
5642
+ },
5643
+ {
5644
+ id: "Specimen.contained",
5645
+ path: "Specimen.contained",
5646
+ definition: "These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.",
5647
+ min: 0,
5648
+ max: "*",
5649
+ type: [
5650
+ {
5651
+ code: "Resource"
5652
+ }
5653
+ ]
5654
+ },
5655
+ {
5656
+ id: "Specimen.extension",
5657
+ path: "Specimen.extension",
5658
+ definition: "May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
5659
+ min: 0,
5660
+ max: "*",
5661
+ type: [
5662
+ {
5663
+ code: "Extension"
5664
+ }
5665
+ ]
5666
+ },
5667
+ {
5668
+ id: "Specimen.modifierExtension",
5669
+ path: "Specimen.modifierExtension",
5670
+ definition: "May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
5671
+ min: 0,
5672
+ max: "*",
5673
+ type: [
5674
+ {
5675
+ code: "Extension"
5676
+ }
5677
+ ]
5678
+ },
5679
+ {
5680
+ id: "Specimen.identifier",
5681
+ path: "Specimen.identifier",
5682
+ definition: "Id for specimen.",
5683
+ min: 0,
5684
+ max: "*",
5685
+ type: [
5686
+ {
5687
+ code: "Identifier"
5688
+ }
5689
+ ]
5690
+ },
5691
+ {
5692
+ id: "Specimen.accessionIdentifier",
5693
+ path: "Specimen.accessionIdentifier",
5694
+ definition: "The identifier assigned by the lab when accessioning specimen(s). This is not necessarily the same as the specimen identifier, depending on local lab procedures.",
5695
+ min: 0,
5696
+ max: "1",
5697
+ type: [
5698
+ {
5699
+ code: "Identifier"
5700
+ }
5701
+ ]
5702
+ },
5703
+ {
5704
+ id: "Specimen.status",
5705
+ path: "Specimen.status",
5706
+ definition: "The availability of the specimen.",
5707
+ min: 0,
5708
+ max: "1",
5709
+ type: [
5710
+ {
5711
+ code: "code"
5712
+ }
5713
+ ],
5714
+ binding: {
5715
+ description: "Codes providing the status/availability of a specimen.",
5716
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-status|4.0.1"
5717
+ }
5718
+ },
5719
+ {
5720
+ id: "Specimen.type",
5721
+ path: "Specimen.type",
5722
+ definition: "The kind of material that forms the specimen.",
5723
+ min: 0,
5724
+ max: "1",
5725
+ type: [
5726
+ {
5727
+ code: "CodeableConcept"
5728
+ }
5729
+ ],
5730
+ binding: {
5731
+ description: "The type of the specimen.",
5732
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0487"
5733
+ }
5734
+ },
5735
+ {
5736
+ id: "Specimen.subject",
5737
+ path: "Specimen.subject",
5738
+ definition: "Where the specimen came from. This may be from patient(s), from a location (e.g., the source of an environmental sample), or a sampling of a substance or a device.",
5739
+ min: 0,
5740
+ max: "1",
5741
+ type: [
5742
+ {
5743
+ code: "Reference",
5744
+ targetProfile: [
5745
+ "http://hl7.org/fhir/StructureDefinition/Patient",
5746
+ "http://hl7.org/fhir/StructureDefinition/Group",
5747
+ "http://hl7.org/fhir/StructureDefinition/Device",
5748
+ "http://hl7.org/fhir/StructureDefinition/Substance",
5749
+ "http://hl7.org/fhir/StructureDefinition/Location"
5750
+ ]
5751
+ }
5752
+ ]
5753
+ },
5754
+ {
5755
+ id: "Specimen.receivedTime",
5756
+ path: "Specimen.receivedTime",
5757
+ definition: "Time when specimen was received for processing or testing.",
5758
+ min: 0,
5759
+ max: "1",
5760
+ type: [
5761
+ {
5762
+ code: "dateTime"
5763
+ }
5764
+ ]
5765
+ },
5766
+ {
5767
+ id: "Specimen.parent",
5768
+ path: "Specimen.parent",
5769
+ definition: "Reference to the parent (source) specimen which is used when the specimen was either derived from or a component of another specimen.",
5770
+ min: 0,
5771
+ max: "*",
5772
+ type: [
5773
+ {
5774
+ code: "Reference",
5775
+ targetProfile: [
5776
+ "http://hl7.org/fhir/StructureDefinition/Specimen"
5777
+ ]
5778
+ }
5779
+ ]
5780
+ },
5781
+ {
5782
+ id: "Specimen.request",
5783
+ path: "Specimen.request",
5784
+ definition: "Details concerning a service request that required a specimen to be collected.",
5785
+ min: 0,
5786
+ max: "*",
5787
+ type: [
5788
+ {
5789
+ code: "Reference",
5790
+ targetProfile: [
5791
+ "http://hl7.org/fhir/StructureDefinition/ServiceRequest"
5792
+ ]
5793
+ }
5794
+ ]
5795
+ },
5796
+ {
5797
+ id: "Specimen.collection",
5798
+ path: "Specimen.collection",
5799
+ definition: "Details concerning the specimen collection.",
5800
+ min: 0,
5801
+ max: "1",
5802
+ type: [
5803
+ {
5804
+ code: "BackboneElement"
5805
+ }
5806
+ ]
5807
+ },
5808
+ {
5809
+ id: "Specimen.collection.id",
5810
+ path: "Specimen.collection.id",
5811
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
5812
+ min: 0,
5813
+ max: "1",
5814
+ type: [
5815
+ {
5816
+ code: "http://hl7.org/fhirpath/System.String"
5817
+ }
5818
+ ]
5819
+ },
5820
+ {
5821
+ id: "Specimen.collection.extension",
5822
+ path: "Specimen.collection.extension",
5823
+ definition: "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
5824
+ min: 0,
5825
+ max: "*",
5826
+ type: [
5827
+ {
5828
+ code: "Extension"
5829
+ }
5830
+ ]
5831
+ },
5832
+ {
5833
+ id: "Specimen.collection.modifierExtension",
5834
+ path: "Specimen.collection.modifierExtension",
5835
+ definition: "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
5836
+ min: 0,
5837
+ max: "*",
5838
+ type: [
5839
+ {
5840
+ code: "Extension"
5841
+ }
5842
+ ]
5843
+ },
5844
+ {
5845
+ id: "Specimen.collection.collector",
5846
+ path: "Specimen.collection.collector",
5847
+ definition: "Person who collected the specimen.",
5848
+ min: 0,
5849
+ max: "1",
5850
+ type: [
5851
+ {
5852
+ code: "Reference",
5853
+ targetProfile: [
5854
+ "http://hl7.org/fhir/StructureDefinition/Practitioner",
5855
+ "http://hl7.org/fhir/StructureDefinition/PractitionerRole"
5856
+ ]
5857
+ }
5858
+ ]
5859
+ },
5860
+ {
5861
+ id: "Specimen.collection.collected[x]",
5862
+ path: "Specimen.collection.collected[x]",
5863
+ definition: "Time when specimen was collected from subject - the physiologically relevant time.",
5864
+ min: 0,
5865
+ max: "1",
5866
+ type: [
5867
+ {
5868
+ code: "dateTime"
5869
+ },
5870
+ {
5871
+ code: "Period"
5872
+ }
5873
+ ]
5874
+ },
5875
+ {
5876
+ id: "Specimen.collection.duration",
5877
+ path: "Specimen.collection.duration",
5878
+ definition: "The span of time over which the collection of a specimen occurred.",
5879
+ min: 0,
5880
+ max: "1",
5881
+ type: [
5882
+ {
5883
+ code: "Duration"
5884
+ }
5885
+ ]
5886
+ },
5887
+ {
5888
+ id: "Specimen.collection.quantity",
5889
+ path: "Specimen.collection.quantity",
5890
+ definition: "The quantity of specimen collected; for instance the volume of a blood sample, or the physical measurement of an anatomic pathology sample.",
5891
+ min: 0,
5892
+ max: "1",
5893
+ type: [
5894
+ {
5895
+ code: "Quantity"
5896
+ }
5897
+ ]
5898
+ },
5899
+ {
5900
+ id: "Specimen.collection.method",
5901
+ path: "Specimen.collection.method",
5902
+ definition: "A coded value specifying the technique that is used to perform the procedure.",
5903
+ min: 0,
5904
+ max: "1",
5905
+ type: [
5906
+ {
5907
+ code: "CodeableConcept"
5908
+ }
5909
+ ],
5910
+ binding: {
5911
+ description: "The technique that is used to perform the procedure.",
5912
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-collection-method"
5913
+ }
5914
+ },
5915
+ {
5916
+ id: "Specimen.collection.bodySite",
5917
+ path: "Specimen.collection.bodySite",
5918
+ definition: "Anatomical location from which the specimen was collected (if subject is a patient). This is the target site. This element is not used for environmental specimens.",
5919
+ min: 0,
5920
+ max: "1",
5921
+ type: [
5922
+ {
5923
+ code: "CodeableConcept"
5924
+ }
5925
+ ],
5926
+ binding: {
5927
+ description: "Codes describing anatomical locations. May include laterality.",
5928
+ valueSet: "http://hl7.org/fhir/ValueSet/body-site"
5929
+ }
5930
+ },
5931
+ {
5932
+ id: "Specimen.collection.fastingStatus[x]",
5933
+ path: "Specimen.collection.fastingStatus[x]",
5934
+ definition: "Abstinence or reduction from some or all food, drink, or both, for a period of time prior to sample collection.",
5935
+ min: 0,
5936
+ max: "1",
5937
+ type: [
5938
+ {
5939
+ code: "CodeableConcept"
5940
+ },
5941
+ {
5942
+ code: "Duration"
5943
+ }
5944
+ ],
5945
+ binding: {
5946
+ description: "Codes describing the fasting status of the patient.",
5947
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0916"
5948
+ }
5949
+ },
5950
+ {
5951
+ id: "Specimen.processing",
5952
+ path: "Specimen.processing",
5953
+ definition: "Details concerning processing and processing steps for the specimen.",
5954
+ min: 0,
5955
+ max: "*",
5956
+ type: [
5957
+ {
5958
+ code: "BackboneElement"
5959
+ }
5960
+ ]
5961
+ },
5962
+ {
5963
+ id: "Specimen.processing.id",
5964
+ path: "Specimen.processing.id",
5965
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
5966
+ min: 0,
5967
+ max: "1",
5968
+ type: [
5969
+ {
5970
+ code: "http://hl7.org/fhirpath/System.String"
5971
+ }
5972
+ ]
5973
+ },
5974
+ {
5975
+ id: "Specimen.processing.extension",
5976
+ path: "Specimen.processing.extension",
5977
+ definition: "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
5978
+ min: 0,
5979
+ max: "*",
5980
+ type: [
5981
+ {
5982
+ code: "Extension"
5983
+ }
5984
+ ]
5985
+ },
5986
+ {
5987
+ id: "Specimen.processing.modifierExtension",
5988
+ path: "Specimen.processing.modifierExtension",
5989
+ definition: "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
5990
+ min: 0,
5991
+ max: "*",
5992
+ type: [
5993
+ {
5994
+ code: "Extension"
5995
+ }
5996
+ ]
5997
+ },
5998
+ {
5999
+ id: "Specimen.processing.description",
6000
+ path: "Specimen.processing.description",
6001
+ definition: "Textual description of procedure.",
6002
+ min: 0,
6003
+ max: "1",
6004
+ type: [
6005
+ {
6006
+ code: "string"
6007
+ }
6008
+ ]
6009
+ },
6010
+ {
6011
+ id: "Specimen.processing.procedure",
6012
+ path: "Specimen.processing.procedure",
6013
+ definition: "A coded value specifying the procedure used to process the specimen.",
6014
+ min: 0,
6015
+ max: "1",
6016
+ type: [
6017
+ {
6018
+ code: "CodeableConcept"
6019
+ }
6020
+ ],
6021
+ binding: {
6022
+ description: "Type indicating the technique used to process the specimen.",
6023
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-processing-procedure"
6024
+ }
6025
+ },
6026
+ {
6027
+ id: "Specimen.processing.additive",
6028
+ path: "Specimen.processing.additive",
6029
+ definition: "Material used in the processing step.",
6030
+ min: 0,
6031
+ max: "*",
6032
+ type: [
6033
+ {
6034
+ code: "Reference",
6035
+ targetProfile: [
6036
+ "http://hl7.org/fhir/StructureDefinition/Substance"
6037
+ ]
6038
+ }
6039
+ ]
6040
+ },
6041
+ {
6042
+ id: "Specimen.processing.time[x]",
6043
+ path: "Specimen.processing.time[x]",
6044
+ definition: "A record of the time or period when the specimen processing occurred. For example the time of sample fixation or the period of time the sample was in formalin.",
6045
+ min: 0,
6046
+ max: "1",
6047
+ type: [
6048
+ {
6049
+ code: "dateTime"
6050
+ },
6051
+ {
6052
+ code: "Period"
6053
+ }
6054
+ ]
6055
+ },
6056
+ {
6057
+ id: "Specimen.container",
6058
+ path: "Specimen.container",
6059
+ definition: "The container holding the specimen. The recursive nature of containers; i.e. blood in tube in tray in rack is not addressed here.",
6060
+ min: 0,
6061
+ max: "*",
6062
+ type: [
6063
+ {
6064
+ code: "BackboneElement"
6065
+ }
6066
+ ]
6067
+ },
6068
+ {
6069
+ id: "Specimen.container.id",
6070
+ path: "Specimen.container.id",
6071
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
6072
+ min: 0,
6073
+ max: "1",
6074
+ type: [
6075
+ {
6076
+ code: "http://hl7.org/fhirpath/System.String"
6077
+ }
6078
+ ]
6079
+ },
6080
+ {
6081
+ id: "Specimen.container.extension",
6082
+ path: "Specimen.container.extension",
6083
+ definition: "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
6084
+ min: 0,
6085
+ max: "*",
6086
+ type: [
6087
+ {
6088
+ code: "Extension"
6089
+ }
6090
+ ]
6091
+ },
6092
+ {
6093
+ id: "Specimen.container.modifierExtension",
6094
+ path: "Specimen.container.modifierExtension",
6095
+ definition: "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
6096
+ min: 0,
6097
+ max: "*",
6098
+ type: [
6099
+ {
6100
+ code: "Extension"
6101
+ }
6102
+ ]
6103
+ },
6104
+ {
6105
+ id: "Specimen.container.identifier",
6106
+ path: "Specimen.container.identifier",
6107
+ definition: "Id for container. There may be multiple; a manufacturer's bar code, lab assigned identifier, etc. The container ID may differ from the specimen id in some circumstances.",
6108
+ min: 0,
6109
+ max: "*",
6110
+ type: [
6111
+ {
6112
+ code: "Identifier"
6113
+ }
6114
+ ]
6115
+ },
6116
+ {
6117
+ id: "Specimen.container.description",
6118
+ path: "Specimen.container.description",
6119
+ definition: "Textual description of the container.",
6120
+ min: 0,
6121
+ max: "1",
6122
+ type: [
6123
+ {
6124
+ code: "string"
6125
+ }
6126
+ ]
6127
+ },
6128
+ {
6129
+ id: "Specimen.container.type",
6130
+ path: "Specimen.container.type",
6131
+ definition: "The type of container associated with the specimen (e.g. slide, aliquot, etc.).",
6132
+ min: 0,
6133
+ max: "1",
6134
+ type: [
6135
+ {
6136
+ code: "CodeableConcept"
6137
+ }
6138
+ ],
6139
+ binding: {
6140
+ description: "Type of specimen container.",
6141
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-container-type"
6142
+ }
6143
+ },
6144
+ {
6145
+ id: "Specimen.container.capacity",
6146
+ path: "Specimen.container.capacity",
6147
+ definition: "The capacity (volume or other measure) the container may contain.",
6148
+ min: 0,
6149
+ max: "1",
6150
+ type: [
6151
+ {
6152
+ code: "Quantity"
6153
+ }
6154
+ ]
6155
+ },
6156
+ {
6157
+ id: "Specimen.container.specimenQuantity",
6158
+ path: "Specimen.container.specimenQuantity",
6159
+ definition: "The quantity of specimen in the container; may be volume, dimensions, or other appropriate measurements, depending on the specimen type.",
6160
+ min: 0,
6161
+ max: "1",
6162
+ type: [
6163
+ {
6164
+ code: "Quantity"
6165
+ }
6166
+ ]
6167
+ },
6168
+ {
6169
+ id: "Specimen.container.additive[x]",
6170
+ path: "Specimen.container.additive[x]",
6171
+ definition: "Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
6172
+ min: 0,
6173
+ max: "1",
6174
+ type: [
6175
+ {
6176
+ code: "CodeableConcept"
6177
+ },
6178
+ {
6179
+ code: "Reference",
6180
+ targetProfile: [
6181
+ "http://hl7.org/fhir/StructureDefinition/Substance"
6182
+ ]
6183
+ }
6184
+ ],
6185
+ binding: {
6186
+ description: "Substance added to specimen container.",
6187
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0371"
6188
+ }
6189
+ },
6190
+ {
6191
+ id: "Specimen.condition",
6192
+ path: "Specimen.condition",
6193
+ definition: "A mode or state of being that describes the nature of the specimen.",
6194
+ min: 0,
6195
+ max: "*",
6196
+ type: [
6197
+ {
6198
+ code: "CodeableConcept"
6199
+ }
6200
+ ],
6201
+ binding: {
6202
+ description: "Codes describing the state of the specimen.",
6203
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0493"
6204
+ }
6205
+ },
6206
+ {
6207
+ id: "Specimen.note",
6208
+ path: "Specimen.note",
6209
+ definition: "To communicate any details or issues about the specimen or during the specimen collection. (for example: broken vial, sent with patient, frozen).",
6210
+ min: 0,
6211
+ max: "*",
6212
+ type: [
6213
+ {
6214
+ code: "Annotation"
6215
+ }
6216
+ ]
6217
+ }
6218
+ ]
6219
+ }
6220
+ }
6221
+ ];
6222
+
6223
+ const PatientSearchParameters = [
6224
+ {
6225
+ resourceType: 'SearchParameter',
6226
+ id: 'Patient-name',
6227
+ base: ['Patient'],
6228
+ code: 'name',
6229
+ name: 'name',
6230
+ type: 'string',
6231
+ expression: 'Patient.name',
6232
+ },
6233
+ {
6234
+ resourceType: 'SearchParameter',
6235
+ id: 'Patient-birthdate',
6236
+ base: ['Patient'],
6237
+ code: 'birthdate',
6238
+ name: 'birthdate',
6239
+ type: 'date',
6240
+ expression: 'Patient.birthDate',
6241
+ },
6242
+ {
6243
+ resourceType: 'SearchParameter',
6244
+ id: 'Patient-organization',
6245
+ base: ['Patient'],
6246
+ code: 'organization',
6247
+ name: 'organization',
6248
+ type: 'reference',
6249
+ expression: 'Patient.managingOrganization',
6250
+ target: ['Organization'],
6251
+ },
6252
+ {
6253
+ resourceType: 'SearchParameter',
6254
+ id: 'Patient-active',
6255
+ base: ['Patient'],
6256
+ code: 'active',
6257
+ name: 'active',
6258
+ type: 'token',
6259
+ expression: 'Patient.active',
6260
+ },
6261
+ {
6262
+ resourceType: 'SearchParameter',
6263
+ id: 'individual-telecom',
6264
+ base: ['Patient', 'Practitioner'],
6265
+ code: 'telecom',
6266
+ name: 'telecom',
6267
+ type: 'token',
6268
+ expression: 'Patient.telecom | Practitioner.telecom',
6269
+ },
6270
+ {
6271
+ resourceType: 'SearchParameter',
6272
+ id: 'individual-email',
6273
+ base: ['Patient', 'Practitioner'],
6274
+ code: 'email',
6275
+ name: 'email',
6276
+ type: 'token',
6277
+ expression: "Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')",
6278
+ },
6279
+ {
6280
+ resourceType: 'SearchParameter',
6281
+ id: 'individual-phone',
6282
+ base: ['Patient', 'Practitioner'],
6283
+ code: 'phone',
6284
+ name: 'phone',
6285
+ type: 'token',
6286
+ expression: "Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')",
6287
+ },
6288
+ {
6289
+ resourceType: 'SearchParameter',
6290
+ id: 'individual-address-city',
6291
+ base: ['Patient', 'Practitioner'],
6292
+ code: 'address-city',
6293
+ name: 'address-city',
6294
+ type: 'token',
6295
+ expression: 'Patient.address.city | Practitioner.address.city',
6296
+ },
6297
+ {
6298
+ resourceType: 'SearchParameter',
6299
+ id: 'individual-address-state',
6300
+ base: ['Patient', 'Practitioner'],
6301
+ code: 'address-state',
6302
+ name: 'address-state',
6303
+ type: 'token',
6304
+ expression: 'Patient.address.state | Practitioner.address.state',
6305
+ },
6306
+ {
6307
+ resourceType: 'SearchParameter',
6308
+ id: 'ServiceRequest-subject',
6309
+ code: 'subject',
6310
+ base: ['ServiceRequest'],
6311
+ type: 'reference',
6312
+ expression: 'ServiceRequest.subject',
6313
+ target: ['Group', 'Device', 'Patient', 'Location'],
6314
+ },
6315
+ {
6316
+ resourceType: 'SearchParameter',
6317
+ id: 'ServiceRequest-authored',
6318
+ code: 'authored',
6319
+ base: ['ServiceRequest'],
6320
+ type: 'date',
6321
+ expression: 'ServiceRequest.authoredOn',
6322
+ },
6323
+ {
6324
+ resourceType: 'SearchParameter',
6325
+ id: 'Observation-value-quantity',
6326
+ code: 'value-quantity',
6327
+ base: ['Observation'],
6328
+ type: 'quantity',
6329
+ expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',
6330
+ },
6331
+ {
6332
+ resourceType: 'SearchParameter',
6333
+ id: 'Encounter-length',
6334
+ code: 'length',
6335
+ base: ['Encounter'],
6336
+ type: 'quantity',
6337
+ expression: 'Encounter.length',
6338
+ },
6339
+ ];
6340
+ const GraphQLSchemaResponse = {
6341
+ data: {
6342
+ StructureDefinitionList,
6343
+ SearchParameterList: [...PatientSearchParameters],
6344
+ },
6345
+ };
6346
+
6347
+ const exampleValueSet = {
6348
+ resourceType: 'ValueSet',
6349
+ expansion: {
6350
+ contains: [
6351
+ {
6352
+ system: 'x',
6353
+ code: 'test-code',
6354
+ display: 'Test Display',
6355
+ },
6356
+ ],
6357
+ },
6358
+ };
6359
+
6360
+ /******************************************************************************
6361
+ Copyright (c) Microsoft Corporation.
6362
+
6363
+ Permission to use, copy, modify, and/or distribute this software for any
6364
+ purpose with or without fee is hereby granted.
6365
+
6366
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6367
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6368
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6369
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6370
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6371
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6372
+ PERFORMANCE OF THIS SOFTWARE.
6373
+ ***************************************************************************** */
6374
+
6375
+ function __classPrivateFieldGet$1(receiver, state, kind, f) {
6376
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6377
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6378
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6379
+ }
6380
+
6381
+ function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
6382
+ if (kind === "m") throw new TypeError("Private method is not writable");
6383
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6384
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6385
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6386
+ }
6387
+
6388
+ /******************************************************************************
6389
+ Copyright (c) Microsoft Corporation.
6390
+
6391
+ Permission to use, copy, modify, and/or distribute this software for any
6392
+ purpose with or without fee is hereby granted.
6393
+
6394
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6395
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6396
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6397
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6398
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6399
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6400
+ PERFORMANCE OF THIS SOFTWARE.
6401
+ ***************************************************************************** */
6402
+
6403
+ function __classPrivateFieldGet(receiver, state, kind, f) {
6404
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6405
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
6406
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6407
+ }
6408
+
6409
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
6410
+ if (kind === "m") throw new TypeError("Private method is not writable");
6411
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6412
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6413
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6414
+ }
6415
+
6416
+ /**
6417
+ * Ensures that the value is wrapped in an array.
6418
+ * @param input The input as a an array or a value.
6419
+ * @returns The input as an array.
6420
+ */
6421
+ function ensureArray(input) {
6422
+ if (input === null || input === undefined) {
6423
+ return [];
6424
+ }
6425
+ return Array.isArray(input) ? input : [input];
6426
+ }
6427
+ /**
6428
+ * Applies a function to single value or an array of values.
6429
+ * @param context The context which will be passed to the function.
6430
+ * @param fn The function to apply.
6431
+ * @returns The result of the function.
6432
+ */
6433
+ function applyMaybeArray(context, fn) {
6434
+ if (context === undefined) {
6435
+ return undefined;
6436
+ }
6437
+ if (Array.isArray(context)) {
6438
+ return context
6439
+ .map((e) => fn(e))
6440
+ .filter((e) => !!e)
6441
+ .flat();
6442
+ }
6443
+ else {
6444
+ return fn(context);
6445
+ }
6446
+ }
6447
+ /**
6448
+ * Determines if the input is an empty array.
6449
+ * @param obj Any value or array of values.
6450
+ * @returns True if the input is an empty array.
6451
+ */
6452
+ function isEmptyArray(obj) {
6453
+ return Array.isArray(obj) && obj.length === 0;
6454
+ }
6455
+ function isFalsy(obj) {
6456
+ return !obj || isEmptyArray(obj);
6457
+ }
6458
+ /**
6459
+ * Converts unknown object into a JavaScript boolean.
6460
+ * Note that this is different than the FHIRPath "toBoolean",
6461
+ * which has particular semantics around arrays, empty arrays, and type conversions.
6462
+ * @param obj Any value or array of values.
6463
+ * @returns The converted boolean value according to FHIRPath rules.
6464
+ */
6465
+ function toJsBoolean(obj) {
6466
+ if (Array.isArray(obj)) {
6467
+ return obj.length === 0 ? false : !!obj[0];
6468
+ }
6469
+ return !!obj;
6470
+ }
6471
+ /**
6472
+ * Removes duplicates in array using FHIRPath equality rules.
6473
+ * @param arr The input array.
6474
+ * @returns The result array with duplicates removed.
6475
+ */
6476
+ function removeDuplicates(arr) {
6477
+ const result = [];
6478
+ for (const i of arr) {
6479
+ let found = false;
6480
+ for (const j of result) {
6481
+ if (fhirPathEquals(i, j)) {
6482
+ found = true;
6483
+ break;
5807
6484
  }
5808
6485
  }
5809
6486
  if (!found) {
@@ -6300,6 +6977,23 @@
6300
6977
  eval(context) {
6301
6978
  return this.impl(ensureArray(context), ...this.args);
6302
6979
  }
6980
+ }
6981
+ class IndexerAtom {
6982
+ constructor(left, expr) {
6983
+ this.left = left;
6984
+ this.expr = expr;
6985
+ }
6986
+ eval(context) {
6987
+ const index = this.expr.eval(context);
6988
+ if (typeof index !== 'number') {
6989
+ throw new Error(`Invalid indexer expression: should return integer}`);
6990
+ }
6991
+ const leftResult = this.left.eval(context);
6992
+ if (!(index in leftResult)) {
6993
+ return [];
6994
+ }
6995
+ return leftResult[index];
6996
+ }
6303
6997
  }
6304
6998
 
6305
6999
  function parseDateString(str) {
@@ -6562,7 +7256,7 @@
6562
7256
  * See: http://hl7.org/fhirpath/#selectprojection-expression-collection
6563
7257
  */
6564
7258
  function select(input, criteria) {
6565
- return ensureArray(criteria.eval(input));
7259
+ return ensureArray(input.map((e) => criteria.eval(e)).flat());
6566
7260
  }
6567
7261
  /**
6568
7262
  * A version of select that will repeat the projection and add it to the output
@@ -8017,7 +8711,7 @@
8017
8711
  prefix(tokenType, precedence, builder) {
8018
8712
  return this.registerPrefix(tokenType, {
8019
8713
  parse(parser, token) {
8020
- const right = parser.parse(precedence);
8714
+ const right = parser.consumeAndParse(precedence);
8021
8715
  return builder(token, right);
8022
8716
  },
8023
8717
  });
@@ -8025,7 +8719,7 @@
8025
8719
  infixLeft(tokenType, precedence, builder) {
8026
8720
  return this.registerInfix(tokenType, {
8027
8721
  parse(parser, left, token) {
8028
- const right = parser.parse(precedence);
8722
+ const right = parser.consumeAndParse(precedence);
8029
8723
  return builder(left, token, right);
8030
8724
  },
8031
8725
  precedence,
@@ -8054,7 +8748,7 @@
8054
8748
  __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
8055
8749
  return true;
8056
8750
  }
8057
- parse(precedence = 100 /* MaximumPrecedence */) {
8751
+ consumeAndParse(precedence = 100 /* MaximumPrecedence */) {
8058
8752
  const token = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
8059
8753
  const prefix = __classPrivateFieldGet(this, _Parser_prefixParselets, "f")[token.id];
8060
8754
  if (!prefix) {
@@ -8089,13 +8783,23 @@
8089
8783
  };
8090
8784
  const PARENTHESES_PARSELET = {
8091
8785
  parse(parser) {
8092
- const expr = parser.parse();
8786
+ const expr = parser.consumeAndParse();
8093
8787
  if (!parser.match(')')) {
8094
8788
  throw new Error('Parse error: expected `)`');
8095
8789
  }
8096
8790
  return expr;
8097
8791
  },
8098
8792
  };
8793
+ const INDEXER_PARSELET = {
8794
+ parse(parser, left) {
8795
+ const expr = parser.consumeAndParse();
8796
+ if (!parser.match(']')) {
8797
+ throw new Error('Parse error: expected `]`');
8798
+ }
8799
+ return new IndexerAtom(left, expr);
8800
+ },
8801
+ precedence: 2 /* Indexer */,
8802
+ };
8099
8803
  const FUNCTION_CALL_PARSELET = {
8100
8804
  parse(parser, left) {
8101
8805
  if (!(left instanceof SymbolAtom)) {
@@ -8106,7 +8810,7 @@
8106
8810
  }
8107
8811
  const args = [];
8108
8812
  while (!parser.match(')')) {
8109
- args.push(parser.parse());
8813
+ args.push(parser.consumeAndParse());
8110
8814
  parser.match(',');
8111
8815
  }
8112
8816
  return new FunctionAtom(left.name, args, functions[left.name]);
@@ -8151,6 +8855,7 @@
8151
8855
  })
8152
8856
  .registerPrefix('{}', { parse: () => new EmptySetAtom() })
8153
8857
  .registerPrefix('(', PARENTHESES_PARSELET)
8858
+ .registerInfix('[', INDEXER_PARSELET)
8154
8859
  .registerInfix('(', FUNCTION_CALL_PARSELET)
8155
8860
  .prefix('+', 3 /* UnaryAdd */, (_, right) => new UnaryOperatorAtom(right, (x) => x))
8156
8861
  .prefix('-', 3 /* UnarySubtract */, (_, right) => new ArithemticOperatorAtom(right, right, (_, y) => -y))
@@ -8203,7 +8908,7 @@
8203
8908
  */
8204
8909
  function parseFhirPath(input) {
8205
8910
  try {
8206
- return new FhirPathAtom(input, parserBuilder.construct(input).parse());
8911
+ return new FhirPathAtom(input, parserBuilder.construct(input).consumeAndParse());
8207
8912
  }
8208
8913
  catch (error) {
8209
8914
  throw new Error(`FhirPathError on "${input}": ${error}`);
@@ -8331,14 +9036,10 @@
8331
9036
  if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
8332
9037
  console.log('MockClient', method, path);
8333
9038
  }
8334
- const result = mockHandler(method, path, options);
8335
- if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) && !result) {
9039
+ const response = mockHandler(method, path, options);
9040
+ if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) && !response) {
8336
9041
  console.log('MockClient: not found', method, path);
8337
9042
  }
8338
- const response = Object.assign({ request: {
8339
- url,
8340
- options,
8341
- } }, result);
8342
9043
  if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
8343
9044
  console.log('MockClient', JSON.stringify(response, null, 2));
8344
9045
  }
@@ -8427,6 +9128,11 @@
8427
9128
  if (path.startsWith('auth/resetpassword')) {
8428
9129
  return mockResetPasswordHandler(method, path, options);
8429
9130
  }
9131
+ if (path.startsWith('auth/me')) {
9132
+ return {
9133
+ profile: { reference: 'Practitioner/123' },
9134
+ };
9135
+ }
8430
9136
  return null;
8431
9137
  }
8432
9138
  function mockChangePasswordHandler(method, path, options) {
@@ -8547,6 +9253,7 @@
8547
9253
  mockRepo.createResource(HomerObservation4);
8548
9254
  mockRepo.createResource(HomerObservation5);
8549
9255
  mockRepo.createResource(HomerObservation6);
9256
+ mockRepo.createResource(HomerSimpsonSpecimen);
8550
9257
  mockRepo.createResource(TestOrganization);
8551
9258
  mockRepo.createResource(DifferentOrganization);
8552
9259
  mockRepo.createResource(ExampleQuestionnaire);
@@ -8593,7 +9300,7 @@
8593
9300
  return mockRepo.readResource(resourceType, id);
8594
9301
  }
8595
9302
  else if (resourceType) {
8596
- return mockRepo.search(core.parseSearchDefinition(new URL(url, 'https://example.com/')));
9303
+ return mockRepo.search(core.parseSearchDefinition(url));
8597
9304
  }
8598
9305
  }
8599
9306
  else if (method === 'PUT') {
@@ -8653,6 +9360,7 @@
8653
9360
  exports.HomerServiceRequest = HomerServiceRequest;
8654
9361
  exports.HomerSimpson = HomerSimpson;
8655
9362
  exports.HomerSimpsonPreviousVersion = HomerSimpsonPreviousVersion;
9363
+ exports.HomerSimpsonSpecimen = HomerSimpsonSpecimen;
8656
9364
  exports.MockClient = MockClient;
8657
9365
  exports.PatientSearchParameters = PatientSearchParameters;
8658
9366
  exports.TestOrganization = TestOrganization;