@medplum/agent 4.1.8 → 4.1.9

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 +206 -204
  2. package/package.json +5 -5
@@ -8184,7 +8184,7 @@ var require_dcmjs = __commonJS({
8184
8184
  };
8185
8185
  const compress_block = (s, ltree, dtree) => {
8186
8186
  let dist2;
8187
- let lc;
8187
+ let lc2;
8188
8188
  let sx = 0;
8189
8189
  let code;
8190
8190
  let extra;
@@ -8192,16 +8192,16 @@ var require_dcmjs = __commonJS({
8192
8192
  do {
8193
8193
  dist2 = s.pending_buf[s.sym_buf + sx++] & 255;
8194
8194
  dist2 += (s.pending_buf[s.sym_buf + sx++] & 255) << 8;
8195
- lc = s.pending_buf[s.sym_buf + sx++];
8195
+ lc2 = s.pending_buf[s.sym_buf + sx++];
8196
8196
  if (dist2 === 0) {
8197
- send_code(s, lc, ltree);
8197
+ send_code(s, lc2, ltree);
8198
8198
  } else {
8199
- code = _length_code[lc];
8199
+ code = _length_code[lc2];
8200
8200
  send_code(s, code + LITERALS$1 + 1, ltree);
8201
8201
  extra = extra_lbits[code];
8202
8202
  if (extra !== 0) {
8203
- lc -= base_length[code];
8204
- send_bits(s, lc, extra);
8203
+ lc2 -= base_length[code];
8204
+ send_bits(s, lc2, extra);
8205
8205
  }
8206
8206
  dist2--;
8207
8207
  code = d_code(dist2);
@@ -8486,16 +8486,16 @@ var require_dcmjs = __commonJS({
8486
8486
  bi_windup(s);
8487
8487
  }
8488
8488
  };
8489
- const _tr_tally$1 = (s, dist2, lc) => {
8489
+ const _tr_tally$1 = (s, dist2, lc2) => {
8490
8490
  s.pending_buf[s.sym_buf + s.sym_next++] = dist2;
8491
8491
  s.pending_buf[s.sym_buf + s.sym_next++] = dist2 >> 8;
8492
- s.pending_buf[s.sym_buf + s.sym_next++] = lc;
8492
+ s.pending_buf[s.sym_buf + s.sym_next++] = lc2;
8493
8493
  if (dist2 === 0) {
8494
- s.dyn_ltree[lc * 2]++;
8494
+ s.dyn_ltree[lc2 * 2]++;
8495
8495
  } else {
8496
8496
  s.matches++;
8497
8497
  dist2--;
8498
- s.dyn_ltree[(_length_code[lc] + LITERALS$1 + 1) * 2]++;
8498
+ s.dyn_ltree[(_length_code[lc2] + LITERALS$1 + 1) * 2]++;
8499
8499
  s.dyn_dtree[d_code(dist2) * 2]++;
8500
8500
  }
8501
8501
  return s.sym_next === s.sym_end;
@@ -24837,7 +24837,7 @@ var require_dcmjs = __commonJS({
24837
24837
  __proto__: null,
24838
24838
  Comprehensive3DSR
24839
24839
  });
24840
- var sr2 = {
24840
+ var sr = {
24841
24841
  coding,
24842
24842
  contentItems,
24843
24843
  documents,
@@ -25149,7 +25149,7 @@ var require_dcmjs = __commonJS({
25149
25149
  data: data2,
25150
25150
  derivations,
25151
25151
  normalizers,
25152
- sr: sr2,
25152
+ sr,
25153
25153
  utilities,
25154
25154
  log: log2,
25155
25155
  anonymizer
@@ -25166,7 +25166,7 @@ var require_dcmjs = __commonJS({
25166
25166
  exports3.derivations = derivations;
25167
25167
  exports3.log = log2;
25168
25168
  exports3.normalizers = normalizers;
25169
- exports3.sr = sr2;
25169
+ exports3.sr = sr;
25170
25170
  exports3.utilities = utilities;
25171
25171
  Object.defineProperty(exports3, "__esModule", { value: true });
25172
25172
  });
@@ -31402,10 +31402,10 @@ var nt = class {
31402
31402
  }, precedence: t });
31403
31403
  }
31404
31404
  construct(e) {
31405
- return new tr(e, this.prefixParselets, this.infixParselets);
31405
+ return new rr(e, this.prefixParselets, this.infixParselets);
31406
31406
  }
31407
31407
  };
31408
- var tr = class {
31408
+ var rr = class {
31409
31409
  constructor(e, t, n) {
31410
31410
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
31411
31411
  }
@@ -31477,16 +31477,16 @@ var Ce = class {
31477
31477
  return this.cache.keys().next().value;
31478
31478
  }
31479
31479
  };
31480
- var rr = "ok";
31480
+ var nr = "ok";
31481
31481
  var it = "created";
31482
- var ir = "not-modified";
31483
- var sr = "not-found";
31484
- var cr = "unauthorized";
31482
+ var or = "not-modified";
31483
+ var ar = "not-found";
31484
+ var ur = "unauthorized";
31485
31485
  var ot = "accepted";
31486
- var vn = { resourceType: "OperationOutcome", id: sr, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
31487
- var Pe = { resourceType: "OperationOutcome", id: cr, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
31486
+ var vn = { resourceType: "OperationOutcome", id: ar, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
31487
+ var Pe = { resourceType: "OperationOutcome", id: ur, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
31488
31488
  var Tn = { ...Pe, issue: [...Pe.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
31489
- var ur = { ...Pe, issue: [...Pe.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
31489
+ var lr = { ...Pe, issue: [...Pe.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
31490
31490
  function b(r6, e) {
31491
31491
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r6 }, ...e ? { expression: [e] } : void 0 }] };
31492
31492
  }
@@ -31499,8 +31499,8 @@ function Sn(r6) {
31499
31499
  function we(r6) {
31500
31500
  return typeof r6 == "object" && r6 !== null && r6.resourceType === "OperationOutcome";
31501
31501
  }
31502
- function lr(r6) {
31503
- return r6.id === rr || r6.id === it || r6.id === ir || r6.id === ot;
31502
+ function dr(r6) {
31503
+ return r6.id === nr || r6.id === it || r6.id === or || r6.id === ot;
31504
31504
  }
31505
31505
  var p = class extends Error {
31506
31506
  constructor(e, t) {
@@ -31531,29 +31531,29 @@ function Cn(r6) {
31531
31531
  return e;
31532
31532
  }
31533
31533
  var Pn = { 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" }] } } }, DataRequirementCodeFilter: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] } } }, DataRequirementDateFilter: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, "value[x]": { type: [{ code: "dateTime" }, { code: "Period" }, { code: "Duration" }] } } }, DataRequirementSort: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, direction: { min: 1, type: [{ code: "code" }] } } }, 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"] }] } } }, DosageDoseAndRate: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { type: [{ code: "CodeableConcept" }] }, "dose[x]": { type: [{ code: "Range" }, { code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, "rate[x]": { type: [{ code: "Ratio" }, { code: "Range" }, { 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" }] } } }, ElementDefinitionSlicingDiscriminator: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, path: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionSlicing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, discriminator: { max: 9007199254740991, type: [{ code: "ElementDefinitionSlicingDiscriminator" }] }, description: { type: [{ code: "string" }] }, ordered: { type: [{ code: "boolean" }] }, rules: { min: 1, type: [{ code: "code" }] } } }, ElementDefinitionBase: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, min: { min: 1, type: [{ code: "unsignedInt" }] }, max: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionType: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, targetProfile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, aggregation: { max: 9007199254740991, type: [{ code: "code" }] }, versioning: { type: [{ code: "code" }] } } }, ElementDefinitionExample: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, label: { min: 1, type: [{ code: "string" }] }, "value[x]": { min: 1, 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" }] } } }, ElementDefinitionConstraint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, key: { min: 1, type: [{ code: "id" }] }, requirements: { type: [{ code: "string" }] }, severity: { min: 1, type: [{ code: "code" }] }, human: { min: 1, type: [{ code: "string" }] }, expression: { type: [{ code: "string" }] }, xpath: { type: [{ code: "string" }] }, source: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, ElementDefinitionBinding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, strength: { min: 1, type: [{ code: "code" }] }, description: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] } } }, ElementDefinitionMapping: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identity: { min: 1, type: [{ code: "id" }] }, language: { type: [{ code: "code" }] }, map: { min: 1, type: [{ code: "string" }] }, comment: { type: [{ code: "string" }] } } }, 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" }] }, accounts: { max: 9007199254740991, 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" }] } } }, SubstanceAmountReferenceRange: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, lowLimit: { type: [{ code: "Quantity" }] }, highLimit: { type: [{ code: "Quantity" }] } } }, 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" }] } } }, TimingRepeat: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "bounds[x]": { type: [{ code: "Duration" }, { code: "Range" }, { code: "Period" }] }, count: { type: [{ code: "positiveInt" }] }, countMax: { type: [{ code: "positiveInt" }] }, duration: { type: [{ code: "decimal" }] }, durationMax: { type: [{ code: "decimal" }] }, durationUnit: { type: [{ code: "code" }] }, frequency: { type: [{ code: "positiveInt" }] }, frequencyMax: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "decimal" }] }, periodMax: { type: [{ code: "decimal" }] }, periodUnit: { type: [{ code: "code" }] }, dayOfWeek: { max: 9007199254740991, type: [{ code: "code" }] }, timeOfDay: { max: 9007199254740991, type: [{ code: "time" }] }, when: { max: 9007199254740991, type: [{ code: "code" }] }, offset: { type: [{ code: "unsignedInt" }] } } }, 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" }] } } } };
31534
- function hr(r6) {
31535
- return new pr(r6).parse();
31534
+ function mr(r6) {
31535
+ return new fr(r6).parse();
31536
31536
  }
31537
31537
  var fe = Cn(Pn);
31538
- var mr = /* @__PURE__ */ Object.create(null);
31538
+ var yr = /* @__PURE__ */ Object.create(null);
31539
31539
  var wn = /* @__PURE__ */ Object.create(null);
31540
31540
  var lo = { "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" };
31541
31541
  function kn(r6) {
31542
31542
  let e;
31543
31543
  return e = wn[r6], e || (e = wn[r6] = /* @__PURE__ */ Object.create(null)), e;
31544
31544
  }
31545
- function yr(r6) {
31545
+ function gr(r6) {
31546
31546
  let t = (Array.isArray(r6) ? r6 : r6.entry?.map((n) => n.resource) ?? []).filter((n) => n?.resourceType === "StructureDefinition");
31547
- Ln(t);
31548
- for (let n of t) gr(n);
31547
+ Fn(t);
31548
+ for (let n of t) xr(n);
31549
31549
  }
31550
- function gr(r6) {
31550
+ function xr(r6) {
31551
31551
  if (!r6?.name) throw new Error("Failed loading StructureDefinition from bundle");
31552
31552
  if (r6.resourceType !== "StructureDefinition") return;
31553
- let e = hr(r6), t = lo[r6.url], n, i2;
31553
+ let e = mr(r6), t = lo[r6.url], n, i2;
31554
31554
  t ? (n = fe, i2 = t) : r6.url === `http://hl7.org/fhir/StructureDefinition/${r6.type}` || r6.url === `https://medplum.com/fhir/StructureDefinition/${r6.type}` || r6.type?.startsWith("http://") || r6.type?.startsWith("https://") ? (n = fe, i2 = r6.type) : (n = kn(r6.url), i2 = r6.type), n[i2] = e;
31555
31555
  for (let o of e.innerTypes) o.parentType = e, n[o.name] = o;
31556
- mr[r6.url] = e;
31556
+ yr[r6.url] = e;
31557
31557
  }
31558
31558
  function Vn(r6) {
31559
31559
  return !!fe[r6];
@@ -31566,9 +31566,9 @@ function Be(r6, e) {
31566
31566
  return fe[r6];
31567
31567
  }
31568
31568
  function _n(r6) {
31569
- return !!mr[r6];
31569
+ return !!yr[r6];
31570
31570
  }
31571
- var pr = class {
31571
+ var fr = class {
31572
31572
  constructor(e) {
31573
31573
  if (!e.snapshot?.element || e.snapshot.element.length === 0) throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
31574
31574
  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, version: e.version, kind: e.kind, description: mo(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
@@ -31579,7 +31579,7 @@ var pr = class {
31579
31579
  if (e.sliceName) this.parseSliceStart(e);
31580
31580
  else if (e.id?.includes(":")) {
31581
31581
  if (this.slicingContext?.current) {
31582
- let t = dr(e, this.slicingContext.path);
31582
+ let t = pr(e, this.slicingContext.path);
31583
31583
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
31584
31584
  }
31585
31585
  } else {
@@ -31588,13 +31588,13 @@ var pr = class {
31588
31588
  let n = this.backboneContext;
31589
31589
  for (; n; ) {
31590
31590
  if (e.path?.startsWith(n.path + ".")) {
31591
- n.type.elements[dr(e, n.path)] = t;
31591
+ n.type.elements[pr(e, n.path)] = t;
31592
31592
  break;
31593
31593
  }
31594
31594
  n = n.parent;
31595
31595
  }
31596
31596
  if (!n) {
31597
- let i2 = dr(e, this.root.path);
31597
+ let i2 = pr(e, this.root.path);
31598
31598
  e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
31599
31599
  }
31600
31600
  this.checkFieldExit(e);
@@ -31608,7 +31608,7 @@ var pr = class {
31608
31608
  }
31609
31609
  enterInnerType(e) {
31610
31610
  for (; this.backboneContext && !Oe(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
31611
- let t = fr(e);
31611
+ let t = hr(e);
31612
31612
  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: Oe(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
31613
31613
  }
31614
31614
  enterSlice(e, t) {
@@ -31648,7 +31648,7 @@ var pr = class {
31648
31648
  parseElementDefinitionType(e) {
31649
31649
  return (e.type ?? []).map((t) => {
31650
31650
  let n;
31651
- return (t.code === "BackboneElement" || t.code === "Element") && (n = fr(e)), n || (n = ne(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
31651
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = hr(e)), n || (n = ne(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
31652
31652
  });
31653
31653
  }
31654
31654
  parseElementDefinition(e) {
@@ -31659,7 +31659,7 @@ var pr = class {
31659
31659
  function On(r6) {
31660
31660
  return r6 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r6, 10);
31661
31661
  }
31662
- function dr(r6, e = "") {
31662
+ function pr(r6, e = "") {
31663
31663
  return fo(r6.path, e);
31664
31664
  }
31665
31665
  function fo(r6, e) {
@@ -31685,7 +31685,7 @@ function h(r6) {
31685
31685
  return [{ type: l.boolean, value: r6 }];
31686
31686
  }
31687
31687
  function v(r6) {
31688
- return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: l.integer, value: r6 } : typeof r6 == "number" ? { type: l.decimal, value: r6 } : typeof r6 == "boolean" ? { type: l.boolean, value: r6 } : typeof r6 == "string" ? { type: l.string, value: r6 } : k(r6) ? { type: l.Quantity, value: r6 } : A(r6) ? { type: r6.resourceType, value: r6 } : Ar(r6) ? { type: l.CodeableConcept, value: r6 } : wr(r6) ? { type: l.Coding, value: r6 } : { type: l.BackboneElement, value: r6 };
31688
+ return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: l.integer, value: r6 } : typeof r6 == "number" ? { type: l.decimal, value: r6 } : typeof r6 == "boolean" ? { type: l.boolean, value: r6 } : typeof r6 == "string" ? { type: l.string, value: r6 } : k(r6) ? { type: l.Quantity, value: r6 } : A(r6) ? { type: r6.resourceType, value: r6 } : Or(r6) ? { type: l.CodeableConcept, value: r6 } : Ar(r6) ? { type: l.Coding, value: r6 } : { type: l.BackboneElement, value: r6 };
31689
31689
  }
31690
31690
  function _(r6) {
31691
31691
  return r6.length === 0 ? false : !!r6[0].value;
@@ -31767,14 +31767,14 @@ function Hn(r6, e) {
31767
31767
  }
31768
31768
  function je(r6, e) {
31769
31769
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
31770
- return typeof t == "number" && typeof n == "number" ? h(Math.abs(t - n) < 1e-8) : k(t) && k(n) ? h(Qn(t, n)) : h(typeof t == "object" && typeof n == "object" ? Pr(r6, e) : t === n);
31770
+ return typeof t == "number" && typeof n == "number" ? h(Math.abs(t - n) < 1e-8) : k(t) && k(n) ? h(Qn(t, n)) : h(typeof t == "object" && typeof n == "object" ? wr(r6, e) : t === n);
31771
31771
  }
31772
- function Cr(r6, e) {
31772
+ function Pr(r6, e) {
31773
31773
  return r6.length === 0 && e.length === 0 ? h(true) : r6.length !== e.length ? h(false) : (r6.sort(Un), e.sort(Un), h(r6.every((t, n) => _(wo(t, e[n])))));
31774
31774
  }
31775
31775
  function wo(r6, e) {
31776
31776
  let { type: t, value: n } = r6, { type: i2, value: o } = e, s = n?.valueOf(), a2 = o?.valueOf();
31777
- return typeof s == "number" && typeof a2 == "number" ? h(Math.abs(s - a2) < 0.01) : k(s) && k(a2) ? h(Qn(s, a2)) : h(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? Pr({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
31777
+ return typeof s == "number" && typeof a2 == "number" ? h(Math.abs(s - a2) < 0.01) : k(s) && k(a2) ? h(Qn(s, a2)) : h(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? wr({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
31778
31778
  }
31779
31779
  function Un(r6, e) {
31780
31780
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
@@ -31819,13 +31819,13 @@ function k(r6) {
31819
31819
  function Qn(r6, e) {
31820
31820
  return Math.abs(r6.value - e.value) < 0.01 && (r6.unit === e.unit || r6.code === e.code || r6.unit === e.code || r6.code === e.unit);
31821
31821
  }
31822
- function Pr(r6, e) {
31822
+ function wr(r6, e) {
31823
31823
  let t = Object.keys(r6), n = Object.keys(e);
31824
31824
  if (t.length !== n.length) return false;
31825
31825
  for (let i2 of t) {
31826
31826
  let o = r6[i2], s = e[i2];
31827
31827
  if (Wn(o) && Wn(s)) {
31828
- if (!Pr(o, s)) return false;
31828
+ if (!wr(o, s)) return false;
31829
31829
  } else if (o !== s) return false;
31830
31830
  }
31831
31831
  return true;
@@ -31843,7 +31843,7 @@ function qn(r6, e) {
31843
31843
  function Ao(r6, e) {
31844
31844
  return delete e.__proto__, delete e.constructor, Object.assign(r6, e);
31845
31845
  }
31846
- function Ir(r6, e) {
31846
+ function kr(r6, e) {
31847
31847
  return A(r6, e) && "id" in r6 && typeof r6.id == "string";
31848
31848
  }
31849
31849
  function he(r6) {
@@ -31852,7 +31852,7 @@ function he(r6) {
31852
31852
  }
31853
31853
  function B(r6) {
31854
31854
  if (Y(r6)) return r6.reference;
31855
- if (Ir(r6)) return `${r6.resourceType}/${r6.id}`;
31855
+ if (kr(r6)) return `${r6.resourceType}/${r6.id}`;
31856
31856
  }
31857
31857
  function me(r6) {
31858
31858
  if (r6) return Y(r6) ? r6.reference.split("/")[1] : r6.id;
@@ -31875,7 +31875,7 @@ function Io(r6) {
31875
31875
  if ("name" in r6 && r6.name && typeof r6.name == "string") return r6.name;
31876
31876
  if ("code" in r6 && r6.code) {
31877
31877
  let e = r6.code;
31878
- if (Array.isArray(e) && (e = e[0]), Ar(e)) return $e(e);
31878
+ if (Array.isArray(e) && (e = e[0]), Or(e)) return $e(e);
31879
31879
  if (Bo(e)) return e.text;
31880
31880
  }
31881
31881
  return B(r6) ?? "";
@@ -31906,10 +31906,10 @@ function ne(r6, ...e) {
31906
31906
  return t;
31907
31907
  }
31908
31908
  function mt(r6, e) {
31909
- let t = kr(r6);
31909
+ let t = Dr(r6);
31910
31910
  return JSON.stringify(t, null, e ? 2 : void 0) ?? "";
31911
31911
  }
31912
- function kr(r6) {
31912
+ function Dr(r6) {
31913
31913
  if (!(r6 == null || r6 === "")) return typeof r6 == "object" ? Array.isArray(r6) ? Mo(r6) : _o(r6) : r6;
31914
31914
  }
31915
31915
  function Mo(r6) {
@@ -31917,7 +31917,7 @@ function Mo(r6) {
31917
31917
  if (e === 0) return;
31918
31918
  let t, n = 0;
31919
31919
  for (let i2 = 0; i2 < e; i2++) {
31920
- let o = r6[i2], s = kr(o);
31920
+ let o = r6[i2], s = Dr(o);
31921
31921
  s !== o && !t && (t = Array.from(r6)), s === void 0 ? t && (t[i2] = null) : (t && (t[i2] = s), n++);
31922
31922
  }
31923
31923
  if (n !== 0) return t ?? r6;
@@ -31925,7 +31925,7 @@ function Mo(r6) {
31925
31925
  function _o(r6) {
31926
31926
  let e, t = 0;
31927
31927
  for (let n in r6) {
31928
- let i2 = r6[n], o = kr(i2);
31928
+ let i2 = r6[n], o = Dr(i2);
31929
31929
  o !== i2 && !e && (e = { ...r6 }), o === void 0 ? e && delete e[n] : (e && (e[n] = o), t++);
31930
31930
  }
31931
31931
  if (t !== 0) return e ?? r6;
@@ -31941,14 +31941,14 @@ function X(r6) {
31941
31941
  return e === "string" && r6 !== "" || e === "object" && ("length" in r6 && r6.length > 0 || Object.keys(r6).length > 0);
31942
31942
  }
31943
31943
  function ie(r6, e, t) {
31944
- return r6 === e || S(r6) && S(e) ? true : S(r6) || S(e) ? false : Array.isArray(r6) && Array.isArray(e) ? Fo(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : E(r6) && E(e) ? Lo(r6, e, t) : (E(r6) || E(e), false);
31944
+ return r6 === e || S(r6) && S(e) ? true : S(r6) || S(e) ? false : Array.isArray(r6) && Array.isArray(e) ? Lo(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : E(r6) && E(e) ? Fo(r6, e, t) : (E(r6) || E(e), false);
31945
31945
  }
31946
- function Fo(r6, e) {
31946
+ function Lo(r6, e) {
31947
31947
  if (r6.length !== e.length) return false;
31948
31948
  for (let t = 0; t < r6.length; t++) if (!ie(r6[t], e[t])) return false;
31949
31949
  return true;
31950
31950
  }
31951
- function Lo(r6, e, t) {
31951
+ function Fo(r6, e, t) {
31952
31952
  let n = /* @__PURE__ */ new Set();
31953
31953
  Object.keys(r6).forEach((i2) => n.add(i2)), Object.keys(e).forEach((i2) => n.add(i2)), t === "meta" && (n.delete("versionId"), n.delete("lastUpdated"), n.delete("author"));
31954
31954
  for (let i2 of n) {
@@ -31961,16 +31961,16 @@ function E(r6) {
31961
31961
  return r6 !== null && typeof r6 == "object";
31962
31962
  }
31963
31963
  function Yn(r6) {
31964
- return r6.every(Dr);
31964
+ return r6.every(Vr);
31965
31965
  }
31966
- function Dr(r6) {
31966
+ function Vr(r6) {
31967
31967
  return typeof r6 == "string";
31968
31968
  }
31969
- function wr(r6) {
31969
+ function Ar(r6) {
31970
31970
  return E(r6) && "code" in r6 && typeof r6.code == "string";
31971
31971
  }
31972
- function Ar(r6) {
31973
- return E(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(wr);
31972
+ function Or(r6) {
31973
+ return E(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(Ar);
31974
31974
  }
31975
31975
  function Bo(r6) {
31976
31976
  return E(r6) && "text" in r6 && typeof r6.text == "string";
@@ -31993,7 +31993,7 @@ function ti(r6) {
31993
31993
  function I(r6) {
31994
31994
  return r6 ? r6.charAt(0).toUpperCase() + r6.substring(1) : "";
31995
31995
  }
31996
- var Mr = (r6) => new Promise((e) => {
31996
+ var _r = (r6) => new Promise((e) => {
31997
31997
  setTimeout(e, r6);
31998
31998
  });
31999
31999
  function yt(r6) {
@@ -32015,7 +32015,7 @@ function si(r6) {
32015
32015
  return typeof r6 == "object" && !Array.isArray(r6) && !(r6 instanceof URLSearchParams) && (r6 = Object.fromEntries(Object.entries(r6).filter((e) => e[1] !== void 0))), new URLSearchParams(r6).toString();
32016
32016
  }
32017
32017
  var zo = /^(([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])$/;
32018
- function bl(r6) {
32018
+ function El(r6) {
32019
32019
  return zo.test(r6);
32020
32020
  }
32021
32021
  function He(r6, e) {
@@ -32044,21 +32044,21 @@ function ge(r6) {
32044
32044
  return typeof r6 == "string" ? r6 : void 0;
32045
32045
  }
32046
32046
  var l = { 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" };
32047
- function Ln(r6) {
32047
+ function Fn(r6) {
32048
32048
  let e = Array.isArray(r6) ? r6 : r6.entry?.map((t) => t.resource) ?? [];
32049
32049
  for (let t of e) t?.resourceType === "StructureDefinition" && t.kind === "resource" && li(t.type);
32050
32050
  }
32051
32051
  function li(r6) {
32052
- let e = F.types[r6];
32053
- return e || (e = { searchParamsDetails: {} }, F.types[r6] = e), e.searchParams || (e.searchParams = { _id: { base: [r6], code: "_id", type: "token", expression: r6 + ".id" }, _lastUpdated: { base: [r6], code: "_lastUpdated", type: "date", expression: r6 + ".meta.lastUpdated" }, _compartment: { base: [r6], code: "_compartment", type: "reference", expression: r6 + ".meta.compartment" }, _profile: { base: [r6], code: "_profile", type: "uri", expression: r6 + ".meta.profile" }, _security: { base: [r6], code: "_security", type: "token", expression: r6 + ".meta.security" }, _source: { base: [r6], code: "_source", type: "uri", expression: r6 + ".meta.source" }, _tag: { base: [r6], code: "_tag", type: "token", expression: r6 + ".meta.tag" } }), e;
32052
+ let e = L.types[r6];
32053
+ return e || (e = { searchParamsDetails: {} }, L.types[r6] = e), e.searchParams || (e.searchParams = { _id: { base: [r6], code: "_id", type: "token", expression: r6 + ".id" }, _lastUpdated: { base: [r6], code: "_lastUpdated", type: "date", expression: r6 + ".meta.lastUpdated" }, _compartment: { base: [r6], code: "_compartment", type: "reference", expression: r6 + ".meta.compartment" }, _profile: { base: [r6], code: "_profile", type: "uri", expression: r6 + ".meta.profile" }, _security: { base: [r6], code: "_security", type: "token", expression: r6 + ".meta.security" }, _source: { base: [r6], code: "_source", type: "uri", expression: r6 + ".meta.source" }, _tag: { base: [r6], code: "_tag", type: "token", expression: r6 + ".meta.tag" } }), e;
32054
32054
  }
32055
- function Ur(r6) {
32055
+ function Br(r6) {
32056
32056
  for (let e of r6.base ?? []) {
32057
32057
  let t = li(e);
32058
32058
  t.searchParams || (t.searchParams = {}), t.searchParams[r6.code] = r6;
32059
32059
  }
32060
32060
  }
32061
- function fr(r6) {
32061
+ function hr(r6) {
32062
32062
  let e = r6.type?.[0]?.code;
32063
32063
  return e === "BackboneElement" || e === "Element" ? os((r6.base?.path ?? r6.path)?.split(".")) : e;
32064
32064
  }
@@ -32086,7 +32086,7 @@ function A(r6, e) {
32086
32086
  function Y(r6) {
32087
32087
  return !!(r6 && typeof r6 == "object" && "reference" in r6 && typeof r6.reference == "string");
32088
32088
  }
32089
- var F = { types: {} };
32089
+ var L = { types: {} };
32090
32090
  function Ve(r6) {
32091
32091
  if (r6.startsWith("T")) return r6 + "T00:00:00.000Z".substring(r6.length);
32092
32092
  if (r6.length <= 10) return r6;
@@ -32196,10 +32196,10 @@ var O = { empty: (r6, e) => h(e.length === 0 || e.every((t) => S(t.value))), has
32196
32196
  if (n) return [{ type: l.time, value: Ve("T" + n[1]) }];
32197
32197
  }
32198
32198
  return [];
32199
- }, convertsToTime: (r6, e) => e.length === 0 ? [] : h(O.toTime(r6, e).length === 1), indexOf: (r6, e, t) => L((n, i2) => n.indexOf(i2), r6, e, t), substring: (r6, e, t, n) => L((i2, o, s) => {
32199
+ }, convertsToTime: (r6, e) => e.length === 0 ? [] : h(O.toTime(r6, e).length === 1), indexOf: (r6, e, t) => F((n, i2) => n.indexOf(i2), r6, e, t), substring: (r6, e, t, n) => F((i2, o, s) => {
32200
32200
  let a2 = o, c = s ? a2 + s : i2.length;
32201
32201
  return a2 < 0 || a2 >= i2.length ? void 0 : i2.substring(a2, c);
32202
- }, r6, e, t, n), startsWith: (r6, e, t) => L((n, i2) => n.startsWith(i2), r6, e, t), endsWith: (r6, e, t) => L((n, i2) => n.endsWith(i2), r6, e, t), contains: (r6, e, t) => L((n, i2) => n.includes(i2), r6, e, t), upper: (r6, e) => L((t) => t.toUpperCase(), r6, e), lower: (r6, e) => L((t) => t.toLowerCase(), r6, e), replace: (r6, e, t, n) => L((i2, o, s) => i2.replaceAll(o, s), r6, e, t, n), matches: (r6, e, t) => L((n, i2) => !!new RegExp(i2).exec(n), r6, e, t), replaceMatches: (r6, e, t, n) => L((i2, o, s) => i2.replaceAll(new RegExp(o, "g"), s), r6, e, t, n), length: (r6, e) => L((t) => t.length, r6, e), toChars: (r6, e) => L((t) => t ? t.split("") : void 0, r6, e), encode: Z, decode: Z, escape: Z, unescape: Z, trim: Z, split: Z, join: (r6, e, t) => {
32202
+ }, r6, e, t, n), startsWith: (r6, e, t) => F((n, i2) => n.startsWith(i2), r6, e, t), endsWith: (r6, e, t) => F((n, i2) => n.endsWith(i2), r6, e, t), contains: (r6, e, t) => F((n, i2) => n.includes(i2), r6, e, t), upper: (r6, e) => F((t) => t.toUpperCase(), r6, e), lower: (r6, e) => F((t) => t.toLowerCase(), r6, e), replace: (r6, e, t, n) => F((i2, o, s) => i2.replaceAll(o, s), r6, e, t, n), matches: (r6, e, t) => F((n, i2) => !!new RegExp(i2).exec(n), r6, e, t), replaceMatches: (r6, e, t, n) => F((i2, o, s) => i2.replaceAll(new RegExp(o, "g"), s), r6, e, t, n), length: (r6, e) => F((t) => t.length, r6, e), toChars: (r6, e) => F((t) => t ? t.split("") : void 0, r6, e), encode: Z, decode: Z, escape: Z, unescape: Z, trim: Z, split: Z, join: (r6, e, t) => {
32203
32203
  let n = t?.eval(r6, xe(r6))[0]?.value ?? "";
32204
32204
  if (typeof n != "string") throw new Error("Separator must be a string.");
32205
32205
  return [{ type: l.string, value: e.map((i2) => i2.value?.toString() ?? "").join(n) }];
@@ -32253,7 +32253,7 @@ var O = { empty: (r6, e) => h(e.length === 0 || e.every((t) => S(t.value))), has
32253
32253
  }
32254
32254
  return [];
32255
32255
  } };
32256
- function L(r6, e, t, ...n) {
32256
+ function F(r6, e, t, ...n) {
32257
32257
  if (t.length === 0) return [];
32258
32258
  let [{ value: i2 }] = z(t, 1);
32259
32259
  if (typeof i2 != "string") throw new Error("String function cannot be called with non-string");
@@ -32426,7 +32426,7 @@ var Rt = class extends R {
32426
32426
  }
32427
32427
  eval(e, t) {
32428
32428
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
32429
- return Cr(n, i2);
32429
+ return Pr(n, i2);
32430
32430
  }
32431
32431
  };
32432
32432
  var Ct = class extends R {
@@ -32435,7 +32435,7 @@ var Ct = class extends R {
32435
32435
  }
32436
32436
  eval(e, t) {
32437
32437
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
32438
- return jn(Cr(n, i2));
32438
+ return jn(Pr(n, i2));
32439
32439
  }
32440
32440
  };
32441
32441
  var Te = class extends R {
@@ -32542,11 +32542,11 @@ function ze() {
32542
32542
  var ys = ze();
32543
32543
  var f = { EQUALS: "eq", NOT_EQUALS: "ne", GREATER_THAN: "gt", LESS_THAN: "lt", GREATER_THAN_OR_EQUALS: "ge", LESS_THAN_OR_EQUALS: "le", STARTS_AFTER: "sa", ENDS_BEFORE: "eb", APPROXIMATELY: "ap", CONTAINS: "contains", STARTS_WITH: "sw", EXACT: "exact", TEXT: "text", NOT: "not", ABOVE: "above", BELOW: "below", IN: "in", NOT_IN: "not-in", OF_TYPE: "of-type", MISSING: "missing", PRESENT: "present", IDENTIFIER: "identifier", ITERATE: "iterate" };
32544
32544
  var xi = { contains: f.CONTAINS, exact: f.EXACT, above: f.ABOVE, below: f.BELOW, text: f.TEXT, not: f.NOT, in: f.IN, "not-in": f.NOT_IN, "of-type": f.OF_TYPE, missing: f.MISSING, identifier: f.IDENTIFIER, iterate: f.ITERATE };
32545
- var Wr = { eq: f.EQUALS, ne: f.NOT_EQUALS, lt: f.LESS_THAN, le: f.LESS_THAN_OR_EQUALS, gt: f.GREATER_THAN, ge: f.GREATER_THAN_OR_EQUALS, sa: f.STARTS_AFTER, eb: f.ENDS_BEFORE, ap: f.APPROXIMATELY, sw: f.STARTS_WITH };
32545
+ var qr = { eq: f.EQUALS, ne: f.NOT_EQUALS, lt: f.LESS_THAN, le: f.LESS_THAN_OR_EQUALS, gt: f.GREATER_THAN, ge: f.GREATER_THAN_OR_EQUALS, sa: f.STARTS_AFTER, eb: f.ENDS_BEFORE, ap: f.APPROXIMATELY, sw: f.STARTS_WITH };
32546
32546
  var Ps = [f.MISSING, f.PRESENT];
32547
32547
  var Ke = { READ: "read", VREAD: "vread", UPDATE: "update", PATCH: "patch", DELETE: "delete", HISTORY: "history", HISTORY_INSTANCE: "history-instance", HISTORY_TYPE: "history-type", HISTORY_SYSTEM: "history-system", CREATE: "create", SEARCH: "search", SEARCH_TYPE: "search-type", SEARCH_SYSTEM: "search-system", SEARCH_COMPARTMENT: "search-compartment", CAPABILITIES: "capabilities", TRANSACTION: "transaction", BATCH: "batch", OPERATION: "operation" };
32548
32548
  var Gs = [Ke.READ, Ke.VREAD, Ke.HISTORY, Ke.HISTORY_INSTANCE];
32549
- function Ti(r6) {
32549
+ function Ks(r6) {
32550
32550
  if (typeof window < "u") {
32551
32551
  let e = window.atob(r6), t = Uint8Array.from(e, (n) => n.charCodeAt(0));
32552
32552
  return new window.TextDecoder().decode(t);
@@ -32554,7 +32554,7 @@ function Ti(r6) {
32554
32554
  if (typeof Buffer < "u") return Buffer.from(r6, "base64").toString("utf-8");
32555
32555
  throw new Error("Unable to decode base64");
32556
32556
  }
32557
- function $r(r6) {
32557
+ function Ft(r6) {
32558
32558
  if (typeof window < "u") {
32559
32559
  let e = new window.TextEncoder().encode(r6), t = String.fromCharCode.apply(null, e);
32560
32560
  return window.btoa(t);
@@ -32562,6 +32562,12 @@ function $r(r6) {
32562
32562
  if (typeof Buffer < "u") return Buffer.from(r6, "utf8").toString("base64");
32563
32563
  throw new Error("Unable to encode base64");
32564
32564
  }
32565
+ function Ti(r6) {
32566
+ if (typeof Buffer < "u") return Buffer.from(r6, "base64url").toString("utf-8");
32567
+ r6 = r6.padEnd(r6.length + (4 - r6.length % 4) % 4, "=");
32568
+ let e = r6.replace(/-/g, "+").replace(/_/g, "/");
32569
+ return Ks(e);
32570
+ }
32565
32571
  function Hr() {
32566
32572
  let r6 = new Uint32Array(28);
32567
32573
  return crypto.getRandomValues(r6), Zn(r6.buffer);
@@ -32619,7 +32625,7 @@ var J = class {
32619
32625
  }
32620
32626
  };
32621
32627
  var Qr = { "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" };
32622
- var ta = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
32628
+ var ra = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
32623
32629
  var zr = ["DiagnosticReport-update"];
32624
32630
  function Ei(r6) {
32625
32631
  return zr.includes(r6);
@@ -32627,46 +32633,46 @@ function Ei(r6) {
32627
32633
  function Ri(r6) {
32628
32634
  if (zr.includes(r6)) throw new p(y(`'context.version' is required for '${r6}'.`));
32629
32635
  }
32630
- var ra = { "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", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, select: { resourceType: "*", reference: true, manyAllowed: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
32631
- function na(r6) {
32632
- return ta.includes(r6);
32636
+ var na = { "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", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, select: { resourceType: "*", reference: true, manyAllowed: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
32637
+ function ia(r6) {
32638
+ return ra.includes(r6);
32633
32639
  }
32634
32640
  function Ci(r6) {
32635
32641
  return !!r6.endpoint;
32636
32642
  }
32637
32643
  function Jr(r6) {
32638
- if (!Nt(r6)) throw new p(y("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
32644
+ if (!Ut(r6)) throw new p(y("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
32639
32645
  let { channelType: e, mode: t, topic: n, events: i2 } = r6, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
32640
32646
  return Ci(r6) && (o.endpoint = r6.endpoint), new URLSearchParams(o).toString();
32641
32647
  }
32642
- function Nt(r6) {
32648
+ function Ut(r6) {
32643
32649
  if (typeof r6 != "object") return false;
32644
32650
  let { channelType: e, mode: t, topic: n, events: i2 } = r6;
32645
32651
  if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe") return false;
32646
32652
  for (let o of i2) if (!Qr[o]) return false;
32647
32653
  return !(Ci(r6) && !(typeof r6.endpoint == "string" && r6.endpoint.startsWith("ws")));
32648
32654
  }
32649
- function ia(r6, e, t, n) {
32655
+ function oa(r6, e, t, n) {
32650
32656
  if (typeof e != "object") throw new p(y(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
32651
32657
  if (!(e.id && typeof e.id == "string")) throw new p(y(`context[${t}] is invalid. Resource must contain a valid string ID.`));
32652
32658
  if (!e.resourceType) throw new p(y(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
32653
32659
  let i2 = n.resourceType;
32654
32660
  if (i2 !== "*") {
32655
- if (!na(e.resourceType)) throw new p(y(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
32661
+ if (!ia(e.resourceType)) throw new p(y(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
32656
32662
  if (i2 && e.resourceType !== i2) throw new p(y(`context[${t}] is invalid. context[${t}] for the '${r6}' event should contain resource of type ${i2}.`));
32657
32663
  }
32658
32664
  }
32659
- function oa(r6, e, t, n, i2) {
32665
+ function sa(r6, e, t, n, i2) {
32660
32666
  if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), n.reference) {
32661
32667
  if (!Y(e.reference)) throw new p(y(`context[${t}] is invalid. Expected key '${e.key}' to be a reference.`));
32662
- } else ia(r6, e.resource, t, n);
32668
+ } else oa(r6, e.resource, t, n);
32663
32669
  }
32664
- function sa(r6, e) {
32665
- let t = /* @__PURE__ */ new Map(), n = ra[r6];
32670
+ function aa(r6, e) {
32671
+ let t = /* @__PURE__ */ new Map(), n = na[r6];
32666
32672
  for (let i2 = 0; i2 < e.length; i2++) {
32667
32673
  let o = e[i2].key;
32668
32674
  if (!n[o]) throw new p(y(`Key '${o}' not found for event '${r6}'. Make sure to add only valid keys.`));
32669
- oa(r6, e[i2], i2, n[o], t);
32675
+ sa(r6, e[i2], i2, n[o], t);
32670
32676
  }
32671
32677
  for (let [i2, o] of Object.entries(n)) {
32672
32678
  if (!(o.optional || t.has(i2))) throw new p(y(`Missing required key '${i2}' on context for '${r6}' event.`));
@@ -32679,12 +32685,12 @@ function Kr(r6, e, t, n) {
32679
32685
  if (typeof t != "object") throw new p(y("context must be a context object or array of context objects."));
32680
32686
  if (zr.includes(e) && !n) throw new p(y(`The '${e}' event must contain a 'context.versionId'.`));
32681
32687
  let i2 = Array.isArray(t) ? t : [t];
32682
- return sa(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: be(), event: { "hub.topic": r6, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
32688
+ return aa(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: be(), event: { "hub.topic": r6, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
32683
32689
  }
32684
- var Lt = class extends J {
32690
+ var Nt = class extends J {
32685
32691
  constructor(e) {
32686
32692
  if (super(), this.subRequest = e, !e.endpoint) throw new p(y("Subscription request should contain an endpoint."));
32687
- if (!Nt(e)) throw new p(y("Subscription request failed validation."));
32693
+ if (!Ut(e)) throw new p(y("Subscription request failed validation."));
32688
32694
  let t = new WebSocket(e.endpoint);
32689
32695
  t.addEventListener("open", () => {
32690
32696
  this.dispatchEvent({ type: "connect" }), t.addEventListener("message", (n) => {
@@ -32701,36 +32707,32 @@ var Lt = class extends J {
32701
32707
  this.websocket.close();
32702
32708
  }
32703
32709
  };
32704
- function aa(r6) {
32705
- let e = r6.replace(/-/g, "+").replace(/_/g, "/"), t = Ti(e), n = Array.from(t).reduce((o, s) => {
32706
- let a2 = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
32707
- return `${o}%${a2}`;
32708
- }, ""), i2 = decodeURIComponent(n);
32709
- return JSON.parse(i2);
32710
+ function ca(r6) {
32711
+ return JSON.parse(Ti(r6));
32710
32712
  }
32711
32713
  function Pi(r6) {
32712
32714
  return r6.split(".").length === 3;
32713
32715
  }
32714
- function Ut(r6) {
32716
+ function Bt(r6) {
32715
32717
  let [e, t, n] = r6.split(".");
32716
- return aa(t);
32718
+ return ca(t);
32717
32719
  }
32718
32720
  function wi(r6) {
32719
32721
  try {
32720
- return typeof Ut(r6).login_id == "string";
32722
+ return typeof Bt(r6).login_id == "string";
32721
32723
  } catch {
32722
32724
  return false;
32723
32725
  }
32724
32726
  }
32725
32727
  function Ai(r6) {
32726
32728
  try {
32727
- let t = Ut(r6).exp;
32729
+ let t = Bt(r6).exp;
32728
32730
  return typeof t == "number" ? t * 1e3 : void 0;
32729
32731
  } catch {
32730
32732
  return;
32731
32733
  }
32732
32734
  }
32733
- var Bt = class {
32735
+ var Wt = class {
32734
32736
  constructor(e) {
32735
32737
  this.medplum = e;
32736
32738
  }
@@ -32824,15 +32826,15 @@ var Yr = class {
32824
32826
  return Array.from(this.data.keys())[e];
32825
32827
  }
32826
32828
  };
32827
- var Le = { Event: typeof globalThis.Event < "u" ? globalThis.Event : void 0, ErrorEvent: void 0, CloseEvent: void 0 };
32829
+ var Fe = { Event: typeof globalThis.Event < "u" ? globalThis.Event : void 0, ErrorEvent: void 0, CloseEvent: void 0 };
32828
32830
  var ki = false;
32829
- function ca() {
32831
+ function ua() {
32830
32832
  if (typeof globalThis.Event > "u") throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");
32831
- Le.Event = globalThis.Event, Le.ErrorEvent = class extends Event {
32833
+ Fe.Event = globalThis.Event, Fe.ErrorEvent = class extends Event {
32832
32834
  constructor(e, t) {
32833
32835
  super("error", t), this.message = e.message, this.error = e;
32834
32836
  }
32835
- }, Le.CloseEvent = class extends Event {
32837
+ }, Fe.CloseEvent = class extends Event {
32836
32838
  constructor(t = 1e3, n = "", i2) {
32837
32839
  super("close", i2);
32838
32840
  this.wasClean = true;
@@ -32840,17 +32842,17 @@ function ca() {
32840
32842
  }
32841
32843
  };
32842
32844
  }
32843
- function ua(r6, e) {
32845
+ function la(r6, e) {
32844
32846
  if (!r6) throw new Error(e);
32845
32847
  }
32846
- function Wt(r6) {
32848
+ function qt(r6) {
32847
32849
  return new r6.constructor(r6.type, r6);
32848
32850
  }
32849
32851
  var Ee = { maxReconnectionDelay: 1e4, minReconnectionDelay: 1e3 + Math.random() * 4e3, minUptime: 5e3, reconnectionDelayGrowFactor: 1.3, connectionTimeout: 4e3, maxRetries: 1 / 0, maxEnqueuedMessages: 1 / 0, startClosed: false, debug: false };
32850
32852
  var Di = false;
32851
- var qt = class r extends J {
32853
+ var jt = class r extends J {
32852
32854
  constructor(t, n, i2 = {}) {
32853
- ki || (ca(), ki = true);
32855
+ ki || (ua(), ki = true);
32854
32856
  super();
32855
32857
  this._retryCount = -1;
32856
32858
  this._shouldReconnect = true;
@@ -32865,16 +32867,16 @@ var qt = class r extends J {
32865
32867
  this._handleOpen = (t2) => {
32866
32868
  this._debug("open event");
32867
32869
  let { minUptime: n2 = Ee.minUptime } = this._options;
32868
- clearTimeout(this._connectTimeout), this._uptimeTimeout = setTimeout(() => this._acceptOpen(), n2), ua(this._ws, "WebSocket is not defined"), this._ws.binaryType = this._binaryType, this._messageQueue.forEach((i3) => this._ws?.send(i3)), this._messageQueue = [], this.onopen && this.onopen(t2), this.dispatchEvent(Wt(t2));
32870
+ clearTimeout(this._connectTimeout), this._uptimeTimeout = setTimeout(() => this._acceptOpen(), n2), la(this._ws, "WebSocket is not defined"), this._ws.binaryType = this._binaryType, this._messageQueue.forEach((i3) => this._ws?.send(i3)), this._messageQueue = [], this.onopen && this.onopen(t2), this.dispatchEvent(qt(t2));
32869
32871
  };
32870
32872
  this._handleMessage = (t2) => {
32871
- this._debug("message event"), this.onmessage && this.onmessage(t2), this.dispatchEvent(Wt(t2));
32873
+ this._debug("message event"), this.onmessage && this.onmessage(t2), this.dispatchEvent(qt(t2));
32872
32874
  };
32873
32875
  this._handleError = (t2) => {
32874
- this._debug("error event", t2.message), this._disconnect(void 0, t2.message === "TIMEOUT" ? "timeout" : void 0), this.onerror && this.onerror(t2), this._debug("exec error listeners"), this.dispatchEvent(Wt(t2)), this._connect();
32876
+ this._debug("error event", t2.message), this._disconnect(void 0, t2.message === "TIMEOUT" ? "timeout" : void 0), this.onerror && this.onerror(t2), this._debug("exec error listeners"), this.dispatchEvent(qt(t2)), this._connect();
32875
32877
  };
32876
32878
  this._handleClose = (t2) => {
32877
- this._debug("close event"), this._clearTimeouts(), this._shouldReconnect && this._connect(), this.onclose && this.onclose(t2), this.dispatchEvent(Wt(t2));
32879
+ this._debug("close event"), this._clearTimeouts(), this._shouldReconnect && this._connect(), this.onclose && this.onclose(t2), this.dispatchEvent(qt(t2));
32878
32880
  };
32879
32881
  this._url = t, this._protocols = n, this._options = i2, this._options.startClosed && (this._shouldReconnect = false), this._options.binaryType ? this._binaryType = this._options.binaryType : this._binaryType = "blob", this._options.debugLogger && (this._debugLogger = this._options.debugLogger), this._connect();
32880
32882
  }
@@ -32979,17 +32981,17 @@ var qt = class r extends J {
32979
32981
  let i2 = this._options.WebSocket || WebSocket;
32980
32982
  this._debug("connect", { url: this._url, protocols: this._protocols }), this._ws = this._protocols ? new i2(this._url, this._protocols) : new i2(this._url), this._ws.binaryType = this._binaryType, this._connectLock = false, this._addListeners(), this._connectTimeout = setTimeout(() => this._handleTimeout(), n);
32981
32983
  }).catch((i2) => {
32982
- this._connectLock = false, this._handleError(new Le.ErrorEvent(Error(i2.message), this));
32984
+ this._connectLock = false, this._handleError(new Fe.ErrorEvent(Error(i2.message), this));
32983
32985
  });
32984
32986
  }
32985
32987
  _handleTimeout() {
32986
- this._debug("timeout event"), this._handleError(new Le.ErrorEvent(Error("TIMEOUT"), this));
32988
+ this._debug("timeout event"), this._handleError(new Fe.ErrorEvent(Error("TIMEOUT"), this));
32987
32989
  }
32988
32990
  _disconnect(t = 1e3, n) {
32989
32991
  if (this._clearTimeouts(), !!this._ws) {
32990
32992
  this._removeListeners();
32991
32993
  try {
32992
- this._ws.close(t, n), this._handleClose(new Le.CloseEvent(t, n, this));
32994
+ this._ws.close(t, n), this._handleClose(new Fe.CloseEvent(t, n, this));
32993
32995
  } catch {
32994
32996
  }
32995
32997
  }
@@ -33007,7 +33009,7 @@ var qt = class r extends J {
33007
33009
  clearTimeout(this._connectTimeout), clearTimeout(this._uptimeTimeout);
33008
33010
  }
33009
33011
  };
33010
- var la = 5e3;
33012
+ var da = 5e3;
33011
33013
  var Xe = class extends J {
33012
33014
  constructor(...e) {
33013
33015
  super(), this.criteria = new Set(e);
@@ -33031,19 +33033,19 @@ var Xr = class {
33031
33033
  this.subscriptionId = void 0, this.token = void 0;
33032
33034
  }
33033
33035
  };
33034
- var jt = class {
33036
+ var $t = class {
33035
33037
  constructor(e, t, n) {
33036
33038
  this.pingTimer = void 0;
33037
33039
  this.waitingForPong = false;
33038
- if (!(e instanceof $t)) throw new p(y("First arg of constructor should be a `MedplumClient`"));
33040
+ if (!(e instanceof Ht)) throw new p(y("First arg of constructor should be a `MedplumClient`"));
33039
33041
  let i2;
33040
33042
  try {
33041
33043
  i2 = new URL(t).toString();
33042
33044
  } catch {
33043
33045
  throw new p(y("Not a valid URL"));
33044
33046
  }
33045
- let o = n?.ReconnectingWebSocket ? new n.ReconnectingWebSocket(i2, void 0, { debug: n?.debug, debugLogger: n?.debugLogger }) : new qt(i2, void 0, { debug: n?.debug, debugLogger: n?.debugLogger });
33046
- this.medplum = e, this.ws = o, this.masterSubEmitter = new Xe(), this.criteriaEntries = /* @__PURE__ */ new Map(), this.criteriaEntriesBySubscriptionId = /* @__PURE__ */ new Map(), this.wsClosed = false, this.pingIntervalMs = n?.pingIntervalMs ?? la, this.currentProfile = e.getProfile(), this.setupListeners();
33047
+ let o = n?.ReconnectingWebSocket ? new n.ReconnectingWebSocket(i2, void 0, { debug: n?.debug, debugLogger: n?.debugLogger }) : new jt(i2, void 0, { debug: n?.debug, debugLogger: n?.debugLogger });
33048
+ this.medplum = e, this.ws = o, this.masterSubEmitter = new Xe(), this.criteriaEntries = /* @__PURE__ */ new Map(), this.criteriaEntriesBySubscriptionId = /* @__PURE__ */ new Map(), this.wsClosed = false, this.pingIntervalMs = n?.pingIntervalMs ?? da, this.currentProfile = e.getProfile(), this.setupListeners();
33047
33049
  }
33048
33050
  setupListeners() {
33049
33051
  let e = this.ws;
@@ -33201,24 +33203,24 @@ var jt = class {
33201
33203
  return this.masterSubEmitter || (this.masterSubEmitter = new Xe(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
33202
33204
  }
33203
33205
  };
33204
- var Zr = "4.1.8-da4c6bf86";
33205
- var fa = w.FHIR_JSON + ", */*; q=0.1";
33206
- var ha = "https://api.medplum.com/";
33207
- var ma = 1e3;
33208
- var ya = 6e4;
33209
- var ga = 0;
33210
- var xa = 3e5;
33211
- var va = "Binary/";
33206
+ var Zr = "4.1.9-916e31cb9";
33207
+ var ha = w.FHIR_JSON + ", */*; q=0.1";
33208
+ var ma = "https://api.medplum.com/";
33209
+ var ya = 1e3;
33210
+ var ga = 6e4;
33211
+ var xa = 0;
33212
+ var va = 3e5;
33213
+ var Ta = "Binary/";
33212
33214
  var Vi = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
33213
33215
  var Ne = { ClientCredentials: "client_credentials", AuthorizationCode: "authorization_code", RefreshToken: "refresh_token", JwtBearer: "urn:ietf:params:oauth:grant-type:jwt-bearer", TokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange" };
33214
- var Ta = { AccessToken: "urn:ietf:params:oauth:token-type:access_token", RefreshToken: "urn:ietf:params:oauth:token-type:refresh_token", IdToken: "urn:ietf:params:oauth:token-type:id_token", Saml1Token: "urn:ietf:params:oauth:token-type:saml1", Saml2Token: "urn:ietf:params:oauth:token-type:saml2" };
33215
- var Sa = { JwtBearer: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" };
33216
- var $t = class extends J {
33216
+ var Sa = { AccessToken: "urn:ietf:params:oauth:token-type:access_token", RefreshToken: "urn:ietf:params:oauth:token-type:refresh_token", IdToken: "urn:ietf:params:oauth:token-type:id_token", Saml1Token: "urn:ietf:params:oauth:token-type:saml1", Saml2Token: "urn:ietf:params:oauth:token-type:saml2" };
33217
+ var ba = { JwtBearer: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" };
33218
+ var Ht = class extends J {
33217
33219
  constructor(t) {
33218
33220
  super();
33219
33221
  this.initComplete = true;
33220
33222
  if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
33221
- this.options = t ?? {}, this.fetch = t?.fetch ?? ba(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = Fr(t?.baseUrl ?? ha), this.fhirBaseUrl = W(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = W(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = W(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = W(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = W(this.baseUrl, t?.fhircastHubUrl ?? "fhircast/STU3"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.credentialsInHeader = t?.authCredentialsMethod === "header", this.defaultHeaders = t?.defaultHeaders ?? {}, this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? xa, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? ga : ya), this.cacheTime > 0 ? this.requestCache = new Ce(t?.resourceCacheSize ?? ma) : 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(() => {
33223
+ this.options = t ?? {}, this.fetch = t?.fetch ?? Ea(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = Fr(t?.baseUrl ?? ma), this.fhirBaseUrl = W(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = W(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = W(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = W(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = W(this.baseUrl, t?.fhircastHubUrl ?? "fhircast/STU3"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.credentialsInHeader = t?.authCredentialsMethod === "header", this.defaultHeaders = t?.defaultHeaders ?? {}, this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? va, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? xa : ga), this.cacheTime > 0 ? this.requestCache = new Ce(t?.resourceCacheSize ?? ya) : 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(() => {
33222
33224
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
33223
33225
  }).catch((n) => {
33224
33226
  console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
@@ -33330,7 +33332,7 @@ var $t = class extends J {
33330
33332
  }
33331
33333
  async exchangeExternalAccessToken(t, n) {
33332
33334
  if (n = n ?? this.clientId, !n) throw new Error("MedplumClient is missing clientId");
33333
- return this.fetchTokens({ grant_type: Ne.TokenExchange, subject_token_type: Ta.AccessToken, client_id: n, subject_token: t });
33335
+ return this.fetchTokens({ grant_type: Ne.TokenExchange, subject_token_type: Sa.AccessToken, client_id: n, subject_token: t });
33334
33336
  }
33335
33337
  getExternalAuthRedirectUri(t, n, i2, o, s = true) {
33336
33338
  let a2 = new URL(t);
@@ -33366,7 +33368,7 @@ var $t = class extends J {
33366
33368
  searchResources(t, n, i2) {
33367
33369
  let s = "searchResources-" + this.fhirSearchUrl(t, n).toString(), a2 = this.getCacheEntry(s, i2);
33368
33370
  if (a2) return a2.value;
33369
- let c = new V(this.search(t, n, i2).then(Fi));
33371
+ let c = new V(this.search(t, n, i2).then(Li));
33370
33372
  return this.setCacheEntry(s, c), c;
33371
33373
  }
33372
33374
  async *searchResourcePages(t, n, i2) {
@@ -33374,7 +33376,7 @@ var $t = class extends J {
33374
33376
  for (; o; ) {
33375
33377
  let s = new URL(o).searchParams, a2 = await this.search(t, s, i2), c = a2.link?.find((u2) => u2.relation === "next");
33376
33378
  if (!a2.entry?.length && !c) break;
33377
- yield Fi(a2), o = c?.url ? new URL(c.url) : void 0;
33379
+ yield Li(a2), o = c?.url ? new URL(c.url) : void 0;
33378
33380
  }
33379
33381
  }
33380
33382
  valueSetExpand(t, n) {
@@ -33449,8 +33451,8 @@ var $t = class extends J {
33449
33451
  target
33450
33452
  }
33451
33453
  }`.replace(/\s+/g, " "), a2 = await this.graphql(s);
33452
- yr(a2.data.StructureDefinitionList);
33453
- for (let c of a2.data.SearchParameterList) Ur(c);
33454
+ gr(a2.data.StructureDefinitionList);
33455
+ for (let c of a2.data.SearchParameterList) Br(c);
33454
33456
  })());
33455
33457
  return this.setCacheEntry(n, o), o;
33456
33458
  }
@@ -33463,14 +33465,14 @@ var $t = class extends J {
33463
33465
  let a2 = this.fhirUrl("StructureDefinition", "$expand-profile");
33464
33466
  a2.search = new URLSearchParams({ url: t }).toString();
33465
33467
  let c = await this.post(a2.toString(), {});
33466
- yr(c);
33468
+ gr(c);
33467
33469
  } else {
33468
33470
  let a2 = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
33469
33471
  if (!a2) {
33470
33472
  console.warn(`No StructureDefinition found for ${t}!`);
33471
33473
  return;
33472
33474
  }
33473
- gr(a2);
33475
+ xr(a2);
33474
33476
  }
33475
33477
  })());
33476
33478
  return this.setCacheEntry(i2, s), s;
@@ -33502,7 +33504,7 @@ var $t = class extends J {
33502
33504
  return s || (s = t), this.cacheResource(s), this.invalidateUrl(this.fhirUrl(t.resourceType, t.id, "_history")), this.invalidateSearches(t.resourceType), s;
33503
33505
  }
33504
33506
  async createAttachment(t, n, i2, o, s) {
33505
- let a2 = Li(t, n, i2, o);
33507
+ let a2 = Fi(t, n, i2, o);
33506
33508
  if (a2.contentType === w.XML) {
33507
33509
  let d2 = a2.data, m2;
33508
33510
  d2 instanceof Blob ? m2 = await new Promise((x, U) => {
@@ -33520,7 +33522,7 @@ var $t = class extends J {
33520
33522
  return { contentType: a2.contentType, url: u2.url, title: a2.filename };
33521
33523
  }
33522
33524
  createBinary(t, n, i2, o, s) {
33523
- let a2 = Li(t, n, i2, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: d2, filename: m2, securityContext: x, onProgress: U } = a2, $ = this.fhirUrl("Binary");
33525
+ let a2 = Fi(t, n, i2, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: d2, filename: m2, securityContext: x, onProgress: U } = a2, $ = this.fhirUrl("Binary");
33524
33526
  return m2 && $.searchParams.set("_filename", m2), x?.reference && this.setRequestHeader(c, "X-Security-Context", x.reference), U ? this.uploadwithProgress($, u2, d2, U, c) : this.post($, u2, d2, c);
33525
33527
  }
33526
33528
  uploadwithProgress(t, n, i2, o, s) {
@@ -33541,7 +33543,7 @@ var $t = class extends J {
33541
33543
  }
33542
33544
  async createPdf(t, n, i2, o) {
33543
33545
  if (!this.createPdfImpl) throw new Error("PDF creation not enabled");
33544
- let s = Ca(t, n, i2, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: d2, ...m2 } = s, x = await this.createPdfImpl(c, u2, d2), U = { ...m2, data: x, contentType: "application/pdf" };
33546
+ let s = Pa(t, n, i2, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: d2, ...m2 } = s, x = await this.createPdfImpl(c, u2, d2), U = { ...m2, data: x, contentType: "application/pdf" };
33545
33547
  return this.createBinary(U, a2);
33546
33548
  }
33547
33549
  createComment(t, n, i2) {
@@ -33651,7 +33653,7 @@ var $t = class extends J {
33651
33653
  async download(t, n = {}) {
33652
33654
  this.refreshPromise && await this.refreshPromise;
33653
33655
  let i2 = t.toString();
33654
- i2.startsWith(va) && (t = this.fhirUrl(i2));
33656
+ i2.startsWith(Ta) && (t = this.fhirUrl(i2));
33655
33657
  let o = n.headers;
33656
33658
  return o || (o = {}, n.headers = o), o.Accept || (o.Accept = "*/*"), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
33657
33659
  }
@@ -33680,7 +33682,7 @@ var $t = class extends J {
33680
33682
  return i2.Prefer = "respond-async", this.request("POST", t, n);
33681
33683
  }
33682
33684
  get keyValue() {
33683
- return this.keyValueClient || (this.keyValueClient = new Bt(this)), this.keyValueClient;
33685
+ return this.keyValueClient || (this.keyValueClient = new Wt(this)), this.keyValueClient;
33684
33686
  }
33685
33687
  getBundle(t, n) {
33686
33688
  return new V((async () => {
@@ -33740,10 +33742,10 @@ var $t = class extends J {
33740
33742
  for (let o = 0; o <= i2; o++) try {
33741
33743
  this.options.verbose && this.logRequest(t, n);
33742
33744
  let s = await this.fetch(t, n);
33743
- if (this.options.verbose && this.logResponse(s), this.setCurrentRateLimit(s), o >= i2 || !Pa(s)) return s;
33745
+ if (this.options.verbose && this.logResponse(s), this.setCurrentRateLimit(s), o >= i2 || !wa(s)) return s;
33744
33746
  let a2 = this.getRetryDelay(o), c = n.maxRetryTime ?? 2e3;
33745
33747
  if (a2 > c) return s;
33746
- await Mr(a2);
33748
+ await _r(a2);
33747
33749
  } catch (s) {
33748
33750
  if (s.message === "Failed to fetch" && o === 0 && this.dispatchEvent({ type: "offline" }), s.name === "AbortError" || o === i2) throw s;
33749
33751
  }
@@ -33783,7 +33785,7 @@ var $t = class extends J {
33783
33785
  if (i2.pollCount === void 0) n.headers && typeof n.headers == "object" && "Prefer" in n.headers && (o.headers = { ...n.headers }, delete o.headers.Prefer), i2.statusUrl = t, i2.pollCount = 1;
33784
33786
  else {
33785
33787
  let s = n.pollStatusPeriod ?? 1e3;
33786
- await Mr(s), i2.pollCount++;
33788
+ await _r(s), i2.pollCount++;
33787
33789
  }
33788
33790
  return this.request("GET", t, o, i2);
33789
33791
  }
@@ -33802,13 +33804,13 @@ var $t = class extends J {
33802
33804
  let n = { resourceType: "Bundle", type: "batch", entry: t.map((o) => ({ request: { method: o.method, url: o.url }, resource: o.options.body ? JSON.parse(o.options.body) : void 0 })) }, i2 = await this.post(this.fhirBaseUrl, n);
33803
33805
  for (let o = 0; o < t.length; o++) {
33804
33806
  let s = t[o], a2 = i2.entry?.[o];
33805
- a2?.response?.outcome && !lr(a2.response.outcome) ? s.reject(new p(a2.response.outcome)) : s.resolve(a2?.resource);
33807
+ a2?.response?.outcome && !dr(a2.response.outcome) ? s.reject(new p(a2.response.outcome)) : s.resolve(a2?.resource);
33806
33808
  }
33807
33809
  }
33808
33810
  addFetchOptionsDefaults(t) {
33809
33811
  Object.entries(this.defaultHeaders).forEach(([n, i2]) => {
33810
33812
  this.setRequestHeader(t, n, i2);
33811
- }), this.setRequestHeader(t, "Accept", fa, true), this.options.extendedMode !== false && this.setRequestHeader(t, "X-Medplum", "extended"), t.body && this.setRequestHeader(t, "Content-Type", w.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
33813
+ }), this.setRequestHeader(t, "Accept", ha, true), this.options.extendedMode !== false && this.setRequestHeader(t, "X-Medplum", "extended"), t.body && this.setRequestHeader(t, "Content-Type", w.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
33812
33814
  }
33813
33815
  setRequestContentType(t, n) {
33814
33816
  this.setRequestHeader(t, "Content-Type", n);
@@ -33859,10 +33861,10 @@ var $t = class extends J {
33859
33861
  return this.clientId = t, this.fetchTokens({ grant_type: Ne.JwtBearer, client_id: t, assertion: n, scope: i2 });
33860
33862
  }
33861
33863
  async startJwtAssertionLogin(t) {
33862
- return this.fetchTokens({ grant_type: Ne.ClientCredentials, client_assertion_type: Sa.JwtBearer, client_assertion: t });
33864
+ return this.fetchTokens({ grant_type: Ne.ClientCredentials, client_assertion_type: ba.JwtBearer, client_assertion: t });
33863
33865
  }
33864
33866
  setBasicAuth(t, n) {
33865
- this.clientId = t, this.clientSecret = n, this.basicAuth = $r(t + ":" + n);
33867
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Ft(t + ":" + n);
33866
33868
  }
33867
33869
  async fhircastSubscribe(t, n) {
33868
33870
  if (!(typeof t == "string" && t !== "")) throw new p(y("Invalid topic provided. Topic must be a valid string."));
@@ -33872,12 +33874,12 @@ var $t = class extends J {
33872
33874
  return i2.endpoint = s, i2;
33873
33875
  }
33874
33876
  async fhircastUnsubscribe(t) {
33875
- if (!Nt(t)) throw new p(y("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
33877
+ if (!Ut(t)) throw new p(y("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
33876
33878
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws"))) throw new p(y("Provided subscription request must have an endpoint in order to unsubscribe."));
33877
33879
  t.mode = "unsubscribe", await this.post(this.fhircastHubUrl, Jr(t), w.FORM_URL_ENCODED);
33878
33880
  }
33879
33881
  fhircastConnect(t) {
33880
- return new Lt(t);
33882
+ return new Nt(t);
33881
33883
  }
33882
33884
  async fhircastPublish(t, n, i2, o) {
33883
33885
  return Ei(n) ? this.post(this.fhircastHubUrl, Kr(t, n, i2, o), w.JSON) : (Ri(n), this.post(this.fhircastHubUrl, Kr(t, n, i2), w.JSON));
@@ -33890,7 +33892,7 @@ var $t = class extends J {
33890
33892
  }
33891
33893
  async fetchTokens(t) {
33892
33894
  let n = new URLSearchParams(t), i2 = { ...this.defaultHeaders, "Content-Type": w.FORM_URL_ENCODED };
33893
- this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`), this.credentialsInHeader && (n.delete("client_id"), n.delete("client_secret"), !this.basicAuth && t.client_id && t.client_secret && (i2.Authorization = `Basic ${$r(t.client_id + ":" + t.client_secret)}`));
33895
+ this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`), this.credentialsInHeader && (n.delete("client_id"), n.delete("client_secret"), !this.basicAuth && t.client_id && t.client_secret && (i2.Authorization = `Basic ${Ft(t.client_id + ":" + t.client_secret)}`));
33894
33896
  let o = { method: "POST", headers: i2, body: n.toString(), credentials: "include" }, s;
33895
33897
  try {
33896
33898
  s = await this.fetchWithRetry(this.tokenUrl, o);
@@ -33912,11 +33914,11 @@ var $t = class extends J {
33912
33914
  async verifyTokens(t) {
33913
33915
  let n = t.access_token;
33914
33916
  if (Pi(n)) {
33915
- let i2 = Ut(n);
33917
+ let i2 = Bt(n);
33916
33918
  if (Date.now() >= i2.exp * 1e3) throw this.clearActiveLogin(), new p(Tn);
33917
33919
  if (i2.cid) {
33918
- if (i2.cid !== this.clientId) throw this.clearActiveLogin(), new p(ur);
33919
- } else if (this.clientId && i2.client_id !== this.clientId) throw this.clearActiveLogin(), new p(ur);
33920
+ if (i2.cid !== this.clientId) throw this.clearActiveLogin(), new p(lr);
33921
+ } else if (this.clientId && i2.client_id !== this.clientId) throw this.clearActiveLogin(), new p(lr);
33920
33922
  }
33921
33923
  return this.setActiveLogin({ accessToken: n, refreshToken: t.refresh_token, project: t.project, profile: t.profile });
33922
33924
  }
@@ -33936,7 +33938,7 @@ var $t = class extends J {
33936
33938
  }
33937
33939
  }
33938
33940
  getSubscriptionManager() {
33939
- return this.subscriptionManager || (this.subscriptionManager = new jt(this, oi(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
33941
+ return this.subscriptionManager || (this.subscriptionManager = new $t(this, oi(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
33940
33942
  }
33941
33943
  subscribeToCriteria(t, n) {
33942
33944
  return this.getSubscriptionManager().addCriteria(t, n);
@@ -33948,7 +33950,7 @@ var $t = class extends J {
33948
33950
  return this.getSubscriptionManager().getMasterEmitter();
33949
33951
  }
33950
33952
  };
33951
- function ba() {
33953
+ function Ea() {
33952
33954
  if (!globalThis.fetch) throw new Error("Fetch not available in this environment");
33953
33955
  return globalThis.fetch.bind(globalThis);
33954
33956
  }
@@ -33962,32 +33964,32 @@ async function _i(r6, e) {
33962
33964
  if (n) return n;
33963
33965
  if (we(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
33964
33966
  }
33965
- function Fi(r6) {
33967
+ function Li(r6) {
33966
33968
  let e = r6.entry?.map((t) => t.resource) ?? [];
33967
33969
  return Object.assign(e, { bundle: r6 });
33968
33970
  }
33969
- function Ea(r6) {
33971
+ function Ra(r6) {
33970
33972
  return E(r6) && "data" in r6 && "contentType" in r6;
33971
33973
  }
33972
- function Li(r6, e, t, n) {
33973
- return Ea(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
33974
+ function Fi(r6, e, t, n) {
33975
+ return Ra(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
33974
33976
  }
33975
- function Ra(r6) {
33977
+ function Ca(r6) {
33976
33978
  return E(r6) && "docDefinition" in r6;
33977
33979
  }
33978
- function Ca(r6, e, t, n) {
33979
- return Ra(r6) ? r6 : { docDefinition: r6, filename: e, tableLayouts: t, fonts: n };
33980
+ function Pa(r6, e, t, n) {
33981
+ return Ca(r6) ? r6 : { docDefinition: r6, filename: e, tableLayouts: t, fonts: n };
33980
33982
  }
33981
- function Pa(r6) {
33983
+ function wa(r6) {
33982
33984
  return r6.status === 429 || r6.status >= 500;
33983
33985
  }
33984
- var Ua = [...Qe, "->", "<<", ">>", "=="];
33985
- var qa = ze().registerInfix("->", { precedence: g.Arrow }).registerInfix(";", { precedence: g.Semicolon });
33986
- var sc = " ".repeat(2);
33987
- var cc = [...Qe, "eq", "ne", "co"];
33988
- var uc = { eq: f.EXACT, ne: f.NOT_EQUALS, co: f.CONTAINS, sw: f.STARTS_WITH, ew: void 0, gt: f.GREATER_THAN, lt: f.LESS_THAN, ge: f.GREATER_THAN_OR_EQUALS, le: f.LESS_THAN_OR_EQUALS, ap: f.APPROXIMATELY, sa: f.STARTS_AFTER, eb: f.ENDS_BEFORE, pr: f.PRESENT, po: void 0, ss: void 0, sb: void 0, in: f.IN, ni: f.NOT_IN, re: f.EQUALS, identifier: f.IDENTIFIER };
33989
- var dc = ze();
33990
- var pc = { AA: "OK", AE: "Application Error", AR: "Application Reject", CA: "Commit Accept", CE: "Commit Error", CR: "Commit Reject" };
33986
+ var Ba = [...Qe, "->", "<<", ">>", "=="];
33987
+ var ja = ze().registerInfix("->", { precedence: g.Arrow }).registerInfix(";", { precedence: g.Semicolon });
33988
+ var ac = " ".repeat(2);
33989
+ var uc = [...Qe, "eq", "ne", "co"];
33990
+ var lc = { eq: f.EXACT, ne: f.NOT_EQUALS, co: f.CONTAINS, sw: f.STARTS_WITH, ew: void 0, gt: f.GREATER_THAN, lt: f.LESS_THAN, ge: f.GREATER_THAN_OR_EQUALS, le: f.LESS_THAN_OR_EQUALS, ap: f.APPROXIMATELY, sa: f.STARTS_AFTER, eb: f.ENDS_BEFORE, pr: f.PRESENT, po: void 0, ss: void 0, sb: void 0, in: f.IN, ni: f.NOT_IN, re: f.EQUALS, identifier: f.IDENTIFIER };
33991
+ var pc = ze();
33992
+ var fc = { AA: "OK", AE: "Application Error", AR: "Application Reject", CA: "Commit Accept", CE: "Commit Error", CR: "Commit Reject" };
33991
33993
  var de = class {
33992
33994
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
33993
33995
  this.segmentSeparator = e, this.fieldSeparator = t, this.componentSeparator = n, this.repetitionSeparator = i2, this.escapeCharacter = o, this.subcomponentSeparator = s;
@@ -34023,7 +34025,7 @@ var no = class r2 {
34023
34025
  }
34024
34026
  buildAck(e) {
34025
34027
  let t = /* @__PURE__ */ new Date(), n = this.getSegment("MSH"), i2 = n?.getField(3)?.toString() ?? "", o = n?.getField(4)?.toString() ?? "", s = n?.getField(5)?.toString() ?? "", a2 = n?.getField(6)?.toString() ?? "", c = n?.getField(10)?.toString() ?? "", u2 = n?.getField(12)?.toString() ?? "2.5.1", d2 = e?.ackCode ?? "AA";
34026
- return new r2([new tt(["MSH", this.context.getMsh2(), s, a2, i2, o, hc(t), "", this.buildAckMessageType(n), t.getTime().toString(), "P", u2], this.context), new tt(["MSA", d2, c, pc[d2]], this.context), ...e?.errSegment ? [e.errSegment] : []]);
34028
+ return new r2([new tt(["MSH", this.context.getMsh2(), s, a2, i2, o, mc(t), "", this.buildAckMessageType(n), t.getTime().toString(), "P", u2], this.context), new tt(["MSA", d2, c, fc[d2]], this.context), ...e?.errSegment ? [e.errSegment] : []]);
34027
34029
  }
34028
34030
  buildAckMessageType(e) {
34029
34031
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -34118,12 +34120,12 @@ var K = class r4 {
34118
34120
  return true;
34119
34121
  }
34120
34122
  };
34121
- function hc(r6) {
34123
+ function mc(r6) {
34122
34124
  let e = r6 instanceof Date ? r6 : new Date(r6), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
34123
34125
  return i2 > 0 && (n += "." + i2.toString()), n;
34124
34126
  }
34125
34127
  var Ue = { NONE: 0, ERROR: 1, WARN: 2, INFO: 3, DEBUG: 4 };
34126
- var mc = ["NONE", "ERROR", "WARN", "INFO", "DEBUG"];
34128
+ var yc = ["NONE", "ERROR", "WARN", "INFO", "DEBUG"];
34127
34129
  var io = class r5 {
34128
34130
  constructor(e, t = {}, n = Ue.INFO, i2 = {}) {
34129
34131
  this.write = e, this.metadata = t, this.level = n, this.options = i2, i2?.prefix && (this.prefix = i2.prefix), this.error = this.error.bind(this), this.warn = this.warn.bind(this), this.info = this.info.bind(this), this.debug = this.debug.bind(this), this.log = this.log.bind(this);
@@ -34150,17 +34152,17 @@ var io = class r5 {
34150
34152
  }
34151
34153
  log(e, t, n) {
34152
34154
  e > this.level || (n instanceof Error && (n = { error: n.toString(), stack: n.stack?.split(`
34153
- `) }), this.write(JSON.stringify({ level: mc[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
34155
+ `) }), this.write(JSON.stringify({ level: yc[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
34154
34156
  }
34155
34157
  };
34156
- function Bh(r6) {
34158
+ function qh(r6) {
34157
34159
  let e = Ue[r6.toUpperCase()];
34158
34160
  if (e === void 0) throw new Error(`Invalid log level: ${r6}`);
34159
34161
  return e;
34160
34162
  }
34161
- var bc = "https://meta.medplum.com/releases";
34162
- var er = /* @__PURE__ */ new Map();
34163
- function Ec(r6) {
34163
+ var Ec = "https://meta.medplum.com/releases";
34164
+ var tr = /* @__PURE__ */ new Map();
34165
+ function Rc(r6) {
34164
34166
  let e = r6;
34165
34167
  if (!e.tag_name) throw new Error("Manifest missing tag_name");
34166
34168
  let t = e.assets;
@@ -34171,9 +34173,9 @@ function Ec(r6) {
34171
34173
  }
34172
34174
  }
34173
34175
  async function dn(r6, e, t) {
34174
- let n = er.get(e ?? "latest");
34176
+ let n = tr.get(e ?? "latest");
34175
34177
  if (!n) {
34176
- let i2 = e ? `v${e}` : "latest", o = new URL(`${bc}/${i2}.json`);
34178
+ let i2 = e ? `v${e}` : "latest", o = new URL(`${Ec}/${i2}.json`);
34177
34179
  if (o.searchParams.set("a", r6), o.searchParams.set("c", Zr), t) for (let [c, u2] of Object.entries(t)) o.searchParams.set(c, u2);
34178
34180
  let s = await fetch(o.toString());
34179
34181
  if (s.status !== 200) {
@@ -34186,15 +34188,15 @@ async function dn(r6, e, t) {
34186
34188
  throw new Error(`Received status code ${s.status} while fetching manifest for version '${e ?? "latest"}'. Message: ${c}`);
34187
34189
  }
34188
34190
  let a2 = await s.json();
34189
- Ec(a2), n = a2, er.set(e ?? "latest", n), e || er.set(n.tag_name.slice(1), n);
34191
+ Rc(a2), n = a2, tr.set(e ?? "latest", n), e || tr.set(n.tag_name.slice(1), n);
34190
34192
  }
34191
34193
  return n;
34192
34194
  }
34193
- function Rc(r6) {
34195
+ function Cc(r6) {
34194
34196
  return /^\d+\.\d+\.\d+$/.test(r6);
34195
34197
  }
34196
- async function tm(r6, e) {
34197
- if (!Rc(e)) return false;
34198
+ async function nm(r6, e) {
34199
+ if (!Cc(e)) return false;
34198
34200
  try {
34199
34201
  await dn(r6, e);
34200
34202
  } catch {
@@ -34202,7 +34204,7 @@ async function tm(r6, e) {
34202
34204
  }
34203
34205
  return true;
34204
34206
  }
34205
- async function rm(r6) {
34207
+ async function im(r6) {
34206
34208
  let e = await dn(r6);
34207
34209
  if (!e.tag_name.startsWith("v")) throw new Error(`Invalid release name found. Release tag '${e.tag_name}' did not start with 'v'`);
34208
34210
  return e.tag_name.slice(1);
@@ -34785,7 +34787,7 @@ var App = class _App {
34785
34787
  webSocketUrl.protocol = webSocketUrl.protocol === "https:" ? "wss:" : "ws:";
34786
34788
  webSocketUrl.pathname = "/ws/agent";
34787
34789
  this.log.info(`Connecting to WebSocket: ${webSocketUrl.href}`);
34788
- this.webSocket = new qt(webSocketUrl.toString(), void 0, {
34790
+ this.webSocket = new jt(webSocketUrl.toString(), void 0, {
34789
34791
  WebSocket: wrapper_default,
34790
34792
  binaryType: "nodebuffer"
34791
34793
  });
@@ -34832,7 +34834,7 @@ var App = class _App {
34832
34834
  case "transmit":
34833
34835
  case "agent:transmit:response": {
34834
34836
  if (!command.callback) {
34835
- throw new Error("Transmit response missing callback");
34837
+ this.log.warn("Transmit response missing callback");
34836
34838
  }
34837
34839
  if (this.config?.status !== "active") {
34838
34840
  this.sendAgentDisabledError(command);
@@ -35095,7 +35097,7 @@ IPv6 is currently unsupported.`;
35095
35097
  this.log.error(errMsg);
35096
35098
  throw new Error(errMsg);
35097
35099
  }
35098
- if (!((0, import_node_net3.isIPv4)(message.remote) || bl(message.remote))) {
35100
+ if (!((0, import_node_net3.isIPv4)(message.remote) || El(message.remote))) {
35099
35101
  const errMsg = `Attempted to ping an invalid host.
35100
35102
 
35101
35103
  "${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
@@ -35158,7 +35160,7 @@ ${result}`);
35158
35160
  return;
35159
35161
  }
35160
35162
  let child;
35161
- if (message.version && !await tm("agent-upgrader", message.version)) {
35163
+ if (message.version && !await nm("agent-upgrader", message.version)) {
35162
35164
  const versionTag = message.version ? `v${message.version}` : "latest";
35163
35165
  const errMsg = `Error during upgrading to version '${versionTag}'. '${message.version}' is not a valid version`;
35164
35166
  this.log.error(errMsg);
@@ -35169,7 +35171,7 @@ ${result}`);
35169
35171
  });
35170
35172
  return;
35171
35173
  }
35172
- const targetVersion = message.version ?? await rm("agent-upgrader");
35174
+ const targetVersion = message.version ?? await im("agent-upgrader");
35173
35175
  if (Zr.startsWith(targetVersion)) {
35174
35176
  if (!message?.force) {
35175
35177
  this.log.info(`Attempted to upgrade to version ${targetVersion}, but agent is already on that version`);
@@ -35357,7 +35359,7 @@ async function agentMain(argv) {
35357
35359
  process.exit(1);
35358
35360
  }
35359
35361
  const { baseUrl, clientId, clientSecret, agentId } = args;
35360
- const medplum = new $t({ baseUrl, clientId });
35362
+ const medplum = new Ht({ baseUrl, clientId });
35361
35363
  let loggedIn = false;
35362
35364
  while (!loggedIn) {
35363
35365
  try {
@@ -35366,10 +35368,10 @@ async function agentMain(argv) {
35366
35368
  } catch (err) {
35367
35369
  console.error("Failed to login", { err: Ae(err) });
35368
35370
  console.log("Retrying login in 10 seconds...");
35369
- await Mr(RETRY_WAIT_DURATION_MS);
35371
+ await _r(RETRY_WAIT_DURATION_MS);
35370
35372
  }
35371
35373
  }
35372
- const app = new App(medplum, agentId, Bh(args.logLevel ?? "INFO"));
35374
+ const app = new App(medplum, agentId, qh(args.logLevel ?? "INFO"));
35373
35375
  await app.start();
35374
35376
  process.on("SIGINT", async () => {
35375
35377
  console.log("Gracefully shutting down from SIGINT (Ctrl-C)");
@@ -35509,10 +35511,10 @@ async function upgraderMain(argv) {
35509
35511
  });
35510
35512
  });
35511
35513
  import_node_process3.default.send({ type: "STARTED" });
35512
- if (argv[3] && !Rc(argv[3])) {
35514
+ if (argv[3] && !Cc(argv[3])) {
35513
35515
  throw new Error("Invalid version specified");
35514
35516
  }
35515
- const version = argv[3] ?? await rm("agent-upgrader");
35517
+ const version = argv[3] ?? await im("agent-upgrader");
35516
35518
  const binPath = getReleaseBinPath(version);
35517
35519
  if (!(0, import_node_fs6.existsSync)(binPath)) {
35518
35520
  globalLogger.info(`Could not find binary at "${binPath}". Downloading release from GitHub...`);