@medplum/agent 3.2.10 → 3.2.11

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 +142 -137
  2. package/package.json +5 -5
@@ -42642,12 +42642,12 @@ var Qt = "ok";
42642
42642
  var ze = "created";
42643
42643
  var zt = "not-modified";
42644
42644
  var Jt = "not-found";
42645
- var Yt = "unauthorized";
42645
+ var Zt = "unauthorized";
42646
42646
  var Je = "accepted";
42647
42647
  var en = { resourceType: "OperationOutcome", id: Jt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
42648
- var Se = { resourceType: "OperationOutcome", id: Yt, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
42649
- var tn = { ...Se, issue: [...Se.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
42650
- var Zt = { ...Se, issue: [...Se.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
42648
+ var Ee = { resourceType: "OperationOutcome", id: Zt, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
42649
+ var tn = { ...Ee, issue: [...Ee.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
42650
+ var Xt = { ...Ee, issue: [...Ee.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
42651
42651
  function R(r7, e) {
42652
42652
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r7 }, ...e ? { expression: [e] } : void 0 }] };
42653
42653
  }
@@ -42657,10 +42657,10 @@ function h(r7) {
42657
42657
  function rn(r7) {
42658
42658
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "exception", details: { text: "Internal server error" }, diagnostics: r7.toString() }] };
42659
42659
  }
42660
- function Ee(r7) {
42660
+ function be(r7) {
42661
42661
  return typeof r7 == "object" && r7 !== null && r7.resourceType === "OperationOutcome";
42662
42662
  }
42663
- function Xt(r7) {
42663
+ function er(r7) {
42664
42664
  return r7.id === Qt || r7.id === ze || r7.id === zt || r7.id === Je;
42665
42665
  }
42666
42666
  var d = class extends Error {
@@ -42669,10 +42669,10 @@ var d = class extends Error {
42669
42669
  }
42670
42670
  };
42671
42671
  function Ye(r7) {
42672
- return r7 instanceof d ? r7.outcome : Ee(r7) ? r7 : R(er(r7));
42672
+ return r7 instanceof d ? r7.outcome : be(r7) ? r7 : R(tr(r7));
42673
42673
  }
42674
- function er(r7) {
42675
- return r7 ? typeof r7 == "string" ? r7 : r7 instanceof Error ? r7.message : Ee(r7) ? nn(r7) : typeof r7 == "object" && "code" in r7 && typeof r7.code == "string" ? r7.code : JSON.stringify(r7) : "Unknown error";
42674
+ function tr(r7) {
42675
+ return r7 ? typeof r7 == "string" ? r7 : r7 instanceof Error ? r7.message : be(r7) ? nn(r7) : typeof r7 == "object" && "code" in r7 && typeof r7.code == "string" ? r7.code : JSON.stringify(r7) : "Unknown error";
42676
42676
  }
42677
42677
  function nn(r7) {
42678
42678
  let e = r7.issue?.map(ji) ?? [];
@@ -42692,28 +42692,28 @@ function an(r7) {
42692
42692
  return e;
42693
42693
  }
42694
42694
  var cn = { 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, 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: "uri" }] }, "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" }] }, onBehalfOf: { 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, 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" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
42695
- function ir(r7) {
42696
- return new rr(r7).parse();
42695
+ function or(r7) {
42696
+ return new nr(r7).parse();
42697
42697
  }
42698
42698
  var ce = an(cn);
42699
- var or = /* @__PURE__ */ Object.create(null);
42699
+ var sr = /* @__PURE__ */ Object.create(null);
42700
42700
  var un = /* @__PURE__ */ Object.create(null);
42701
42701
  var Hi = { "http://hl7.org/fhir/StructureDefinition/MoneyQuantity": "MoneyQuantity", "http://hl7.org/fhir/StructureDefinition/SimpleQuantity": "SimpleQuantity", "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition": "ViewDefinition" };
42702
42702
  function fn(r7) {
42703
42703
  let e;
42704
42704
  return e = un[r7], e || (e = un[r7] = /* @__PURE__ */ Object.create(null)), e;
42705
42705
  }
42706
- function sr(r7) {
42706
+ function ar(r7) {
42707
42707
  let e = Array.isArray(r7) ? r7 : r7.entry?.map((t) => t.resource) ?? [];
42708
- for (let t of e) ar(t);
42708
+ for (let t of e) cr(t);
42709
42709
  }
42710
- function ar(r7) {
42710
+ function cr(r7) {
42711
42711
  if (!r7?.name) throw new Error("Failed loading StructureDefinition from bundle");
42712
42712
  if (r7.resourceType !== "StructureDefinition") return;
42713
- let e = ir(r7), t = Hi[r7.url], n, i;
42713
+ let e = or(r7), t = Hi[r7.url], n, i;
42714
42714
  t ? (n = ce, i = t) : r7.url === `http://hl7.org/fhir/StructureDefinition/${r7.type}` || r7.url === `https://medplum.com/fhir/StructureDefinition/${r7.type}` || r7.type?.startsWith("http://") || r7.type?.startsWith("https://") ? (n = ce, i = r7.type) : (n = fn(r7.url), i = r7.type), n[i] = e;
42715
42715
  for (let o of e.innerTypes) o.parentType = e, n[o.name] = o;
42716
- or[r7.url] = e;
42716
+ sr[r7.url] = e;
42717
42717
  }
42718
42718
  function hn(r7) {
42719
42719
  return !!ce[r7];
@@ -42726,9 +42726,9 @@ function _e(r7, e) {
42726
42726
  return ce[r7];
42727
42727
  }
42728
42728
  function gn(r7) {
42729
- return !!or[r7];
42729
+ return !!sr[r7];
42730
42730
  }
42731
- var rr = class {
42731
+ var nr = class {
42732
42732
  constructor(e) {
42733
42733
  if (!e.snapshot?.element || e.snapshot.element.length === 0) throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
42734
42734
  this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, path: this.root.path, title: e.title, type: e.type, url: e.url, kind: e.kind, description: Ji(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
@@ -42739,7 +42739,7 @@ var rr = class {
42739
42739
  if (e.sliceName) this.parseSliceStart(e);
42740
42740
  else if (e.id?.includes(":")) {
42741
42741
  if (this.slicingContext?.current) {
42742
- let t = tr(e, this.slicingContext.path);
42742
+ let t = rr(e, this.slicingContext.path);
42743
42743
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
42744
42744
  }
42745
42745
  } else {
@@ -42748,13 +42748,13 @@ var rr = class {
42748
42748
  let n = this.backboneContext;
42749
42749
  for (; n; ) {
42750
42750
  if (e.path?.startsWith(n.path + ".")) {
42751
- n.type.elements[tr(e, n.path)] = t;
42751
+ n.type.elements[rr(e, n.path)] = t;
42752
42752
  break;
42753
42753
  }
42754
42754
  n = n.parent;
42755
42755
  }
42756
42756
  if (!n) {
42757
- let i = tr(e, this.root.path);
42757
+ let i = rr(e, this.root.path);
42758
42758
  e.isSummary && this.resourceSchema.summaryProperties?.add(i.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i.replace("[x]", "")), this.resourceSchema.elements[i] = t;
42759
42759
  }
42760
42760
  this.checkFieldExit(e);
@@ -42764,12 +42764,12 @@ var rr = class {
42764
42764
  return this.checkFieldExit(), this.innerTypes.length > 0 && (this.resourceSchema.innerTypes = this.innerTypes), this.resourceSchema;
42765
42765
  }
42766
42766
  checkFieldEnter(e, t) {
42767
- this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !be(this.slicingContext.path, e?.path) && (this.slicingContext = void 0), e.slicing && !this.slicingContext && this.enterSlice(e, t);
42767
+ this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !Re(this.slicingContext.path, e?.path) && (this.slicingContext = void 0), e.slicing && !this.slicingContext && this.enterSlice(e, t);
42768
42768
  }
42769
42769
  enterInnerType(e) {
42770
- for (; this.backboneContext && !be(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42771
- let t = nr(e);
42772
- this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent: be(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
42770
+ for (; this.backboneContext && !Re(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42771
+ let t = ir(e);
42772
+ this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent: Re(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
42773
42773
  }
42774
42774
  enterSlice(e, t) {
42775
42775
  zi(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
@@ -42778,9 +42778,9 @@ var rr = class {
42778
42778
  }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
42779
42779
  }
42780
42780
  checkFieldExit(e = void 0) {
42781
- if (this.backboneContext && !be(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
42781
+ if (this.backboneContext && !Re(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
42782
42782
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42783
- while (this.backboneContext && !be(this.backboneContext.path, e?.path));
42783
+ while (this.backboneContext && !Re(this.backboneContext.path, e?.path));
42784
42784
  else this.innerTypes.push(this.backboneContext.type), this.backboneContext = void 0;
42785
42785
  }
42786
42786
  next() {
@@ -42799,7 +42799,7 @@ var rr = class {
42799
42799
  }
42800
42800
  isInnerType(e) {
42801
42801
  let t = this.peek();
42802
- return !!(be(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
42802
+ return !!(Re(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
42803
42803
  }
42804
42804
  parseSliceStart(e) {
42805
42805
  if (!this.slicingContext) throw new Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);
@@ -42808,7 +42808,7 @@ var rr = class {
42808
42808
  parseElementDefinitionType(e) {
42809
42809
  return (e.type ?? []).map((t) => {
42810
42810
  let n;
42811
- return (t.code === "BackboneElement" || t.code === "Element") && (n = nr(e)), n || (n = X(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
42811
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = ir(e)), n || (n = X(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
42812
42812
  });
42813
42813
  }
42814
42814
  parseElementDefinition(e) {
@@ -42819,13 +42819,13 @@ var rr = class {
42819
42819
  function pn(r7) {
42820
42820
  return r7 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r7, 10);
42821
42821
  }
42822
- function tr(r7, e = "") {
42822
+ function rr(r7, e = "") {
42823
42823
  return Ki(r7.path, e);
42824
42824
  }
42825
42825
  function Ki(r7, e) {
42826
42826
  return r7 ? e && r7.startsWith(e) ? r7.substring(e.length + 1) : r7 : "";
42827
42827
  }
42828
- function be(r7, e) {
42828
+ function Re(r7, e) {
42829
42829
  return !r7 || !e ? false : e.startsWith(r7 + ".") || e === r7;
42830
42830
  }
42831
42831
  function dn(r7) {
@@ -42898,7 +42898,7 @@ function nt(r7) {
42898
42898
  let e = [];
42899
42899
  for (let t of r7) {
42900
42900
  let n = false;
42901
- for (let i of e) if (N(mr(t, i))) {
42901
+ for (let i of e) if (N(hr(t, i))) {
42902
42902
  n = true;
42903
42903
  break;
42904
42904
  }
@@ -42910,21 +42910,21 @@ function Cn(r7) {
42910
42910
  return f(!N(r7));
42911
42911
  }
42912
42912
  function Pn(r7, e) {
42913
- return r7.length === 0 || e.length === 0 ? [] : r7.length !== e.length ? f(false) : f(r7.every((t, n) => N(mr(t, e[n]))));
42913
+ return r7.length === 0 || e.length === 0 ? [] : r7.length !== e.length ? f(false) : f(r7.every((t, n) => N(hr(t, e[n]))));
42914
42914
  }
42915
42915
  function wn(r7, e) {
42916
- return r7.length === 0 || e.length === 0 ? [] : r7.length !== e.length ? f(true) : f(r7.some((t, n) => !N(mr(t, e[n]))));
42916
+ return r7.length === 0 || e.length === 0 ? [] : r7.length !== e.length ? f(true) : f(r7.some((t, n) => !N(hr(t, e[n]))));
42917
42917
  }
42918
- function mr(r7, e) {
42918
+ function hr(r7, e) {
42919
42919
  let t = r7.value?.valueOf(), n = e.value?.valueOf();
42920
- return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : k(t) && k(n) ? f(In(t, n)) : f(typeof t == "object" && typeof n == "object" ? yr(r7, e) : t === n);
42920
+ return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : k(t) && k(n) ? f(In(t, n)) : f(typeof t == "object" && typeof n == "object" ? gr(r7, e) : t === n);
42921
42921
  }
42922
- function hr(r7, e) {
42922
+ function yr(r7, e) {
42923
42923
  return r7.length === 0 && e.length === 0 ? f(true) : r7.length !== e.length ? f(false) : (r7.sort(Sn), e.sort(Sn), f(r7.every((t, n) => N(uo(t, e[n])))));
42924
42924
  }
42925
42925
  function uo(r7, e) {
42926
42926
  let { type: t, value: n } = r7, { type: i, value: o } = e, s = n?.valueOf(), a2 = o?.valueOf();
42927
- return typeof s == "number" && typeof a2 == "number" ? f(Math.abs(s - a2) < 0.01) : k(s) && k(a2) ? f(In(s, a2)) : f(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? yr({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
42927
+ return typeof s == "number" && typeof a2 == "number" ? f(Math.abs(s - a2) < 0.01) : k(s) && k(a2) ? f(In(s, a2)) : f(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? gr({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
42928
42928
  }
42929
42929
  function Sn(r7, e) {
42930
42930
  let t = r7.value?.valueOf(), n = e.value?.valueOf();
@@ -42968,13 +42968,13 @@ function k(r7) {
42968
42968
  function In(r7, e) {
42969
42969
  return Math.abs(r7.value - e.value) < 0.01 && (r7.unit === e.unit || r7.code === e.code || r7.unit === e.code || r7.code === e.unit);
42970
42970
  }
42971
- function yr(r7, e) {
42971
+ function gr(r7, e) {
42972
42972
  let t = Object.keys(r7), n = Object.keys(e);
42973
42973
  if (t.length !== n.length) return false;
42974
42974
  for (let i of t) {
42975
42975
  let o = r7[i], s = e[i];
42976
42976
  if (bn(o) && bn(s)) {
42977
- if (!yr(o, s)) return false;
42977
+ if (!gr(o, s)) return false;
42978
42978
  } else if (o !== s) return false;
42979
42979
  }
42980
42980
  return true;
@@ -43119,20 +43119,20 @@ function Ln(r7) {
43119
43119
  function w(r7) {
43120
43120
  return r7 ? r7.charAt(0).toUpperCase() + r7.substring(1) : "";
43121
43121
  }
43122
- var xr = (r7) => new Promise((e) => {
43122
+ var Tr = (r7) => new Promise((e) => {
43123
43123
  setTimeout(e, r7);
43124
43124
  });
43125
43125
  function ct(r7) {
43126
43126
  return r7.sort((e, t) => e.localeCompare(t));
43127
43127
  }
43128
- function Sr(r7) {
43128
+ function Er(r7) {
43129
43129
  return r7.endsWith("/") ? r7 : r7 + "/";
43130
43130
  }
43131
43131
  function Vo(r7) {
43132
43132
  return r7.startsWith("/") ? r7.slice(1) : r7;
43133
43133
  }
43134
43134
  function $(r7, e) {
43135
- return new URL(Vo(e), Sr(r7.toString())).toString();
43135
+ return new URL(Vo(e), Er(r7.toString())).toString();
43136
43136
  }
43137
43137
  function jn(r7, e) {
43138
43138
  return $(r7, e).toString().replace("http://", "ws://").replace("https://", "wss://");
@@ -43141,36 +43141,41 @@ function $n(r7) {
43141
43141
  return typeof r7 == "object" && !Array.isArray(r7) && !(r7 instanceof URLSearchParams) && (r7 = Object.fromEntries(Object.entries(r7).filter((e) => e[1] !== void 0))), new URLSearchParams(r7).toString();
43142
43142
  }
43143
43143
  var Do = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/;
43144
- function Hu(r7) {
43144
+ function Ku(r7) {
43145
43145
  return Do.test(r7);
43146
43146
  }
43147
43147
  function ut(r7, e) {
43148
43148
  let t = [];
43149
43149
  if (r7.prefix && e?.prefix !== false && t.push(...r7.prefix), r7.given && t.push(...r7.given), r7.family && t.push(r7.family), r7.suffix && e?.suffix !== false && t.push(...r7.suffix), r7.use && (e?.all || e?.use) && t.push("[" + r7.use + "]"), t.length === 0) {
43150
- let n = we(r7.text);
43150
+ let n = me(r7.text);
43151
43151
  if (n) return n;
43152
43152
  }
43153
43153
  return t.join(" ").trim();
43154
43154
  }
43155
43155
  function st(r7) {
43156
43156
  if (!r7) return "";
43157
- let e = we(r7.text);
43157
+ let e = me(r7.text);
43158
43158
  return e || (r7.coding ? r7.coding.map((t) => Uo(t)).join(", ") : "");
43159
43159
  }
43160
- function Uo(r7) {
43161
- return we(r7?.display) ?? we(r7?.code) ?? "";
43160
+ function Uo(r7, e) {
43161
+ let t = me(r7?.display);
43162
+ if (t) {
43163
+ let n = e ? me(r7?.code) : void 0;
43164
+ return `${t}${n ? " (" + n + ")" : ""}`;
43165
+ }
43166
+ return me(r7?.code) ?? "";
43162
43167
  }
43163
- function we(r7) {
43168
+ function me(r7) {
43164
43169
  return typeof r7 == "string" ? r7 : void 0;
43165
43170
  }
43166
43171
  var p = { 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" };
43167
- function Rr(r7) {
43172
+ function Cr(r7) {
43168
43173
  for (let e of r7.base ?? []) {
43169
43174
  let t = F.types[e];
43170
43175
  t || (t = { searchParamsDetails: {} }, F.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[r7.code] = r7;
43171
43176
  }
43172
43177
  }
43173
- function nr(r7) {
43178
+ function ir(r7) {
43174
43179
  let e = r7.type?.[0]?.code;
43175
43180
  return e === "BackboneElement" || e === "Element" ? $o((r7.base?.path ?? r7.path)?.split(".")) : e;
43176
43181
  }
@@ -43223,10 +43228,10 @@ var O = { empty: (r7, e) => f(e.length === 0 || e.every((t) => S(t.value))), has
43223
43228
  return f(false);
43224
43229
  }, subsetOf: (r7, e, t) => {
43225
43230
  if (e.length === 0) return f(true);
43226
- let n = t.eval(r7, me(r7));
43231
+ let n = t.eval(r7, he(r7));
43227
43232
  return n.length === 0 ? f(false) : f(e.every((i) => n.some((o) => o.value === i.value)));
43228
43233
  }, supersetOf: (r7, e, t) => {
43229
- let n = t.eval(r7, me(r7));
43234
+ let n = t.eval(r7, he(r7));
43230
43235
  return n.length === 0 ? f(true) : e.length === 0 ? f(false) : f(n.every((i) => e.some((o) => o.value === i.value)));
43231
43236
  }, count: (r7, e) => [{ type: p.integer, value: e.length }], distinct: (r7, e) => {
43232
43237
  let t = [];
@@ -43245,21 +43250,21 @@ var O = { empty: (r7, e) => f(e.length === 0 || e.every((t) => S(t.value))), has
43245
43250
  return n >= e.length ? e : n <= 0 ? [] : e.slice(0, n);
43246
43251
  }, intersect: (r7, e, t) => {
43247
43252
  if (!t) return e;
43248
- let n = t.eval(r7, me(r7)), i = [];
43253
+ let n = t.eval(r7, he(r7)), i = [];
43249
43254
  for (let o of e) !i.some((s) => s.value === o.value) && n.some((s) => s.value === o.value) && i.push(o);
43250
43255
  return i;
43251
43256
  }, exclude: (r7, e, t) => {
43252
43257
  if (!t) return e;
43253
- let n = t.eval(r7, me(r7)), i = [];
43258
+ let n = t.eval(r7, he(r7)), i = [];
43254
43259
  for (let o of e) n.some((s) => s.value === o.value) || i.push(o);
43255
43260
  return i;
43256
43261
  }, union: (r7, e, t) => {
43257
43262
  if (!t) return e;
43258
- let n = t.eval(r7, me(r7));
43263
+ let n = t.eval(r7, he(r7));
43259
43264
  return nt([...e, ...n]);
43260
43265
  }, combine: (r7, e, t) => {
43261
43266
  if (!t) return e;
43262
- let n = t.eval(r7, me(r7));
43267
+ let n = t.eval(r7, he(r7));
43263
43268
  return [...e, ...n];
43264
43269
  }, htmlChecks: (r7, e, t) => [g(true)], iif: (r7, e, t, n, i) => {
43265
43270
  let o = t.eval(r7, e);
@@ -43312,7 +43317,7 @@ var O = { empty: (r7, e) => f(e.length === 0 || e.every((t) => S(t.value))), has
43312
43317
  let a2 = o, c = s ? a2 + s : i.length;
43313
43318
  return a2 < 0 || a2 >= i.length ? void 0 : i.substring(a2, c);
43314
43319
  }, r7, e, t, n), startsWith: (r7, e, t) => L((n, i) => n.startsWith(i), r7, e, t), endsWith: (r7, e, t) => L((n, i) => n.endsWith(i), r7, e, t), contains: (r7, e, t) => L((n, i) => n.includes(i), r7, e, t), upper: (r7, e) => L((t) => t.toUpperCase(), r7, e), lower: (r7, e) => L((t) => t.toLowerCase(), r7, e), replace: (r7, e, t, n) => L((i, o, s) => i.replaceAll(o, s), r7, e, t, n), matches: (r7, e, t) => L((n, i) => !!new RegExp(i).exec(n), r7, e, t), replaceMatches: (r7, e, t, n) => L((i, o, s) => i.replaceAll(o, s), r7, e, t, n), length: (r7, e) => L((t) => t.length, r7, e), toChars: (r7, e) => L((t) => t ? t.split("") : void 0, r7, e), encode: z, decode: z, escape: z, unescape: z, trim: z, split: z, join: (r7, e, t) => {
43315
- let n = t?.eval(r7, me(r7))[0]?.value ?? "";
43320
+ let n = t?.eval(r7, he(r7))[0]?.value ?? "";
43316
43321
  if (typeof n != "string") throw new Error("Separator must be a string.");
43317
43322
  return [{ type: p.string, value: e.map((i) => i.value?.toString() ?? "").join(n) }];
43318
43323
  }, abs: (r7, e) => W(Math.abs, r7, e), ceiling: (r7, e) => W(Math.ceil, r7, e), exp: (r7, e) => W(Math.exp, r7, e), floor: (r7, e) => W(Math.floor, r7, e), ln: (r7, e) => W(Math.log, r7, e), log: (r7, e, t) => W((n, i) => Math.log(n) / Math.log(i), r7, e, t), power: (r7, e, t) => W(Math.pow, r7, e, t), round: (r7, e) => W(Math.round, r7, e), sqrt: (r7, e) => W(Math.sqrt, r7, e), truncate: (r7, e) => W((t) => t | 0, r7, e), children: z, descendants: z, trace: (r7, e, t) => e, now: () => [{ type: p.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: p.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: p.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r7, e, t, n, i) => {
@@ -43384,7 +43389,7 @@ function G(r7, e) {
43384
43389
  for (let t of r7) if (t == null) throw new Error("Expected non-null argument");
43385
43390
  return r7;
43386
43391
  }
43387
- function me(r7) {
43392
+ function he(r7) {
43388
43393
  let e = r7;
43389
43394
  for (; e.parent?.variables.$this; ) e = e.parent;
43390
43395
  return [e.variables.$this];
@@ -43445,7 +43450,7 @@ var dt = class extends Qe {
43445
43450
  return this.operator + this.child.toString();
43446
43451
  }
43447
43452
  };
43448
- var he = class extends Y {
43453
+ var ye = class extends Y {
43449
43454
  constructor(e, t) {
43450
43455
  super("as", e, t);
43451
43456
  }
@@ -43540,7 +43545,7 @@ var vt = class extends C {
43540
43545
  }
43541
43546
  eval(e, t) {
43542
43547
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43543
- return hr(n, i);
43548
+ return yr(n, i);
43544
43549
  }
43545
43550
  };
43546
43551
  var xt = class extends C {
@@ -43549,10 +43554,10 @@ var xt = class extends C {
43549
43554
  }
43550
43555
  eval(e, t) {
43551
43556
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43552
- return Cn(hr(n, i));
43557
+ return Cn(yr(n, i));
43553
43558
  }
43554
43559
  };
43555
- var ye = class extends C {
43560
+ var ge = class extends C {
43556
43561
  constructor(e, t) {
43557
43562
  super("is", e, t);
43558
43563
  }
@@ -43613,7 +43618,7 @@ var J = class {
43613
43618
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
43614
43619
  }
43615
43620
  };
43616
- var ge = class {
43621
+ var ve = class {
43617
43622
  constructor(e, t) {
43618
43623
  this.left = e;
43619
43624
  this.expr = t;
@@ -43640,7 +43645,7 @@ var Jo = { parse(r7) {
43640
43645
  var Yo = { parse(r7, e) {
43641
43646
  let t = r7.consumeAndParse();
43642
43647
  if (!r7.match("]")) throw new Error("Parse error: expected `]`");
43643
- return new ge(e, t);
43648
+ return new ve(e, t);
43644
43649
  }, precedence: y.Indexer };
43645
43650
  var Zo = { parse(r7, e) {
43646
43651
  if (!(e instanceof B)) throw new Error("Unexpected parentheses");
@@ -43653,7 +43658,7 @@ function Xo(r7) {
43653
43658
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
43654
43659
  }
43655
43660
  function Be() {
43656
- return new Ke().registerPrefix("String", { parse: (r7, e) => new U({ type: p.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r7, e) => new U({ type: p.dateTime, value: Ae(e.value) }) }).registerPrefix("Quantity", { parse: (r7, e) => new U({ type: p.Quantity, value: Xo(e.value) }) }).registerPrefix("Number", { parse: (r7, e) => new U({ type: e.value.includes(".") ? p.decimal : p.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new U({ type: p.boolean, value: true }) }).registerPrefix("false", { parse: () => new U({ type: p.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r7, e) => new B(e.value) }).registerPrefix("{}", { parse: () => new pt() }).registerPrefix("(", Jo).registerInfix("[", Yo).registerInfix("(", Zo).prefix("+", y.UnaryAdd, (r7, e) => new dt("+", e, (t) => t)).prefix("-", y.UnarySubtract, (r7, e) => new V("-", e, e, (t, n) => -n)).infixLeft(".", y.Dot, (r7, e, t) => new re(r7, t)).infixLeft("/", y.Divide, (r7, e, t) => new V("/", r7, t, (n, i) => n / i)).infixLeft("*", y.Multiply, (r7, e, t) => new V("*", r7, t, (n, i) => n * i)).infixLeft("+", y.Add, (r7, e, t) => new V("+", r7, t, (n, i) => n + i)).infixLeft("-", y.Subtract, (r7, e, t) => new V("-", r7, t, (n, i) => n - i)).infixLeft("|", y.Union, (r7, e, t) => new Oe(r7, t)).infixLeft("=", y.Equals, (r7, e, t) => new yt(r7, t)).infixLeft("!=", y.NotEquals, (r7, e, t) => new gt(r7, t)).infixLeft("~", y.Equivalent, (r7, e, t) => new vt(r7, t)).infixLeft("!~", y.NotEquivalent, (r7, e, t) => new xt(r7, t)).infixLeft("<", y.LessThan, (r7, e, t) => new V("<", r7, t, (n, i) => n < i)).infixLeft("<=", y.LessThanOrEquals, (r7, e, t) => new V("<=", r7, t, (n, i) => n <= i)).infixLeft(">", y.GreaterThan, (r7, e, t) => new V(">", r7, t, (n, i) => n > i)).infixLeft(">=", y.GreaterThanOrEquals, (r7, e, t) => new V(">=", r7, t, (n, i) => n >= i)).infixLeft("&", y.Ampersand, (r7, e, t) => new ft(r7, t)).infixLeft("and", y.And, (r7, e, t) => new Tt(r7, t)).infixLeft("as", y.As, (r7, e, t) => new he(r7, t)).infixLeft("contains", y.Contains, (r7, e, t) => new mt(r7, t)).infixLeft("div", y.Divide, (r7, e, t) => new V("div", r7, t, (n, i) => n / i | 0)).infixLeft("in", y.In, (r7, e, t) => new ht(r7, t)).infixLeft("is", y.Is, (r7, e, t) => new ye(r7, t)).infixLeft("mod", y.Modulo, (r7, e, t) => new V("mod", r7, t, (n, i) => n % i)).infixLeft("or", y.Or, (r7, e, t) => new St(r7, t)).infixLeft("xor", y.Xor, (r7, e, t) => new Et(r7, t)).infixLeft("implies", y.Implies, (r7, e, t) => new bt(r7, t));
43661
+ return new Ke().registerPrefix("String", { parse: (r7, e) => new U({ type: p.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r7, e) => new U({ type: p.dateTime, value: Ae(e.value) }) }).registerPrefix("Quantity", { parse: (r7, e) => new U({ type: p.Quantity, value: Xo(e.value) }) }).registerPrefix("Number", { parse: (r7, e) => new U({ type: e.value.includes(".") ? p.decimal : p.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new U({ type: p.boolean, value: true }) }).registerPrefix("false", { parse: () => new U({ type: p.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r7, e) => new B(e.value) }).registerPrefix("{}", { parse: () => new pt() }).registerPrefix("(", Jo).registerInfix("[", Yo).registerInfix("(", Zo).prefix("+", y.UnaryAdd, (r7, e) => new dt("+", e, (t) => t)).prefix("-", y.UnarySubtract, (r7, e) => new V("-", e, e, (t, n) => -n)).infixLeft(".", y.Dot, (r7, e, t) => new re(r7, t)).infixLeft("/", y.Divide, (r7, e, t) => new V("/", r7, t, (n, i) => n / i)).infixLeft("*", y.Multiply, (r7, e, t) => new V("*", r7, t, (n, i) => n * i)).infixLeft("+", y.Add, (r7, e, t) => new V("+", r7, t, (n, i) => n + i)).infixLeft("-", y.Subtract, (r7, e, t) => new V("-", r7, t, (n, i) => n - i)).infixLeft("|", y.Union, (r7, e, t) => new Oe(r7, t)).infixLeft("=", y.Equals, (r7, e, t) => new yt(r7, t)).infixLeft("!=", y.NotEquals, (r7, e, t) => new gt(r7, t)).infixLeft("~", y.Equivalent, (r7, e, t) => new vt(r7, t)).infixLeft("!~", y.NotEquivalent, (r7, e, t) => new xt(r7, t)).infixLeft("<", y.LessThan, (r7, e, t) => new V("<", r7, t, (n, i) => n < i)).infixLeft("<=", y.LessThanOrEquals, (r7, e, t) => new V("<=", r7, t, (n, i) => n <= i)).infixLeft(">", y.GreaterThan, (r7, e, t) => new V(">", r7, t, (n, i) => n > i)).infixLeft(">=", y.GreaterThanOrEquals, (r7, e, t) => new V(">=", r7, t, (n, i) => n >= i)).infixLeft("&", y.Ampersand, (r7, e, t) => new ft(r7, t)).infixLeft("and", y.And, (r7, e, t) => new Tt(r7, t)).infixLeft("as", y.As, (r7, e, t) => new ye(r7, t)).infixLeft("contains", y.Contains, (r7, e, t) => new mt(r7, t)).infixLeft("div", y.Divide, (r7, e, t) => new V("div", r7, t, (n, i) => n / i | 0)).infixLeft("in", y.In, (r7, e, t) => new ht(r7, t)).infixLeft("is", y.Is, (r7, e, t) => new ge(r7, t)).infixLeft("mod", y.Modulo, (r7, e, t) => new V("mod", r7, t, (n, i) => n % i)).infixLeft("or", y.Or, (r7, e, t) => new St(r7, t)).infixLeft("xor", y.Xor, (r7, e, t) => new Et(r7, t)).infixLeft("implies", y.Implies, (r7, e, t) => new bt(r7, t));
43657
43662
  }
43658
43663
  var es = Be();
43659
43664
  var Kn = ((l2) => (l2.BOOLEAN = "BOOLEAN", l2.NUMBER = "NUMBER", l2.QUANTITY = "QUANTITY", l2.TEXT = "TEXT", l2.REFERENCE = "REFERENCE", l2.CANONICAL = "CANONICAL", l2.DATE = "DATE", l2.DATETIME = "DATETIME", l2.PERIOD = "PERIOD", l2.UUID = "UUID", l2))(Kn || {});
@@ -43675,14 +43680,14 @@ function ii(r7) {
43675
43680
  if (typeof Buffer < "u") return Buffer.from(r7, "utf8").toString("base64");
43676
43681
  throw new Error("Unable to encode base64");
43677
43682
  }
43678
- function kr() {
43683
+ function Vr() {
43679
43684
  let r7 = new Uint32Array(28);
43680
43685
  return crypto.getRandomValues(r7), Fn(r7.buffer);
43681
43686
  }
43682
43687
  async function oi(r7) {
43683
43688
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r7));
43684
43689
  }
43685
- function ve() {
43690
+ function xe() {
43686
43691
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r7) => {
43687
43692
  let e = Math.random() * 16 | 0;
43688
43693
  return (r7 === "x" ? e : e & 3 | 8).toString(16);
@@ -43713,7 +43718,7 @@ var wt = class {
43713
43718
  }
43714
43719
  };
43715
43720
  var D = { CSS: "text/css", DICOM: "application/dicom", 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", SCIM_JSON: "application/scim+json", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript", PING: "x-application/ping" };
43716
- var Vr = class {
43721
+ var Dr = class {
43717
43722
  constructor() {
43718
43723
  this.listeners = {};
43719
43724
  }
@@ -43740,7 +43745,7 @@ var Vr = class {
43740
43745
  };
43741
43746
  var H = class {
43742
43747
  constructor() {
43743
- this.emitter = new Vr();
43748
+ this.emitter = new Dr();
43744
43749
  }
43745
43750
  dispatchEvent(e) {
43746
43751
  this.emitter.dispatchEvent(e);
@@ -43755,14 +43760,14 @@ var H = class {
43755
43760
  this.emitter.removeAllListeners();
43756
43761
  }
43757
43762
  };
43758
- var Dr = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
43763
+ var Mr = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
43759
43764
  var Bs = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
43760
- var Mr = ["DiagnosticReport-update"];
43765
+ var _r = ["DiagnosticReport-update"];
43761
43766
  function ci(r7) {
43762
- return Mr.includes(r7);
43767
+ return _r.includes(r7);
43763
43768
  }
43764
43769
  function ui(r7) {
43765
- if (Mr.includes(r7)) throw new d(h(`'context.version' is required for '${r7}'.`));
43770
+ if (_r.includes(r7)) throw new d(h(`'context.version' is required for '${r7}'.`));
43766
43771
  }
43767
43772
  var qs = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
43768
43773
  function js(r7) {
@@ -43771,7 +43776,7 @@ function js(r7) {
43771
43776
  function li(r7) {
43772
43777
  return !!r7.endpoint;
43773
43778
  }
43774
- function _r(r7) {
43779
+ function Nr(r7) {
43775
43780
  if (!Ot(r7)) throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
43776
43781
  let { channelType: e, mode: t, topic: n, events: i } = r7, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i.join(",") };
43777
43782
  return li(r7) && (o.endpoint = r7.endpoint), new URLSearchParams(o).toString();
@@ -43780,7 +43785,7 @@ function Ot(r7) {
43780
43785
  if (typeof r7 != "object") return false;
43781
43786
  let { channelType: e, mode: t, topic: n, events: i } = r7;
43782
43787
  if (!(e && t && n && i) || typeof n != "string" || typeof i != "object" || !Array.isArray(i) || i.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe") return false;
43783
- for (let o of i) if (!Dr[o]) return false;
43788
+ for (let o of i) if (!Mr[o]) return false;
43784
43789
  return !(li(r7) && !(typeof r7.endpoint == "string" && r7.endpoint.startsWith("ws")));
43785
43790
  }
43786
43791
  function ai(r7, e, t, n) {
@@ -43813,13 +43818,13 @@ function Ws(r7, e) {
43813
43818
  if (!o.manyAllowed && (t.get(i) || 0) > 1) throw new d(h(`${t.get(i)} context entries with key '${i}' found for the '${r7}' event when schema only allows for 1.`));
43814
43819
  }
43815
43820
  }
43816
- function Nr(r7, e, t, n) {
43821
+ function Fr(r7, e, t, n) {
43817
43822
  if (!(r7 && typeof r7 == "string")) throw new d(h("Must provide a topic."));
43818
- if (!Dr[e]) throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Dr).join(", ")}`));
43823
+ if (!Mr[e]) throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Mr).join(", ")}`));
43819
43824
  if (typeof t != "object") throw new d(h("context must be a context object or array of context objects."));
43820
- if (Mr.includes(e) && !n) throw new d(h(`The '${e}' event must contain a 'context.versionId'.`));
43825
+ if (_r.includes(e) && !n) throw new d(h(`The '${e}' event must contain a 'context.versionId'.`));
43821
43826
  let i = Array.isArray(t) ? t : [t];
43822
- return Ws(e, i), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ve(), event: { "hub.topic": r7, "hub.event": e, context: i, ...n ? { "context.versionId": n } : {} } };
43827
+ return Ws(e, i), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: xe(), event: { "hub.topic": r7, "hub.event": e, context: i, ...n ? { "context.versionId": n } : {} } };
43823
43828
  }
43824
43829
  var At = class extends H {
43825
43830
  constructor(e) {
@@ -43922,7 +43927,7 @@ var M = class {
43922
43927
  };
43923
43928
  var je = class {
43924
43929
  constructor(e) {
43925
- this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Fr());
43930
+ this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Lr());
43926
43931
  }
43927
43932
  clear() {
43928
43933
  this.storage.clear();
@@ -43941,7 +43946,7 @@ var je = class {
43941
43946
  this.setString(e, t ? Mn(t) : void 0);
43942
43947
  }
43943
43948
  };
43944
- var Fr = class {
43949
+ var Lr = class {
43945
43950
  constructor() {
43946
43951
  this.data = /* @__PURE__ */ new Map();
43947
43952
  }
@@ -43986,7 +43991,7 @@ function Qs(r7, e) {
43986
43991
  function Vt(r7) {
43987
43992
  return new r7.constructor(r7.type, r7);
43988
43993
  }
43989
- var xe = { maxReconnectionDelay: 1e4, minReconnectionDelay: 1e3 + Math.random() * 4e3, minUptime: 5e3, reconnectionDelayGrowFactor: 1.3, connectionTimeout: 4e3, maxRetries: 1 / 0, maxEnqueuedMessages: 1 / 0, startClosed: false, debug: false };
43994
+ var Te = { maxReconnectionDelay: 1e4, minReconnectionDelay: 1e3 + Math.random() * 4e3, minUptime: 5e3, reconnectionDelayGrowFactor: 1.3, connectionTimeout: 4e3, maxRetries: 1 / 0, maxEnqueuedMessages: 1 / 0, startClosed: false, debug: false };
43990
43995
  var gi = false;
43991
43996
  var Dt = class r extends H {
43992
43997
  constructor(t, n, i = {}) {
@@ -44005,7 +44010,7 @@ var Dt = class r extends H {
44005
44010
  this.onopen = null;
44006
44011
  this._handleOpen = (t2) => {
44007
44012
  this._debug("open event");
44008
- let { minUptime: n2 = xe.minUptime } = this._options;
44013
+ let { minUptime: n2 = Te.minUptime } = this._options;
44009
44014
  clearTimeout(this._connectTimeout), this._uptimeTimeout = setTimeout(() => this._acceptOpen(), n2), Qs(this._ws, "WebSocket is not defined"), this._ws.binaryType = this._binaryType, this._messageQueue.forEach((i2) => this._ws?.send(i2)), this._messageQueue = [], this.onopen && this.onopen(t2), this.dispatchEvent(Vt(t2));
44010
44015
  };
44011
44016
  this._handleMessage = (t2) => {
@@ -44087,7 +44092,7 @@ var Dt = class r extends H {
44087
44092
  send(t) {
44088
44093
  if (this._ws && this._ws.readyState === this.OPEN) this._debug("send", t), this._ws.send(t);
44089
44094
  else {
44090
- let { maxEnqueuedMessages: n = xe.maxEnqueuedMessages } = this._options;
44095
+ let { maxEnqueuedMessages: n = Te.maxEnqueuedMessages } = this._options;
44091
44096
  this._messageQueue.length < n && (this._debug("enqueue", t), this._messageQueue.push(t));
44092
44097
  }
44093
44098
  }
@@ -44095,7 +44100,7 @@ var Dt = class r extends H {
44095
44100
  this._options.debug && this._debugLogger("RWS>", ...t);
44096
44101
  }
44097
44102
  _getNextDelay() {
44098
- let { reconnectionDelayGrowFactor: t = xe.reconnectionDelayGrowFactor, minReconnectionDelay: n = xe.minReconnectionDelay, maxReconnectionDelay: i = xe.maxReconnectionDelay } = this._options, o = 0;
44103
+ let { reconnectionDelayGrowFactor: t = Te.reconnectionDelayGrowFactor, minReconnectionDelay: n = Te.minReconnectionDelay, maxReconnectionDelay: i = Te.maxReconnectionDelay } = this._options, o = 0;
44099
44104
  return this._retryCount > 0 && (o = n * Math.pow(t, this._retryCount - 1), o > i && (o = i)), this._debug("next delay", o), o;
44100
44105
  }
44101
44106
  _wait() {
@@ -44106,7 +44111,7 @@ var Dt = class r extends H {
44106
44111
  _connect() {
44107
44112
  if (this._connectLock || !this._shouldReconnect) return;
44108
44113
  this._connectLock = true;
44109
- let { maxRetries: t = xe.maxRetries, connectionTimeout: n = xe.connectionTimeout } = this._options;
44114
+ let { maxRetries: t = Te.maxRetries, connectionTimeout: n = Te.connectionTimeout } = this._options;
44110
44115
  if (this._retryCount >= t) {
44111
44116
  this._debug("max retries reached", this._retryCount, ">=", t);
44112
44117
  return;
@@ -44163,7 +44168,7 @@ var $e = class extends H {
44163
44168
  this.criteria.delete(e);
44164
44169
  }
44165
44170
  };
44166
- var Lr = class {
44171
+ var Ur = class {
44167
44172
  constructor(e, t) {
44168
44173
  this.connecting = false;
44169
44174
  this.criteria = e, this.emitter = new $e(e), this.refCount = 1, this.subscriptionProps = t ? { ...t } : void 0;
@@ -44303,7 +44308,7 @@ var Mt = class {
44303
44308
  let [t, n] = await this.getTokenForCriteria(e);
44304
44309
  e.subscriptionId = t, e.token = n, this.criteriaEntriesBySubscriptionId.set(t, e), this.ws.send(JSON.stringify({ type: "bind-with-token", payload: { token: n } }));
44305
44310
  } catch (t) {
44306
- console.error(er(t)), this.emitError(e, t), this.removeCriteriaEntry(e);
44311
+ console.error(tr(t)), this.emitError(e, t), this.removeCriteriaEntry(e);
44307
44312
  }
44308
44313
  }
44309
44314
  }
@@ -44315,7 +44320,7 @@ var Mt = class {
44315
44320
  this.masterSubEmitter && this.masterSubEmitter._addCriteria(e);
44316
44321
  let n = this.maybeGetCriteriaEntry(e, t);
44317
44322
  if (n) return n.refCount += 1, n.emitter;
44318
- let i = new Lr(e, t);
44323
+ let i = new Ur(e, t);
44319
44324
  return this.addCriteriaEntry(i), this.subscribeToCriteria(i).catch(console.error), i.emitter;
44320
44325
  }
44321
44326
  removeCriteria(e, t) {
@@ -44342,7 +44347,7 @@ var Mt = class {
44342
44347
  return this.masterSubEmitter || (this.masterSubEmitter = new $e(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
44343
44348
  }
44344
44349
  };
44345
- var jd = "3.2.10-97f4103aa";
44350
+ var Wd = "3.2.11-2a9ee14b4";
44346
44351
  var Ys = D.FHIR_JSON + ", */*; q=0.1";
44347
44352
  var Zs = "https://api.medplum.com/";
44348
44353
  var Xs = 1e3;
@@ -44360,7 +44365,7 @@ var _t = class extends H {
44360
44365
  super();
44361
44366
  this.initComplete = true;
44362
44367
  if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
44363
- this.options = t ?? {}, this.fetch = t?.fetch ?? ca(), this.storage = t?.storage ?? new je(), this.createPdfImpl = t?.createPdf, this.baseUrl = Sr(t?.baseUrl ?? Zs), this.fhirBaseUrl = $(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = $(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = $(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = $(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? ra, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? ta : ea), this.cacheTime > 0 ? this.requestCache = new wt(t?.resourceCacheSize ?? Xs) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve(), this.dispatchEvent({ type: "storageInitialized" })) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
44368
+ this.options = t ?? {}, this.fetch = t?.fetch ?? ca(), this.storage = t?.storage ?? new je(), this.createPdfImpl = t?.createPdf, this.baseUrl = Er(t?.baseUrl ?? Zs), this.fhirBaseUrl = $(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = $(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = $(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = $(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? ra, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? ta : ea), this.cacheTime > 0 ? this.requestCache = new wt(t?.resourceCacheSize ?? Xs) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve(), this.dispatchEvent({ type: "storageInitialized" })) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
44364
44369
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
44365
44370
  }).catch((n) => {
44366
44371
  console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
@@ -44593,8 +44598,8 @@ var _t = class extends H {
44593
44598
  target
44594
44599
  }
44595
44600
  }`.replace(/\s+/g, " "), a2 = await this.graphql(s);
44596
- sr(a2.data.StructureDefinitionList);
44597
- for (let c of a2.data.SearchParameterList) Rr(c);
44601
+ ar(a2.data.StructureDefinitionList);
44602
+ for (let c of a2.data.SearchParameterList) Cr(c);
44598
44603
  })());
44599
44604
  return this.setCacheEntry(n, o), o;
44600
44605
  }
@@ -44607,14 +44612,14 @@ var _t = class extends H {
44607
44612
  let a2 = this.fhirUrl("StructureDefinition", "$expand-profile");
44608
44613
  a2.search = new URLSearchParams({ url: t }).toString();
44609
44614
  let c = await this.post(a2.toString(), {});
44610
- sr(c);
44615
+ ar(c);
44611
44616
  } else {
44612
44617
  let a2 = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
44613
44618
  if (!a2) {
44614
44619
  console.warn(`No StructureDefinition found for ${t}!`);
44615
44620
  return;
44616
44621
  }
44617
- ar(a2);
44622
+ cr(a2);
44618
44623
  }
44619
44624
  })());
44620
44625
  return this.setCacheEntry(i, s), s;
@@ -44851,7 +44856,7 @@ var _t = class extends H {
44851
44856
  } catch (a2) {
44852
44857
  if (a2.message === "Failed to fetch" && s === 0 && this.dispatchEvent({ type: "offline" }), a2.name === "AbortError" || s === i) throw a2;
44853
44858
  }
44854
- await xr(o);
44859
+ await Tr(o);
44855
44860
  }
44856
44861
  throw new Error("Unreachable");
44857
44862
  }
@@ -44869,7 +44874,7 @@ var _t = class extends H {
44869
44874
  if (i.pollCount === void 0) n.headers && typeof n.headers == "object" && "Prefer" in n.headers && (o.headers = { ...n.headers }, delete o.headers.Prefer), i.statusUrl = t, i.pollCount = 1;
44870
44875
  else {
44871
44876
  let s = n.pollStatusPeriod ?? 1e3;
44872
- await xr(s), i.pollCount++;
44877
+ await Tr(s), i.pollCount++;
44873
44878
  }
44874
44879
  return this.request("GET", t, o, i);
44875
44880
  }
@@ -44887,7 +44892,7 @@ var _t = class extends H {
44887
44892
  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 })) }, i = await this.post(this.fhirBaseUrl, n);
44888
44893
  for (let o = 0; o < t.length; o++) {
44889
44894
  let s = t[o], a2 = i.entry?.[o];
44890
- a2?.response?.outcome && !Xt(a2.response.outcome) ? s.reject(new d(a2.response.outcome)) : s.resolve(a2?.resource);
44895
+ a2?.response?.outcome && !er(a2.response.outcome) ? s.reject(new d(a2.response.outcome)) : s.resolve(a2?.resource);
44891
44896
  }
44892
44897
  }
44893
44898
  addFetchOptionsDefaults(t) {
@@ -44905,12 +44910,12 @@ var _t = class extends H {
44905
44910
  typeof n == "string" || typeof Blob < "u" && (n instanceof Blob || n.constructor.name === "Blob") || typeof File < "u" && (n instanceof File || n.constructor.name === "File") || typeof Uint8Array < "u" && (n instanceof Uint8Array || n.constructor.name === "Uint8Array") ? t.body = n : n && (t.body = JSON.stringify(n));
44906
44911
  }
44907
44912
  handleUnauthenticated(t, n, i) {
44908
- return this.refresh() ? this.request(t, n, i) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new d(Se)));
44913
+ return this.refresh() ? this.request(t, n, i) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new d(Ee)));
44909
44914
  }
44910
44915
  async startPkce() {
44911
- let t = kr();
44916
+ let t = Vr();
44912
44917
  sessionStorage.setItem("pkceState", t);
44913
- let n = kr();
44918
+ let n = Vr();
44914
44919
  sessionStorage.setItem("codeVerifier", n);
44915
44920
  let i = await oi(n), o = Ln(i).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
44916
44921
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
@@ -44958,20 +44963,20 @@ var _t = class extends H {
44958
44963
  async fhircastSubscribe(t, n) {
44959
44964
  if (!(typeof t == "string" && t !== "")) throw new d(h("Invalid topic provided. Topic must be a valid string."));
44960
44965
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0)) throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
44961
- let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", _r(i), D.FORM_URL_ENCODED))["hub.channel.endpoint"];
44966
+ let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", Nr(i), D.FORM_URL_ENCODED))["hub.channel.endpoint"];
44962
44967
  if (!s) throw new Error("Invalid response!");
44963
44968
  return i.endpoint = s, i;
44964
44969
  }
44965
44970
  async fhircastUnsubscribe(t) {
44966
44971
  if (!Ot(t)) throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
44967
44972
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws"))) throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
44968
- t.mode = "unsubscribe", await this.post("/fhircast/STU3", _r(t), D.FORM_URL_ENCODED);
44973
+ t.mode = "unsubscribe", await this.post("/fhircast/STU3", Nr(t), D.FORM_URL_ENCODED);
44969
44974
  }
44970
44975
  fhircastConnect(t) {
44971
44976
  return new At(t);
44972
44977
  }
44973
44978
  async fhircastPublish(t, n, i, o) {
44974
- return ci(n) ? this.post(`/fhircast/STU3/${t}`, Nr(t, n, i, o), D.JSON) : (ui(n), this.post(`/fhircast/STU3/${t}`, Nr(t, n, i), D.JSON));
44979
+ return ci(n) ? this.post(`/fhircast/STU3/${t}`, Fr(t, n, i, o), D.JSON) : (ui(n), this.post(`/fhircast/STU3/${t}`, Fr(t, n, i), D.JSON));
44975
44980
  }
44976
44981
  async fhircastGetContext(t) {
44977
44982
  return this.get(`/fhircast/STU3/${t}`);
@@ -45006,8 +45011,8 @@ var _t = class extends H {
45006
45011
  let i = It(n);
45007
45012
  if (Date.now() >= i.exp * 1e3) throw this.clearActiveLogin(), new d(tn);
45008
45013
  if (i.cid) {
45009
- if (i.cid !== this.clientId) throw this.clearActiveLogin(), new d(Zt);
45010
- } else if (this.clientId && i.client_id !== this.clientId) throw this.clearActiveLogin(), new d(Zt);
45014
+ if (i.cid !== this.clientId) throw this.clearActiveLogin(), new d(Xt);
45015
+ } else if (this.clientId && i.client_id !== this.clientId) throw this.clearActiveLogin(), new d(Xt);
45011
45016
  }
45012
45017
  return this.setActiveLogin({ accessToken: n, refreshToken: t.refresh_token, project: t.project, profile: t.profile });
45013
45018
  }
@@ -45044,7 +45049,7 @@ async function Ti(r7, e) {
45044
45049
  if (t) return t;
45045
45050
  let n = r7.headers.get("location");
45046
45051
  if (n) return n;
45047
- if (Ee(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
45052
+ if (be(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
45048
45053
  }
45049
45054
  function Si(r7) {
45050
45055
  let e = r7.entry?.map((t) => t.resource) ?? [];
@@ -45168,7 +45173,7 @@ function za(r7) {
45168
45173
  let e = r7 instanceof Date ? r7 : new Date(r7), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i = e.getUTCMilliseconds();
45169
45174
  return i > 0 && (n += "." + i.toString()), n;
45170
45175
  }
45171
- var Gr = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(Gr || {});
45176
+ var Hr = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(Hr || {});
45172
45177
  var Bi = class r5 {
45173
45178
  constructor(e, t = {}, n = 3, i) {
45174
45179
  this.write = e;
@@ -45199,11 +45204,11 @@ var Bi = class r5 {
45199
45204
  }
45200
45205
  log(e, t, n) {
45201
45206
  e > this.level || (n instanceof Error && (n = { error: n.toString(), stack: n.stack?.split(`
45202
- `) }), this.write(JSON.stringify({ level: Gr[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
45207
+ `) }), this.write(JSON.stringify({ level: Hr[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
45203
45208
  }
45204
45209
  };
45205
- function tm(r7) {
45206
- let e = Gr[r7.toUpperCase()];
45210
+ function nm(r7) {
45211
+ let e = Hr[r7.toUpperCase()];
45207
45212
  if (e === void 0) throw new Error(`Invalid log level: ${r7}`);
45208
45213
  return e;
45209
45214
  }
@@ -45504,7 +45509,7 @@ var AgentDicomChannel = class extends BaseChannel {
45504
45509
  });
45505
45510
  response.setStatus(dimse.constants.Status.Success);
45506
45511
  } catch (err) {
45507
- DcmjsDimseScp.channel.log.error(`DICOM error: ${er(err)}`);
45512
+ DcmjsDimseScp.channel.log.error(`DICOM error: ${tr(err)}`);
45508
45513
  response.setStatus(dimse.constants.Status.ProcessingFailure);
45509
45514
  }
45510
45515
  return response;
@@ -45609,7 +45614,7 @@ var AgentHl7ChannelConnection = class {
45609
45614
  callback: `Agent/${this.channel.app.agentId}-${(0, import_node_crypto2.randomUUID)()}`
45610
45615
  });
45611
45616
  } catch (err) {
45612
- this.channel.log.error(`HL7 error: ${er(err)}`);
45617
+ this.channel.log.error(`HL7 error: ${tr(err)}`);
45613
45618
  }
45614
45619
  }
45615
45620
  close() {
@@ -45692,7 +45697,7 @@ async function fetchVersionManifest(version) {
45692
45697
  try {
45693
45698
  message = (await res.json()).message;
45694
45699
  } catch (err) {
45695
- console.error(`Failed to parse message from body: ${er(err)}`);
45700
+ console.error(`Failed to parse message from body: ${tr(err)}`);
45696
45701
  }
45697
45702
  throw new Error(
45698
45703
  `Received status code ${res.status} while fetching manifest for version '${version ?? "latest"}'. Message: ${message}`
@@ -45790,7 +45795,7 @@ var App = class _App {
45790
45795
  if ((0, import_node_fs3.existsSync)(UPGRADE_MANIFEST_PATH)) {
45791
45796
  const upgradeFile = (0, import_node_fs3.readFileSync)(UPGRADE_MANIFEST_PATH, { encoding: "utf-8" });
45792
45797
  const upgradeDetails = JSON.parse(upgradeFile);
45793
- if (upgradeDetails.targetVersion === jd.split("-")[0]) {
45798
+ if (upgradeDetails.targetVersion === Wd.split("-")[0]) {
45794
45799
  await this.sendToWebSocket({
45795
45800
  type: "agent:upgrade:response",
45796
45801
  statusCode: 200,
@@ -45798,7 +45803,7 @@ var App = class _App {
45798
45803
  });
45799
45804
  this.log.info(`Successfully upgraded to version ${upgradeDetails.targetVersion}`);
45800
45805
  } else {
45801
- const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${jd}`;
45806
+ const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${Wd}`;
45802
45807
  await this.sendToWebSocket({
45803
45808
  type: "agent:error",
45804
45809
  body: errMsg,
@@ -45836,7 +45841,7 @@ var App = class _App {
45836
45841
  this.webSocket.binaryType = "nodebuffer";
45837
45842
  this.webSocket.addEventListener("error", (err) => {
45838
45843
  if (!this.shutdown) {
45839
- this.log.error(`WebSocket closed due to an error: ${er(err)}`);
45844
+ this.log.error(`WebSocket closed due to an error: ${tr(err)}`);
45840
45845
  }
45841
45846
  });
45842
45847
  this.webSocket.addEventListener("open", async () => {
@@ -45868,7 +45873,7 @@ var App = class _App {
45868
45873
  this.startWebSocketWorker();
45869
45874
  break;
45870
45875
  case "agent:heartbeat:request":
45871
- await this.sendToWebSocket({ type: "agent:heartbeat:response", version: jd });
45876
+ await this.sendToWebSocket({ type: "agent:heartbeat:response", version: Wd });
45872
45877
  break;
45873
45878
  case "agent:heartbeat:response":
45874
45879
  break;
@@ -45910,7 +45915,7 @@ var App = class _App {
45910
45915
  } catch (err) {
45911
45916
  await this.sendToWebSocket({
45912
45917
  type: "agent:error",
45913
- body: er(err),
45918
+ body: tr(err),
45914
45919
  callback: command.callback
45915
45920
  });
45916
45921
  }
@@ -45925,7 +45930,7 @@ var App = class _App {
45925
45930
  this.log.error(`Unknown message type: ${command.type}`);
45926
45931
  }
45927
45932
  } catch (err) {
45928
- this.log.error(`WebSocket error on incoming message: ${er(err)}`);
45933
+ this.log.error(`WebSocket error on incoming message: ${tr(err)}`);
45929
45934
  }
45930
45935
  });
45931
45936
  return new Promise((resolve2, reject) => {
@@ -46000,7 +46005,7 @@ var App = class _App {
46000
46005
  try {
46001
46006
  await this.startOrReloadChannel(definition, endpoint);
46002
46007
  } catch (err) {
46003
- this.log.error(er(err));
46008
+ this.log.error(tr(err));
46004
46009
  }
46005
46010
  }
46006
46011
  }
@@ -46026,7 +46031,7 @@ var App = class _App {
46026
46031
  parsedEndpoint = new URL(endpoint.address);
46027
46032
  } catch (err) {
46028
46033
  throw new Error(
46029
- `Error while validating endpoint address for channel '${channel.name}': ${er(err)}`
46034
+ `Error while validating endpoint address for channel '${channel.name}': ${tr(err)}`
46030
46035
  );
46031
46036
  }
46032
46037
  if (seenPorts.has(parsedEndpoint.port)) {
@@ -46109,7 +46114,7 @@ var App = class _App {
46109
46114
  try {
46110
46115
  await this.sendToWebSocket(msg);
46111
46116
  } catch (err) {
46112
- this.log.error(`WebSocket error while attempting to send message: ${er(err)}`);
46117
+ this.log.error(`WebSocket error while attempting to send message: ${tr(err)}`);
46113
46118
  this.webSocketQueue.unshift(msg);
46114
46119
  throw err;
46115
46120
  }
@@ -46146,7 +46151,7 @@ IPv6 is currently unsupported.`;
46146
46151
  this.log.error(errMsg);
46147
46152
  throw new Error(errMsg);
46148
46153
  }
46149
- if (!((0, import_node_net3.isIPv4)(message.remote) || Hu(message.remote))) {
46154
+ if (!((0, import_node_net3.isIPv4)(message.remote) || Ku(message.remote))) {
46150
46155
  const errMsg = `Attempted to ping an invalid host.
46151
46156
 
46152
46157
  "${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
@@ -46185,7 +46190,7 @@ ${result}`);
46185
46190
  body: result
46186
46191
  });
46187
46192
  } catch (err) {
46188
- this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${er(err)}`);
46193
+ this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${tr(err)}`);
46189
46194
  this.addToWebSocketQueue({
46190
46195
  type: "agent:transmit:response",
46191
46196
  channel: message.channel,
@@ -46193,7 +46198,7 @@ ${result}`);
46193
46198
  remote: message.remote,
46194
46199
  callback: message.callback,
46195
46200
  statusCode: 400,
46196
- body: er(err)
46201
+ body: tr(err)
46197
46202
  });
46198
46203
  }
46199
46204
  }
@@ -46240,11 +46245,11 @@ ${result}`);
46240
46245
  });
46241
46246
  });
46242
46247
  child.on("error", (err) => {
46243
- this.log.error(er(err));
46248
+ this.log.error(tr(err));
46244
46249
  });
46245
46250
  } catch (err) {
46246
46251
  const versionTag = message.version ? `v${message.version}` : "latest";
46247
- const errMsg = `Error during upgrading to version '${versionTag}': ${er(err)}`;
46252
+ const errMsg = `Error during upgrading to version '${versionTag}': ${tr(err)}`;
46248
46253
  this.log.error(errMsg);
46249
46254
  await this.sendToWebSocket({
46250
46255
  type: "agent:error",
@@ -46257,11 +46262,11 @@ ${result}`);
46257
46262
  await this.stop();
46258
46263
  this.log.info("Successfully stopped agent network services");
46259
46264
  const targetVersion = message.version ?? await fetchLatestVersionString();
46260
- this.log.info("Writing upgrade manifest...", { previousVersion: jd, targetVersion });
46265
+ this.log.info("Writing upgrade manifest...", { previousVersion: Wd, targetVersion });
46261
46266
  (0, import_node_fs3.writeFileSync)(
46262
46267
  UPGRADE_MANIFEST_PATH,
46263
46268
  JSON.stringify({
46264
- previousVersion: jd,
46269
+ previousVersion: Wd,
46265
46270
  targetVersion,
46266
46271
  callback: message.callback ?? null
46267
46272
  }),
@@ -46271,7 +46276,7 @@ ${result}`);
46271
46276
  child.disconnect();
46272
46277
  } catch (err) {
46273
46278
  this.log.error(
46274
- `Error while stopping agent or messaging child process as part of upgrade: ${er(err)}`
46279
+ `Error while stopping agent or messaging child process as part of upgrade: ${tr(err)}`
46275
46280
  );
46276
46281
  import_node_process.default.exit(1);
46277
46282
  }
@@ -46341,7 +46346,7 @@ ${result}`);
46341
46346
  body: response.toString()
46342
46347
  });
46343
46348
  }).catch((err) => {
46344
- this.log.error(`HL7 error: ${er(err)}`);
46349
+ this.log.error(`HL7 error: ${tr(err)}`);
46345
46350
  this.addToWebSocketQueue({
46346
46351
  type: "agent:transmit:response",
46347
46352
  channel: message.channel,
@@ -46349,7 +46354,7 @@ ${result}`);
46349
46354
  callback: message.callback,
46350
46355
  contentType: D.TEXT,
46351
46356
  statusCode: 400,
46352
- body: er(err)
46357
+ body: tr(err)
46353
46358
  });
46354
46359
  if (client.keepAlive) {
46355
46360
  this.hl7Clients.delete(message.remote);
@@ -46398,7 +46403,7 @@ async function agentMain(argv) {
46398
46403
  const { baseUrl, clientId, clientSecret, agentId } = args;
46399
46404
  const medplum = new _t({ baseUrl, clientId });
46400
46405
  await medplum.startClientLogin(clientId, clientSecret);
46401
- const app = new App(medplum, agentId, tm(args.logLevel ?? "INFO"));
46406
+ const app = new App(medplum, agentId, nm(args.logLevel ?? "INFO"));
46402
46407
  await app.start();
46403
46408
  process.on("SIGINT", async () => {
46404
46409
  console.log("Gracefully shutting down from SIGINT (Ctrl-C)");
@@ -46465,7 +46470,7 @@ async function upgraderMain(argv) {
46465
46470
  (0, import_node_child_process2.spawnSync)(binPath, ["/S"]);
46466
46471
  globalLogger.info(`Agent version ${version} successfully installed`);
46467
46472
  } catch (err) {
46468
- globalLogger.error(`Error while attempting to run installer: ${er(err)}`);
46473
+ globalLogger.error(`Error while attempting to run installer: ${tr(err)}`);
46469
46474
  globalLogger.error("Failed to run installer, attempting to restart agent service...");
46470
46475
  try {
46471
46476
  (0, import_node_child_process2.execSync)('net start "Medplum Agent"');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/agent",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "Medplum Agent",
5
5
  "homepage": "https://www.medplum.com/",
6
6
  "bugs": {
@@ -24,15 +24,15 @@
24
24
  "test": "jest"
25
25
  },
26
26
  "dependencies": {
27
- "@medplum/core": "3.2.10",
28
- "@medplum/hl7": "3.2.10",
27
+ "@medplum/core": "3.2.11",
28
+ "@medplum/hl7": "3.2.11",
29
29
  "dcmjs-dimse": "0.1.28",
30
30
  "iconv-lite": "0.6.3",
31
31
  "ws": "8.18.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@medplum/fhirtypes": "3.2.10",
35
- "@medplum/mock": "3.2.10",
34
+ "@medplum/fhirtypes": "3.2.11",
35
+ "@medplum/mock": "3.2.11",
36
36
  "@types/async-eventemitter": "0.2.4",
37
37
  "@types/ws": "8.5.12",
38
38
  "mock-socket": "9.3.1",