@medplum/agent 2.1.7 → 2.1.8

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 +320 -311
  2. package/package.json +1 -1
@@ -1295,9 +1295,9 @@ var require_receiver = __commonJS({
1295
1295
  }
1296
1296
  this._fragments.push(buf);
1297
1297
  }
1298
- const er2 = this.dataMessage();
1299
- if (er2)
1300
- return cb(er2);
1298
+ const er = this.dataMessage();
1299
+ if (er)
1300
+ return cb(er);
1301
1301
  this.startLoop(cb);
1302
1302
  });
1303
1303
  }
@@ -3548,7 +3548,7 @@ __export(main_exports, {
3548
3548
  module.exports = __toCommonJS(main_exports);
3549
3549
 
3550
3550
  // ../core/dist/esm/index.mjs
3551
- var he = class {
3551
+ var ge = class {
3552
3552
  constructor(e, t) {
3553
3553
  this.operator = e;
3554
3554
  this.child = t;
@@ -3567,7 +3567,7 @@ var $ = class {
3567
3567
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
3568
3568
  }
3569
3569
  };
3570
- var ye = class {
3570
+ var xe = class {
3571
3571
  constructor() {
3572
3572
  this.prefixParselets = {};
3573
3573
  this.infixParselets = {};
@@ -3591,10 +3591,10 @@ var ye = class {
3591
3591
  }, precedence: t });
3592
3592
  }
3593
3593
  construct(e) {
3594
- return new et(e, this.prefixParselets, this.infixParselets);
3594
+ return new rt(e, this.prefixParselets, this.infixParselets);
3595
3595
  }
3596
3596
  };
3597
- var et = class {
3597
+ var rt = class {
3598
3598
  constructor(e, t, n) {
3599
3599
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3600
3600
  }
@@ -3646,39 +3646,43 @@ var et = class {
3646
3646
  }
3647
3647
  };
3648
3648
  function K(r4) {
3649
- let e = $t(r4), t = ln(r4);
3649
+ let e = se(r4), t = dn(r4);
3650
3650
  return t === e ? { reference: e } : { reference: e, display: t };
3651
3651
  }
3652
- function $t(r4) {
3653
- return r4.resourceType + "/" + r4.id;
3652
+ function se(r4) {
3653
+ return ae(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
3654
3654
  }
3655
- function un(r4) {
3656
- return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3655
+ function Ht(r4) {
3656
+ if (r4)
3657
+ return ae(r4) ? r4.reference.split("/")[1] : r4.id;
3657
3658
  }
3658
3659
  function ln(r4) {
3659
- if (un(r4)) {
3660
- let e = dn(r4);
3660
+ return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3661
+ }
3662
+ function dn(r4) {
3663
+ if (ln(r4)) {
3664
+ let e = pn(r4);
3661
3665
  if (e)
3662
3666
  return e;
3663
3667
  }
3664
3668
  if (r4.resourceType === "Device") {
3665
- let e = pn(r4);
3669
+ let e = fn(r4);
3666
3670
  if (e)
3667
3671
  return e;
3668
3672
  }
3669
- 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 : $t(r4);
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);
3670
3674
  }
3671
- function dn(r4) {
3675
+ function pn(r4) {
3672
3676
  let e = r4.name;
3673
3677
  if (e && e.length > 0)
3674
- return be(e[0]);
3678
+ return Ee(e[0]);
3675
3679
  }
3676
- function pn(r4) {
3680
+ function fn(r4) {
3677
3681
  let e = r4.deviceName;
3678
3682
  if (e && e.length > 0)
3679
3683
  return e[0].name;
3680
3684
  }
3681
- function ge(r4, e) {
3685
+ function Te(r4, e) {
3682
3686
  let t = new Date(r4);
3683
3687
  t.setUTCHours(0, 0, 0, 0);
3684
3688
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
@@ -3687,37 +3691,37 @@ function ge(r4, e) {
3687
3691
  (c2 < o || c2 === o && m2 < s) && p2--;
3688
3692
  let q = a * 12 + c2 - (i2 * 12 + o);
3689
3693
  m2 < s && q--;
3690
- let cn = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3691
- return { years: p2, months: q, days: cn };
3694
+ let un = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3695
+ return { years: p2, months: q, days: un };
3692
3696
  }
3693
- function Qt(r4, e) {
3694
- return JSON.stringify(r4, fn, e ? 2 : void 0);
3697
+ function Gt(r4, e) {
3698
+ return JSON.stringify(r4, mn, e ? 2 : void 0);
3695
3699
  }
3696
- function fn(r4, e) {
3697
- return !mn(r4) && b(e) ? void 0 : e;
3700
+ function mn(r4, e) {
3701
+ return !hn(r4) && R(e) ? void 0 : e;
3698
3702
  }
3699
- function mn(r4) {
3703
+ function hn(r4) {
3700
3704
  return !!/\d+$/.exec(r4);
3701
3705
  }
3702
- function b(r4) {
3706
+ function R(r4) {
3703
3707
  if (r4 == null)
3704
3708
  return true;
3705
3709
  let e = typeof r4;
3706
3710
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3707
3711
  }
3708
- function Wt(r4) {
3712
+ function Kt(r4) {
3709
3713
  return r4.every((e) => typeof e == "string");
3710
3714
  }
3711
- var Gt = [];
3715
+ var zt = [];
3712
3716
  for (let r4 = 0; r4 < 256; r4++)
3713
- Gt.push(r4.toString(16).padStart(2, "0"));
3714
- function Kt(r4) {
3717
+ zt.push(r4.toString(16).padStart(2, "0"));
3718
+ function Jt(r4) {
3715
3719
  let e = new Uint8Array(r4), t = new Array(e.length);
3716
3720
  for (let n = 0; n < e.length; n++)
3717
- t[n] = Gt[e[n]];
3721
+ t[n] = zt[e[n]];
3718
3722
  return t.join("");
3719
3723
  }
3720
- function zt(r4) {
3724
+ function Yt(r4) {
3721
3725
  let e = new Uint8Array(r4), t = [];
3722
3726
  for (let n = 0; n < e.length; n++)
3723
3727
  t[n] = String.fromCharCode(e[n]);
@@ -3726,34 +3730,34 @@ function zt(r4) {
3726
3730
  function A(r4) {
3727
3731
  return r4.charAt(0).toUpperCase() + r4.substring(1);
3728
3732
  }
3729
- var nt = (r4) => new Promise((e) => {
3733
+ var ot = (r4) => new Promise((e) => {
3730
3734
  setTimeout(e, r4);
3731
3735
  });
3732
- function be(r4, e) {
3736
+ function Ee(r4, e) {
3733
3737
  let t = [];
3734
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();
3735
3739
  }
3736
- function Un(r4) {
3740
+ function Ln(r4) {
3737
3741
  let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
3738
3742
  return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
3739
3743
  }
3740
- function Zt(r4) {
3744
+ function tr(r4) {
3741
3745
  let e = /* @__PURE__ */ Object.create(null);
3742
3746
  for (let [t, n] of Object.entries(r4))
3743
- 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, Ln(o)])), constraints: [], innerTypes: [] };
3744
3748
  return e;
3745
3749
  }
3746
- var er = { 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 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" }] } } } };
3747
3751
  function l(r4) {
3748
3752
  return [{ type: u.boolean, value: r4 }];
3749
3753
  }
3750
3754
  function T(r4) {
3751
- 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 } : V(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 } : _(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3752
3756
  }
3753
3757
  function N(r4) {
3754
3758
  return r4.length === 0 ? false : !!r4[0].value;
3755
3759
  }
3756
- function D(r4, e) {
3760
+ function V(r4, e) {
3757
3761
  if (r4.length !== 0) {
3758
3762
  if (r4.length === 1 && (!e || r4[0].type === e))
3759
3763
  return r4[0];
@@ -3763,10 +3767,10 @@ function D(r4, e) {
3763
3767
  function w(r4, e) {
3764
3768
  if (!r4.value)
3765
3769
  return;
3766
- let t = Ae(r4.type, e);
3767
- return t ? Fn(r4, e, t) : Nn(r4, e);
3770
+ let t = Ce(r4.type, e);
3771
+ return t ? Nn(r4, e, t) : Mn(r4, e);
3768
3772
  }
3769
- function Fn(r4, e, t) {
3773
+ function Nn(r4, e, t) {
3770
3774
  let n = t.type;
3771
3775
  if (!n || n.length === 0)
3772
3776
  return;
@@ -3782,13 +3786,13 @@ function Fn(r4, e, t) {
3782
3786
  }
3783
3787
  }
3784
3788
  let s = r4.value["_" + e];
3785
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? ir(a ?? {}, s[c2]) : a) : i2 = ir(i2 ?? {}, s)), !b(i2))
3786
- return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => tr(a, o)) : tr(i2, o);
3789
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? sr(a ?? {}, s[c2]) : a) : i2 = sr(i2 ?? {}, s)), !R(i2))
3790
+ return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => nr(a, o)) : nr(i2, o);
3787
3791
  }
3788
- function tr(r4, e) {
3789
- return e === "Resource" && V(r4) && (e = r4.resourceType), { type: e, value: r4 };
3792
+ function nr(r4, e) {
3793
+ return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
3790
3794
  }
3791
- function Nn(r4, e) {
3795
+ function Mn(r4, e) {
3792
3796
  let t = r4.value;
3793
3797
  if (!t || typeof t != "object")
3794
3798
  return;
@@ -3803,15 +3807,15 @@ function Nn(r4, e) {
3803
3807
  break;
3804
3808
  }
3805
3809
  }
3806
- if (!b(n))
3810
+ if (!R(n))
3807
3811
  return Array.isArray(n) ? n.map(T) : T(n);
3808
3812
  }
3809
- function Re(r4) {
3813
+ function Ae(r4) {
3810
3814
  let e = [];
3811
3815
  for (let t of r4) {
3812
3816
  let n = false;
3813
3817
  for (let i2 of e)
3814
- if (N(or(t, i2))) {
3818
+ if (N(ar(t, i2))) {
3815
3819
  n = true;
3816
3820
  break;
3817
3821
  }
@@ -3819,28 +3823,28 @@ function Re(r4) {
3819
3823
  }
3820
3824
  return e;
3821
3825
  }
3822
- function st(r4) {
3826
+ function ct(r4) {
3823
3827
  return l(!N(r4));
3824
3828
  }
3825
- function at(r4, e) {
3826
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => N(or(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) => N(ar(t, e[n]))));
3827
3831
  }
3828
- function or(r4, e) {
3832
+ function ar(r4, e) {
3829
3833
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3830
- return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(sr(t, n)) : l(typeof t == "object" && typeof n == "object" ? ut(r4, e) : t === n);
3834
+ return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : b(t) && b(n) ? l(cr(t, n)) : l(typeof t == "object" && typeof n == "object" ? dt(r4, e) : t === n);
3831
3835
  }
3832
- function ct(r4, e) {
3833
- return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(rr), e.sort(rr), l(r4.every((t, n) => N(Mn(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(ir), e.sort(ir), l(r4.every((t, n) => N(Bn(t, e[n])))));
3834
3838
  }
3835
- function Mn(r4, e) {
3839
+ function Bn(r4, e) {
3836
3840
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3837
- return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(sr(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" ? ut({ ...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(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" ? dt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3838
3842
  }
3839
- function rr(r4, e) {
3843
+ function ir(r4, e) {
3840
3844
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3841
3845
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3842
3846
  }
3843
- function Ee(r4, e) {
3847
+ function Pe(r4, e) {
3844
3848
  let { value: t } = r4;
3845
3849
  if (t == null)
3846
3850
  return false;
@@ -3857,106 +3861,106 @@ function Ee(r4, e) {
3857
3861
  case "Time":
3858
3862
  return typeof t == "string" && !!/^T\d/.exec(t);
3859
3863
  case "Period":
3860
- return Bn(t);
3864
+ return qn(t);
3861
3865
  case "Quantity":
3862
- return R(t);
3866
+ return b(t);
3863
3867
  default:
3864
3868
  return typeof t == "object" && t?.resourceType === e;
3865
3869
  }
3866
3870
  }
3867
- function Bn(r4) {
3871
+ function qn(r4) {
3868
3872
  return !!(r4 && typeof r4 == "object" && "start" in r4);
3869
3873
  }
3870
- function R(r4) {
3874
+ function b(r4) {
3871
3875
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3872
3876
  }
3873
- function sr(r4, e) {
3877
+ function cr(r4, e) {
3874
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);
3875
3879
  }
3876
- function ut(r4, e) {
3880
+ function dt(r4, e) {
3877
3881
  let t = Object.keys(r4), n = Object.keys(e);
3878
3882
  if (t.length !== n.length)
3879
3883
  return false;
3880
3884
  for (let i2 of t) {
3881
3885
  let o = r4[i2], s = e[i2];
3882
- if (nr(o) && nr(s)) {
3883
- if (!ut(o, s))
3886
+ if (or(o) && or(s)) {
3887
+ if (!dt(o, s))
3884
3888
  return false;
3885
3889
  } else if (o !== s)
3886
3890
  return false;
3887
3891
  }
3888
3892
  return true;
3889
3893
  }
3890
- function nr(r4) {
3894
+ function or(r4) {
3891
3895
  return r4 !== null && typeof r4 == "object";
3892
3896
  }
3893
- function ir(r4, e) {
3897
+ function sr(r4, e) {
3894
3898
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3895
3899
  }
3896
- var lt = "ok";
3897
- var Pe = "created";
3898
- var pt = "not-modified";
3899
- var ft = "not-found";
3900
- var Ce = "accepted";
3901
- var lr = { resourceType: "OperationOutcome", id: ft, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3902
- function _(r4, e) {
3900
+ var pt = "ok";
3901
+ var we = "created";
3902
+ var mt = "not-modified";
3903
+ var ht = "not-found";
3904
+ var Ie = "accepted";
3905
+ var pr = { resourceType: "OperationOutcome", id: ht, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3906
+ function U(r4, e) {
3903
3907
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3904
3908
  }
3905
3909
  function h(r4) {
3906
3910
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
3907
3911
  }
3908
- function we(r4) {
3912
+ function ke(r4) {
3909
3913
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3910
3914
  }
3911
- function mt(r4) {
3912
- return r4.id === lt || r4.id === Pe || r4.id === pt || r4.id === Ce;
3915
+ function yt(r4) {
3916
+ return r4.id === pt || r4.id === we || r4.id === mt || r4.id === Ie;
3913
3917
  }
3914
3918
  var d = class extends Error {
3915
3919
  constructor(t, n) {
3916
- super(pr(t));
3920
+ super(mr(t));
3917
3921
  this.outcome = t, this.cause = n;
3918
3922
  }
3919
3923
  };
3920
- function ht(r4) {
3921
- return r4 instanceof d ? r4.outcome : we(r4) ? r4 : _(qn(r4));
3924
+ function gt(r4) {
3925
+ return r4 instanceof d ? r4.outcome : ke(r4) ? r4 : U($n(r4));
3922
3926
  }
3923
- function qn(r4) {
3924
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : we(r4) ? pr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
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";
3925
3929
  }
3926
- function pr(r4) {
3927
- let e = r4.issue?.map($n) ?? [];
3930
+ function mr(r4) {
3931
+ let e = r4.issue?.map(jn) ?? [];
3928
3932
  return e.length > 0 ? e.join("; ") : "Unknown error";
3929
3933
  }
3930
- function $n(r4) {
3934
+ function jn(r4) {
3931
3935
  let e;
3932
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;
3933
3937
  }
3934
- function vt(r4) {
3935
- return new xt(r4).parse();
3938
+ function Rt(r4) {
3939
+ return new vt(r4).parse();
3936
3940
  }
3937
- var H = Zt(er);
3938
- function xr(r4) {
3941
+ var H = tr(rr);
3942
+ function vr(r4) {
3939
3943
  let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3940
3944
  for (let t of e)
3941
- jn(t);
3945
+ Hn(t);
3942
3946
  }
3943
- function jn(r4) {
3947
+ function Hn(r4) {
3944
3948
  if (!r4?.name)
3945
3949
  throw new Error("Failed loading StructureDefinition from bundle");
3946
3950
  if (r4.resourceType !== "StructureDefinition")
3947
3951
  return;
3948
- let e = vt(r4);
3952
+ let e = Rt(r4);
3949
3953
  H[r4.name] = e;
3950
3954
  for (let t of e.innerTypes)
3951
3955
  t.parentType = e, H[t.name] = t;
3952
3956
  }
3953
- function vr(r4) {
3957
+ function Rr(r4) {
3954
3958
  return !!H[r4];
3955
3959
  }
3956
- function Sr(r4) {
3960
+ function br(r4) {
3957
3961
  return H[r4];
3958
3962
  }
3959
- var xt = class {
3963
+ var vt = class {
3960
3964
  constructor(e) {
3961
3965
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
3962
3966
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
@@ -3969,7 +3973,7 @@ var xt = class {
3969
3973
  this.parseSliceStart(e);
3970
3974
  else if (e.id?.includes(":")) {
3971
3975
  if (this.slicingContext?.current) {
3972
- let t = gt(e, this.slicingContext.path);
3976
+ let t = Tt(e, this.slicingContext.path);
3973
3977
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
3974
3978
  }
3975
3979
  } else {
@@ -3978,13 +3982,13 @@ var xt = class {
3978
3982
  let n = this.backboneContext;
3979
3983
  for (; n; ) {
3980
3984
  if (e.path?.startsWith(n.path + ".")) {
3981
- n.type.elements[gt(e, n.path)] = t;
3985
+ n.type.elements[Tt(e, n.path)] = t;
3982
3986
  break;
3983
3987
  }
3984
3988
  n = n.parent;
3985
3989
  }
3986
3990
  if (!n) {
3987
- let i2 = gt(e, this.root.path);
3991
+ let i2 = Tt(e, this.root.path);
3988
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;
3989
3993
  }
3990
3994
  this.checkFieldExit(e);
@@ -3999,10 +4003,10 @@ var xt = class {
3999
4003
  enterInnerType(e) {
4000
4004
  for (; this.backboneContext && !ee(this.backboneContext?.path, e.path); )
4001
4005
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4002
- this.backboneContext = { type: { name: Tt(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: 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 };
4003
4007
  }
4004
4008
  enterSlice(e, t) {
4005
- Wn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4009
+ Gn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4006
4010
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
4007
4011
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
4008
4012
  return { path: n.path, type: n.type };
@@ -4043,51 +4047,54 @@ var xt = class {
4043
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) };
4044
4048
  }
4045
4049
  parseElementDefinition(e) {
4046
- let t = yr(e.max), n = e.base?.max ? yr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4047
- 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) ? Tt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: gr(w(i2, "fixed")), pattern: gr(w(i2, "pattern")), binding: e.binding };
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 };
4048
4052
  }
4049
4053
  };
4050
- function yr(r4) {
4054
+ function xr(r4) {
4051
4055
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
4052
4056
  }
4053
- function gt(r4, e = "") {
4054
- return Qn(r4.path, e);
4057
+ function Tt(r4, e = "") {
4058
+ return Wn(r4.path, e);
4055
4059
  }
4056
- function Qn(r4, e) {
4060
+ function Wn(r4, e) {
4057
4061
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
4058
4062
  }
4059
4063
  function ee(r4, e) {
4060
4064
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
4061
4065
  }
4062
- function gr(r4) {
4063
- return Array.isArray(r4) && r4.length > 0 ? r4[0] : b(r4) ? void 0 : r4;
4066
+ function Tr(r4) {
4067
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : R(r4) ? void 0 : r4;
4064
4068
  }
4065
- function Wn(r4) {
4069
+ function Gn(r4) {
4066
4070
  let e = r4.slicing?.discriminator;
4067
4071
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
4068
4072
  }
4069
4073
  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" };
4070
- function bt(r4) {
4074
+ function Et(r4) {
4071
4075
  for (let e of r4.base ?? []) {
4072
4076
  let t = I.types[e];
4073
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;
4074
4078
  }
4075
4079
  }
4076
- function Tt(r4) {
4080
+ function St(r4) {
4077
4081
  let e = r4.type?.[0]?.code;
4078
- return e === "BackboneElement" || e === "Element" ? Gn((r4.base?.path ?? r4.path)?.split(".")) : e;
4082
+ return e === "BackboneElement" || e === "Element" ? Kn((r4.base?.path ?? r4.path)?.split(".")) : e;
4079
4083
  }
4080
- function Gn(r4) {
4084
+ function Kn(r4) {
4081
4085
  return r4.length === 1 ? r4[0] : r4.map(A).join("");
4082
4086
  }
4083
- function Ae(r4, e) {
4084
- let t = Sr(r4);
4087
+ function Ce(r4, e) {
4088
+ let t = br(r4);
4085
4089
  if (t)
4086
4090
  return t.elements[e] ?? t.elements[e + "[x]"];
4087
4091
  }
4088
- function V(r4) {
4092
+ function _(r4) {
4089
4093
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
4090
4094
  }
4095
+ function ae(r4) {
4096
+ return !!(r4 && typeof r4 == "object" && "reference" in r4);
4097
+ }
4091
4098
  var I = { types: {} };
4092
4099
  function re(r4) {
4093
4100
  if (r4.startsWith("T"))
@@ -4100,7 +4107,7 @@ function re(r4) {
4100
4107
  return r4;
4101
4108
  }
4102
4109
  }
4103
- var se = () => [];
4110
+ var ce = () => [];
4104
4111
  var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => N(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => N(t.eval(r4, [n])))), allTrue: (r4, e) => {
4105
4112
  for (let t of e)
4106
4113
  if (!t.value)
@@ -4121,12 +4128,12 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4121
4128
  if (!t.value)
4122
4129
  return l(true);
4123
4130
  return l(false);
4124
- }, subsetOf: se, supersetOf: se, count: (r4, e) => [{ type: u.integer, value: e.length }], distinct: (r4, e) => {
4131
+ }, subsetOf: ce, supersetOf: ce, count: (r4, e) => [{ type: u.integer, value: e.length }], distinct: (r4, e) => {
4125
4132
  let t = [];
4126
4133
  for (let n of e)
4127
4134
  t.some((i2) => i2.value === n.value) || t.push(n);
4128
4135
  return t;
4129
- }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => N(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: se, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4136
+ }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => N(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) => {
4130
4137
  if (e.length > 1)
4131
4138
  throw new Error("Expected input length one for single()");
4132
4139
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4158,7 +4165,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4158
4165
  if (!t)
4159
4166
  return e;
4160
4167
  let n = t.eval(r4, e);
4161
- return Re([...e, ...n]);
4168
+ return Ae([...e, ...n]);
4162
4169
  }, combine: (r4, e, t) => {
4163
4170
  if (!t)
4164
4171
  return e;
@@ -4172,7 +4179,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4172
4179
  }, toBoolean: (r4, e) => {
4173
4180
  if (e.length === 0)
4174
4181
  return [];
4175
- let [{ value: t }] = L(e, 1);
4182
+ let [{ value: t }] = F(e, 1);
4176
4183
  if (typeof t == "boolean")
4177
4184
  return [{ type: u.boolean, value: t }];
4178
4185
  if (typeof t == "number" && (t === 0 || t === 1))
@@ -4188,37 +4195,37 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4188
4195
  }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4189
4196
  if (e.length === 0)
4190
4197
  return [];
4191
- let [{ value: t }] = L(e, 1);
4198
+ let [{ value: t }] = F(e, 1);
4192
4199
  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 }] : [];
4193
4200
  }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4194
4201
  if (e.length === 0)
4195
4202
  return [];
4196
- let [{ value: t }] = L(e, 1);
4203
+ let [{ value: t }] = F(e, 1);
4197
4204
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4198
4205
  }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4199
4206
  if (e.length === 0)
4200
4207
  return [];
4201
- let [{ value: t }] = L(e, 1);
4208
+ let [{ value: t }] = F(e, 1);
4202
4209
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4203
4210
  }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4204
4211
  if (e.length === 0)
4205
4212
  return [];
4206
- let [{ value: t }] = L(e, 1);
4213
+ let [{ value: t }] = F(e, 1);
4207
4214
  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 }] : [];
4208
4215
  }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4209
4216
  if (e.length === 0)
4210
4217
  return [];
4211
- let [{ value: t }] = L(e, 1);
4212
- 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" } }] : [];
4218
+ let [{ value: t }] = F(e, 1);
4219
+ 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" } }] : [];
4213
4220
  }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4214
4221
  if (e.length === 0)
4215
4222
  return [];
4216
- let [{ value: t }] = L(e, 1);
4217
- return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4223
+ let [{ value: t }] = F(e, 1);
4224
+ return t == null ? [] : b(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4218
4225
  }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4219
4226
  if (e.length === 0)
4220
4227
  return [];
4221
- let [{ value: t }] = L(e, 1);
4228
+ let [{ value: t }] = F(e, 1);
4222
4229
  if (typeof t == "string") {
4223
4230
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4224
4231
  if (n)
@@ -4228,7 +4235,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4228
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) => {
4229
4236
  let a = o, c2 = s ? a + s : i2.length;
4230
4237
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4231
- }, 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: se, descendants: se, 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) => {
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) => L(Math.abs, r4, e), ceiling: (r4, e) => L(Math.ceil, r4, e), exp: (r4, e) => L(Math.exp, r4, e), floor: (r4, e) => L(Math.floor, r4, e), ln: (r4, e) => L(Math.log, r4, e), log: (r4, e, t) => L((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => L(Math.pow, r4, e, t), round: (r4, e) => L(Math.round, r4, e), sqrt: (r4, e) => L(Math.sqrt, r4, e), truncate: (r4, e) => L((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) => {
4232
4239
  let o = S.toDateTime(r4, t.eval(r4, e));
4233
4240
  if (o.length === 0)
4234
4241
  throw new Error("Invalid start date");
@@ -4238,11 +4245,11 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4238
4245
  let a = i2.eval(r4, e)[0]?.value;
4239
4246
  if (a !== "years" && a !== "months" && a !== "days")
4240
4247
  throw new Error("Invalid units");
4241
- let c2 = ge(o[0].value, s[0].value);
4248
+ let c2 = Te(o[0].value, s[0].value);
4242
4249
  return [{ type: u.Quantity, value: { value: c2[a], unit: a } }];
4243
4250
  }, is: (r4, e, t) => {
4244
4251
  let n = "";
4245
- 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: Ee(i2, 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) })) : [];
4246
4253
  }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4247
4254
  let n = t.value, i2;
4248
4255
  if (typeof n == "string")
@@ -4262,7 +4269,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4262
4269
  return { type: o, value: { resourceType: o, id: s } };
4263
4270
  }
4264
4271
  return { type: u.BackboneElement, value: void 0 };
4265
- }).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" } } : V(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
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) => {
4266
4273
  let n = t.eval(r4, e)[0].value;
4267
4274
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4268
4275
  throw new Error("Expected a StructureDefinition URL");
@@ -4272,22 +4279,22 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4272
4279
  function P(r4, e, t, ...n) {
4273
4280
  if (t.length === 0)
4274
4281
  return [];
4275
- let [{ value: i2 }] = L(t, 1);
4282
+ let [{ value: i2 }] = F(t, 1);
4276
4283
  if (typeof i2 != "string")
4277
4284
  throw new Error("String function cannot be called with non-string");
4278
4285
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4279
4286
  return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4280
4287
  }
4281
- function U(r4, e, t, ...n) {
4288
+ function L(r4, e, t, ...n) {
4282
4289
  if (t.length === 0)
4283
4290
  return [];
4284
- let [{ value: i2 }] = L(t, 1), o = R(i2), s = o ? i2.value : i2;
4291
+ let [{ value: i2 }] = F(t, 1), o = b(i2), s = o ? i2.value : i2;
4285
4292
  if (typeof s != "number")
4286
4293
  throw new Error("Math function cannot be called with non-number");
4287
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;
4288
4295
  return [{ type: c2, value: m2 }];
4289
4296
  }
4290
- function L(r4, e) {
4297
+ function F(r4, e) {
4291
4298
  if (r4.length !== e)
4292
4299
  throw new Error(`Expected ${e} arguments`);
4293
4300
  for (let t of r4)
@@ -4325,13 +4332,13 @@ var M = class {
4325
4332
  evalValue(e) {
4326
4333
  let t = e.value;
4327
4334
  if (!(!t || typeof t != "object"))
4328
- return V(t) && t.resourceType === this.name ? e : w(e, this.name);
4335
+ return _(t) && t.resourceType === this.name ? e : w(e, this.name);
4329
4336
  }
4330
4337
  toString() {
4331
4338
  return this.name;
4332
4339
  }
4333
4340
  };
4334
- var ke = class {
4341
+ var De = class {
4335
4342
  eval() {
4336
4343
  return [];
4337
4344
  }
@@ -4339,7 +4346,7 @@ var ke = class {
4339
4346
  return "{}";
4340
4347
  }
4341
4348
  };
4342
- var Oe = class extends he {
4349
+ var Ve = class extends ge {
4343
4350
  constructor(t, n, i2) {
4344
4351
  super(t, n);
4345
4352
  this.impl = i2;
@@ -4373,11 +4380,11 @@ var E = class extends v {
4373
4380
  let o = this.right.eval(t, n);
4374
4381
  if (o.length !== 1)
4375
4382
  return [];
4376
- 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);
4377
- return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4383
+ let s = i2[0].value, a = o[0].value, c2 = b(s) ? s.value : s, m2 = b(a) ? a.value : a, p2 = this.impl(c2, m2);
4384
+ return typeof p2 == "boolean" ? l(p2) : b(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4378
4385
  }
4379
4386
  };
4380
- var De = class extends $ {
4387
+ var _e = class extends $ {
4381
4388
  constructor(e, t) {
4382
4389
  super("&", e, t);
4383
4390
  }
@@ -4386,7 +4393,7 @@ var De = class extends $ {
4386
4393
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: u.string, value: o.map((s) => s.value).join("") }] : o;
4387
4394
  }
4388
4395
  };
4389
- var Ve = class extends v {
4396
+ var Ue = class extends v {
4390
4397
  constructor(e, t) {
4391
4398
  super("contains", e, t);
4392
4399
  }
@@ -4395,12 +4402,12 @@ var Ve = class extends v {
4395
4402
  return l(n.some((o) => o.value === i2[0].value));
4396
4403
  }
4397
4404
  };
4398
- var _e = class extends v {
4405
+ var Le = class extends v {
4399
4406
  constructor(e, t) {
4400
4407
  super("in", e, t);
4401
4408
  }
4402
4409
  eval(e, t) {
4403
- let n = D(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4410
+ let n = V(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4404
4411
  return n ? l(i2.some((o) => o.value === n.value)) : [];
4405
4412
  }
4406
4413
  };
@@ -4421,43 +4428,43 @@ var ne = class extends $ {
4421
4428
  }
4422
4429
  eval(e, t) {
4423
4430
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4424
- return Re([...n, ...i2]);
4431
+ return Ae([...n, ...i2]);
4425
4432
  }
4426
4433
  };
4427
- var Ue = class extends v {
4434
+ var Fe = class extends v {
4428
4435
  constructor(e, t) {
4429
4436
  super("=", e, t);
4430
4437
  }
4431
4438
  eval(e, t) {
4432
4439
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4433
- return at(n, i2);
4440
+ return ut(n, i2);
4434
4441
  }
4435
4442
  };
4436
- var Le = class extends v {
4443
+ var Ne = class extends v {
4437
4444
  constructor(e, t) {
4438
4445
  super("!=", e, t);
4439
4446
  }
4440
4447
  eval(e, t) {
4441
4448
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4442
- return st(at(n, i2));
4449
+ return ct(ut(n, i2));
4443
4450
  }
4444
4451
  };
4445
- var Fe = class extends v {
4452
+ var Me = class extends v {
4446
4453
  constructor(e, t) {
4447
4454
  super("~", e, t);
4448
4455
  }
4449
4456
  eval(e, t) {
4450
4457
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4451
- return ct(n, i2);
4458
+ return lt(n, i2);
4452
4459
  }
4453
4460
  };
4454
- var Ne = class extends v {
4461
+ var Be = class extends v {
4455
4462
  constructor(e, t) {
4456
4463
  super("!~", e, t);
4457
4464
  }
4458
4465
  eval(e, t) {
4459
4466
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4460
- return st(ct(n, i2));
4467
+ return ct(lt(n, i2));
4461
4468
  }
4462
4469
  };
4463
4470
  var Y = class extends v {
@@ -4469,42 +4476,42 @@ var Y = class extends v {
4469
4476
  if (n.length !== 1)
4470
4477
  return [];
4471
4478
  let i2 = this.right.name;
4472
- return l(Ee(n[0], i2));
4479
+ return l(Pe(n[0], i2));
4473
4480
  }
4474
4481
  };
4475
- var Me = class extends v {
4482
+ var qe = class extends v {
4476
4483
  constructor(e, t) {
4477
4484
  super("and", e, t);
4478
4485
  }
4479
4486
  eval(e, t) {
4480
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4487
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4481
4488
  return n?.value === true && i2?.value === true ? l(true) : n?.value === false || i2?.value === false ? l(false) : [];
4482
4489
  }
4483
4490
  };
4484
- var Be = class extends v {
4491
+ var $e = class extends v {
4485
4492
  constructor(e, t) {
4486
4493
  super("or", e, t);
4487
4494
  }
4488
4495
  eval(e, t) {
4489
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4496
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4490
4497
  return n?.value === false && i2?.value === false ? l(false) : n?.value || i2?.value ? l(true) : [];
4491
4498
  }
4492
4499
  };
4493
- var qe = class extends v {
4500
+ var je = class extends v {
4494
4501
  constructor(e, t) {
4495
4502
  super("xor", e, t);
4496
4503
  }
4497
4504
  eval(e, t) {
4498
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4505
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4499
4506
  return !n || !i2 ? [] : l(n.value !== i2.value);
4500
4507
  }
4501
4508
  };
4502
- var $e = class extends v {
4509
+ var He = class extends v {
4503
4510
  constructor(e, t) {
4504
4511
  super("implies", e, t);
4505
4512
  }
4506
4513
  eval(e, t) {
4507
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4514
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4508
4515
  return i2?.value === true || n?.value === false ? l(true) : !n || !i2 ? [] : l(false);
4509
4516
  }
4510
4517
  };
@@ -4542,21 +4549,21 @@ var X = class {
4542
4549
  return `${this.left.toString()}[${this.expr.toString()}]`;
4543
4550
  }
4544
4551
  };
4545
- var ce = ["!=", "!~", "<=", ">=", "{}", "->"];
4552
+ var le = ["!=", "!~", "<=", ">=", "{}", "->"];
4546
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 };
4547
- var Xn = { parse(r4) {
4554
+ var Zn = { parse(r4) {
4548
4555
  let e = r4.consumeAndParse();
4549
4556
  if (!r4.match(")"))
4550
4557
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4551
4558
  return e;
4552
4559
  } };
4553
- var Zn = { parse(r4, e) {
4560
+ var ei = { parse(r4, e) {
4554
4561
  let t = r4.consumeAndParse();
4555
4562
  if (!r4.match("]"))
4556
4563
  throw new Error("Parse error: expected `]`");
4557
4564
  return new X(e, t);
4558
4565
  }, precedence: f.Indexer };
4559
- var ei = { parse(r4, e) {
4566
+ var ti = { parse(r4, e) {
4560
4567
  if (!(e instanceof M))
4561
4568
  throw new Error("Unexpected parentheses");
4562
4569
  let t = [];
@@ -4564,45 +4571,45 @@ var ei = { parse(r4, e) {
4564
4571
  t.push(r4.consumeAndParse()), r4.match(",");
4565
4572
  return new B(e.name, t);
4566
4573
  }, precedence: f.FunctionCall };
4567
- function ti(r4) {
4574
+ function ri(r4) {
4568
4575
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4569
4576
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4570
4577
  }
4571
- function ue() {
4572
- return new ye().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: ti(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 ke() }).registerPrefix("(", Xn).registerInfix("[", Zn).registerInfix("(", ei).prefix("+", f.UnaryAdd, (r4, e) => new Oe("+", 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 Ue(r4, t)).infixLeft("!=", f.NotEquals, (r4, e, t) => new Le(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Fe(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new Ne(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 De(r4, t)).infixLeft("and", f.And, (r4, e, t) => new Me(r4, t)).infixLeft("as", f.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", f.Contains, (r4, e, t) => new Ve(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 _e(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 Be(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new qe(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new $e(r4, t));
4578
+ 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 De() }).registerPrefix("(", Zn).registerInfix("[", ei).registerInfix("(", ti).prefix("+", f.UnaryAdd, (r4, e) => new Ve("+", 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 Ne(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Me(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new Be(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 _e(r4, t)).infixLeft("and", f.And, (r4, e, t) => new qe(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 Le(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 $e(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new je(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new He(r4, t));
4573
4580
  }
4574
- var ri = ue();
4575
- var Cr = ((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))(Cr || {});
4576
- var ui = ((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))(ui || {});
4577
- var ki = ((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))(ki || {});
4578
- function Mr(r4) {
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) {
4579
4586
  if (typeof window < "u")
4580
4587
  return window.atob(r4);
4581
4588
  if (typeof Buffer < "u")
4582
4589
  return Buffer.from(r4, "base64").toString("binary");
4583
4590
  throw new Error("Unable to decode base64");
4584
4591
  }
4585
- function Br(r4) {
4592
+ function qr(r4) {
4586
4593
  if (typeof window < "u")
4587
4594
  return window.btoa(r4);
4588
4595
  if (typeof Buffer < "u")
4589
4596
  return Buffer.from(r4, "binary").toString("base64");
4590
4597
  throw new Error("Unable to encode base64");
4591
4598
  }
4592
- function It() {
4599
+ function Ot() {
4593
4600
  let r4 = new Uint32Array(28);
4594
- return crypto.getRandomValues(r4), Kt(r4.buffer);
4601
+ return crypto.getRandomValues(r4), Jt(r4.buffer);
4595
4602
  }
4596
- async function qr(r4) {
4603
+ async function $r(r4) {
4597
4604
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4598
4605
  }
4599
- function pe() {
4606
+ function me() {
4600
4607
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
4601
4608
  let e = Math.random() * 16 | 0;
4602
4609
  return (r4 === "x" ? e : e & 3 | 8).toString(16);
4603
4610
  });
4604
4611
  }
4605
- var Qe = class {
4612
+ var Ge = class {
4606
4613
  constructor(e = 10) {
4607
4614
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4608
4615
  }
@@ -4626,8 +4633,8 @@ var Qe = class {
4626
4633
  return this.cache.keys().next().value;
4627
4634
  }
4628
4635
  };
4629
- var F = { 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" };
4630
- var fe = class {
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" };
4637
+ var he = class {
4631
4638
  constructor() {
4632
4639
  this.listeners = {};
4633
4640
  }
@@ -4652,9 +4659,9 @@ var fe = class {
4652
4659
  return !e.defaultPrevented;
4653
4660
  }
4654
4661
  };
4655
- var We = class {
4662
+ var Ke = class {
4656
4663
  constructor() {
4657
- this.emitter = new fe();
4664
+ this.emitter = new he();
4658
4665
  }
4659
4666
  dispatchEvent(e) {
4660
4667
  this.emitter.dispatchEvent(e);
@@ -4666,35 +4673,35 @@ var We = class {
4666
4673
  this.emitter.removeEventListener(e, t);
4667
4674
  }
4668
4675
  };
4669
- var kt = { "patient-open": "patient-open", "patient-close": "patient-close", "imagingstudy-open": "imagingstudy-open", "imagingstudy-close": "imagingstudy-close" };
4670
- var Mi = ["Patient", "Encounter", "ImagingStudy"];
4671
- var Bi = { "patient-open": ["Patient"], "patient-close": ["Patient"], "imagingstudy-open": ["Patient", "ImagingStudy"], "imagingstudy-close": ["Patient", "ImagingStudy"] };
4672
- var qi = { "patient-open": ["Encounter"], "patient-close": ["Encounter"], "imagingstudy-open": [], "imagingstudy-close": [] };
4673
- function $i(r4) {
4674
- return Mi.includes(r4);
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);
4675
4682
  }
4676
- var ji = { ImagingStudy: "study", Patient: "patient", Encounter: "encounter" };
4677
- function jr(r4) {
4683
+ var Hi = { ImagingStudy: "study", Patient: "patient", Encounter: "encounter" };
4684
+ function Hr(r4) {
4678
4685
  return !!r4.endpoint;
4679
4686
  }
4680
- function Ot(r4) {
4681
- if (!Ke(r4))
4687
+ function Vt(r4) {
4688
+ if (!Je(r4))
4682
4689
  throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4683
4690
  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(",") };
4684
- return jr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4691
+ return Hr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4685
4692
  }
4686
- function Ke(r4) {
4693
+ function Je(r4) {
4687
4694
  if (typeof r4 != "object")
4688
4695
  return false;
4689
4696
  let { channelType: e, mode: t, topic: n, events: i2 } = r4;
4690
4697
  if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
4691
4698
  return false;
4692
4699
  for (let o of i2)
4693
- if (!kt[o])
4700
+ if (!Dt[o])
4694
4701
  return false;
4695
- return !(jr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4702
+ return !(Hr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4696
4703
  }
4697
- function Hi(r4, e, t, n) {
4704
+ function Qi(r4, e, t, n) {
4698
4705
  if (!(e.key && typeof e.key == "string"))
4699
4706
  throw new d(h(`context[${t}] is invalid. Context must contain a key.`));
4700
4707
  if (n.has(e.key))
@@ -4706,36 +4713,36 @@ function Hi(r4, e, t, n) {
4706
4713
  if (!e.resource.resourceType)
4707
4714
  throw new d(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4708
4715
  let i2 = e.resource.resourceType;
4709
- if (!$i(i2))
4716
+ if (!ji(i2))
4710
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.`));
4711
- let o = Bi[r4], s = qi[r4], a;
4718
+ let o = qi[r4], s = $i[r4], a;
4712
4719
  if (t < o.length ? a = o[t] : t - o.length < s.length && (a = s[t - o.length]), a && i2 !== a)
4713
4720
  throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${a}.`));
4714
- let c2 = ji[i2];
4721
+ let c2 = Hi[i2];
4715
4722
  if (c2 !== e.key)
4716
4723
  throw new d(h(`context[${t}] is invalid. Context key for type ${i2} must be ${c2}.`));
4717
4724
  }
4718
- function Qi(r4, e) {
4725
+ function Wi(r4, e) {
4719
4726
  let t = /* @__PURE__ */ new Set();
4720
4727
  for (let n = 0; n < e.length; n++)
4721
- Hi(r4, e[n], n, t);
4728
+ Qi(r4, e[n], n, t);
4722
4729
  }
4723
- function Hr(r4, e, t) {
4730
+ function Qr(r4, e, t) {
4724
4731
  if (!(r4 && typeof r4 == "string"))
4725
4732
  throw new d(h("Must provide a topic."));
4726
- if (!kt[e])
4727
- throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(kt).join(", ")}`));
4733
+ if (!Dt[e])
4734
+ throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Dt).join(", ")}`));
4728
4735
  if (typeof t != "object")
4729
4736
  throw new d(h("context must be a context object or array of context objects."));
4730
4737
  let n = Array.isArray(t) ? t : [t];
4731
- return Qi(e, n), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: pe(), event: { "hub.topic": r4, "hub.event": e, context: n } };
4738
+ return Wi(e, n), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: me(), event: { "hub.topic": r4, "hub.event": e, context: n } };
4732
4739
  }
4733
- var Ge = class extends We {
4740
+ var ze = class extends Ke {
4734
4741
  constructor(t) {
4735
4742
  super();
4736
4743
  if (this.subRequest = t, !t.endpoint)
4737
4744
  throw new d(h("Subscription request should contain an endpoint."));
4738
- if (!Ke(t))
4745
+ if (!Je(t))
4739
4746
  throw new d(h("Subscription request failed validation."));
4740
4747
  let n = new WebSocket(t.endpoint);
4741
4748
  n.addEventListener("open", () => {
@@ -4754,31 +4761,31 @@ var Ge = class extends We {
4754
4761
  this.websocket.close();
4755
4762
  }
4756
4763
  };
4757
- function Wi(r4) {
4758
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Mr(e), n = Array.from(t).reduce((o, s) => {
4764
+ function Gi(r4) {
4765
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Br(e), n = Array.from(t).reduce((o, s) => {
4759
4766
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4760
4767
  return `${o}%${a}`;
4761
4768
  }, ""), i2 = decodeURIComponent(n);
4762
4769
  return JSON.parse(i2);
4763
4770
  }
4764
- function Qr(r4) {
4771
+ function Wr(r4) {
4765
4772
  return r4.split(".").length === 3;
4766
4773
  }
4767
- function Dt(r4) {
4774
+ function _t(r4) {
4768
4775
  let [e, t, n] = r4.split(".");
4769
- return Wi(t);
4776
+ return Gi(t);
4770
4777
  }
4771
- function Wr(r4) {
4778
+ function Gr(r4) {
4772
4779
  try {
4773
- return typeof Dt(r4).login_id == "string";
4780
+ return typeof _t(r4).login_id == "string";
4774
4781
  } catch {
4775
4782
  return false;
4776
4783
  }
4777
4784
  }
4778
- var Gi;
4785
+ var Ki;
4779
4786
  var C = class {
4780
4787
  constructor(e) {
4781
- this[Gi] = "ReadablePromise";
4788
+ this[Ki] = "ReadablePromise";
4782
4789
  this.status = "pending";
4783
4790
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4784
4791
  throw this.status = "error", this.error = t, t;
@@ -4810,10 +4817,10 @@ var C = class {
4810
4817
  return this.suspender.finally(e);
4811
4818
  }
4812
4819
  };
4813
- Gi = Symbol.toStringTag;
4814
- var ze = class {
4820
+ Ki = Symbol.toStringTag;
4821
+ var Ye = class {
4815
4822
  constructor() {
4816
- this.storage = typeof localStorage < "u" ? localStorage : new Vt();
4823
+ this.storage = typeof localStorage < "u" ? localStorage : new Ut();
4817
4824
  }
4818
4825
  clear() {
4819
4826
  this.storage.clear();
@@ -4829,10 +4836,10 @@ var ze = class {
4829
4836
  return t ? JSON.parse(t) : void 0;
4830
4837
  }
4831
4838
  setObject(e, t) {
4832
- this.setString(e, t ? Qt(t) : void 0);
4839
+ this.setString(e, t ? Gt(t) : void 0);
4833
4840
  }
4834
4841
  };
4835
- var Vt = class {
4842
+ var Ut = class {
4836
4843
  constructor() {
4837
4844
  this.data = /* @__PURE__ */ new Map();
4838
4845
  }
@@ -4855,21 +4862,21 @@ var Vt = class {
4855
4862
  return Array.from(this.data.keys())[e];
4856
4863
  }
4857
4864
  };
4858
- var Ki = F.FHIR_JSON + ", */*; q=0.1";
4859
- var zi = "https://api.medplum.com/";
4860
- var Ji = 1e3;
4861
- var Yi = 6e4;
4862
- var Gr = "Binary/";
4863
- var Kr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4864
- var Xi = ((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))(Xi || {});
4865
- var Zi = ((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))(Zi || {});
4866
- var eo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(eo || {});
4867
- var zr = class extends fe {
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 {
4868
4875
  constructor(t) {
4869
4876
  super();
4870
4877
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4871
4878
  throw new Error("Base URL must start with http or https");
4872
- if (this.options = t ?? {}, this.fetch = t?.fetch ?? to(), this.storage = t?.storage ?? new ze(), this.createPdfImpl = t?.createPdf, this.baseUrl = Yr(t?.baseUrl ?? zi), this.fhirBaseUrl = Yr(Je(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Je(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Je(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Je(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Yi, this.cacheTime > 0 ? this.requestCache = new Qe(t?.resourceCacheSize ?? Ji) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4879
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? ro(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = Xr(t?.baseUrl ?? Ji), this.fhirBaseUrl = Xr(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 ?? Xi, this.cacheTime > 0 ? this.requestCache = new Ge(t?.resourceCacheSize ?? Yi) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4873
4880
  this.setAccessToken(t.accessToken);
4874
4881
  else {
4875
4882
  let n = this.getActiveLogin();
@@ -4926,7 +4933,7 @@ var zr = class extends fe {
4926
4933
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4927
4934
  }
4928
4935
  patch(t, n, i2 = {}) {
4929
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, F.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4936
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, O.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4930
4937
  }
4931
4938
  delete(t, n) {
4932
4939
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -5014,7 +5021,7 @@ var zr = class extends fe {
5014
5021
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
5015
5022
  if (a)
5016
5023
  return a.value;
5017
- let c2 = new C(this.search(t, n, i2).then(Zr));
5024
+ let c2 = new C(this.search(t, n, i2).then(en));
5018
5025
  return this.setCacheEntry(s, c2), c2;
5019
5026
  }
5020
5027
  async *searchResourcePages(t, n, i2) {
@@ -5023,7 +5030,7 @@ var zr = class extends fe {
5023
5030
  let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((m2) => m2.relation === "next");
5024
5031
  if (!a.entry?.length && !c2)
5025
5032
  break;
5026
- yield Zr(a), o = c2?.url ? new URL(c2.url) : void 0;
5033
+ yield en(a), o = c2?.url ? new URL(c2.url) : void 0;
5027
5034
  }
5028
5035
  }
5029
5036
  searchValueSet(t, n, i2) {
@@ -5039,7 +5046,7 @@ var zr = class extends fe {
5039
5046
  if (!n)
5040
5047
  return;
5041
5048
  if (n === "system")
5042
- return Kr;
5049
+ return zr;
5043
5050
  let [i2, o] = n.split("/");
5044
5051
  if (!(!i2 || !o))
5045
5052
  return this.getCached(i2, o);
@@ -5052,12 +5059,12 @@ var zr = class extends fe {
5052
5059
  if (!i2)
5053
5060
  return new C(Promise.reject(new Error("Missing reference")));
5054
5061
  if (i2 === "system")
5055
- return new C(Promise.resolve(Kr));
5062
+ return new C(Promise.resolve(zr));
5056
5063
  let [o, s] = i2.split("/");
5057
5064
  return !o || !s ? new C(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
5058
5065
  }
5059
5066
  requestSchema(t) {
5060
- if (vr(t))
5067
+ if (Rr(t))
5061
5068
  return Promise.resolve();
5062
5069
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
5063
5070
  if (i2)
@@ -5101,9 +5108,9 @@ var zr = class extends fe {
5101
5108
  target
5102
5109
  }
5103
5110
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
5104
- xr(a.data.StructureDefinitionList);
5111
+ vr(a.data.StructureDefinitionList);
5105
5112
  for (let c2 of a.data.SearchParameterList)
5106
- bt(c2);
5113
+ Et(c2);
5107
5114
  })());
5108
5115
  return this.setCacheEntry(n, o), o;
5109
5116
  }
@@ -5183,28 +5190,28 @@ var zr = class extends fe {
5183
5190
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
5184
5191
  }
5185
5192
  sendEmail(t, n) {
5186
- return this.post("email/v1/send", t, F.JSON, n);
5193
+ return this.post("email/v1/send", t, O.JSON, n);
5187
5194
  }
5188
5195
  graphql(t, n, i2, o) {
5189
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, F.JSON, o);
5196
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, O.JSON, o);
5190
5197
  }
5191
5198
  readResourceGraph(t, n, i2, o) {
5192
5199
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
5193
5200
  }
5194
- pushToAgent(t, n, i2, o) {
5195
- return this.post(this.fhirUrl("Agent", t.id, "$push"), n, i2, o);
5201
+ 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);
5196
5203
  }
5197
5204
  getActiveLogin() {
5198
5205
  return this.storage.getObject("activeLogin");
5199
5206
  }
5200
5207
  async setActiveLogin(t) {
5201
- this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
5208
+ (!this.sessionDetails?.profile || se(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
5202
5209
  }
5203
5210
  getAccessToken() {
5204
5211
  return this.accessToken;
5205
5212
  }
5206
5213
  setAccessToken(t, n) {
5207
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Wr(t);
5214
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Gr(t);
5208
5215
  }
5209
5216
  getLogins() {
5210
5217
  return this.storage.getObject("logins") ?? [];
@@ -5216,7 +5223,9 @@ var zr = class extends fe {
5216
5223
  async refreshProfile() {
5217
5224
  return this.medplumServer ? (this.profilePromise = new Promise((t, n) => {
5218
5225
  this.get("auth/me").then((i2) => {
5219
- this.profilePromise = void 0, this.sessionDetails = i2, this.dispatchEvent({ type: "change" }), t(i2.profile);
5226
+ this.profilePromise = void 0;
5227
+ let o = this.sessionDetails?.profile?.id !== i2.profile.id;
5228
+ this.sessionDetails = i2, o && this.dispatchEvent({ type: "change" }), t(i2.profile);
5220
5229
  }).catch(n);
5221
5230
  }), this.profilePromise) : Promise.resolve(void 0);
5222
5231
  }
@@ -5250,11 +5259,11 @@ var zr = class extends fe {
5250
5259
  async download(t, n = {}) {
5251
5260
  this.refreshPromise && await this.refreshPromise;
5252
5261
  let i2 = t.toString();
5253
- return i2.startsWith(Gr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5262
+ return i2.startsWith(Kr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5254
5263
  }
5255
5264
  async uploadMedia(t, n, i2, o, s) {
5256
5265
  let a = await this.createBinary(t, i2, n);
5257
- return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Gr + a.id, title: i2 }, ...o }, s);
5266
+ return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Kr + a.id, title: i2 }, ...o }, s);
5258
5267
  }
5259
5268
  async bulkExport(t = "", n, i2, o) {
5260
5269
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5266,7 +5275,7 @@ var zr = class extends fe {
5266
5275
  i2.Prefer = "respond-async";
5267
5276
  let o = await this.fetchWithRetry(t, n);
5268
5277
  if (o.status === 202) {
5269
- let s = await Xr(o);
5278
+ let s = await Zr(o);
5270
5279
  if (s)
5271
5280
  return this.pollStatus(s);
5272
5281
  }
@@ -5300,7 +5309,7 @@ var zr = class extends fe {
5300
5309
  return;
5301
5310
  let a = t.headers.get("content-type")?.includes("json");
5302
5311
  if (t.status === 404 && !a)
5303
- throw new d(lr);
5312
+ throw new d(pr);
5304
5313
  let c2 = t.headers.get("content-location"), m2 = o.redirect ?? this.options.redirect;
5305
5314
  if (t.status === 201 && c2 && m2 === "follow")
5306
5315
  return this.request("GET", c2, { ...o, body: void 0 });
@@ -5314,7 +5323,7 @@ var zr = class extends fe {
5314
5323
  else
5315
5324
  p2 = await t.text();
5316
5325
  if (t.status >= 400)
5317
- throw new d(ht(p2));
5326
+ throw new d(gt(p2));
5318
5327
  return p2;
5319
5328
  }
5320
5329
  async fetchWithRetry(t, n) {
@@ -5327,7 +5336,7 @@ var zr = class extends fe {
5327
5336
  } catch (c2) {
5328
5337
  this.retryCatch(a, i2, c2);
5329
5338
  }
5330
- await nt(o);
5339
+ await ot(o);
5331
5340
  }
5332
5341
  return s;
5333
5342
  }
@@ -5348,10 +5357,10 @@ var zr = class extends fe {
5348
5357
  this.addFetchOptionsDefaults(s);
5349
5358
  let a = await this.fetchWithRetry(t, s);
5350
5359
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5351
- let c2 = await Xr(a);
5360
+ let c2 = await Zr(a);
5352
5361
  c2 && (i2 = await this.fetchWithRetry(c2, s));
5353
5362
  }
5354
- await nt(o);
5363
+ await ot(o);
5355
5364
  }
5356
5365
  return this.parseResponse(i2, "POST", t);
5357
5366
  }
@@ -5362,19 +5371,19 @@ var zr = class extends fe {
5362
5371
  try {
5363
5372
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
5364
5373
  } catch (s) {
5365
- o.reject(new d(ht(s)));
5374
+ o.reject(new d(gt(s)));
5366
5375
  }
5367
5376
  return;
5368
5377
  }
5369
5378
  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);
5370
5379
  for (let o = 0; o < t.length; o++) {
5371
5380
  let s = t[o], a = i2.entry?.[o];
5372
- a?.response?.outcome && !mt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5381
+ a?.response?.outcome && !yt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5373
5382
  }
5374
5383
  }
5375
5384
  addFetchOptionsDefaults(t) {
5376
5385
  let n = t.headers;
5377
- n || (n = {}, t.headers = n), n.Accept || (n.Accept = Ki), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = F.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");
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");
5378
5387
  }
5379
5388
  setRequestContentType(t, n) {
5380
5389
  t.headers || (t.headers = {});
@@ -5388,20 +5397,20 @@ var zr = class extends fe {
5388
5397
  return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
5389
5398
  }
5390
5399
  async startPkce() {
5391
- let t = It();
5400
+ let t = Ot();
5392
5401
  sessionStorage.setItem("pkceState", t);
5393
- let n = It();
5402
+ let n = Ot();
5394
5403
  sessionStorage.setItem("codeVerifier", n);
5395
- let i2 = await qr(n), o = zt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5404
+ let i2 = await $r(n), o = Yt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5396
5405
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5397
5406
  }
5398
5407
  async requestAuthorization(t) {
5399
5408
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
5400
- 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 ?? Jr()), 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());
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());
5401
5410
  }
5402
5411
  processCode(t, n) {
5403
5412
  let i2 = new URLSearchParams();
5404
- 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 ?? Jr()), typeof sessionStorage < "u") {
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") {
5405
5414
  let o = sessionStorage.getItem("codeVerifier");
5406
5415
  o && i2.set("code_verifier", o);
5407
5416
  }
@@ -5432,45 +5441,45 @@ var zr = class extends fe {
5432
5441
  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);
5433
5442
  }
5434
5443
  setBasicAuth(t, n) {
5435
- this.clientId = t, this.clientSecret = n, this.basicAuth = Br(t + ":" + n);
5444
+ this.clientId = t, this.clientSecret = n, this.basicAuth = qr(t + ":" + n);
5436
5445
  }
5437
5446
  async fhircastSubscribe(t, n) {
5438
5447
  if (!(typeof t == "string" && t !== ""))
5439
5448
  throw new d(h("Invalid topic provided. Topic must be a valid string."));
5440
5449
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
5441
5450
  throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5442
- let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU2", Ot(i2), F.FORM_URL_ENCODED))["hub.channel.endpoint"];
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"];
5443
5452
  if (!s)
5444
5453
  throw new Error("Invalid response!");
5445
5454
  return i2.endpoint = s, i2;
5446
5455
  }
5447
5456
  async fhircastUnsubscribe(t) {
5448
- if (!Ke(t))
5457
+ if (!Je(t))
5449
5458
  throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5450
5459
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
5451
5460
  throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5452
- t.mode = "unsubscribe", await this.post("/fhircast/STU2", Ot(t), F.FORM_URL_ENCODED);
5461
+ t.mode = "unsubscribe", await this.post("/fhircast/STU2", Vt(t), O.FORM_URL_ENCODED);
5453
5462
  }
5454
5463
  fhircastConnect(t) {
5455
- return new Ge(t);
5464
+ return new ze(t);
5456
5465
  }
5457
5466
  async fhircastPublish(t, n, i2) {
5458
- return this.post(`/fhircast/STU2/${t}`, Hr(t, n, i2), F.JSON);
5467
+ return this.post(`/fhircast/STU2/${t}`, Qr(t, n, i2), O.JSON);
5459
5468
  }
5460
5469
  async invite(t, n) {
5461
5470
  return this.post("admin/projects/" + t + "/invite", n);
5462
5471
  }
5463
5472
  async fetchTokens(t) {
5464
- let n = { method: "POST", headers: { "Content-Type": F.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5473
+ let n = { method: "POST", headers: { "Content-Type": O.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5465
5474
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5466
5475
  let o = await this.fetchWithRetry(this.tokenUrl, n);
5467
5476
  if (!o.ok) {
5468
5477
  this.clearActiveLogin();
5469
5478
  try {
5470
5479
  let a = await o.json();
5471
- throw new d(_(a.error_description));
5480
+ throw new d(U(a.error_description));
5472
5481
  } catch (a) {
5473
- throw new d(_("Failed to fetch tokens"), a);
5482
+ throw new d(U("Failed to fetch tokens"), a);
5474
5483
  }
5475
5484
  }
5476
5485
  let s = await o.json();
@@ -5478,8 +5487,8 @@ var zr = class extends fe {
5478
5487
  }
5479
5488
  async verifyTokens(t) {
5480
5489
  let n = t.access_token;
5481
- if (Qr(n)) {
5482
- let i2 = Dt(n);
5490
+ if (Wr(n)) {
5491
+ let i2 = _t(n);
5483
5492
  if (Date.now() >= i2.exp * 1e3)
5484
5493
  throw this.clearActiveLogin(), new Error("Token expired");
5485
5494
  if (i2.cid) {
@@ -5503,21 +5512,21 @@ var zr = class extends fe {
5503
5512
  throw i2;
5504
5513
  }
5505
5514
  };
5506
- function to() {
5515
+ function ro() {
5507
5516
  if (!globalThis.fetch)
5508
5517
  throw new Error("Fetch not available in this environment");
5509
5518
  return globalThis.fetch.bind(globalThis);
5510
5519
  }
5511
- function Jr() {
5520
+ function Yr() {
5512
5521
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5513
5522
  }
5514
- function Yr(r4) {
5523
+ function Xr(r4) {
5515
5524
  return r4.endsWith("/") ? r4 : r4 + "/";
5516
5525
  }
5517
- function Je(r4, e) {
5526
+ function Xe(r4, e) {
5518
5527
  return new URL(e, r4).toString();
5519
5528
  }
5520
- async function Xr(r4) {
5529
+ async function Zr(r4) {
5521
5530
  let e = r4.headers.get("content-location");
5522
5531
  if (e)
5523
5532
  return e;
@@ -5525,17 +5534,17 @@ async function Xr(r4) {
5525
5534
  if (t)
5526
5535
  return t;
5527
5536
  let n = await r4.json();
5528
- if (we(n) && n.issue?.[0]?.diagnostics)
5537
+ if (ke(n) && n.issue?.[0]?.diagnostics)
5529
5538
  return n.issue[0].diagnostics;
5530
5539
  }
5531
- function Zr(r4) {
5540
+ function en(r4) {
5532
5541
  let e = r4.entry?.map((t) => t.resource) ?? [];
5533
5542
  return Object.assign(e, { bundle: r4 });
5534
5543
  }
5535
- var ro = [...ce, "->", "<<", ">>"];
5536
- var no = ue().registerInfix("->", { precedence: f.Arrow }).registerInfix(";", { precedence: f.Semicolon });
5537
- var io = [...ce, "eq", "ne", "co"];
5538
- var ao = ue();
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();
5539
5548
  var G = class {
5540
5549
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5541
5550
  this.segmentSeparator = e;
@@ -5552,7 +5561,7 @@ var G = class {
5552
5561
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5553
5562
  }
5554
5563
  };
5555
- var nn = class r {
5564
+ var on = class r {
5556
5565
  constructor(e, t = new G()) {
5557
5566
  this.context = t, this.segments = e;
5558
5567
  }
@@ -5576,7 +5585,7 @@ var nn = class r {
5576
5585
  }
5577
5586
  buildAck() {
5578
5587
  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";
5579
- return new r([new me(["MSH", this.context.getMsh2(), o, s, n, i2, uo(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new me(["MSA", "AA", a, "OK"], this.context)]);
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)]);
5580
5589
  }
5581
5590
  buildAckMessageType(e) {
5582
5591
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5588,12 +5597,12 @@ var nn = class r {
5588
5597
  throw n.type = "entity.parse.failed", n;
5589
5598
  }
5590
5599
  let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5591
- return new r(e.split(/[\r\n]+/).map((n) => me.parse(n, t)), t);
5600
+ return new r(e.split(/[\r\n]+/).map((n) => ye.parse(n, t)), t);
5592
5601
  }
5593
5602
  };
5594
- var me = class r2 {
5603
+ var ye = class r2 {
5595
5604
  constructor(e, t = new G()) {
5596
- this.context = t, Wt(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
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];
5597
5606
  }
5598
5607
  get(e) {
5599
5608
  return this.fields[e];
@@ -5637,7 +5646,7 @@ var oe = class r3 {
5637
5646
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5638
5647
  }
5639
5648
  };
5640
- function uo(r4) {
5649
+ function lo(r4) {
5641
5650
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5642
5651
  return i2 > 0 && (n += "." + i2.toString()), n;
5643
5652
  }
@@ -5678,7 +5687,7 @@ var c = class extends i {
5678
5687
  e.on("data", (s) => {
5679
5688
  try {
5680
5689
  if (o += s.toString(), o.endsWith(p + v2)) {
5681
- let r4 = nn.parse(o.substring(1, o.length - 2));
5690
+ let r4 = on.parse(o.substring(1, o.length - 2));
5682
5691
  this.dispatchEvent(new d2(this, r4)), o = "";
5683
5692
  }
5684
5693
  } catch (r4) {
@@ -5799,7 +5808,7 @@ var App = class {
5799
5808
  break;
5800
5809
  }
5801
5810
  } catch (err) {
5802
- this.log.error(`WebSocket error: ${qn(err)}`);
5811
+ this.log.error(`WebSocket error: ${$n(err)}`);
5803
5812
  }
5804
5813
  });
5805
5814
  }
@@ -5851,7 +5860,7 @@ var App = class {
5851
5860
  if (channel) {
5852
5861
  const connection = channel.connections.get(msg.remote);
5853
5862
  if (connection) {
5854
- connection.hl7Connection.send(nn.parse(msg.body));
5863
+ connection.hl7Connection.send(on.parse(msg.body));
5855
5864
  }
5856
5865
  }
5857
5866
  }
@@ -5863,10 +5872,10 @@ var App = class {
5863
5872
  host: address.hostname,
5864
5873
  port: parseInt(address.port, 10)
5865
5874
  });
5866
- client.sendAndWait(nn.parse(message.body)).then((response) => {
5875
+ client.sendAndWait(on.parse(message.body)).then((response) => {
5867
5876
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
5868
5877
  }).catch((err) => {
5869
- this.log.error(`HL7 error: ${qn(err)}`);
5878
+ this.log.error(`HL7 error: ${$n(err)}`);
5870
5879
  }).finally(() => {
5871
5880
  client.close();
5872
5881
  });
@@ -5915,7 +5924,7 @@ var AgentHl7ChannelConnection = class {
5915
5924
  body: event.message.toString()
5916
5925
  });
5917
5926
  } catch (err) {
5918
- this.channel.app.log.error(`HL7 error: ${qn(err)}`);
5927
+ this.channel.app.log.error(`HL7 error: ${$n(err)}`);
5919
5928
  }
5920
5929
  }
5921
5930
  close() {
@@ -5928,7 +5937,7 @@ if (typeof require !== "undefined" && require.main === module) {
5928
5937
  process.exit(1);
5929
5938
  }
5930
5939
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
5931
- const medplum = new zr({ baseUrl, clientId });
5940
+ const medplum = new Jr({ baseUrl, clientId });
5932
5941
  medplum.startClientLogin(clientId, clientSecret).then(() => new App(medplum, agentId).start()).catch(console.error);
5933
5942
  }
5934
5943
  // Annotate the CommonJS export names for ESM import in node: