@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/esm/index.js CHANGED
@@ -342,14 +342,17 @@ const HomerObservation4 = {
342
342
  valueQuantity: {
343
343
  value: 50,
344
344
  unit: 'x',
345
+ comparator: '>',
345
346
  },
346
347
  referenceRange: [
347
348
  {
348
349
  low: {
349
350
  value: 10,
351
+ unit: 'x',
350
352
  },
351
353
  high: {
352
354
  value: 50,
355
+ unit: 'x',
353
356
  },
354
357
  },
355
358
  ],
@@ -395,6 +398,13 @@ const HomerObservation6 = {
395
398
  },
396
399
  ],
397
400
  };
401
+ const HomerSimpsonSpecimen = {
402
+ resourceType: 'Specimen',
403
+ subject: createReference(HomerSimpson),
404
+ collection: {
405
+ collectedDateTime: '2020-01-01T12:00:00Z',
406
+ },
407
+ };
398
408
  const HomerServiceRequest = {
399
409
  resourceType: 'ServiceRequest',
400
410
  id: '123',
@@ -429,6 +439,8 @@ const HomerServiceRequest = {
429
439
  text: 'ORDERED',
430
440
  },
431
441
  ],
442
+ specimen: [createReference(HomerSimpsonSpecimen)],
443
+ authoredOn: '2020-01-01T12:00:00Z',
432
444
  };
433
445
  const BartSimpson = {
434
446
  resourceType: 'Patient',
@@ -5544,262 +5556,927 @@ var StructureDefinitionList = [
5544
5556
  }
5545
5557
  ]
5546
5558
  }
5547
- }
5548
- ];
5549
-
5550
- const PatientSearchParameters = [
5551
- {
5552
- resourceType: 'SearchParameter',
5553
- id: 'Patient-name',
5554
- base: ['Patient'],
5555
- code: 'name',
5556
- name: 'name',
5557
- type: 'string',
5558
- expression: 'Patient.name',
5559
- },
5560
- {
5561
- resourceType: 'SearchParameter',
5562
- id: 'Patient-birthdate',
5563
- base: ['Patient'],
5564
- code: 'birthdate',
5565
- name: 'birthdate',
5566
- type: 'date',
5567
- expression: 'Patient.birthDate',
5568
- },
5569
- {
5570
- resourceType: 'SearchParameter',
5571
- id: 'Patient-organization',
5572
- base: ['Patient'],
5573
- code: 'organization',
5574
- name: 'organization',
5575
- type: 'reference',
5576
- expression: 'Patient.managingOrganization',
5577
- target: ['Organization'],
5578
- },
5579
- {
5580
- resourceType: 'SearchParameter',
5581
- id: 'Patient-active',
5582
- base: ['Patient'],
5583
- code: 'active',
5584
- name: 'active',
5585
- type: 'token',
5586
- expression: 'Patient.active',
5587
- },
5588
- {
5589
- resourceType: 'SearchParameter',
5590
- id: 'individual-telecom',
5591
- base: ['Patient', 'Practitioner'],
5592
- code: 'telecom',
5593
- name: 'telecom',
5594
- type: 'token',
5595
- expression: 'Patient.telecom | Practitioner.telecom',
5596
- },
5597
- {
5598
- resourceType: 'SearchParameter',
5599
- id: 'individual-email',
5600
- base: ['Patient', 'Practitioner'],
5601
- code: 'email',
5602
- name: 'email',
5603
- type: 'token',
5604
- expression: "Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')",
5605
- },
5606
- {
5607
- resourceType: 'SearchParameter',
5608
- id: 'individual-phone',
5609
- base: ['Patient', 'Practitioner'],
5610
- code: 'phone',
5611
- name: 'phone',
5612
- type: 'token',
5613
- expression: "Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')",
5614
- },
5615
- {
5616
- resourceType: 'SearchParameter',
5617
- id: 'individual-address-city',
5618
- base: ['Patient', 'Practitioner'],
5619
- code: 'address-city',
5620
- name: 'address-city',
5621
- type: 'token',
5622
- expression: 'Patient.address.city | Practitioner.address.city',
5623
- },
5624
- {
5625
- resourceType: 'SearchParameter',
5626
- id: 'individual-address-state',
5627
- base: ['Patient', 'Practitioner'],
5628
- code: 'address-state',
5629
- name: 'address-state',
5630
- type: 'token',
5631
- expression: 'Patient.address.state | Practitioner.address.state',
5632
- },
5633
- {
5634
- resourceType: 'SearchParameter',
5635
- id: 'ServiceRequest-subject',
5636
- code: 'subject',
5637
- base: ['ServiceRequest'],
5638
- type: 'reference',
5639
- expression: 'ServiceRequest.subject',
5640
- target: ['Group', 'Device', 'Patient', 'Location'],
5641
- },
5642
- {
5643
- resourceType: 'SearchParameter',
5644
- id: 'Observation-value-quantity',
5645
- code: 'value-quantity',
5646
- base: ['Observation'],
5647
- type: 'quantity',
5648
- expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',
5649
- },
5650
- {
5651
- resourceType: 'SearchParameter',
5652
- id: 'Encounter-length',
5653
- code: 'length',
5654
- base: ['Encounter'],
5655
- type: 'quantity',
5656
- expression: 'Encounter.length',
5657
- },
5658
- ];
5659
- const GraphQLSchemaResponse = {
5660
- data: {
5661
- StructureDefinitionList,
5662
- SearchParameterList: [...PatientSearchParameters],
5663
- },
5664
- };
5665
-
5666
- const exampleValueSet = {
5667
- resourceType: 'ValueSet',
5668
- expansion: {
5669
- contains: [
5670
- {
5671
- system: 'x',
5672
- code: 'test-code',
5673
- display: 'Test Display',
5674
- },
5675
- ],
5676
- },
5677
- };
5678
-
5679
- /*! *****************************************************************************
5680
- Copyright (c) Microsoft Corporation.
5681
-
5682
- Permission to use, copy, modify, and/or distribute this software for any
5683
- purpose with or without fee is hereby granted.
5684
-
5685
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5686
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5687
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5688
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5689
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5690
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5691
- PERFORMANCE OF THIS SOFTWARE.
5692
- ***************************************************************************** */
5693
-
5694
- function __classPrivateFieldGet$1(receiver, state, kind, f) {
5695
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5696
- 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");
5697
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5698
- }
5699
-
5700
- function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
5701
- if (kind === "m") throw new TypeError("Private method is not writable");
5702
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5703
- 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");
5704
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5705
- }
5706
-
5707
- /*! *****************************************************************************
5708
- Copyright (c) Microsoft Corporation.
5709
-
5710
- Permission to use, copy, modify, and/or distribute this software for any
5711
- purpose with or without fee is hereby granted.
5712
-
5713
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5714
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
5715
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
5716
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
5717
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
5718
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
5719
- PERFORMANCE OF THIS SOFTWARE.
5720
- ***************************************************************************** */
5721
-
5722
- function __classPrivateFieldGet(receiver, state, kind, f) {
5723
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
5724
- 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");
5725
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5726
- }
5727
-
5728
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
5729
- if (kind === "m") throw new TypeError("Private method is not writable");
5730
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5731
- 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");
5732
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
5733
- }
5734
-
5735
- /**
5736
- * Ensures that the value is wrapped in an array.
5737
- * @param input The input as a an array or a value.
5738
- * @returns The input as an array.
5739
- */
5740
- function ensureArray(input) {
5741
- if (input === null || input === undefined) {
5742
- return [];
5743
- }
5744
- return Array.isArray(input) ? input : [input];
5745
- }
5746
- /**
5747
- * Applies a function to single value or an array of values.
5748
- * @param context The context which will be passed to the function.
5749
- * @param fn The function to apply.
5750
- * @returns The result of the function.
5751
- */
5752
- function applyMaybeArray(context, fn) {
5753
- if (context === undefined) {
5754
- return undefined;
5755
- }
5756
- if (Array.isArray(context)) {
5757
- return context
5758
- .map((e) => fn(e))
5759
- .filter((e) => !!e)
5760
- .flat();
5761
- }
5762
- else {
5763
- return fn(context);
5764
- }
5765
- }
5766
- /**
5767
- * Determines if the input is an empty array.
5768
- * @param obj Any value or array of values.
5769
- * @returns True if the input is an empty array.
5770
- */
5771
- function isEmptyArray(obj) {
5772
- return Array.isArray(obj) && obj.length === 0;
5773
- }
5774
- function isFalsy(obj) {
5775
- return !obj || isEmptyArray(obj);
5776
- }
5777
- /**
5778
- * Converts unknown object into a JavaScript boolean.
5779
- * Note that this is different than the FHIRPath "toBoolean",
5780
- * which has particular semantics around arrays, empty arrays, and type conversions.
5781
- * @param obj Any value or array of values.
5782
- * @returns The converted boolean value according to FHIRPath rules.
5783
- */
5784
- function toJsBoolean(obj) {
5785
- if (Array.isArray(obj)) {
5786
- return obj.length === 0 ? false : !!obj[0];
5787
- }
5788
- return !!obj;
5789
- }
5790
- /**
5791
- * Removes duplicates in array using FHIRPath equality rules.
5792
- * @param arr The input array.
5793
- * @returns The result array with duplicates removed.
5794
- */
5795
- function removeDuplicates(arr) {
5796
- const result = [];
5797
- for (const i of arr) {
5798
- let found = false;
5799
- for (const j of result) {
5800
- if (fhirPathEquals(i, j)) {
5801
- found = true;
5802
- break;
5559
+ },
5560
+ {
5561
+ resourceType: "StructureDefinition",
5562
+ id: "Specimen",
5563
+ name: "Specimen",
5564
+ description: "A sample to be used for analysis.",
5565
+ type: "Specimen",
5566
+ snapshot: {
5567
+ element: [
5568
+ {
5569
+ id: "Specimen",
5570
+ path: "Specimen",
5571
+ definition: "A sample to be used for analysis.",
5572
+ min: 0,
5573
+ max: "*"
5574
+ },
5575
+ {
5576
+ id: "Specimen.id",
5577
+ path: "Specimen.id",
5578
+ definition: "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.",
5579
+ min: 0,
5580
+ max: "1",
5581
+ type: [
5582
+ {
5583
+ code: "http://hl7.org/fhirpath/System.String"
5584
+ }
5585
+ ]
5586
+ },
5587
+ {
5588
+ id: "Specimen.meta",
5589
+ path: "Specimen.meta",
5590
+ 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.",
5591
+ min: 0,
5592
+ max: "1",
5593
+ type: [
5594
+ {
5595
+ code: "Meta"
5596
+ }
5597
+ ]
5598
+ },
5599
+ {
5600
+ id: "Specimen.implicitRules",
5601
+ path: "Specimen.implicitRules",
5602
+ 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.",
5603
+ min: 0,
5604
+ max: "1",
5605
+ type: [
5606
+ {
5607
+ code: "uri"
5608
+ }
5609
+ ]
5610
+ },
5611
+ {
5612
+ id: "Specimen.language",
5613
+ path: "Specimen.language",
5614
+ definition: "The base language in which the resource is written.",
5615
+ min: 0,
5616
+ max: "1",
5617
+ type: [
5618
+ {
5619
+ code: "code"
5620
+ }
5621
+ ],
5622
+ binding: {
5623
+ description: "A human language.",
5624
+ valueSet: "http://hl7.org/fhir/ValueSet/languages"
5625
+ }
5626
+ },
5627
+ {
5628
+ id: "Specimen.text",
5629
+ path: "Specimen.text",
5630
+ 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.",
5631
+ min: 0,
5632
+ max: "1",
5633
+ type: [
5634
+ {
5635
+ code: "Narrative"
5636
+ }
5637
+ ]
5638
+ },
5639
+ {
5640
+ id: "Specimen.contained",
5641
+ path: "Specimen.contained",
5642
+ 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.",
5643
+ min: 0,
5644
+ max: "*",
5645
+ type: [
5646
+ {
5647
+ code: "Resource"
5648
+ }
5649
+ ]
5650
+ },
5651
+ {
5652
+ id: "Specimen.extension",
5653
+ path: "Specimen.extension",
5654
+ 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.",
5655
+ min: 0,
5656
+ max: "*",
5657
+ type: [
5658
+ {
5659
+ code: "Extension"
5660
+ }
5661
+ ]
5662
+ },
5663
+ {
5664
+ id: "Specimen.modifierExtension",
5665
+ path: "Specimen.modifierExtension",
5666
+ 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).",
5667
+ min: 0,
5668
+ max: "*",
5669
+ type: [
5670
+ {
5671
+ code: "Extension"
5672
+ }
5673
+ ]
5674
+ },
5675
+ {
5676
+ id: "Specimen.identifier",
5677
+ path: "Specimen.identifier",
5678
+ definition: "Id for specimen.",
5679
+ min: 0,
5680
+ max: "*",
5681
+ type: [
5682
+ {
5683
+ code: "Identifier"
5684
+ }
5685
+ ]
5686
+ },
5687
+ {
5688
+ id: "Specimen.accessionIdentifier",
5689
+ path: "Specimen.accessionIdentifier",
5690
+ 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.",
5691
+ min: 0,
5692
+ max: "1",
5693
+ type: [
5694
+ {
5695
+ code: "Identifier"
5696
+ }
5697
+ ]
5698
+ },
5699
+ {
5700
+ id: "Specimen.status",
5701
+ path: "Specimen.status",
5702
+ definition: "The availability of the specimen.",
5703
+ min: 0,
5704
+ max: "1",
5705
+ type: [
5706
+ {
5707
+ code: "code"
5708
+ }
5709
+ ],
5710
+ binding: {
5711
+ description: "Codes providing the status/availability of a specimen.",
5712
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-status|4.0.1"
5713
+ }
5714
+ },
5715
+ {
5716
+ id: "Specimen.type",
5717
+ path: "Specimen.type",
5718
+ definition: "The kind of material that forms the specimen.",
5719
+ min: 0,
5720
+ max: "1",
5721
+ type: [
5722
+ {
5723
+ code: "CodeableConcept"
5724
+ }
5725
+ ],
5726
+ binding: {
5727
+ description: "The type of the specimen.",
5728
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0487"
5729
+ }
5730
+ },
5731
+ {
5732
+ id: "Specimen.subject",
5733
+ path: "Specimen.subject",
5734
+ 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.",
5735
+ min: 0,
5736
+ max: "1",
5737
+ type: [
5738
+ {
5739
+ code: "Reference",
5740
+ targetProfile: [
5741
+ "http://hl7.org/fhir/StructureDefinition/Patient",
5742
+ "http://hl7.org/fhir/StructureDefinition/Group",
5743
+ "http://hl7.org/fhir/StructureDefinition/Device",
5744
+ "http://hl7.org/fhir/StructureDefinition/Substance",
5745
+ "http://hl7.org/fhir/StructureDefinition/Location"
5746
+ ]
5747
+ }
5748
+ ]
5749
+ },
5750
+ {
5751
+ id: "Specimen.receivedTime",
5752
+ path: "Specimen.receivedTime",
5753
+ definition: "Time when specimen was received for processing or testing.",
5754
+ min: 0,
5755
+ max: "1",
5756
+ type: [
5757
+ {
5758
+ code: "dateTime"
5759
+ }
5760
+ ]
5761
+ },
5762
+ {
5763
+ id: "Specimen.parent",
5764
+ path: "Specimen.parent",
5765
+ definition: "Reference to the parent (source) specimen which is used when the specimen was either derived from or a component of another specimen.",
5766
+ min: 0,
5767
+ max: "*",
5768
+ type: [
5769
+ {
5770
+ code: "Reference",
5771
+ targetProfile: [
5772
+ "http://hl7.org/fhir/StructureDefinition/Specimen"
5773
+ ]
5774
+ }
5775
+ ]
5776
+ },
5777
+ {
5778
+ id: "Specimen.request",
5779
+ path: "Specimen.request",
5780
+ definition: "Details concerning a service request that required a specimen to be collected.",
5781
+ min: 0,
5782
+ max: "*",
5783
+ type: [
5784
+ {
5785
+ code: "Reference",
5786
+ targetProfile: [
5787
+ "http://hl7.org/fhir/StructureDefinition/ServiceRequest"
5788
+ ]
5789
+ }
5790
+ ]
5791
+ },
5792
+ {
5793
+ id: "Specimen.collection",
5794
+ path: "Specimen.collection",
5795
+ definition: "Details concerning the specimen collection.",
5796
+ min: 0,
5797
+ max: "1",
5798
+ type: [
5799
+ {
5800
+ code: "BackboneElement"
5801
+ }
5802
+ ]
5803
+ },
5804
+ {
5805
+ id: "Specimen.collection.id",
5806
+ path: "Specimen.collection.id",
5807
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
5808
+ min: 0,
5809
+ max: "1",
5810
+ type: [
5811
+ {
5812
+ code: "http://hl7.org/fhirpath/System.String"
5813
+ }
5814
+ ]
5815
+ },
5816
+ {
5817
+ id: "Specimen.collection.extension",
5818
+ path: "Specimen.collection.extension",
5819
+ 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.",
5820
+ min: 0,
5821
+ max: "*",
5822
+ type: [
5823
+ {
5824
+ code: "Extension"
5825
+ }
5826
+ ]
5827
+ },
5828
+ {
5829
+ id: "Specimen.collection.modifierExtension",
5830
+ path: "Specimen.collection.modifierExtension",
5831
+ 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).",
5832
+ min: 0,
5833
+ max: "*",
5834
+ type: [
5835
+ {
5836
+ code: "Extension"
5837
+ }
5838
+ ]
5839
+ },
5840
+ {
5841
+ id: "Specimen.collection.collector",
5842
+ path: "Specimen.collection.collector",
5843
+ definition: "Person who collected the specimen.",
5844
+ min: 0,
5845
+ max: "1",
5846
+ type: [
5847
+ {
5848
+ code: "Reference",
5849
+ targetProfile: [
5850
+ "http://hl7.org/fhir/StructureDefinition/Practitioner",
5851
+ "http://hl7.org/fhir/StructureDefinition/PractitionerRole"
5852
+ ]
5853
+ }
5854
+ ]
5855
+ },
5856
+ {
5857
+ id: "Specimen.collection.collected[x]",
5858
+ path: "Specimen.collection.collected[x]",
5859
+ definition: "Time when specimen was collected from subject - the physiologically relevant time.",
5860
+ min: 0,
5861
+ max: "1",
5862
+ type: [
5863
+ {
5864
+ code: "dateTime"
5865
+ },
5866
+ {
5867
+ code: "Period"
5868
+ }
5869
+ ]
5870
+ },
5871
+ {
5872
+ id: "Specimen.collection.duration",
5873
+ path: "Specimen.collection.duration",
5874
+ definition: "The span of time over which the collection of a specimen occurred.",
5875
+ min: 0,
5876
+ max: "1",
5877
+ type: [
5878
+ {
5879
+ code: "Duration"
5880
+ }
5881
+ ]
5882
+ },
5883
+ {
5884
+ id: "Specimen.collection.quantity",
5885
+ path: "Specimen.collection.quantity",
5886
+ definition: "The quantity of specimen collected; for instance the volume of a blood sample, or the physical measurement of an anatomic pathology sample.",
5887
+ min: 0,
5888
+ max: "1",
5889
+ type: [
5890
+ {
5891
+ code: "Quantity"
5892
+ }
5893
+ ]
5894
+ },
5895
+ {
5896
+ id: "Specimen.collection.method",
5897
+ path: "Specimen.collection.method",
5898
+ definition: "A coded value specifying the technique that is used to perform the procedure.",
5899
+ min: 0,
5900
+ max: "1",
5901
+ type: [
5902
+ {
5903
+ code: "CodeableConcept"
5904
+ }
5905
+ ],
5906
+ binding: {
5907
+ description: "The technique that is used to perform the procedure.",
5908
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-collection-method"
5909
+ }
5910
+ },
5911
+ {
5912
+ id: "Specimen.collection.bodySite",
5913
+ path: "Specimen.collection.bodySite",
5914
+ 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.",
5915
+ min: 0,
5916
+ max: "1",
5917
+ type: [
5918
+ {
5919
+ code: "CodeableConcept"
5920
+ }
5921
+ ],
5922
+ binding: {
5923
+ description: "Codes describing anatomical locations. May include laterality.",
5924
+ valueSet: "http://hl7.org/fhir/ValueSet/body-site"
5925
+ }
5926
+ },
5927
+ {
5928
+ id: "Specimen.collection.fastingStatus[x]",
5929
+ path: "Specimen.collection.fastingStatus[x]",
5930
+ definition: "Abstinence or reduction from some or all food, drink, or both, for a period of time prior to sample collection.",
5931
+ min: 0,
5932
+ max: "1",
5933
+ type: [
5934
+ {
5935
+ code: "CodeableConcept"
5936
+ },
5937
+ {
5938
+ code: "Duration"
5939
+ }
5940
+ ],
5941
+ binding: {
5942
+ description: "Codes describing the fasting status of the patient.",
5943
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0916"
5944
+ }
5945
+ },
5946
+ {
5947
+ id: "Specimen.processing",
5948
+ path: "Specimen.processing",
5949
+ definition: "Details concerning processing and processing steps for the specimen.",
5950
+ min: 0,
5951
+ max: "*",
5952
+ type: [
5953
+ {
5954
+ code: "BackboneElement"
5955
+ }
5956
+ ]
5957
+ },
5958
+ {
5959
+ id: "Specimen.processing.id",
5960
+ path: "Specimen.processing.id",
5961
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
5962
+ min: 0,
5963
+ max: "1",
5964
+ type: [
5965
+ {
5966
+ code: "http://hl7.org/fhirpath/System.String"
5967
+ }
5968
+ ]
5969
+ },
5970
+ {
5971
+ id: "Specimen.processing.extension",
5972
+ path: "Specimen.processing.extension",
5973
+ 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.",
5974
+ min: 0,
5975
+ max: "*",
5976
+ type: [
5977
+ {
5978
+ code: "Extension"
5979
+ }
5980
+ ]
5981
+ },
5982
+ {
5983
+ id: "Specimen.processing.modifierExtension",
5984
+ path: "Specimen.processing.modifierExtension",
5985
+ 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).",
5986
+ min: 0,
5987
+ max: "*",
5988
+ type: [
5989
+ {
5990
+ code: "Extension"
5991
+ }
5992
+ ]
5993
+ },
5994
+ {
5995
+ id: "Specimen.processing.description",
5996
+ path: "Specimen.processing.description",
5997
+ definition: "Textual description of procedure.",
5998
+ min: 0,
5999
+ max: "1",
6000
+ type: [
6001
+ {
6002
+ code: "string"
6003
+ }
6004
+ ]
6005
+ },
6006
+ {
6007
+ id: "Specimen.processing.procedure",
6008
+ path: "Specimen.processing.procedure",
6009
+ definition: "A coded value specifying the procedure used to process the specimen.",
6010
+ min: 0,
6011
+ max: "1",
6012
+ type: [
6013
+ {
6014
+ code: "CodeableConcept"
6015
+ }
6016
+ ],
6017
+ binding: {
6018
+ description: "Type indicating the technique used to process the specimen.",
6019
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-processing-procedure"
6020
+ }
6021
+ },
6022
+ {
6023
+ id: "Specimen.processing.additive",
6024
+ path: "Specimen.processing.additive",
6025
+ definition: "Material used in the processing step.",
6026
+ min: 0,
6027
+ max: "*",
6028
+ type: [
6029
+ {
6030
+ code: "Reference",
6031
+ targetProfile: [
6032
+ "http://hl7.org/fhir/StructureDefinition/Substance"
6033
+ ]
6034
+ }
6035
+ ]
6036
+ },
6037
+ {
6038
+ id: "Specimen.processing.time[x]",
6039
+ path: "Specimen.processing.time[x]",
6040
+ 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.",
6041
+ min: 0,
6042
+ max: "1",
6043
+ type: [
6044
+ {
6045
+ code: "dateTime"
6046
+ },
6047
+ {
6048
+ code: "Period"
6049
+ }
6050
+ ]
6051
+ },
6052
+ {
6053
+ id: "Specimen.container",
6054
+ path: "Specimen.container",
6055
+ definition: "The container holding the specimen. The recursive nature of containers; i.e. blood in tube in tray in rack is not addressed here.",
6056
+ min: 0,
6057
+ max: "*",
6058
+ type: [
6059
+ {
6060
+ code: "BackboneElement"
6061
+ }
6062
+ ]
6063
+ },
6064
+ {
6065
+ id: "Specimen.container.id",
6066
+ path: "Specimen.container.id",
6067
+ definition: "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
6068
+ min: 0,
6069
+ max: "1",
6070
+ type: [
6071
+ {
6072
+ code: "http://hl7.org/fhirpath/System.String"
6073
+ }
6074
+ ]
6075
+ },
6076
+ {
6077
+ id: "Specimen.container.extension",
6078
+ path: "Specimen.container.extension",
6079
+ 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.",
6080
+ min: 0,
6081
+ max: "*",
6082
+ type: [
6083
+ {
6084
+ code: "Extension"
6085
+ }
6086
+ ]
6087
+ },
6088
+ {
6089
+ id: "Specimen.container.modifierExtension",
6090
+ path: "Specimen.container.modifierExtension",
6091
+ 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).",
6092
+ min: 0,
6093
+ max: "*",
6094
+ type: [
6095
+ {
6096
+ code: "Extension"
6097
+ }
6098
+ ]
6099
+ },
6100
+ {
6101
+ id: "Specimen.container.identifier",
6102
+ path: "Specimen.container.identifier",
6103
+ 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.",
6104
+ min: 0,
6105
+ max: "*",
6106
+ type: [
6107
+ {
6108
+ code: "Identifier"
6109
+ }
6110
+ ]
6111
+ },
6112
+ {
6113
+ id: "Specimen.container.description",
6114
+ path: "Specimen.container.description",
6115
+ definition: "Textual description of the container.",
6116
+ min: 0,
6117
+ max: "1",
6118
+ type: [
6119
+ {
6120
+ code: "string"
6121
+ }
6122
+ ]
6123
+ },
6124
+ {
6125
+ id: "Specimen.container.type",
6126
+ path: "Specimen.container.type",
6127
+ definition: "The type of container associated with the specimen (e.g. slide, aliquot, etc.).",
6128
+ min: 0,
6129
+ max: "1",
6130
+ type: [
6131
+ {
6132
+ code: "CodeableConcept"
6133
+ }
6134
+ ],
6135
+ binding: {
6136
+ description: "Type of specimen container.",
6137
+ valueSet: "http://hl7.org/fhir/ValueSet/specimen-container-type"
6138
+ }
6139
+ },
6140
+ {
6141
+ id: "Specimen.container.capacity",
6142
+ path: "Specimen.container.capacity",
6143
+ definition: "The capacity (volume or other measure) the container may contain.",
6144
+ min: 0,
6145
+ max: "1",
6146
+ type: [
6147
+ {
6148
+ code: "Quantity"
6149
+ }
6150
+ ]
6151
+ },
6152
+ {
6153
+ id: "Specimen.container.specimenQuantity",
6154
+ path: "Specimen.container.specimenQuantity",
6155
+ definition: "The quantity of specimen in the container; may be volume, dimensions, or other appropriate measurements, depending on the specimen type.",
6156
+ min: 0,
6157
+ max: "1",
6158
+ type: [
6159
+ {
6160
+ code: "Quantity"
6161
+ }
6162
+ ]
6163
+ },
6164
+ {
6165
+ id: "Specimen.container.additive[x]",
6166
+ path: "Specimen.container.additive[x]",
6167
+ definition: "Introduced substance to preserve, maintain or enhance the specimen. Examples: Formalin, Citrate, EDTA.",
6168
+ min: 0,
6169
+ max: "1",
6170
+ type: [
6171
+ {
6172
+ code: "CodeableConcept"
6173
+ },
6174
+ {
6175
+ code: "Reference",
6176
+ targetProfile: [
6177
+ "http://hl7.org/fhir/StructureDefinition/Substance"
6178
+ ]
6179
+ }
6180
+ ],
6181
+ binding: {
6182
+ description: "Substance added to specimen container.",
6183
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0371"
6184
+ }
6185
+ },
6186
+ {
6187
+ id: "Specimen.condition",
6188
+ path: "Specimen.condition",
6189
+ definition: "A mode or state of being that describes the nature of the specimen.",
6190
+ min: 0,
6191
+ max: "*",
6192
+ type: [
6193
+ {
6194
+ code: "CodeableConcept"
6195
+ }
6196
+ ],
6197
+ binding: {
6198
+ description: "Codes describing the state of the specimen.",
6199
+ valueSet: "http://terminology.hl7.org/ValueSet/v2-0493"
6200
+ }
6201
+ },
6202
+ {
6203
+ id: "Specimen.note",
6204
+ path: "Specimen.note",
6205
+ definition: "To communicate any details or issues about the specimen or during the specimen collection. (for example: broken vial, sent with patient, frozen).",
6206
+ min: 0,
6207
+ max: "*",
6208
+ type: [
6209
+ {
6210
+ code: "Annotation"
6211
+ }
6212
+ ]
6213
+ }
6214
+ ]
6215
+ }
6216
+ }
6217
+ ];
6218
+
6219
+ const PatientSearchParameters = [
6220
+ {
6221
+ resourceType: 'SearchParameter',
6222
+ id: 'Patient-name',
6223
+ base: ['Patient'],
6224
+ code: 'name',
6225
+ name: 'name',
6226
+ type: 'string',
6227
+ expression: 'Patient.name',
6228
+ },
6229
+ {
6230
+ resourceType: 'SearchParameter',
6231
+ id: 'Patient-birthdate',
6232
+ base: ['Patient'],
6233
+ code: 'birthdate',
6234
+ name: 'birthdate',
6235
+ type: 'date',
6236
+ expression: 'Patient.birthDate',
6237
+ },
6238
+ {
6239
+ resourceType: 'SearchParameter',
6240
+ id: 'Patient-organization',
6241
+ base: ['Patient'],
6242
+ code: 'organization',
6243
+ name: 'organization',
6244
+ type: 'reference',
6245
+ expression: 'Patient.managingOrganization',
6246
+ target: ['Organization'],
6247
+ },
6248
+ {
6249
+ resourceType: 'SearchParameter',
6250
+ id: 'Patient-active',
6251
+ base: ['Patient'],
6252
+ code: 'active',
6253
+ name: 'active',
6254
+ type: 'token',
6255
+ expression: 'Patient.active',
6256
+ },
6257
+ {
6258
+ resourceType: 'SearchParameter',
6259
+ id: 'individual-telecom',
6260
+ base: ['Patient', 'Practitioner'],
6261
+ code: 'telecom',
6262
+ name: 'telecom',
6263
+ type: 'token',
6264
+ expression: 'Patient.telecom | Practitioner.telecom',
6265
+ },
6266
+ {
6267
+ resourceType: 'SearchParameter',
6268
+ id: 'individual-email',
6269
+ base: ['Patient', 'Practitioner'],
6270
+ code: 'email',
6271
+ name: 'email',
6272
+ type: 'token',
6273
+ expression: "Patient.telecom.where(system='email') | Practitioner.telecom.where(system='email')",
6274
+ },
6275
+ {
6276
+ resourceType: 'SearchParameter',
6277
+ id: 'individual-phone',
6278
+ base: ['Patient', 'Practitioner'],
6279
+ code: 'phone',
6280
+ name: 'phone',
6281
+ type: 'token',
6282
+ expression: "Patient.telecom.where(system='phone') | Practitioner.telecom.where(system='phone')",
6283
+ },
6284
+ {
6285
+ resourceType: 'SearchParameter',
6286
+ id: 'individual-address-city',
6287
+ base: ['Patient', 'Practitioner'],
6288
+ code: 'address-city',
6289
+ name: 'address-city',
6290
+ type: 'token',
6291
+ expression: 'Patient.address.city | Practitioner.address.city',
6292
+ },
6293
+ {
6294
+ resourceType: 'SearchParameter',
6295
+ id: 'individual-address-state',
6296
+ base: ['Patient', 'Practitioner'],
6297
+ code: 'address-state',
6298
+ name: 'address-state',
6299
+ type: 'token',
6300
+ expression: 'Patient.address.state | Practitioner.address.state',
6301
+ },
6302
+ {
6303
+ resourceType: 'SearchParameter',
6304
+ id: 'ServiceRequest-subject',
6305
+ code: 'subject',
6306
+ base: ['ServiceRequest'],
6307
+ type: 'reference',
6308
+ expression: 'ServiceRequest.subject',
6309
+ target: ['Group', 'Device', 'Patient', 'Location'],
6310
+ },
6311
+ {
6312
+ resourceType: 'SearchParameter',
6313
+ id: 'ServiceRequest-authored',
6314
+ code: 'authored',
6315
+ base: ['ServiceRequest'],
6316
+ type: 'date',
6317
+ expression: 'ServiceRequest.authoredOn',
6318
+ },
6319
+ {
6320
+ resourceType: 'SearchParameter',
6321
+ id: 'Observation-value-quantity',
6322
+ code: 'value-quantity',
6323
+ base: ['Observation'],
6324
+ type: 'quantity',
6325
+ expression: '(Observation.value as Quantity) | (Observation.value as SampledData)',
6326
+ },
6327
+ {
6328
+ resourceType: 'SearchParameter',
6329
+ id: 'Encounter-length',
6330
+ code: 'length',
6331
+ base: ['Encounter'],
6332
+ type: 'quantity',
6333
+ expression: 'Encounter.length',
6334
+ },
6335
+ ];
6336
+ const GraphQLSchemaResponse = {
6337
+ data: {
6338
+ StructureDefinitionList,
6339
+ SearchParameterList: [...PatientSearchParameters],
6340
+ },
6341
+ };
6342
+
6343
+ const exampleValueSet = {
6344
+ resourceType: 'ValueSet',
6345
+ expansion: {
6346
+ contains: [
6347
+ {
6348
+ system: 'x',
6349
+ code: 'test-code',
6350
+ display: 'Test Display',
6351
+ },
6352
+ ],
6353
+ },
6354
+ };
6355
+
6356
+ /******************************************************************************
6357
+ Copyright (c) Microsoft Corporation.
6358
+
6359
+ Permission to use, copy, modify, and/or distribute this software for any
6360
+ purpose with or without fee is hereby granted.
6361
+
6362
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6363
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6364
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6365
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6366
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6367
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6368
+ PERFORMANCE OF THIS SOFTWARE.
6369
+ ***************************************************************************** */
6370
+
6371
+ function __classPrivateFieldGet$1(receiver, state, kind, f) {
6372
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6373
+ 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");
6374
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6375
+ }
6376
+
6377
+ function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
6378
+ if (kind === "m") throw new TypeError("Private method is not writable");
6379
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6380
+ 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");
6381
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6382
+ }
6383
+
6384
+ /******************************************************************************
6385
+ Copyright (c) Microsoft Corporation.
6386
+
6387
+ Permission to use, copy, modify, and/or distribute this software for any
6388
+ purpose with or without fee is hereby granted.
6389
+
6390
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
6391
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6392
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
6393
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
6394
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
6395
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
6396
+ PERFORMANCE OF THIS SOFTWARE.
6397
+ ***************************************************************************** */
6398
+
6399
+ function __classPrivateFieldGet(receiver, state, kind, f) {
6400
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
6401
+ 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");
6402
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6403
+ }
6404
+
6405
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
6406
+ if (kind === "m") throw new TypeError("Private method is not writable");
6407
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
6408
+ 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");
6409
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6410
+ }
6411
+
6412
+ /**
6413
+ * Ensures that the value is wrapped in an array.
6414
+ * @param input The input as a an array or a value.
6415
+ * @returns The input as an array.
6416
+ */
6417
+ function ensureArray(input) {
6418
+ if (input === null || input === undefined) {
6419
+ return [];
6420
+ }
6421
+ return Array.isArray(input) ? input : [input];
6422
+ }
6423
+ /**
6424
+ * Applies a function to single value or an array of values.
6425
+ * @param context The context which will be passed to the function.
6426
+ * @param fn The function to apply.
6427
+ * @returns The result of the function.
6428
+ */
6429
+ function applyMaybeArray(context, fn) {
6430
+ if (context === undefined) {
6431
+ return undefined;
6432
+ }
6433
+ if (Array.isArray(context)) {
6434
+ return context
6435
+ .map((e) => fn(e))
6436
+ .filter((e) => !!e)
6437
+ .flat();
6438
+ }
6439
+ else {
6440
+ return fn(context);
6441
+ }
6442
+ }
6443
+ /**
6444
+ * Determines if the input is an empty array.
6445
+ * @param obj Any value or array of values.
6446
+ * @returns True if the input is an empty array.
6447
+ */
6448
+ function isEmptyArray(obj) {
6449
+ return Array.isArray(obj) && obj.length === 0;
6450
+ }
6451
+ function isFalsy(obj) {
6452
+ return !obj || isEmptyArray(obj);
6453
+ }
6454
+ /**
6455
+ * Converts unknown object into a JavaScript boolean.
6456
+ * Note that this is different than the FHIRPath "toBoolean",
6457
+ * which has particular semantics around arrays, empty arrays, and type conversions.
6458
+ * @param obj Any value or array of values.
6459
+ * @returns The converted boolean value according to FHIRPath rules.
6460
+ */
6461
+ function toJsBoolean(obj) {
6462
+ if (Array.isArray(obj)) {
6463
+ return obj.length === 0 ? false : !!obj[0];
6464
+ }
6465
+ return !!obj;
6466
+ }
6467
+ /**
6468
+ * Removes duplicates in array using FHIRPath equality rules.
6469
+ * @param arr The input array.
6470
+ * @returns The result array with duplicates removed.
6471
+ */
6472
+ function removeDuplicates(arr) {
6473
+ const result = [];
6474
+ for (const i of arr) {
6475
+ let found = false;
6476
+ for (const j of result) {
6477
+ if (fhirPathEquals(i, j)) {
6478
+ found = true;
6479
+ break;
5803
6480
  }
5804
6481
  }
5805
6482
  if (!found) {
@@ -6296,6 +6973,23 @@ class FunctionAtom {
6296
6973
  eval(context) {
6297
6974
  return this.impl(ensureArray(context), ...this.args);
6298
6975
  }
6976
+ }
6977
+ class IndexerAtom {
6978
+ constructor(left, expr) {
6979
+ this.left = left;
6980
+ this.expr = expr;
6981
+ }
6982
+ eval(context) {
6983
+ const index = this.expr.eval(context);
6984
+ if (typeof index !== 'number') {
6985
+ throw new Error(`Invalid indexer expression: should return integer}`);
6986
+ }
6987
+ const leftResult = this.left.eval(context);
6988
+ if (!(index in leftResult)) {
6989
+ return [];
6990
+ }
6991
+ return leftResult[index];
6992
+ }
6299
6993
  }
6300
6994
 
6301
6995
  function parseDateString(str) {
@@ -6558,7 +7252,7 @@ function where(input, criteria) {
6558
7252
  * See: http://hl7.org/fhirpath/#selectprojection-expression-collection
6559
7253
  */
6560
7254
  function select(input, criteria) {
6561
- return ensureArray(criteria.eval(input));
7255
+ return ensureArray(input.map((e) => criteria.eval(e)).flat());
6562
7256
  }
6563
7257
  /**
6564
7258
  * A version of select that will repeat the projection and add it to the output
@@ -8013,7 +8707,7 @@ class ParserBuilder {
8013
8707
  prefix(tokenType, precedence, builder) {
8014
8708
  return this.registerPrefix(tokenType, {
8015
8709
  parse(parser, token) {
8016
- const right = parser.parse(precedence);
8710
+ const right = parser.consumeAndParse(precedence);
8017
8711
  return builder(token, right);
8018
8712
  },
8019
8713
  });
@@ -8021,7 +8715,7 @@ class ParserBuilder {
8021
8715
  infixLeft(tokenType, precedence, builder) {
8022
8716
  return this.registerInfix(tokenType, {
8023
8717
  parse(parser, left, token) {
8024
- const right = parser.parse(precedence);
8718
+ const right = parser.consumeAndParse(precedence);
8025
8719
  return builder(left, token, right);
8026
8720
  },
8027
8721
  precedence,
@@ -8050,7 +8744,7 @@ class Parser {
8050
8744
  __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
8051
8745
  return true;
8052
8746
  }
8053
- parse(precedence = 100 /* MaximumPrecedence */) {
8747
+ consumeAndParse(precedence = 100 /* MaximumPrecedence */) {
8054
8748
  const token = __classPrivateFieldGet(this, _Parser_instances, "m", _Parser_consume).call(this);
8055
8749
  const prefix = __classPrivateFieldGet(this, _Parser_prefixParselets, "f")[token.id];
8056
8750
  if (!prefix) {
@@ -8085,13 +8779,23 @@ _Parser_tokens = new WeakMap(), _Parser_prefixParselets = new WeakMap(), _Parser
8085
8779
  };
8086
8780
  const PARENTHESES_PARSELET = {
8087
8781
  parse(parser) {
8088
- const expr = parser.parse();
8782
+ const expr = parser.consumeAndParse();
8089
8783
  if (!parser.match(')')) {
8090
8784
  throw new Error('Parse error: expected `)`');
8091
8785
  }
8092
8786
  return expr;
8093
8787
  },
8094
8788
  };
8789
+ const INDEXER_PARSELET = {
8790
+ parse(parser, left) {
8791
+ const expr = parser.consumeAndParse();
8792
+ if (!parser.match(']')) {
8793
+ throw new Error('Parse error: expected `]`');
8794
+ }
8795
+ return new IndexerAtom(left, expr);
8796
+ },
8797
+ precedence: 2 /* Indexer */,
8798
+ };
8095
8799
  const FUNCTION_CALL_PARSELET = {
8096
8800
  parse(parser, left) {
8097
8801
  if (!(left instanceof SymbolAtom)) {
@@ -8102,7 +8806,7 @@ const FUNCTION_CALL_PARSELET = {
8102
8806
  }
8103
8807
  const args = [];
8104
8808
  while (!parser.match(')')) {
8105
- args.push(parser.parse());
8809
+ args.push(parser.consumeAndParse());
8106
8810
  parser.match(',');
8107
8811
  }
8108
8812
  return new FunctionAtom(left.name, args, functions[left.name]);
@@ -8147,6 +8851,7 @@ const parserBuilder = new ParserBuilder()
8147
8851
  })
8148
8852
  .registerPrefix('{}', { parse: () => new EmptySetAtom() })
8149
8853
  .registerPrefix('(', PARENTHESES_PARSELET)
8854
+ .registerInfix('[', INDEXER_PARSELET)
8150
8855
  .registerInfix('(', FUNCTION_CALL_PARSELET)
8151
8856
  .prefix('+', 3 /* UnaryAdd */, (_, right) => new UnaryOperatorAtom(right, (x) => x))
8152
8857
  .prefix('-', 3 /* UnarySubtract */, (_, right) => new ArithemticOperatorAtom(right, right, (_, y) => -y))
@@ -8199,7 +8904,7 @@ const parserBuilder = new ParserBuilder()
8199
8904
  */
8200
8905
  function parseFhirPath(input) {
8201
8906
  try {
8202
- return new FhirPathAtom(input, parserBuilder.construct(input).parse());
8907
+ return new FhirPathAtom(input, parserBuilder.construct(input).consumeAndParse());
8203
8908
  }
8204
8909
  catch (error) {
8205
8910
  throw new Error(`FhirPathError on "${input}": ${error}`);
@@ -8327,14 +9032,10 @@ class MockClient extends MedplumClient {
8327
9032
  if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
8328
9033
  console.log('MockClient', method, path);
8329
9034
  }
8330
- const result = mockHandler(method, path, options);
8331
- if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) && !result) {
9035
+ const response = mockHandler(method, path, options);
9036
+ if ((clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) && !response) {
8332
9037
  console.log('MockClient: not found', method, path);
8333
9038
  }
8334
- const response = Object.assign({ request: {
8335
- url,
8336
- options,
8337
- } }, result);
8338
9039
  if (clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.debug) {
8339
9040
  console.log('MockClient', JSON.stringify(response, null, 2));
8340
9041
  }
@@ -8423,6 +9124,11 @@ function mockAuthHandler(method, path, options) {
8423
9124
  if (path.startsWith('auth/resetpassword')) {
8424
9125
  return mockResetPasswordHandler(method, path, options);
8425
9126
  }
9127
+ if (path.startsWith('auth/me')) {
9128
+ return {
9129
+ profile: { reference: 'Practitioner/123' },
9130
+ };
9131
+ }
8426
9132
  return null;
8427
9133
  }
8428
9134
  function mockChangePasswordHandler(method, path, options) {
@@ -8543,6 +9249,7 @@ mockRepo.createResource(HomerObservation3);
8543
9249
  mockRepo.createResource(HomerObservation4);
8544
9250
  mockRepo.createResource(HomerObservation5);
8545
9251
  mockRepo.createResource(HomerObservation6);
9252
+ mockRepo.createResource(HomerSimpsonSpecimen);
8546
9253
  mockRepo.createResource(TestOrganization);
8547
9254
  mockRepo.createResource(DifferentOrganization);
8548
9255
  mockRepo.createResource(ExampleQuestionnaire);
@@ -8589,7 +9296,7 @@ function mockFhirHandler(method, url, options) {
8589
9296
  return mockRepo.readResource(resourceType, id);
8590
9297
  }
8591
9298
  else if (resourceType) {
8592
- return mockRepo.search(parseSearchDefinition(new URL(url, 'https://example.com/')));
9299
+ return mockRepo.search(parseSearchDefinition(url));
8593
9300
  }
8594
9301
  }
8595
9302
  else if (method === 'PUT') {
@@ -8621,5 +9328,5 @@ function mockFhirBatchHandler(method, path, options) {
8621
9328
  };
8622
9329
  }
8623
9330
 
8624
- export { BartSimpson, DifferentOrganization, DrAliceSmith, DrAliceSmithPreviousVersion, DrAliceSmithSchedule, DrAliceSmithSlots, ExampleAccessPolicy, ExampleAuditEvent, ExampleBot, ExampleQuestionnaire, ExampleQuestionnaireResponse, ExampleStatusValueSet, ExampleSubscription, ExampleUserConfiguration, GraphQLSchemaResponse, HomerCommunication, HomerDiagnosticReport, HomerEncounter, HomerMedia, HomerObservation1, HomerObservation2, HomerObservation3, HomerObservation4, HomerObservation5, HomerObservation6, HomerServiceRequest, HomerSimpson, HomerSimpsonPreviousVersion, MockClient, PatientSearchParameters, TestOrganization, exampleValueSet };
9331
+ export { BartSimpson, DifferentOrganization, DrAliceSmith, DrAliceSmithPreviousVersion, DrAliceSmithSchedule, DrAliceSmithSlots, ExampleAccessPolicy, ExampleAuditEvent, ExampleBot, ExampleQuestionnaire, ExampleQuestionnaireResponse, ExampleStatusValueSet, ExampleSubscription, ExampleUserConfiguration, GraphQLSchemaResponse, HomerCommunication, HomerDiagnosticReport, HomerEncounter, HomerMedia, HomerObservation1, HomerObservation2, HomerObservation3, HomerObservation4, HomerObservation5, HomerObservation6, HomerServiceRequest, HomerSimpson, HomerSimpsonPreviousVersion, HomerSimpsonSpecimen, MockClient, PatientSearchParameters, TestOrganization, exampleValueSet };
8625
9332
  //# sourceMappingURL=index.js.map