@medplum/agent 2.1.10 → 2.1.12

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.
Files changed (2) hide show
  1. package/dist/cjs/index.cjs +387 -356
  2. package/package.json +11 -11
@@ -3591,10 +3591,10 @@ var xe = class {
3591
3591
  }, precedence: t });
3592
3592
  }
3593
3593
  construct(e) {
3594
- return new nt(e, this.prefixParselets, this.infixParselets);
3594
+ return new rt(e, this.prefixParselets, this.infixParselets);
3595
3595
  }
3596
3596
  };
3597
- var nt = class {
3597
+ var rt = class {
3598
3598
  constructor(e, t, n) {
3599
3599
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3600
3600
  }
@@ -3645,39 +3645,39 @@ var nt = class {
3645
3645
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
3646
3646
  }
3647
3647
  };
3648
- function K(r4) {
3649
- let e = se(r4), t = dn(r4);
3648
+ function G(r4) {
3649
+ let e = se(r4), t = hn(r4);
3650
3650
  return t === e ? { reference: e } : { reference: e, display: t };
3651
3651
  }
3652
3652
  function se(r4) {
3653
3653
  return ae(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
3654
3654
  }
3655
- function Ht(r4) {
3655
+ function Kt(r4) {
3656
3656
  if (r4)
3657
3657
  return ae(r4) ? r4.reference.split("/")[1] : r4.id;
3658
3658
  }
3659
- function ln(r4) {
3659
+ function mn(r4) {
3660
3660
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3661
3661
  }
3662
- function dn(r4) {
3663
- if (ln(r4)) {
3664
- let e = pn(r4);
3662
+ function hn(r4) {
3663
+ if (mn(r4)) {
3664
+ let e = yn(r4);
3665
3665
  if (e)
3666
3666
  return e;
3667
3667
  }
3668
3668
  if (r4.resourceType === "Device") {
3669
- let e = fn(r4);
3669
+ let e = gn(r4);
3670
3670
  if (e)
3671
3671
  return e;
3672
3672
  }
3673
3673
  return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : se(r4);
3674
3674
  }
3675
- function pn(r4) {
3675
+ function yn(r4) {
3676
3676
  let e = r4.name;
3677
3677
  if (e && e.length > 0)
3678
- return Ee(e[0]);
3678
+ return Re(e[0]);
3679
3679
  }
3680
- function fn(r4) {
3680
+ function gn(r4) {
3681
3681
  let e = r4.deviceName;
3682
3682
  if (e && e.length > 0)
3683
3683
  return e[0].name;
@@ -3687,90 +3687,90 @@ function Te(r4, e) {
3687
3687
  t.setUTCHours(0, 0, 0, 0);
3688
3688
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3689
3689
  n.setUTCHours(0, 0, 0, 0);
3690
- let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), m2 = n.getUTCDate(), p2 = a - i2;
3691
- (c2 < o || c2 === o && m2 < s) && p2--;
3690
+ let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), f = n.getUTCDate(), p2 = a - i2;
3691
+ (c2 < o || c2 === o && f < s) && p2--;
3692
3692
  let q = a * 12 + c2 - (i2 * 12 + o);
3693
- m2 < s && q--;
3694
- let un = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3695
- return { years: p2, months: q, days: un };
3693
+ f < s && q--;
3694
+ let fn = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3695
+ return { years: p2, months: q, days: fn };
3696
3696
  }
3697
- function Gt(r4, e) {
3698
- return JSON.stringify(r4, mn, e ? 2 : void 0);
3697
+ function zt(r4, e) {
3698
+ return JSON.stringify(r4, xn, e ? 2 : void 0);
3699
3699
  }
3700
- function mn(r4, e) {
3701
- return !hn(r4) && b(e) ? void 0 : e;
3700
+ function xn(r4, e) {
3701
+ return !Tn(r4) && E(e) ? void 0 : e;
3702
3702
  }
3703
- function hn(r4) {
3703
+ function Tn(r4) {
3704
3704
  return !!/\d+$/.exec(r4);
3705
3705
  }
3706
- function b(r4) {
3706
+ function E(r4) {
3707
3707
  if (r4 == null)
3708
3708
  return true;
3709
3709
  let e = typeof r4;
3710
3710
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3711
3711
  }
3712
- function Kt(r4) {
3712
+ function Jt(r4) {
3713
3713
  return r4.every((e) => typeof e == "string");
3714
3714
  }
3715
- var zt = [];
3715
+ var Yt = [];
3716
3716
  for (let r4 = 0; r4 < 256; r4++)
3717
- zt.push(r4.toString(16).padStart(2, "0"));
3718
- function Jt(r4) {
3717
+ Yt.push(r4.toString(16).padStart(2, "0"));
3718
+ function Xt(r4) {
3719
3719
  let e = new Uint8Array(r4), t = new Array(e.length);
3720
3720
  for (let n = 0; n < e.length; n++)
3721
- t[n] = zt[e[n]];
3721
+ t[n] = Yt[e[n]];
3722
3722
  return t.join("");
3723
3723
  }
3724
- function Yt(r4) {
3724
+ function Zt(r4) {
3725
3725
  let e = new Uint8Array(r4), t = [];
3726
3726
  for (let n = 0; n < e.length; n++)
3727
3727
  t[n] = String.fromCharCode(e[n]);
3728
3728
  return window.btoa(t.join(""));
3729
3729
  }
3730
- function A(r4) {
3730
+ function P(r4) {
3731
3731
  return r4.charAt(0).toUpperCase() + r4.substring(1);
3732
3732
  }
3733
- var st = (r4) => new Promise((e) => {
3733
+ var ot = (r4) => new Promise((e) => {
3734
3734
  setTimeout(e, r4);
3735
3735
  });
3736
- function Ee(r4, e) {
3736
+ function Re(r4, e) {
3737
3737
  let t = [];
3738
3738
  return r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0 && r4.text ? r4.text : t.join(" ").trim();
3739
3739
  }
3740
- function Un(r4) {
3740
+ function Bn(r4) {
3741
3741
  let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
3742
3742
  return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
3743
3743
  }
3744
- function tr(r4) {
3744
+ function nr(r4) {
3745
3745
  let e = /* @__PURE__ */ Object.create(null);
3746
3746
  for (let [t, n] of Object.entries(r4))
3747
- e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Un(o)])), constraints: [], innerTypes: [] };
3747
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Bn(o)])), constraints: [], innerTypes: [] };
3748
3748
  return e;
3749
3749
  }
3750
- var rr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3750
+ var ir = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3751
3751
  function l(r4) {
3752
3752
  return [{ type: u.boolean, value: r4 }];
3753
3753
  }
3754
3754
  function T(r4) {
3755
- return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : R(r4) ? { type: u.Quantity, value: r4 } : _(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3755
+ return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : b(r4) ? { type: u.Quantity, value: r4 } : N(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3756
3756
  }
3757
- function F(r4) {
3757
+ function L(r4) {
3758
3758
  return r4.length === 0 ? false : !!r4[0].value;
3759
3759
  }
3760
- function V(r4, e) {
3760
+ function D(r4, e) {
3761
3761
  if (r4.length !== 0) {
3762
3762
  if (r4.length === 1 && (!e || r4[0].type === e))
3763
3763
  return r4[0];
3764
3764
  throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3765
3765
  }
3766
3766
  }
3767
- function w(r4, e) {
3767
+ function I(r4, e) {
3768
3768
  if (!r4.value)
3769
3769
  return;
3770
3770
  let t = Ce(r4.type, e);
3771
- return t ? Fn(r4, e, t) : Mn(r4, e);
3771
+ return t ? $n(r4, e, t) : jn(r4, e);
3772
3772
  }
3773
- function Fn(r4, e, t) {
3773
+ function $n(r4, e, t) {
3774
3774
  let n = t.type;
3775
3775
  if (!n || n.length === 0)
3776
3776
  return;
@@ -3779,20 +3779,20 @@ function Fn(r4, e, t) {
3779
3779
  i2 = r4.value[e], o = n[0].code;
3780
3780
  else
3781
3781
  for (let a of n) {
3782
- let c2 = e.replace("[x]", "") + A(a.code);
3782
+ let c2 = e.replace("[x]", "") + P(a.code);
3783
3783
  if (c2 in r4.value) {
3784
3784
  i2 = r4.value[c2], o = a.code;
3785
3785
  break;
3786
3786
  }
3787
3787
  }
3788
3788
  let s = r4.value["_" + e];
3789
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? sr(a ?? {}, s[c2]) : a) : i2 = sr(i2 ?? {}, s)), !b(i2))
3790
- return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => nr(a, o)) : nr(i2, o);
3789
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !E(i2))
3790
+ return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => or(a, o)) : or(i2, o);
3791
3791
  }
3792
- function nr(r4, e) {
3793
- return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
3792
+ function or(r4, e) {
3793
+ return e === "Resource" && N(r4) && (e = r4.resourceType), { type: e, value: r4 };
3794
3794
  }
3795
- function Mn(r4, e) {
3795
+ function jn(r4, e) {
3796
3796
  let t = r4.value;
3797
3797
  if (!t || typeof t != "object")
3798
3798
  return;
@@ -3801,21 +3801,21 @@ function Mn(r4, e) {
3801
3801
  n = t[e];
3802
3802
  else
3803
3803
  for (let i2 in u) {
3804
- let o = e + A(i2);
3804
+ let o = e + P(i2);
3805
3805
  if (o in t) {
3806
3806
  n = t[o];
3807
3807
  break;
3808
3808
  }
3809
3809
  }
3810
- if (!b(n))
3810
+ if (!E(n))
3811
3811
  return Array.isArray(n) ? n.map(T) : T(n);
3812
3812
  }
3813
- function Ae(r4) {
3813
+ function Pe(r4) {
3814
3814
  let e = [];
3815
3815
  for (let t of r4) {
3816
3816
  let n = false;
3817
3817
  for (let i2 of e)
3818
- if (F(ar(t, i2))) {
3818
+ if (L(ur(t, i2))) {
3819
3819
  n = true;
3820
3820
  break;
3821
3821
  }
@@ -3823,28 +3823,28 @@ function Ae(r4) {
3823
3823
  }
3824
3824
  return e;
3825
3825
  }
3826
- function ut(r4) {
3827
- return l(!F(r4));
3826
+ function ct(r4) {
3827
+ return l(!L(r4));
3828
3828
  }
3829
- function lt(r4, e) {
3830
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => F(ar(t, e[n]))));
3829
+ function ut(r4, e) {
3830
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => L(ur(t, e[n]))));
3831
3831
  }
3832
- function ar(r4, e) {
3832
+ function ur(r4, e) {
3833
3833
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3834
- return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(cr(t, n)) : l(typeof t == "object" && typeof n == "object" ? pt(r4, e) : t === n);
3834
+ return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : b(t) && b(n) ? l(lr(t, n)) : l(typeof t == "object" && typeof n == "object" ? dt(r4, e) : t === n);
3835
3835
  }
3836
- function dt(r4, e) {
3837
- return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(ir), e.sort(ir), l(r4.every((t, n) => F(Bn(t, e[n])))));
3836
+ function lt(r4, e) {
3837
+ return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(sr), e.sort(sr), l(r4.every((t, n) => L(Qn(t, e[n])))));
3838
3838
  }
3839
- function Bn(r4, e) {
3839
+ function Qn(r4, e) {
3840
3840
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3841
- return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(cr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? pt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3841
+ return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : b(s) && b(a) ? l(lr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? dt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3842
3842
  }
3843
- function ir(r4, e) {
3843
+ function sr(r4, e) {
3844
3844
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3845
3845
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3846
3846
  }
3847
- function Pe(r4, e) {
3847
+ function Ae(r4, e) {
3848
3848
  let { value: t } = r4;
3849
3849
  if (t == null)
3850
3850
  return false;
@@ -3861,49 +3861,49 @@ function Pe(r4, e) {
3861
3861
  case "Time":
3862
3862
  return typeof t == "string" && !!/^T\d/.exec(t);
3863
3863
  case "Period":
3864
- return qn(t);
3864
+ return Hn(t);
3865
3865
  case "Quantity":
3866
- return R(t);
3866
+ return b(t);
3867
3867
  default:
3868
3868
  return typeof t == "object" && t?.resourceType === e;
3869
3869
  }
3870
3870
  }
3871
- function qn(r4) {
3871
+ function Hn(r4) {
3872
3872
  return !!(r4 && typeof r4 == "object" && "start" in r4);
3873
3873
  }
3874
- function R(r4) {
3874
+ function b(r4) {
3875
3875
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3876
3876
  }
3877
- function cr(r4, e) {
3877
+ function lr(r4, e) {
3878
3878
  return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
3879
3879
  }
3880
- function pt(r4, e) {
3880
+ function dt(r4, e) {
3881
3881
  let t = Object.keys(r4), n = Object.keys(e);
3882
3882
  if (t.length !== n.length)
3883
3883
  return false;
3884
3884
  for (let i2 of t) {
3885
3885
  let o = r4[i2], s = e[i2];
3886
- if (or(o) && or(s)) {
3887
- if (!pt(o, s))
3886
+ if (ar(o) && ar(s)) {
3887
+ if (!dt(o, s))
3888
3888
  return false;
3889
3889
  } else if (o !== s)
3890
3890
  return false;
3891
3891
  }
3892
3892
  return true;
3893
3893
  }
3894
- function or(r4) {
3894
+ function ar(r4) {
3895
3895
  return r4 !== null && typeof r4 == "object";
3896
3896
  }
3897
- function sr(r4, e) {
3897
+ function cr(r4, e) {
3898
3898
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3899
3899
  }
3900
- var ft = "ok";
3900
+ var pt = "ok";
3901
3901
  var we = "created";
3902
- var ht = "not-modified";
3903
- var yt = "not-found";
3902
+ var mt = "not-modified";
3903
+ var ht = "not-found";
3904
3904
  var Ie = "accepted";
3905
- var pr = { resourceType: "OperationOutcome", id: yt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3906
- function L(r4, e) {
3905
+ var mr = { resourceType: "OperationOutcome", id: ht, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3906
+ function F(r4, e) {
3907
3907
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3908
3908
  }
3909
3909
  function h(r4) {
@@ -3912,59 +3912,59 @@ function h(r4) {
3912
3912
  function ke(r4) {
3913
3913
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3914
3914
  }
3915
- function gt(r4) {
3916
- return r4.id === ft || r4.id === we || r4.id === ht || r4.id === Ie;
3915
+ function yt(r4) {
3916
+ return r4.id === pt || r4.id === we || r4.id === mt || r4.id === Ie;
3917
3917
  }
3918
3918
  var d = class extends Error {
3919
3919
  constructor(t, n) {
3920
- super(mr(t));
3920
+ super(yr(t));
3921
3921
  this.outcome = t, this.cause = n;
3922
3922
  }
3923
3923
  };
3924
3924
  function Oe(r4) {
3925
- return r4 instanceof d ? r4.outcome : ke(r4) ? r4 : L($n(r4));
3925
+ return r4 instanceof d ? r4.outcome : ke(r4) ? r4 : F(Kn(r4));
3926
3926
  }
3927
- function $n(r4) {
3928
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ke(r4) ? mr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3927
+ function Kn(r4) {
3928
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ke(r4) ? yr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3929
3929
  }
3930
- function mr(r4) {
3931
- let e = r4.issue?.map(jn) ?? [];
3930
+ function yr(r4) {
3931
+ let e = r4.issue?.map(Wn) ?? [];
3932
3932
  return e.length > 0 ? e.join("; ") : "Unknown error";
3933
3933
  }
3934
- function jn(r4) {
3934
+ function Wn(r4) {
3935
3935
  let e;
3936
3936
  return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3937
3937
  }
3938
- function bt(r4) {
3939
- return new vt(r4).parse();
3938
+ function St(r4) {
3939
+ return new Tt(r4).parse();
3940
3940
  }
3941
- var H = tr(rr);
3942
- function vr(r4) {
3941
+ var Q = nr(ir);
3942
+ function Er(r4) {
3943
3943
  let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3944
3944
  for (let t of e)
3945
- Hn(t);
3945
+ Gn(t);
3946
3946
  }
3947
- function Hn(r4) {
3947
+ function Gn(r4) {
3948
3948
  if (!r4?.name)
3949
3949
  throw new Error("Failed loading StructureDefinition from bundle");
3950
3950
  if (r4.resourceType !== "StructureDefinition")
3951
3951
  return;
3952
- let e = bt(r4);
3953
- H[r4.name] = e;
3952
+ let e = St(r4);
3953
+ Q[r4.name] = e;
3954
3954
  for (let t of e.innerTypes)
3955
- t.parentType = e, H[t.name] = t;
3956
- }
3957
- function br(r4) {
3958
- return !!H[r4];
3955
+ t.parentType = e, Q[t.name] = t;
3959
3956
  }
3960
3957
  function Rr(r4) {
3961
- return H[r4];
3958
+ return !!Q[r4];
3959
+ }
3960
+ function Pr(r4) {
3961
+ return Q[r4];
3962
3962
  }
3963
- var vt = class {
3963
+ var Tt = class {
3964
3964
  constructor(e) {
3965
3965
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
3966
3966
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
3967
- this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: e.description, elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3967
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: Xn(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3968
3968
  }
3969
3969
  parse() {
3970
3970
  let e = this.next();
@@ -3973,7 +3973,7 @@ var vt = class {
3973
3973
  this.parseSliceStart(e);
3974
3974
  else if (e.id?.includes(":")) {
3975
3975
  if (this.slicingContext?.current) {
3976
- let t = Tt(e, this.slicingContext.path);
3976
+ let t = xt(e, this.slicingContext.path);
3977
3977
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
3978
3978
  }
3979
3979
  } else {
@@ -3982,13 +3982,13 @@ var vt = class {
3982
3982
  let n = this.backboneContext;
3983
3983
  for (; n; ) {
3984
3984
  if (e.path?.startsWith(n.path + ".")) {
3985
- n.type.elements[Tt(e, n.path)] = t;
3985
+ n.type.elements[xt(e, n.path)] = t;
3986
3986
  break;
3987
3987
  }
3988
3988
  n = n.parent;
3989
3989
  }
3990
3990
  if (!n) {
3991
- let i2 = Tt(e, this.root.path);
3991
+ let i2 = xt(e, this.root.path);
3992
3992
  e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
3993
3993
  }
3994
3994
  this.checkFieldExit(e);
@@ -4003,10 +4003,10 @@ var vt = class {
4003
4003
  enterInnerType(e) {
4004
4004
  for (; this.backboneContext && !ee(this.backboneContext?.path, e.path); )
4005
4005
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4006
- this.backboneContext = { type: { name: St(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ee(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
4006
+ this.backboneContext = { type: { name: vt(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ee(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
4007
4007
  }
4008
4008
  enterSlice(e, t) {
4009
- Gn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4009
+ Yn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4010
4010
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
4011
4011
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
4012
4012
  return { path: n.path, type: n.type };
@@ -4047,55 +4047,59 @@ var vt = class {
4047
4047
  this.slicingContext.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext.current = { name: e.sliceName ?? "", type: e.type?.map((t) => ({ code: t.code ?? "", targetProfile: t.targetProfile })), elements: {}, min: e.min ?? 0, max: e.max === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(e.max, 10) };
4048
4048
  }
4049
4049
  parseElementDefinition(e) {
4050
- let t = xr(e.max), n = e.base?.max ? xr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4051
- return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? St(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Tr(w(i2, "fixed")), pattern: Tr(w(i2, "pattern")), binding: e.binding };
4050
+ let t = vr(e.max), n = e.base?.max ? vr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4051
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Sr(I(i2, "fixed")), pattern: Sr(I(i2, "pattern")), binding: e.binding };
4052
4052
  }
4053
4053
  };
4054
- function xr(r4) {
4054
+ function vr(r4) {
4055
4055
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
4056
4056
  }
4057
- function Tt(r4, e = "") {
4058
- return Wn(r4.path, e);
4057
+ function xt(r4, e = "") {
4058
+ return Jn(r4.path, e);
4059
4059
  }
4060
- function Wn(r4, e) {
4060
+ function Jn(r4, e) {
4061
4061
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
4062
4062
  }
4063
4063
  function ee(r4, e) {
4064
4064
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
4065
4065
  }
4066
- function Tr(r4) {
4067
- return Array.isArray(r4) && r4.length > 0 ? r4[0] : b(r4) ? void 0 : r4;
4066
+ function Sr(r4) {
4067
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : E(r4) ? void 0 : r4;
4068
4068
  }
4069
- function Gn(r4) {
4069
+ function Yn(r4) {
4070
4070
  let e = r4.slicing?.discriminator;
4071
4071
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
4072
4072
  }
4073
+ function Xn(r4) {
4074
+ let e = r4.description;
4075
+ return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
4076
+ }
4073
4077
  var u = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
4074
- function Et(r4) {
4078
+ function bt(r4) {
4075
4079
  for (let e of r4.base ?? []) {
4076
- let t = I.types[e];
4077
- t || (t = { searchParamsDetails: {} }, I.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
4080
+ let t = k.types[e];
4081
+ t || (t = { searchParamsDetails: {} }, k.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
4078
4082
  }
4079
4083
  }
4080
- function St(r4) {
4084
+ function vt(r4) {
4081
4085
  let e = r4.type?.[0]?.code;
4082
- return e === "BackboneElement" || e === "Element" ? Kn((r4.base?.path ?? r4.path)?.split(".")) : e;
4086
+ return e === "BackboneElement" || e === "Element" ? Zn((r4.base?.path ?? r4.path)?.split(".")) : e;
4083
4087
  }
4084
- function Kn(r4) {
4085
- return r4.length === 1 ? r4[0] : r4.map(A).join("");
4088
+ function Zn(r4) {
4089
+ return r4.length === 1 ? r4[0] : r4.map(P).join("");
4086
4090
  }
4087
4091
  function Ce(r4, e) {
4088
- let t = Rr(r4);
4092
+ let t = Pr(r4);
4089
4093
  if (t)
4090
4094
  return t.elements[e] ?? t.elements[e + "[x]"];
4091
4095
  }
4092
- function _(r4) {
4096
+ function N(r4) {
4093
4097
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
4094
4098
  }
4095
4099
  function ae(r4) {
4096
4100
  return !!(r4 && typeof r4 == "object" && "reference" in r4);
4097
4101
  }
4098
- var I = { types: {} };
4102
+ var k = { types: {} };
4099
4103
  function re(r4) {
4100
4104
  if (r4.startsWith("T"))
4101
4105
  return r4 + "T00:00:00.000Z".substring(r4.length);
@@ -4108,7 +4112,7 @@ function re(r4) {
4108
4112
  }
4109
4113
  }
4110
4114
  var ce = () => [];
4111
- var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => F(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => F(t.eval(r4, [n])))), allTrue: (r4, e) => {
4115
+ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => L(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => L(t.eval(r4, [n])))), allTrue: (r4, e) => {
4112
4116
  for (let t of e)
4113
4117
  if (!t.value)
4114
4118
  return l(false);
@@ -4133,7 +4137,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4133
4137
  for (let n of e)
4134
4138
  t.some((i2) => i2.value === n.value) || t.push(n);
4135
4139
  return t;
4136
- }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => F(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4140
+ }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => L(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4137
4141
  if (e.length > 1)
4138
4142
  throw new Error("Expected input length one for single()");
4139
4143
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4165,7 +4169,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4165
4169
  if (!t)
4166
4170
  return e;
4167
4171
  let n = t.eval(r4, e);
4168
- return Ae([...e, ...n]);
4172
+ return Pe([...e, ...n]);
4169
4173
  }, combine: (r4, e, t) => {
4170
4174
  if (!t)
4171
4175
  return e;
@@ -4175,11 +4179,11 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4175
4179
  let o = t.eval(r4, e);
4176
4180
  if (o.length > 1 || o.length === 1 && typeof o[0].value != "boolean")
4177
4181
  throw new Error("Expected criterion to evaluate to a Boolean");
4178
- return F(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4182
+ return L(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4179
4183
  }, toBoolean: (r4, e) => {
4180
4184
  if (e.length === 0)
4181
4185
  return [];
4182
- let [{ value: t }] = N(e, 1);
4186
+ let [{ value: t }] = U(e, 1);
4183
4187
  if (typeof t == "boolean")
4184
4188
  return [{ type: u.boolean, value: t }];
4185
4189
  if (typeof t == "number" && (t === 0 || t === 1))
@@ -4195,47 +4199,47 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4195
4199
  }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4196
4200
  if (e.length === 0)
4197
4201
  return [];
4198
- let [{ value: t }] = N(e, 1);
4202
+ let [{ value: t }] = U(e, 1);
4199
4203
  return typeof t == "number" ? [{ type: u.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: u.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: u.integer, value: t ? 1 : 0 }] : [];
4200
4204
  }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4201
4205
  if (e.length === 0)
4202
4206
  return [];
4203
- let [{ value: t }] = N(e, 1);
4207
+ let [{ value: t }] = U(e, 1);
4204
4208
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4205
4209
  }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4206
4210
  if (e.length === 0)
4207
4211
  return [];
4208
- let [{ value: t }] = N(e, 1);
4212
+ let [{ value: t }] = U(e, 1);
4209
4213
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4210
4214
  }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4211
4215
  if (e.length === 0)
4212
4216
  return [];
4213
- let [{ value: t }] = N(e, 1);
4217
+ let [{ value: t }] = U(e, 1);
4214
4218
  return typeof t == "number" ? [{ type: u.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: u.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: u.decimal, value: t ? 1 : 0 }] : [];
4215
4219
  }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4216
4220
  if (e.length === 0)
4217
4221
  return [];
4218
- let [{ value: t }] = N(e, 1);
4219
- return R(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4222
+ let [{ value: t }] = U(e, 1);
4223
+ return b(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4220
4224
  }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4221
4225
  if (e.length === 0)
4222
4226
  return [];
4223
- let [{ value: t }] = N(e, 1);
4224
- return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4227
+ let [{ value: t }] = U(e, 1);
4228
+ return t == null ? [] : b(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4225
4229
  }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4226
4230
  if (e.length === 0)
4227
4231
  return [];
4228
- let [{ value: t }] = N(e, 1);
4232
+ let [{ value: t }] = U(e, 1);
4229
4233
  if (typeof t == "string") {
4230
4234
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4231
4235
  if (n)
4232
4236
  return [{ type: u.time, value: re("T" + n[1]) }];
4233
4237
  }
4234
4238
  return [];
4235
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => P((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => P((i2, o, s) => {
4239
+ }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => A((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => A((i2, o, s) => {
4236
4240
  let a = o, c2 = s ? a + s : i2.length;
4237
4241
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4238
- }, r4, e, t, n), startsWith: (r4, e, t) => P((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => P((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => P((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => P((t) => t.toUpperCase(), r4, e), lower: (r4, e) => P((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => P((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => P((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => P((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => P((t) => t.length, r4, e), toChars: (r4, e) => P((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => U(Math.abs, r4, e), ceiling: (r4, e) => U(Math.ceil, r4, e), exp: (r4, e) => U(Math.exp, r4, e), floor: (r4, e) => U(Math.floor, r4, e), ln: (r4, e) => U(Math.log, r4, e), log: (r4, e, t) => U((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => U(Math.pow, r4, e, t), round: (r4, e) => U(Math.round, r4, e), sqrt: (r4, e) => U(Math.sqrt, r4, e), truncate: (r4, e) => U((t) => t | 0, r4, e), children: ce, descendants: ce, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4242
+ }, r4, e, t, n), startsWith: (r4, e, t) => A((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => A((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => A((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => A((t) => t.toUpperCase(), r4, e), lower: (r4, e) => A((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => A((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => A((t) => t.length, r4, e), toChars: (r4, e) => A((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => _(Math.abs, r4, e), ceiling: (r4, e) => _(Math.ceil, r4, e), exp: (r4, e) => _(Math.exp, r4, e), floor: (r4, e) => _(Math.floor, r4, e), ln: (r4, e) => _(Math.log, r4, e), log: (r4, e, t) => _((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => _(Math.pow, r4, e, t), round: (r4, e) => _(Math.round, r4, e), sqrt: (r4, e) => _(Math.sqrt, r4, e), truncate: (r4, e) => _((t) => t | 0, r4, e), children: ce, descendants: ce, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4239
4243
  let o = S.toDateTime(r4, t.eval(r4, e));
4240
4244
  if (o.length === 0)
4241
4245
  throw new Error("Invalid start date");
@@ -4249,7 +4253,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4249
4253
  return [{ type: u.Quantity, value: { value: c2[a], unit: a } }];
4250
4254
  }, is: (r4, e, t) => {
4251
4255
  let n = "";
4252
- return t instanceof M ? n = t.name : t instanceof Q && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Pe(i2, n) })) : [];
4256
+ return t instanceof M ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Ae(i2, n) })) : [];
4253
4257
  }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4254
4258
  let n = t.value, i2;
4255
4259
  if (typeof n == "string")
@@ -4269,32 +4273,32 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4269
4273
  return { type: o, value: { resourceType: o, id: s } };
4270
4274
  }
4271
4275
  return { type: u.BackboneElement, value: void 0 };
4272
- }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: u.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: u.BackboneElement, value: { namespace: "System", name: "Integer" } } : _(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4276
+ }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: u.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: u.BackboneElement, value: { namespace: "System", name: "Integer" } } : N(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4273
4277
  let n = t.eval(r4, e)[0].value;
4274
4278
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4275
4279
  throw new Error("Expected a StructureDefinition URL");
4276
4280
  let i2 = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
4277
4281
  return e.map((o) => ({ type: u.boolean, value: o.value?.resourceType === i2 }));
4278
4282
  } };
4279
- function P(r4, e, t, ...n) {
4283
+ function A(r4, e, t, ...n) {
4280
4284
  if (t.length === 0)
4281
4285
  return [];
4282
- let [{ value: i2 }] = N(t, 1);
4286
+ let [{ value: i2 }] = U(t, 1);
4283
4287
  if (typeof i2 != "string")
4284
4288
  throw new Error("String function cannot be called with non-string");
4285
4289
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4286
4290
  return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4287
4291
  }
4288
- function U(r4, e, t, ...n) {
4292
+ function _(r4, e, t, ...n) {
4289
4293
  if (t.length === 0)
4290
4294
  return [];
4291
- let [{ value: i2 }] = N(t, 1), o = R(i2), s = o ? i2.value : i2;
4295
+ let [{ value: i2 }] = U(t, 1), o = b(i2), s = o ? i2.value : i2;
4292
4296
  if (typeof s != "number")
4293
4297
  throw new Error("Math function cannot be called with non-number");
4294
- let a = r4(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c2 = o ? u.Quantity : t[0].type, m2 = o ? { ...i2, value: a } : a;
4295
- return [{ type: c2, value: m2 }];
4298
+ let a = r4(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c2 = o ? u.Quantity : t[0].type, f = o ? { ...i2, value: a } : a;
4299
+ return [{ type: c2, value: f }];
4296
4300
  }
4297
- function N(r4, e) {
4301
+ function U(r4, e) {
4298
4302
  if (r4.length !== e)
4299
4303
  throw new Error(`Expected ${e} arguments`);
4300
4304
  for (let t of r4)
@@ -4302,7 +4306,7 @@ function N(r4, e) {
4302
4306
  throw new Error("Expected non-null argument");
4303
4307
  return r4;
4304
4308
  }
4305
- var k = class {
4309
+ var O = class {
4306
4310
  constructor(e) {
4307
4311
  this.value = e;
4308
4312
  }
@@ -4332,13 +4336,13 @@ var M = class {
4332
4336
  evalValue(e) {
4333
4337
  let t = e.value;
4334
4338
  if (!(!t || typeof t != "object"))
4335
- return _(t) && t.resourceType === this.name ? e : w(e, this.name);
4339
+ return N(t) && t.resourceType === this.name ? e : I(e, this.name);
4336
4340
  }
4337
4341
  toString() {
4338
4342
  return this.name;
4339
4343
  }
4340
4344
  };
4341
- var Ve = class {
4345
+ var De = class {
4342
4346
  eval() {
4343
4347
  return [];
4344
4348
  }
@@ -4346,7 +4350,7 @@ var Ve = class {
4346
4350
  return "{}";
4347
4351
  }
4348
4352
  };
4349
- var _e = class extends ge {
4353
+ var Ne = class extends ge {
4350
4354
  constructor(t, n, i2) {
4351
4355
  super(t, n);
4352
4356
  this.impl = i2;
@@ -4368,7 +4372,7 @@ var J = class extends $ {
4368
4372
  };
4369
4373
  var v = class extends $ {
4370
4374
  };
4371
- var E = class extends v {
4375
+ var R = class extends v {
4372
4376
  constructor(t, n, i2, o) {
4373
4377
  super(t, n, i2);
4374
4378
  this.impl = o;
@@ -4380,11 +4384,11 @@ var E = class extends v {
4380
4384
  let o = this.right.eval(t, n);
4381
4385
  if (o.length !== 1)
4382
4386
  return [];
4383
- let s = i2[0].value, a = o[0].value, c2 = R(s) ? s.value : s, m2 = R(a) ? a.value : a, p2 = this.impl(c2, m2);
4384
- return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4387
+ let s = i2[0].value, a = o[0].value, c2 = b(s) ? s.value : s, f = b(a) ? a.value : a, p2 = this.impl(c2, f);
4388
+ return typeof p2 == "boolean" ? l(p2) : b(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4385
4389
  }
4386
4390
  };
4387
- var Le = class extends $ {
4391
+ var Fe = class extends $ {
4388
4392
  constructor(e, t) {
4389
4393
  super("&", e, t);
4390
4394
  }
@@ -4393,7 +4397,7 @@ var Le = class extends $ {
4393
4397
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: u.string, value: o.map((s) => s.value).join("") }] : o;
4394
4398
  }
4395
4399
  };
4396
- var Ue = class extends v {
4400
+ var _e = class extends v {
4397
4401
  constructor(e, t) {
4398
4402
  super("contains", e, t);
4399
4403
  }
@@ -4402,16 +4406,16 @@ var Ue = class extends v {
4402
4406
  return l(n.some((o) => o.value === i2[0].value));
4403
4407
  }
4404
4408
  };
4405
- var Ne = class extends v {
4409
+ var Ue = class extends v {
4406
4410
  constructor(e, t) {
4407
4411
  super("in", e, t);
4408
4412
  }
4409
4413
  eval(e, t) {
4410
- let n = V(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4414
+ let n = D(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4411
4415
  return n ? l(i2.some((o) => o.value === n.value)) : [];
4412
4416
  }
4413
4417
  };
4414
- var Q = class extends $ {
4418
+ var H = class extends $ {
4415
4419
  constructor(e, t) {
4416
4420
  super(".", e, t);
4417
4421
  }
@@ -4428,16 +4432,16 @@ var ne = class extends $ {
4428
4432
  }
4429
4433
  eval(e, t) {
4430
4434
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4431
- return Ae([...n, ...i2]);
4435
+ return Pe([...n, ...i2]);
4432
4436
  }
4433
4437
  };
4434
- var Fe = class extends v {
4438
+ var Le = class extends v {
4435
4439
  constructor(e, t) {
4436
4440
  super("=", e, t);
4437
4441
  }
4438
4442
  eval(e, t) {
4439
4443
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4440
- return lt(n, i2);
4444
+ return ut(n, i2);
4441
4445
  }
4442
4446
  };
4443
4447
  var Me = class extends v {
@@ -4446,7 +4450,7 @@ var Me = class extends v {
4446
4450
  }
4447
4451
  eval(e, t) {
4448
4452
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4449
- return ut(lt(n, i2));
4453
+ return ct(ut(n, i2));
4450
4454
  }
4451
4455
  };
4452
4456
  var Be = class extends v {
@@ -4455,7 +4459,7 @@ var Be = class extends v {
4455
4459
  }
4456
4460
  eval(e, t) {
4457
4461
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4458
- return dt(n, i2);
4462
+ return lt(n, i2);
4459
4463
  }
4460
4464
  };
4461
4465
  var qe = class extends v {
@@ -4464,7 +4468,7 @@ var qe = class extends v {
4464
4468
  }
4465
4469
  eval(e, t) {
4466
4470
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4467
- return ut(dt(n, i2));
4471
+ return ct(lt(n, i2));
4468
4472
  }
4469
4473
  };
4470
4474
  var Y = class extends v {
@@ -4476,7 +4480,7 @@ var Y = class extends v {
4476
4480
  if (n.length !== 1)
4477
4481
  return [];
4478
4482
  let i2 = this.right.name;
4479
- return l(Pe(n[0], i2));
4483
+ return l(Ae(n[0], i2));
4480
4484
  }
4481
4485
  };
4482
4486
  var $e = class extends v {
@@ -4484,7 +4488,7 @@ var $e = class extends v {
4484
4488
  super("and", e, t);
4485
4489
  }
4486
4490
  eval(e, t) {
4487
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4491
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4488
4492
  return n?.value === true && i2?.value === true ? l(true) : n?.value === false || i2?.value === false ? l(false) : [];
4489
4493
  }
4490
4494
  };
@@ -4493,25 +4497,25 @@ var je = class extends v {
4493
4497
  super("or", e, t);
4494
4498
  }
4495
4499
  eval(e, t) {
4496
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4500
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4497
4501
  return n?.value === false && i2?.value === false ? l(false) : n?.value || i2?.value ? l(true) : [];
4498
4502
  }
4499
4503
  };
4500
- var He = class extends v {
4504
+ var Qe = class extends v {
4501
4505
  constructor(e, t) {
4502
4506
  super("xor", e, t);
4503
4507
  }
4504
4508
  eval(e, t) {
4505
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4509
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4506
4510
  return !n || !i2 ? [] : l(n.value !== i2.value);
4507
4511
  }
4508
4512
  };
4509
- var Qe = class extends v {
4513
+ var He = class extends v {
4510
4514
  constructor(e, t) {
4511
4515
  super("implies", e, t);
4512
4516
  }
4513
4517
  eval(e, t) {
4514
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4518
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4515
4519
  return i2?.value === true || n?.value === false ? l(true) : !n || !i2 ? [] : l(false);
4516
4520
  }
4517
4521
  };
@@ -4550,46 +4554,46 @@ var X = class {
4550
4554
  }
4551
4555
  };
4552
4556
  var le = ["!=", "!~", "<=", ">=", "{}", "->"];
4553
- var f = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
4554
- var Zn = { parse(r4) {
4557
+ var m = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
4558
+ var ii = { parse(r4) {
4555
4559
  let e = r4.consumeAndParse();
4556
4560
  if (!r4.match(")"))
4557
4561
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4558
4562
  return e;
4559
4563
  } };
4560
- var ei = { parse(r4, e) {
4564
+ var oi = { parse(r4, e) {
4561
4565
  let t = r4.consumeAndParse();
4562
4566
  if (!r4.match("]"))
4563
4567
  throw new Error("Parse error: expected `]`");
4564
4568
  return new X(e, t);
4565
- }, precedence: f.Indexer };
4566
- var ti = { parse(r4, e) {
4569
+ }, precedence: m.Indexer };
4570
+ var si = { parse(r4, e) {
4567
4571
  if (!(e instanceof M))
4568
4572
  throw new Error("Unexpected parentheses");
4569
4573
  let t = [];
4570
4574
  for (; !r4.match(")"); )
4571
4575
  t.push(r4.consumeAndParse()), r4.match(",");
4572
4576
  return new B(e.name, t);
4573
- }, precedence: f.FunctionCall };
4574
- function ri(r4) {
4577
+ }, precedence: m.FunctionCall };
4578
+ function ai(r4) {
4575
4579
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4576
4580
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4577
4581
  }
4578
4582
  function de() {
4579
- return new xe().registerPrefix("String", { parse: (r4, e) => new k({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new k({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new k({ type: u.Quantity, value: ri(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new k({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new k({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new k({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new Ve() }).registerPrefix("(", Zn).registerInfix("[", ei).registerInfix("(", ti).prefix("+", f.UnaryAdd, (r4, e) => new _e("+", e, (t) => t)).prefix("-", f.UnarySubtract, (r4, e) => new E("-", e, e, (t, n) => -n)).infixLeft(".", f.Dot, (r4, e, t) => new Q(r4, t)).infixLeft("/", f.Divide, (r4, e, t) => new E("/", r4, t, (n, i2) => n / i2)).infixLeft("*", f.Multiply, (r4, e, t) => new E("*", r4, t, (n, i2) => n * i2)).infixLeft("+", f.Add, (r4, e, t) => new E("+", r4, t, (n, i2) => n + i2)).infixLeft("-", f.Subtract, (r4, e, t) => new E("-", r4, t, (n, i2) => n - i2)).infixLeft("|", f.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", f.Equals, (r4, e, t) => new Fe(r4, t)).infixLeft("!=", f.NotEquals, (r4, e, t) => new Me(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Be(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new qe(r4, t)).infixLeft("<", f.LessThan, (r4, e, t) => new E("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", f.LessThanOrEquals, (r4, e, t) => new E("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", f.GreaterThan, (r4, e, t) => new E(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", f.GreaterThanOrEquals, (r4, e, t) => new E(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", f.Ampersand, (r4, e, t) => new Le(r4, t)).infixLeft("and", f.And, (r4, e, t) => new $e(r4, t)).infixLeft("as", f.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", f.Contains, (r4, e, t) => new Ue(r4, t)).infixLeft("div", f.Divide, (r4, e, t) => new E("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", f.In, (r4, e, t) => new Ne(r4, t)).infixLeft("is", f.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", f.Modulo, (r4, e, t) => new E("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", f.Or, (r4, e, t) => new je(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new He(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new Qe(r4, t));
4583
+ return new xe().registerPrefix("String", { parse: (r4, e) => new O({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new O({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new O({ type: u.Quantity, value: ai(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new O({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new O({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new O({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new De() }).registerPrefix("(", ii).registerInfix("[", oi).registerInfix("(", si).prefix("+", m.UnaryAdd, (r4, e) => new Ne("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new R("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new H(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new R("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new R("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new R("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new R("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Le(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new Me(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new Be(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new qe(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new R("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new R("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new R(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new R(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Fe(r4, t)).infixLeft("and", m.And, (r4, e, t) => new $e(r4, t)).infixLeft("as", m.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new _e(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new R("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Ue(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new R("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new je(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Qe(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new He(r4, t));
4580
4584
  }
4581
- var ni = de();
4582
- var wr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(wr || {});
4583
- var li = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(li || {});
4584
- var Oi = ((x) => (x.READ = "read", x.VREAD = "vread", x.UPDATE = "update", x.PATCH = "patch", x.DELETE = "delete", x.HISTORY = "history", x.HISTORY_INSTANCE = "history-instance", x.HISTORY_TYPE = "history-type", x.HISTORY_SYSTEM = "history-system", x.CREATE = "create", x.SEARCH = "search", x.SEARCH_TYPE = "search-type", x.SEARCH_SYSTEM = "search-system", x.SEARCH_COMPARTMENT = "search-compartment", x.CAPABILITIES = "capabilities", x.TRANSACTION = "transaction", x.BATCH = "batch", x.OPERATION = "operation", x))(Oi || {});
4585
- function Br(r4) {
4585
+ var ci = de();
4586
+ var kr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(kr || {});
4587
+ var hi = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(hi || {});
4588
+ var _i = ((x) => (x.READ = "read", x.VREAD = "vread", x.UPDATE = "update", x.PATCH = "patch", x.DELETE = "delete", x.HISTORY = "history", x.HISTORY_INSTANCE = "history-instance", x.HISTORY_TYPE = "history-type", x.HISTORY_SYSTEM = "history-system", x.CREATE = "create", x.SEARCH = "search", x.SEARCH_TYPE = "search-type", x.SEARCH_SYSTEM = "search-system", x.SEARCH_COMPARTMENT = "search-compartment", x.CAPABILITIES = "capabilities", x.TRANSACTION = "transaction", x.BATCH = "batch", x.OPERATION = "operation", x))(_i || {});
4589
+ function $r(r4) {
4586
4590
  if (typeof window < "u")
4587
4591
  return window.atob(r4);
4588
4592
  if (typeof Buffer < "u")
4589
4593
  return Buffer.from(r4, "base64").toString("binary");
4590
4594
  throw new Error("Unable to decode base64");
4591
4595
  }
4592
- function qr(r4) {
4596
+ function jr(r4) {
4593
4597
  if (typeof window < "u")
4594
4598
  return window.btoa(r4);
4595
4599
  if (typeof Buffer < "u")
@@ -4598,9 +4602,9 @@ function qr(r4) {
4598
4602
  }
4599
4603
  function Ot() {
4600
4604
  let r4 = new Uint32Array(28);
4601
- return crypto.getRandomValues(r4), Jt(r4.buffer);
4605
+ return crypto.getRandomValues(r4), Xt(r4.buffer);
4602
4606
  }
4603
- async function $r(r4) {
4607
+ async function Qr(r4) {
4604
4608
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4605
4609
  }
4606
4610
  function me() {
@@ -4609,7 +4613,7 @@ function me() {
4609
4613
  return (r4 === "x" ? e : e & 3 | 8).toString(16);
4610
4614
  });
4611
4615
  }
4612
- var Ke = class {
4616
+ var We = class {
4613
4617
  constructor(e = 10) {
4614
4618
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4615
4619
  }
@@ -4633,7 +4637,7 @@ var Ke = class {
4633
4637
  return this.cache.keys().next().value;
4634
4638
  }
4635
4639
  };
4636
- var O = { CSS: "text/css", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
4640
+ var C = { CSS: "text/css", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
4637
4641
  var he = class {
4638
4642
  constructor() {
4639
4643
  this.listeners = {};
@@ -4659,7 +4663,7 @@ var he = class {
4659
4663
  return !e.defaultPrevented;
4660
4664
  }
4661
4665
  };
4662
- var ze = class {
4666
+ var Ge = class {
4663
4667
  constructor() {
4664
4668
  this.emitter = new he();
4665
4669
  }
@@ -4673,76 +4677,99 @@ var ze = class {
4673
4677
  this.emitter.removeEventListener(e, t);
4674
4678
  }
4675
4679
  };
4676
- var Dt = { "patient-open": "patient-open", "patient-close": "patient-close", "imagingstudy-open": "imagingstudy-open", "imagingstudy-close": "imagingstudy-close" };
4677
- var Bi = ["Patient", "Encounter", "ImagingStudy"];
4678
- var qi = { "patient-open": ["Patient"], "patient-close": ["Patient"], "imagingstudy-open": ["Patient", "ImagingStudy"], "imagingstudy-close": ["Patient", "ImagingStudy"] };
4679
- var $i = { "patient-open": ["Encounter"], "patient-close": ["Encounter"], "imagingstudy-open": [], "imagingstudy-close": [] };
4680
- function ji(r4) {
4681
- return Bi.includes(r4);
4680
+ var Vt = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
4681
+ var Hi = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
4682
+ var Dt = ["DiagnosticReport-update"];
4683
+ function Wr(r4) {
4684
+ return Dt.includes(r4);
4685
+ }
4686
+ function Gr(r4) {
4687
+ if (Dt.includes(r4))
4688
+ throw new d(h(`'context.version' is required for '${r4}'.`));
4689
+ }
4690
+ var Ki = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
4691
+ function Wi(r4) {
4692
+ return Hi.includes(r4);
4682
4693
  }
4683
- var Hi = { ImagingStudy: "study", Patient: "patient", Encounter: "encounter" };
4684
- function Hr(r4) {
4694
+ function zr(r4) {
4685
4695
  return !!r4.endpoint;
4686
4696
  }
4687
- function Vt(r4) {
4688
- if (!Ye(r4))
4697
+ function Nt(r4) {
4698
+ if (!Je(r4))
4689
4699
  throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4690
4700
  let { channelType: e, mode: t, topic: n, events: i2 } = r4, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
4691
- return Hr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4701
+ return zr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4692
4702
  }
4693
- function Ye(r4) {
4703
+ function Je(r4) {
4694
4704
  if (typeof r4 != "object")
4695
4705
  return false;
4696
4706
  let { channelType: e, mode: t, topic: n, events: i2 } = r4;
4697
4707
  if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
4698
4708
  return false;
4699
4709
  for (let o of i2)
4700
- if (!Dt[o])
4710
+ if (!Vt[o])
4701
4711
  return false;
4702
- return !(Hr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4712
+ return !(zr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4703
4713
  }
4704
- function Qi(r4, e, t, n) {
4705
- if (!(e.key && typeof e.key == "string"))
4706
- throw new d(h(`context[${t}] is invalid. Context must contain a key.`));
4707
- if (n.has(e.key))
4708
- throw new d(h(`context[${t}] is invalid. Key ${e.key} has already been used in a previous context.`));
4709
- if (n.add(e.key), typeof e.resource != "object")
4714
+ function Kr(r4, e, t, n) {
4715
+ if (typeof e != "object")
4710
4716
  throw new d(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
4711
- if (!(e.resource.id && typeof e.resource.id == "string"))
4717
+ if (!(e.id && typeof e.id == "string"))
4712
4718
  throw new d(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
4713
- if (!e.resource.resourceType)
4719
+ if (!e.resourceType)
4714
4720
  throw new d(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4715
- let i2 = e.resource.resourceType;
4716
- if (!ji(i2))
4717
- throw new d(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4718
- let o = qi[r4], s = $i[r4], a;
4719
- if (t < o.length ? a = o[t] : t - o.length < s.length && (a = s[t - o.length]), a && i2 !== a)
4720
- throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${a}.`));
4721
- let c2 = Hi[i2];
4722
- if (c2 !== e.key)
4723
- throw new d(h(`context[${t}] is invalid. Context key for type ${i2} must be ${c2}.`));
4721
+ let i2 = n.resourceType;
4722
+ if (i2 !== "*") {
4723
+ if (!Wi(e.resourceType))
4724
+ throw new d(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4725
+ if (i2 && e.resourceType !== i2)
4726
+ throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
4727
+ }
4724
4728
  }
4725
- function Wi(r4, e) {
4726
- let t = /* @__PURE__ */ new Set();
4727
- for (let n = 0; n < e.length; n++)
4728
- Qi(r4, e[n], n, t);
4729
+ function Gi(r4, e, t, n, i2) {
4730
+ if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), !n.isArray)
4731
+ Kr(r4, e.resource, t, n);
4732
+ else {
4733
+ let { resources: o } = e;
4734
+ if (!o)
4735
+ throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
4736
+ for (let s of o)
4737
+ Kr(r4, s, t, n);
4738
+ }
4729
4739
  }
4730
- function Qr(r4, e, t) {
4740
+ function zi(r4, e) {
4741
+ let t = /* @__PURE__ */ new Map(), n = Ki[r4];
4742
+ for (let i2 = 0; i2 < e.length; i2++) {
4743
+ let o = e[i2].key;
4744
+ if (!n[o])
4745
+ throw new d(h(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
4746
+ Gi(r4, e[i2], i2, n[o], t);
4747
+ }
4748
+ for (let [i2, o] of Object.entries(n)) {
4749
+ if (!(o.optional || t.has(i2)))
4750
+ throw new d(h(`Missing required key '${i2}' on context for '${r4}' event.`));
4751
+ if (!o.manyAllowed && (t.get(i2) || 0) > 1)
4752
+ throw new d(h(`${t.get(i2)} context entries with key '${i2}' found for the '${r4}' event when schema only allows for 1.`));
4753
+ }
4754
+ }
4755
+ function Ft(r4, e, t, n) {
4731
4756
  if (!(r4 && typeof r4 == "string"))
4732
4757
  throw new d(h("Must provide a topic."));
4733
- if (!Dt[e])
4734
- throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Dt).join(", ")}`));
4758
+ if (!Vt[e])
4759
+ throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Vt).join(", ")}`));
4735
4760
  if (typeof t != "object")
4736
4761
  throw new d(h("context must be a context object or array of context objects."));
4737
- let n = Array.isArray(t) ? t : [t];
4738
- return Wi(e, n), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: me(), event: { "hub.topic": r4, "hub.event": e, context: n } };
4762
+ if (Dt.includes(e) && !n)
4763
+ throw new d(h(`The '${e}' event must contain a 'context.versionId'.`));
4764
+ let i2 = Array.isArray(t) ? t : [t];
4765
+ return zi(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: me(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
4739
4766
  }
4740
- var Je = class extends ze {
4767
+ var ze = class extends Ge {
4741
4768
  constructor(t) {
4742
4769
  super();
4743
4770
  if (this.subRequest = t, !t.endpoint)
4744
4771
  throw new d(h("Subscription request should contain an endpoint."));
4745
- if (!Ye(t))
4772
+ if (!Je(t))
4746
4773
  throw new d(h("Subscription request failed validation."));
4747
4774
  let n = new WebSocket(t.endpoint);
4748
4775
  n.addEventListener("open", () => {
@@ -4761,31 +4788,31 @@ var Je = class extends ze {
4761
4788
  this.websocket.close();
4762
4789
  }
4763
4790
  };
4764
- function Gi(r4) {
4765
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Br(e), n = Array.from(t).reduce((o, s) => {
4791
+ function Ji(r4) {
4792
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = $r(e), n = Array.from(t).reduce((o, s) => {
4766
4793
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4767
4794
  return `${o}%${a}`;
4768
4795
  }, ""), i2 = decodeURIComponent(n);
4769
4796
  return JSON.parse(i2);
4770
4797
  }
4771
- function Wr(r4) {
4798
+ function Jr(r4) {
4772
4799
  return r4.split(".").length === 3;
4773
4800
  }
4774
4801
  function _t(r4) {
4775
4802
  let [e, t, n] = r4.split(".");
4776
- return Gi(t);
4803
+ return Ji(t);
4777
4804
  }
4778
- function Gr(r4) {
4805
+ function Yr(r4) {
4779
4806
  try {
4780
4807
  return typeof _t(r4).login_id == "string";
4781
4808
  } catch {
4782
4809
  return false;
4783
4810
  }
4784
4811
  }
4785
- var Ki;
4786
- var C = class {
4812
+ var Yi;
4813
+ var w = class {
4787
4814
  constructor(e) {
4788
- this[Ki] = "ReadablePromise";
4815
+ this[Yi] = "ReadablePromise";
4789
4816
  this.status = "pending";
4790
4817
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4791
4818
  throw this.status = "error", this.error = t, t;
@@ -4817,10 +4844,10 @@ var C = class {
4817
4844
  return this.suspender.finally(e);
4818
4845
  }
4819
4846
  };
4820
- Ki = Symbol.toStringTag;
4821
- var Xe = class {
4847
+ Yi = Symbol.toStringTag;
4848
+ var Ye = class {
4822
4849
  constructor() {
4823
- this.storage = typeof localStorage < "u" ? localStorage : new Lt();
4850
+ this.storage = typeof localStorage < "u" ? localStorage : new Ut();
4824
4851
  }
4825
4852
  clear() {
4826
4853
  this.storage.clear();
@@ -4836,10 +4863,10 @@ var Xe = class {
4836
4863
  return t ? JSON.parse(t) : void 0;
4837
4864
  }
4838
4865
  setObject(e, t) {
4839
- this.setString(e, t ? Gt(t) : void 0);
4866
+ this.setString(e, t ? zt(t) : void 0);
4840
4867
  }
4841
4868
  };
4842
- var Lt = class {
4869
+ var Ut = class {
4843
4870
  constructor() {
4844
4871
  this.data = /* @__PURE__ */ new Map();
4845
4872
  }
@@ -4862,21 +4889,22 @@ var Lt = class {
4862
4889
  return Array.from(this.data.keys())[e];
4863
4890
  }
4864
4891
  };
4865
- var zi = O.FHIR_JSON + ", */*; q=0.1";
4866
- var Ji = "https://api.medplum.com/";
4867
- var Yi = 1e3;
4868
- var Xi = 6e4;
4869
- var Kr = "Binary/";
4870
- var zr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4871
- var Zi = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Zi || {});
4872
- var eo = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(eo || {});
4873
- var to = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(to || {});
4874
- var Jr = class extends he {
4892
+ var Xi = C.FHIR_JSON + ", */*; q=0.1";
4893
+ var Zi = "https://api.medplum.com/";
4894
+ var eo = 1e3;
4895
+ var to = 6e4;
4896
+ var Xr = "Binary/";
4897
+ var Zr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4898
+ var ro = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(ro || {});
4899
+ var no = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(no || {});
4900
+ var io = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(io || {});
4901
+ var oo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(oo || {});
4902
+ var en = class extends he {
4875
4903
  constructor(t) {
4876
4904
  super();
4877
4905
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4878
4906
  throw new Error("Base URL must start with http or https");
4879
- if (this.options = t ?? {}, this.fetch = t?.fetch ?? ro(), this.storage = t?.storage ?? new Xe(), this.createPdfImpl = t?.createPdf, this.baseUrl = Xr(t?.baseUrl ?? Ji), this.fhirBaseUrl = Xr(Ze(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Ze(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Ze(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Ze(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Xi, this.cacheTime > 0 ? this.requestCache = new Ke(t?.resourceCacheSize ?? Yi) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4907
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? so(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = rn(t?.baseUrl ?? Zi), this.fhirBaseUrl = rn(Xe(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Xe(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Xe(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Xe(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? to, this.cacheTime > 0 ? this.requestCache = new We(t?.resourceCacheSize ?? eo) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4880
4908
  this.setAccessToken(t.accessToken);
4881
4909
  else {
4882
4910
  let n = this.getActiveLogin();
@@ -4897,7 +4925,7 @@ var Jr = class extends he {
4897
4925
  return this.logoutUrl;
4898
4926
  }
4899
4927
  clear() {
4900
- this.storage.clear(), this.clearActiveLogin();
4928
+ this.storage.clear(), sessionStorage.clear(), this.clearActiveLogin();
4901
4929
  }
4902
4930
  clearActiveLogin() {
4903
4931
  this.storage.setString("activeLogin", void 0), this.requestCache?.clear(), this.accessToken = void 0, this.refreshToken = void 0, this.sessionDetails = void 0, this.medplumServer = void 0, this.dispatchEvent({ type: "change" });
@@ -4923,7 +4951,7 @@ var Jr = class extends he {
4923
4951
  t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, c2) => {
4924
4952
  this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a, reject: c2 }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
4925
4953
  }) : o = this.request("GET", t, n);
4926
- let s = new C(o);
4954
+ let s = new w(o);
4927
4955
  return this.setCacheEntry(t, s), s;
4928
4956
  }
4929
4957
  post(t, n, i2, o = {}) {
@@ -4933,7 +4961,7 @@ var Jr = class extends he {
4933
4961
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4934
4962
  }
4935
4963
  patch(t, n, i2 = {}) {
4936
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, O.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4964
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, C.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4937
4965
  }
4938
4966
  delete(t, n) {
4939
4967
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -4969,9 +4997,9 @@ var Jr = class extends he {
4969
4997
  signOutWithRedirect() {
4970
4998
  window.location.assign(this.logoutUrl);
4971
4999
  }
4972
- async signInWithExternalAuth(t, n, i2, o) {
4973
- let s = await this.ensureCodeChallenge(o);
4974
- window.location.assign(this.getExternalAuthRedirectUri(t, n, i2, s));
5000
+ async signInWithExternalAuth(t, n, i2, o, s = true) {
5001
+ let a = o;
5002
+ s && (a = await this.ensureCodeChallenge(o)), window.location.assign(this.getExternalAuthRedirectUri(t, n, i2, a, s));
4975
5003
  }
4976
5004
  async exchangeExternalAccessToken(t, n) {
4977
5005
  if (n = n ?? this.clientId, !n)
@@ -4979,14 +5007,17 @@ var Jr = class extends he {
4979
5007
  let i2 = new URLSearchParams();
4980
5008
  return i2.set("grant_type", "urn:ietf:params:oauth:grant-type:token-exchange"), i2.set("subject_token_type", "urn:ietf:params:oauth:token-type:access_token"), i2.set("client_id", n), i2.set("subject_token", t), this.fetchTokens(i2);
4981
5009
  }
4982
- getExternalAuthRedirectUri(t, n, i2, o) {
4983
- let { codeChallenge: s, codeChallengeMethod: a } = o;
4984
- if (!a)
4985
- throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");
4986
- if (!s)
4987
- throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");
4988
- let c2 = new URL(t);
4989
- return c2.searchParams.set("response_type", "code"), c2.searchParams.set("client_id", n), c2.searchParams.set("redirect_uri", i2), c2.searchParams.set("scope", "openid profile email"), c2.searchParams.set("state", JSON.stringify(o)), c2.searchParams.set("code_challenge_method", a), c2.searchParams.set("code_challenge", s), c2.toString();
5010
+ getExternalAuthRedirectUri(t, n, i2, o, s = true) {
5011
+ let a = new URL(t);
5012
+ if (a.searchParams.set("response_type", "code"), a.searchParams.set("client_id", n), a.searchParams.set("redirect_uri", i2), a.searchParams.set("scope", "openid profile email"), a.searchParams.set("state", JSON.stringify(o)), s) {
5013
+ let { codeChallenge: c2, codeChallengeMethod: f } = o;
5014
+ if (!f)
5015
+ throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");
5016
+ if (!c2)
5017
+ throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");
5018
+ a.searchParams.set("code_challenge_method", f), a.searchParams.set("code_challenge", c2);
5019
+ }
5020
+ return a.toString();
4990
5021
  }
4991
5022
  fhirUrl(...t) {
4992
5023
  return new URL(t.join("/"), this.fhirBaseUrl);
@@ -4999,12 +5030,12 @@ var Jr = class extends he {
4999
5030
  let o = this.fhirSearchUrl(t, n), s = o.toString() + "-search", a = this.getCacheEntry(s, i2);
5000
5031
  if (a)
5001
5032
  return a.value;
5002
- let c2 = new C((async () => {
5003
- let m2 = await this.get(o, i2);
5004
- if (m2.entry)
5005
- for (let p2 of m2.entry)
5033
+ let c2 = new w((async () => {
5034
+ let f = await this.get(o, i2);
5035
+ if (f.entry)
5036
+ for (let p2 of f.entry)
5006
5037
  this.cacheResource(p2.resource);
5007
- return m2;
5038
+ return f;
5008
5039
  })());
5009
5040
  return this.setCacheEntry(s, c2), c2;
5010
5041
  }
@@ -5014,23 +5045,23 @@ var Jr = class extends he {
5014
5045
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
5015
5046
  if (a)
5016
5047
  return a.value;
5017
- let c2 = new C(this.search(t, o.searchParams, i2).then((m2) => m2.entry?.[0]?.resource));
5048
+ let c2 = new w(this.search(t, o.searchParams, i2).then((f) => f.entry?.[0]?.resource));
5018
5049
  return this.setCacheEntry(s, c2), c2;
5019
5050
  }
5020
5051
  searchResources(t, n, i2) {
5021
5052
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
5022
5053
  if (a)
5023
5054
  return a.value;
5024
- let c2 = new C(this.search(t, n, i2).then(en));
5055
+ let c2 = new w(this.search(t, n, i2).then(on));
5025
5056
  return this.setCacheEntry(s, c2), c2;
5026
5057
  }
5027
5058
  async *searchResourcePages(t, n, i2) {
5028
5059
  let o = this.fhirSearchUrl(t, n);
5029
5060
  for (; o; ) {
5030
- let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((m2) => m2.relation === "next");
5061
+ let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((f) => f.relation === "next");
5031
5062
  if (!a.entry?.length && !c2)
5032
5063
  break;
5033
- yield en(a), o = c2?.url ? new URL(c2.url) : void 0;
5064
+ yield on(a), o = c2?.url ? new URL(c2.url) : void 0;
5034
5065
  }
5035
5066
  }
5036
5067
  searchValueSet(t, n, i2) {
@@ -5046,7 +5077,7 @@ var Jr = class extends he {
5046
5077
  if (!n)
5047
5078
  return;
5048
5079
  if (n === "system")
5049
- return zr;
5080
+ return Zr;
5050
5081
  let [i2, o] = n.split("/");
5051
5082
  if (!(!i2 || !o))
5052
5083
  return this.getCached(i2, o);
@@ -5057,19 +5088,19 @@ var Jr = class extends he {
5057
5088
  readReference(t, n) {
5058
5089
  let i2 = t.reference;
5059
5090
  if (!i2)
5060
- return new C(Promise.reject(new Error("Missing reference")));
5091
+ return new w(Promise.reject(new Error("Missing reference")));
5061
5092
  if (i2 === "system")
5062
- return new C(Promise.resolve(zr));
5093
+ return new w(Promise.resolve(Zr));
5063
5094
  let [o, s] = i2.split("/");
5064
- return !o || !s ? new C(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
5095
+ return !o || !s ? new w(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
5065
5096
  }
5066
5097
  requestSchema(t) {
5067
- if (br(t))
5098
+ if (Rr(t))
5068
5099
  return Promise.resolve();
5069
5100
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
5070
5101
  if (i2)
5071
5102
  return i2.value;
5072
- let o = new C((async () => {
5103
+ let o = new w((async () => {
5073
5104
  let s = `{
5074
5105
  StructureDefinitionList(name: "${t}") {
5075
5106
  resourceType,
@@ -5108,9 +5139,9 @@ var Jr = class extends he {
5108
5139
  target
5109
5140
  }
5110
5141
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
5111
- vr(a.data.StructureDefinitionList);
5142
+ Er(a.data.StructureDefinitionList);
5112
5143
  for (let c2 of a.data.SearchParameterList)
5113
- Et(c2);
5144
+ bt(c2);
5114
5145
  })());
5115
5146
  return this.setCacheEntry(n, o), o;
5116
5147
  }
@@ -5142,7 +5173,7 @@ var Jr = class extends he {
5142
5173
  uploadwithProgress(t, n, i2, o) {
5143
5174
  return new Promise((s, a) => {
5144
5175
  let c2 = new XMLHttpRequest();
5145
- c2.responseType = "json", c2.onabort = () => a(new Error("Request aborted")), c2.onerror = () => a(new Error("Request error")), o && (c2.upload.onprogress = (m2) => o(m2), c2.upload.onload = (m2) => o(m2)), c2.onload = () => {
5176
+ c2.responseType = "json", c2.onabort = () => a(new Error("Request aborted")), c2.onerror = () => a(new Error("Request error")), o && (c2.upload.onprogress = (f) => o(f), c2.upload.onload = (f) => o(f)), c2.onload = () => {
5146
5177
  c2.status >= 200 && c2.status < 300 ? s(c2.response) : a(new d(Oe(c2.response || c2.statusText)));
5147
5178
  }, c2.open("POST", t), c2.withCredentials = true, c2.setRequestHeader("Authorization", "Bearer " + this.accessToken), c2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), c2.setRequestHeader("Content-Type", i2), c2.setRequestHeader("X-Medplum", "extended"), c2.send(n);
5148
5179
  });
@@ -5155,7 +5186,7 @@ var Jr = class extends he {
5155
5186
  }
5156
5187
  createComment(t, n, i2) {
5157
5188
  let o = this.getProfile(), s, a;
5158
- return t.resourceType === "Encounter" && (s = K(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = K(t)), this.createResource({ resourceType: "Communication", basedOn: [K(t)], encounter: s, subject: a, sender: o ? K(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5189
+ return t.resourceType === "Encounter" && (s = G(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = G(t)), this.createResource({ resourceType: "Communication", basedOn: [G(t)], encounter: s, subject: a, sender: o ? G(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5159
5190
  }
5160
5191
  async updateResource(t, n) {
5161
5192
  if (!t.resourceType)
@@ -5190,16 +5221,16 @@ var Jr = class extends he {
5190
5221
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
5191
5222
  }
5192
5223
  sendEmail(t, n) {
5193
- return this.post("email/v1/send", t, O.JSON, n);
5224
+ return this.post("email/v1/send", t, C.JSON, n);
5194
5225
  }
5195
5226
  graphql(t, n, i2, o) {
5196
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, O.JSON, o);
5227
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, C.JSON, o);
5197
5228
  }
5198
5229
  readResourceGraph(t, n, i2, o) {
5199
5230
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
5200
5231
  }
5201
5232
  pushToAgent(t, n, i2, o, s) {
5202
- return this.post(this.fhirUrl("Agent", Ht(t), "$push"), { destination: se(n), body: i2, contentType: o }, O.FHIR_JSON, s);
5233
+ return this.post(this.fhirUrl("Agent", Kt(t), "$push"), { destination: se(n), body: i2, contentType: o }, C.FHIR_JSON, s);
5203
5234
  }
5204
5235
  getActiveLogin() {
5205
5236
  return this.storage.getObject("activeLogin");
@@ -5211,7 +5242,7 @@ var Jr = class extends he {
5211
5242
  return this.accessToken;
5212
5243
  }
5213
5244
  setAccessToken(t, n) {
5214
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Gr(t);
5245
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Yr(t);
5215
5246
  }
5216
5247
  getLogins() {
5217
5248
  return this.storage.getObject("logins") ?? [];
@@ -5259,11 +5290,11 @@ var Jr = class extends he {
5259
5290
  async download(t, n = {}) {
5260
5291
  this.refreshPromise && await this.refreshPromise;
5261
5292
  let i2 = t.toString();
5262
- return i2.startsWith(Kr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5293
+ return i2.startsWith(Xr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5263
5294
  }
5264
5295
  async uploadMedia(t, n, i2, o, s) {
5265
5296
  let a = await this.createBinary(t, i2, n);
5266
- return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Kr + a.id, title: i2 }, ...o }, s);
5297
+ return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Xr + a.id, title: i2 }, ...o }, s);
5267
5298
  }
5268
5299
  async bulkExport(t = "", n, i2, o) {
5269
5300
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5275,7 +5306,7 @@ var Jr = class extends he {
5275
5306
  i2.Prefer = "respond-async";
5276
5307
  let o = await this.fetchWithRetry(t, n);
5277
5308
  if (o.status === 202) {
5278
- let s = await Zr(o);
5309
+ let s = await nn(o);
5279
5310
  if (s)
5280
5311
  return this.pollStatus(s);
5281
5312
  }
@@ -5292,7 +5323,7 @@ var Jr = class extends he {
5292
5323
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
5293
5324
  }
5294
5325
  cacheResource(t) {
5295
- t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new C(Promise.resolve(t)));
5326
+ t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new w(Promise.resolve(t)));
5296
5327
  }
5297
5328
  deleteCacheEntry(t) {
5298
5329
  this.requestCache && this.requestCache.delete(t);
@@ -5309,9 +5340,9 @@ var Jr = class extends he {
5309
5340
  return;
5310
5341
  let a = t.headers.get("content-type")?.includes("json");
5311
5342
  if (t.status === 404 && !a)
5312
- throw new d(pr);
5313
- let c2 = t.headers.get("content-location"), m2 = o.redirect ?? this.options.redirect;
5314
- if (t.status === 201 && c2 && m2 === "follow")
5343
+ throw new d(mr);
5344
+ let c2 = t.headers.get("content-location"), f = o.redirect ?? this.options.redirect;
5345
+ if (t.status === 201 && c2 && f === "follow")
5315
5346
  return this.request("GET", c2, { ...o, body: void 0 });
5316
5347
  let p2;
5317
5348
  if (a)
@@ -5336,7 +5367,7 @@ var Jr = class extends he {
5336
5367
  } catch (c2) {
5337
5368
  this.retryCatch(a, i2, c2);
5338
5369
  }
5339
- await st(o);
5370
+ await ot(o);
5340
5371
  }
5341
5372
  return s;
5342
5373
  }
@@ -5357,10 +5388,10 @@ var Jr = class extends he {
5357
5388
  this.addFetchOptionsDefaults(s);
5358
5389
  let a = await this.fetchWithRetry(t, s);
5359
5390
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5360
- let c2 = await Zr(a);
5391
+ let c2 = await nn(a);
5361
5392
  c2 && (i2 = await this.fetchWithRetry(c2, s));
5362
5393
  }
5363
- await st(o);
5394
+ await ot(o);
5364
5395
  }
5365
5396
  return this.parseResponse(i2, "POST", t);
5366
5397
  }
@@ -5378,12 +5409,12 @@ var Jr = class extends he {
5378
5409
  let n = { resourceType: "Bundle", type: "batch", entry: t.map((o) => ({ request: { method: o.method, url: o.url }, resource: o.options.body ? JSON.parse(o.options.body) : void 0 })) }, i2 = await this.post(this.fhirBaseUrl.slice(0, -1), n);
5379
5410
  for (let o = 0; o < t.length; o++) {
5380
5411
  let s = t[o], a = i2.entry?.[o];
5381
- a?.response?.outcome && !gt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5412
+ a?.response?.outcome && !yt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5382
5413
  }
5383
5414
  }
5384
5415
  addFetchOptionsDefaults(t) {
5385
5416
  let n = t.headers;
5386
- n || (n = {}, t.headers = n), n.Accept || (n.Accept = zi), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = O.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
5417
+ n || (n = {}, t.headers = n), n.Accept || (n.Accept = Xi), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = C.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
5387
5418
  }
5388
5419
  setRequestContentType(t, n) {
5389
5420
  t.headers || (t.headers = {});
@@ -5401,16 +5432,16 @@ var Jr = class extends he {
5401
5432
  sessionStorage.setItem("pkceState", t);
5402
5433
  let n = Ot();
5403
5434
  sessionStorage.setItem("codeVerifier", n);
5404
- let i2 = await $r(n), o = Yt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5435
+ let i2 = await Qr(n), o = Zt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5405
5436
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5406
5437
  }
5407
5438
  async requestAuthorization(t) {
5408
5439
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
5409
- i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Yr()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
5440
+ i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? tn()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
5410
5441
  }
5411
5442
  processCode(t, n) {
5412
5443
  let i2 = new URLSearchParams();
5413
- if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Yr()), typeof sessionStorage < "u") {
5444
+ if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? tn()), typeof sessionStorage < "u") {
5414
5445
  let o = sessionStorage.getItem("codeVerifier");
5415
5446
  o && i2.set("code_verifier", o);
5416
5447
  }
@@ -5441,45 +5472,45 @@ var Jr = class extends he {
5441
5472
  return n.append("grant_type", "client_credentials"), n.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.append("client_assertion", t), this.fetchTokens(n);
5442
5473
  }
5443
5474
  setBasicAuth(t, n) {
5444
- this.clientId = t, this.clientSecret = n, this.basicAuth = qr(t + ":" + n);
5475
+ this.clientId = t, this.clientSecret = n, this.basicAuth = jr(t + ":" + n);
5445
5476
  }
5446
5477
  async fhircastSubscribe(t, n) {
5447
5478
  if (!(typeof t == "string" && t !== ""))
5448
5479
  throw new d(h("Invalid topic provided. Topic must be a valid string."));
5449
5480
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
5450
5481
  throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5451
- let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU2", Vt(i2), O.FORM_URL_ENCODED))["hub.channel.endpoint"];
5482
+ let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", Nt(i2), C.FORM_URL_ENCODED))["hub.channel.endpoint"];
5452
5483
  if (!s)
5453
5484
  throw new Error("Invalid response!");
5454
5485
  return i2.endpoint = s, i2;
5455
5486
  }
5456
5487
  async fhircastUnsubscribe(t) {
5457
- if (!Ye(t))
5488
+ if (!Je(t))
5458
5489
  throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5459
5490
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
5460
5491
  throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5461
- t.mode = "unsubscribe", await this.post("/fhircast/STU2", Vt(t), O.FORM_URL_ENCODED);
5492
+ t.mode = "unsubscribe", await this.post("/fhircast/STU3", Nt(t), C.FORM_URL_ENCODED);
5462
5493
  }
5463
5494
  fhircastConnect(t) {
5464
- return new Je(t);
5495
+ return new ze(t);
5465
5496
  }
5466
- async fhircastPublish(t, n, i2) {
5467
- return this.post(`/fhircast/STU2/${t}`, Qr(t, n, i2), O.JSON);
5497
+ async fhircastPublish(t, n, i2, o) {
5498
+ return Wr(n) ? this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2, o), C.JSON) : (Gr(n), this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2), C.JSON));
5468
5499
  }
5469
5500
  async invite(t, n) {
5470
5501
  return this.post("admin/projects/" + t + "/invite", n);
5471
5502
  }
5472
5503
  async fetchTokens(t) {
5473
- let n = { method: "POST", headers: { "Content-Type": O.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5504
+ let n = { method: "POST", headers: { "Content-Type": C.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5474
5505
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5475
5506
  let o = await this.fetchWithRetry(this.tokenUrl, n);
5476
5507
  if (!o.ok) {
5477
5508
  this.clearActiveLogin();
5478
5509
  try {
5479
5510
  let a = await o.json();
5480
- throw new d(L(a.error_description));
5511
+ throw new d(F(a.error_description));
5481
5512
  } catch (a) {
5482
- throw new d(L("Failed to fetch tokens"), a);
5513
+ throw new d(F("Failed to fetch tokens"), a);
5483
5514
  }
5484
5515
  }
5485
5516
  let s = await o.json();
@@ -5487,7 +5518,7 @@ var Jr = class extends he {
5487
5518
  }
5488
5519
  async verifyTokens(t) {
5489
5520
  let n = t.access_token;
5490
- if (Wr(n)) {
5521
+ if (Jr(n)) {
5491
5522
  let i2 = _t(n);
5492
5523
  if (Date.now() >= i2.exp * 1e3)
5493
5524
  throw this.clearActiveLogin(), new Error("Token expired");
@@ -5512,21 +5543,21 @@ var Jr = class extends he {
5512
5543
  throw i2;
5513
5544
  }
5514
5545
  };
5515
- function ro() {
5546
+ function so() {
5516
5547
  if (!globalThis.fetch)
5517
5548
  throw new Error("Fetch not available in this environment");
5518
5549
  return globalThis.fetch.bind(globalThis);
5519
5550
  }
5520
- function Yr() {
5551
+ function tn() {
5521
5552
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5522
5553
  }
5523
- function Xr(r4) {
5554
+ function rn(r4) {
5524
5555
  return r4.endsWith("/") ? r4 : r4 + "/";
5525
5556
  }
5526
- function Ze(r4, e) {
5557
+ function Xe(r4, e) {
5527
5558
  return new URL(e, r4).toString();
5528
5559
  }
5529
- async function Zr(r4) {
5560
+ async function nn(r4) {
5530
5561
  let e = r4.headers.get("content-location");
5531
5562
  if (e)
5532
5563
  return e;
@@ -5537,15 +5568,15 @@ async function Zr(r4) {
5537
5568
  if (ke(n) && n.issue?.[0]?.diagnostics)
5538
5569
  return n.issue[0].diagnostics;
5539
5570
  }
5540
- function en(r4) {
5571
+ function on(r4) {
5541
5572
  let e = r4.entry?.map((t) => t.resource) ?? [];
5542
5573
  return Object.assign(e, { bundle: r4 });
5543
5574
  }
5544
- var no = [...le, "->", "<<", ">>"];
5545
- var io = de().registerInfix("->", { precedence: f.Arrow }).registerInfix(";", { precedence: f.Semicolon });
5546
- var oo = [...le, "eq", "ne", "co"];
5547
- var co = de();
5548
- var G = class {
5575
+ var ao = [...le, "->", "<<", ">>"];
5576
+ var co = de().registerInfix("->", { precedence: m.Arrow }).registerInfix(";", { precedence: m.Semicolon });
5577
+ var uo = [...le, "eq", "ne", "co"];
5578
+ var fo = de();
5579
+ var W = class {
5549
5580
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5550
5581
  this.segmentSeparator = e;
5551
5582
  this.fieldSeparator = t;
@@ -5561,8 +5592,8 @@ var G = class {
5561
5592
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5562
5593
  }
5563
5594
  };
5564
- var on = class r {
5565
- constructor(e, t = new G()) {
5595
+ var un = class r {
5596
+ constructor(e, t = new W()) {
5566
5597
  this.context = t, this.segments = e;
5567
5598
  }
5568
5599
  get header() {
@@ -5585,7 +5616,7 @@ var on = class r {
5585
5616
  }
5586
5617
  buildAck() {
5587
5618
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i2 = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a = t?.getField(10)?.toString() ?? "", c2 = t?.getField(12)?.toString() ?? "2.5.1";
5588
- return new r([new ye(["MSH", this.context.getMsh2(), o, s, n, i2, lo(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new ye(["MSA", "AA", a, "OK"], this.context)]);
5619
+ return new r([new ye(["MSH", this.context.getMsh2(), o, s, n, i2, ho(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new ye(["MSA", "AA", a, "OK"], this.context)]);
5589
5620
  }
5590
5621
  buildAckMessageType(e) {
5591
5622
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5596,13 +5627,13 @@ var on = class r {
5596
5627
  let n = new Error("Invalid HL7 message");
5597
5628
  throw n.type = "entity.parse.failed", n;
5598
5629
  }
5599
- let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5630
+ let t = new W("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5600
5631
  return new r(e.split(/[\r\n]+/).map((n) => ye.parse(n, t)), t);
5601
5632
  }
5602
5633
  };
5603
5634
  var ye = class r2 {
5604
- constructor(e, t = new G()) {
5605
- this.context = t, Kt(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5635
+ constructor(e, t = new W()) {
5636
+ this.context = t, Jt(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5606
5637
  }
5607
5638
  get(e) {
5608
5639
  return this.fields[e];
@@ -5624,12 +5655,12 @@ var ye = class r2 {
5624
5655
  toString() {
5625
5656
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
5626
5657
  }
5627
- static parse(e, t = new G()) {
5658
+ static parse(e, t = new W()) {
5628
5659
  return new r2(e.split(t.fieldSeparator).map((n) => oe.parse(n, t)), t);
5629
5660
  }
5630
5661
  };
5631
5662
  var oe = class r3 {
5632
- constructor(e, t = new G()) {
5663
+ constructor(e, t = new W()) {
5633
5664
  this.context = t, this.components = e;
5634
5665
  }
5635
5666
  get(e, t, n = 0) {
@@ -5642,11 +5673,11 @@ var oe = class r3 {
5642
5673
  toString() {
5643
5674
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
5644
5675
  }
5645
- static parse(e, t = new G()) {
5676
+ static parse(e, t = new W()) {
5646
5677
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5647
5678
  }
5648
5679
  };
5649
- function lo(r4) {
5680
+ function ho(r4) {
5650
5681
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5651
5682
  return i2 > 0 && (n += "." + i2.toString()), n;
5652
5683
  }
@@ -5662,7 +5693,7 @@ var i = class extends EventTarget {
5662
5693
  super.removeEventListener(n, e, t);
5663
5694
  }
5664
5695
  };
5665
- var m = String.fromCharCode(11);
5696
+ var m2 = String.fromCharCode(11);
5666
5697
  var p = String.fromCharCode(28);
5667
5698
  var v2 = String.fromCharCode(13);
5668
5699
  var d2 = class extends Event {
@@ -5687,7 +5718,7 @@ var c = class extends i {
5687
5718
  e.on("data", (s) => {
5688
5719
  try {
5689
5720
  if (o += s.toString(), o.endsWith(p + v2)) {
5690
- let r4 = on.parse(o.substring(1, o.length - 2));
5721
+ let r4 = un.parse(o.substring(1, o.length - 2));
5691
5722
  this.dispatchEvent(new d2(this, r4)), o = "";
5692
5723
  }
5693
5724
  } catch (r4) {
@@ -5698,7 +5729,7 @@ var c = class extends i {
5698
5729
  });
5699
5730
  }
5700
5731
  send(e) {
5701
- this.socket.write(m + e.toString() + p + v2);
5732
+ this.socket.write(m2 + e.toString() + p + v2);
5702
5733
  }
5703
5734
  async sendAndWait(e) {
5704
5735
  let t = new Promise((o) => {
@@ -5808,7 +5839,7 @@ var App = class {
5808
5839
  break;
5809
5840
  }
5810
5841
  } catch (err) {
5811
- this.log.error(`WebSocket error: ${$n(err)}`);
5842
+ this.log.error(`WebSocket error: ${Kn(err)}`);
5812
5843
  }
5813
5844
  });
5814
5845
  }
@@ -5860,7 +5891,7 @@ var App = class {
5860
5891
  if (channel) {
5861
5892
  const connection = channel.connections.get(msg.remote);
5862
5893
  if (connection) {
5863
- connection.hl7Connection.send(on.parse(msg.body));
5894
+ connection.hl7Connection.send(un.parse(msg.body));
5864
5895
  }
5865
5896
  }
5866
5897
  }
@@ -5872,10 +5903,10 @@ var App = class {
5872
5903
  host: address.hostname,
5873
5904
  port: parseInt(address.port, 10)
5874
5905
  });
5875
- client.sendAndWait(on.parse(message.body)).then((response) => {
5906
+ client.sendAndWait(un.parse(message.body)).then((response) => {
5876
5907
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
5877
5908
  }).catch((err) => {
5878
- this.log.error(`HL7 error: ${$n(err)}`);
5909
+ this.log.error(`HL7 error: ${Kn(err)}`);
5879
5910
  }).finally(() => {
5880
5911
  client.close();
5881
5912
  });
@@ -5924,7 +5955,7 @@ var AgentHl7ChannelConnection = class {
5924
5955
  body: event.message.toString()
5925
5956
  });
5926
5957
  } catch (err) {
5927
- this.channel.app.log.error(`HL7 error: ${$n(err)}`);
5958
+ this.channel.app.log.error(`HL7 error: ${Kn(err)}`);
5928
5959
  }
5929
5960
  }
5930
5961
  close() {
@@ -5937,7 +5968,7 @@ if (typeof require !== "undefined" && require.main === module) {
5937
5968
  process.exit(1);
5938
5969
  }
5939
5970
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
5940
- const medplum = new Jr({ baseUrl, clientId });
5971
+ const medplum = new en({ baseUrl, clientId });
5941
5972
  medplum.startClientLogin(clientId, clientSecret).then(() => new App(medplum, agentId).start()).catch(console.error);
5942
5973
  }
5943
5974
  // Annotate the CommonJS export names for ESM import in node: