@medplum/agent 2.1.3 → 2.1.5

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 +778 -531
  2. package/package.json +1 -1
@@ -12,13 +12,13 @@ var __export = (target, all) => {
12
12
  for (var name in all)
13
13
  __defProp(target, name, { get: all[name], enumerable: true });
14
14
  };
15
- var __copyProps = (to, from, except, desc) => {
15
+ var __copyProps = (to2, from, except, desc) => {
16
16
  if (from && typeof from === "object" || typeof from === "function") {
17
17
  for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ if (!__hasOwnProp.call(to2, key) && key !== except)
19
+ __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
20
  }
21
- return to;
21
+ return to2;
22
22
  };
23
23
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
24
  // If the importer is in node compatibility mode or this is not an ESM
@@ -1294,9 +1294,9 @@ var require_receiver = __commonJS({
1294
1294
  }
1295
1295
  this._fragments.push(buf);
1296
1296
  }
1297
- const er = this.dataMessage();
1298
- if (er)
1299
- return cb(er);
1297
+ const er2 = this.dataMessage();
1298
+ if (er2)
1299
+ return cb(er2);
1300
1300
  this.startLoop(cb);
1301
1301
  });
1302
1302
  }
@@ -2251,7 +2251,7 @@ var require_websocket = __commonJS({
2251
2251
  var protocolVersions = [8, 13];
2252
2252
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
2253
2253
  var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
2254
- var WebSocket2 = class _WebSocket extends EventEmitter {
2254
+ var WebSocket3 = class _WebSocket extends EventEmitter {
2255
2255
  /**
2256
2256
  * Create a new `WebSocket`.
2257
2257
  *
@@ -2630,35 +2630,35 @@ var require_websocket = __commonJS({
2630
2630
  }
2631
2631
  }
2632
2632
  };
2633
- Object.defineProperty(WebSocket2, "CONNECTING", {
2633
+ Object.defineProperty(WebSocket3, "CONNECTING", {
2634
2634
  enumerable: true,
2635
2635
  value: readyStates.indexOf("CONNECTING")
2636
2636
  });
2637
- Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
2637
+ Object.defineProperty(WebSocket3.prototype, "CONNECTING", {
2638
2638
  enumerable: true,
2639
2639
  value: readyStates.indexOf("CONNECTING")
2640
2640
  });
2641
- Object.defineProperty(WebSocket2, "OPEN", {
2641
+ Object.defineProperty(WebSocket3, "OPEN", {
2642
2642
  enumerable: true,
2643
2643
  value: readyStates.indexOf("OPEN")
2644
2644
  });
2645
- Object.defineProperty(WebSocket2.prototype, "OPEN", {
2645
+ Object.defineProperty(WebSocket3.prototype, "OPEN", {
2646
2646
  enumerable: true,
2647
2647
  value: readyStates.indexOf("OPEN")
2648
2648
  });
2649
- Object.defineProperty(WebSocket2, "CLOSING", {
2649
+ Object.defineProperty(WebSocket3, "CLOSING", {
2650
2650
  enumerable: true,
2651
2651
  value: readyStates.indexOf("CLOSING")
2652
2652
  });
2653
- Object.defineProperty(WebSocket2.prototype, "CLOSING", {
2653
+ Object.defineProperty(WebSocket3.prototype, "CLOSING", {
2654
2654
  enumerable: true,
2655
2655
  value: readyStates.indexOf("CLOSING")
2656
2656
  });
2657
- Object.defineProperty(WebSocket2, "CLOSED", {
2657
+ Object.defineProperty(WebSocket3, "CLOSED", {
2658
2658
  enumerable: true,
2659
2659
  value: readyStates.indexOf("CLOSED")
2660
2660
  });
2661
- Object.defineProperty(WebSocket2.prototype, "CLOSED", {
2661
+ Object.defineProperty(WebSocket3.prototype, "CLOSED", {
2662
2662
  enumerable: true,
2663
2663
  value: readyStates.indexOf("CLOSED")
2664
2664
  });
@@ -2671,10 +2671,10 @@ var require_websocket = __commonJS({
2671
2671
  "readyState",
2672
2672
  "url"
2673
2673
  ].forEach((property) => {
2674
- Object.defineProperty(WebSocket2.prototype, property, { enumerable: true });
2674
+ Object.defineProperty(WebSocket3.prototype, property, { enumerable: true });
2675
2675
  });
2676
2676
  ["open", "error", "close", "message"].forEach((method) => {
2677
- Object.defineProperty(WebSocket2.prototype, `on${method}`, {
2677
+ Object.defineProperty(WebSocket3.prototype, `on${method}`, {
2678
2678
  enumerable: true,
2679
2679
  get() {
2680
2680
  for (const listener of this.listeners(method)) {
@@ -2698,9 +2698,9 @@ var require_websocket = __commonJS({
2698
2698
  }
2699
2699
  });
2700
2700
  });
2701
- WebSocket2.prototype.addEventListener = addEventListener;
2702
- WebSocket2.prototype.removeEventListener = removeEventListener;
2703
- module2.exports = WebSocket2;
2701
+ WebSocket3.prototype.addEventListener = addEventListener;
2702
+ WebSocket3.prototype.removeEventListener = removeEventListener;
2703
+ module2.exports = WebSocket3;
2704
2704
  function initAsClient(websocket, address, protocols, options) {
2705
2705
  const opts = {
2706
2706
  protocolVersion: protocolVersions[1],
@@ -2886,7 +2886,7 @@ var require_websocket = __commonJS({
2886
2886
  });
2887
2887
  req.on("upgrade", (res, socket, head) => {
2888
2888
  websocket.emit("upgrade", res);
2889
- if (websocket.readyState !== WebSocket2.CONNECTING)
2889
+ if (websocket.readyState !== WebSocket3.CONNECTING)
2890
2890
  return;
2891
2891
  req = websocket._req = null;
2892
2892
  if (res.headers.upgrade.toLowerCase() !== "websocket") {
@@ -2958,7 +2958,7 @@ var require_websocket = __commonJS({
2958
2958
  }
2959
2959
  }
2960
2960
  function emitErrorAndClose(websocket, err) {
2961
- websocket._readyState = WebSocket2.CLOSING;
2961
+ websocket._readyState = WebSocket3.CLOSING;
2962
2962
  websocket.emit("error", err);
2963
2963
  websocket.emitClose();
2964
2964
  }
@@ -2974,7 +2974,7 @@ var require_websocket = __commonJS({
2974
2974
  return tls.connect(options);
2975
2975
  }
2976
2976
  function abortHandshake(websocket, stream, message) {
2977
- websocket._readyState = WebSocket2.CLOSING;
2977
+ websocket._readyState = WebSocket3.CLOSING;
2978
2978
  const err = new Error(message);
2979
2979
  Error.captureStackTrace(err, abortHandshake);
2980
2980
  if (stream.setHeader) {
@@ -3055,7 +3055,7 @@ var require_websocket = __commonJS({
3055
3055
  this.removeListener("close", socketOnClose);
3056
3056
  this.removeListener("data", socketOnData);
3057
3057
  this.removeListener("end", socketOnEnd);
3058
- websocket._readyState = WebSocket2.CLOSING;
3058
+ websocket._readyState = WebSocket3.CLOSING;
3059
3059
  let chunk;
3060
3060
  if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) {
3061
3061
  websocket._receiver.write(chunk);
@@ -3077,7 +3077,7 @@ var require_websocket = __commonJS({
3077
3077
  }
3078
3078
  function socketOnEnd() {
3079
3079
  const websocket = this[kWebSocket];
3080
- websocket._readyState = WebSocket2.CLOSING;
3080
+ websocket._readyState = WebSocket3.CLOSING;
3081
3081
  websocket._receiver.end();
3082
3082
  this.end();
3083
3083
  }
@@ -3086,7 +3086,7 @@ var require_websocket = __commonJS({
3086
3086
  this.removeListener("error", socketOnError);
3087
3087
  this.on("error", NOOP);
3088
3088
  if (websocket) {
3089
- websocket._readyState = WebSocket2.CLOSING;
3089
+ websocket._readyState = WebSocket3.CLOSING;
3090
3090
  this.destroy();
3091
3091
  }
3092
3092
  }
@@ -3152,7 +3152,7 @@ var require_websocket_server = __commonJS({
3152
3152
  var extension = require_extension();
3153
3153
  var PerMessageDeflate = require_permessage_deflate();
3154
3154
  var subprotocol = require_subprotocol();
3155
- var WebSocket2 = require_websocket();
3155
+ var WebSocket3 = require_websocket();
3156
3156
  var { GUID, kWebSocket } = require_constants();
3157
3157
  var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
3158
3158
  var RUNNING = 0;
@@ -3201,7 +3201,7 @@ var require_websocket_server = __commonJS({
3201
3201
  host: null,
3202
3202
  path: null,
3203
3203
  port: null,
3204
- WebSocket: WebSocket2,
3204
+ WebSocket: WebSocket3,
3205
3205
  ...options
3206
3206
  };
3207
3207
  if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
@@ -3538,197 +3538,454 @@ __export(main_exports, {
3538
3538
  module.exports = __toCommonJS(main_exports);
3539
3539
 
3540
3540
  // ../core/dist/esm/index.mjs
3541
- var Ye = "ok";
3542
- var Xe = "created";
3543
- var et = "not-modified";
3544
- var tt = "not-found";
3545
- var ge = "accepted";
3546
- var jt = { resourceType: "OperationOutcome", id: tt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3547
- function k(r4, e) {
3541
+ var Ze = "ok";
3542
+ var et = "created";
3543
+ var rt = "not-modified";
3544
+ var nt = "not-found";
3545
+ var he = "accepted";
3546
+ var Ht = { resourceType: "OperationOutcome", id: nt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3547
+ function O(r4, e) {
3548
3548
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3549
3549
  }
3550
- function xe(r4) {
3550
+ function h(r4) {
3551
+ return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
3552
+ }
3553
+ function ye(r4) {
3551
3554
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3552
3555
  }
3553
- function rt(r4) {
3554
- return r4.id === Ye || r4.id === Xe || r4.id === et || r4.id === ge;
3556
+ function it(r4) {
3557
+ return r4.id === Ze || r4.id === et || r4.id === rt || r4.id === he;
3555
3558
  }
3556
- var h = class extends Error {
3559
+ var d = class extends Error {
3557
3560
  constructor(t, n) {
3558
- super(Qt(t));
3561
+ super(Wt(t));
3559
3562
  this.outcome = t, this.cause = n;
3560
3563
  }
3561
3564
  };
3562
- function nt(r4) {
3563
- return r4 instanceof h ? r4.outcome : xe(r4) ? r4 : k(Jr(r4));
3565
+ function ot(r4) {
3566
+ return r4 instanceof d ? r4.outcome : ye(r4) ? r4 : O(un(r4));
3564
3567
  }
3565
- function Jr(r4) {
3566
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : xe(r4) ? Qt(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3568
+ function un(r4) {
3569
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ye(r4) ? Wt(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3567
3570
  }
3568
- function Qt(r4) {
3569
- let e = r4.issue?.map(Yr) ?? [];
3571
+ function Wt(r4) {
3572
+ let e = r4.issue?.map(ln) ?? [];
3570
3573
  return e.length > 0 ? e.join("; ") : "Unknown error";
3571
3574
  }
3572
- function Yr(r4) {
3573
- let e = r4.details?.text ?? r4.diagnostics ?? "Unknown error";
3574
- return r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3575
- }
3576
- var Gt = { types: { Element: { display: "Element", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] } } }, BackboneElement: { display: "BackboneElement", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] } } }, Address: { display: "Address", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: "*", 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: { display: "Age", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { display: "Annotation", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Attachment", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "CodeableConcept", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, coding: { max: "*", type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { display: "Coding", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { display: "ContactDetail", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: "*", type: [{ code: "ContactPoint" }] } } }, ContactPoint: { display: "ContactPoint", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { display: "Contributor", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: "*", type: [{ code: "ContactDetail" }] } } }, Count: { display: "Count", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { display: "DataRequirement", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: "*", 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: "*", type: [{ code: "string" }] }, codeFilter: { max: "*", type: [{ code: "Element" }] }, dateFilter: { max: "*", type: [{ code: "Element" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: "*", type: [{ code: "Element" }] } } }, DataRequirementCodeFilter: { display: "DataRequirementCodeFilter", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] }, code: { max: "*", type: [{ code: "Coding" }] } } }, DataRequirementDateFilter: { display: "DataRequirementDateFilter", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, "value[x]": { type: [{ code: "dateTime" }, { code: "Period" }, { code: "Duration" }] } } }, DataRequirementSort: { display: "DataRequirementSort", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, direction: { min: 1, type: [{ code: "code" }] } } }, Distance: { display: "Distance", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { display: "Dosage", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: "*", 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: "*", type: [{ code: "Element" }] }, 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: { display: "DosageDoseAndRate", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Duration", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { display: "ElementDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: "*", type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: "*", type: [{ code: "Coding" }] }, slicing: { type: [{ code: "Element" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: "*", type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "Element" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: "*", type: [{ code: "Element" }] }, "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: "*", type: [{ code: "Element" }] }, "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: "*", type: [{ code: "id" }] }, constraint: { max: "*", type: [{ code: "Element" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "Element" }] }, mapping: { max: "*", type: [{ code: "Element" }] } } }, ElementDefinitionSlicing: { display: "ElementDefinitionSlicing", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, discriminator: { max: "*", type: [{ code: "Element" }] }, description: { type: [{ code: "string" }] }, ordered: { type: [{ code: "boolean" }] }, rules: { min: 1, type: [{ code: "code" }] } } }, ElementDefinitionSlicingDiscriminator: { display: "ElementDefinitionSlicingDiscriminator", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, path: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionBase: { display: "ElementDefinitionBase", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, min: { min: 1, type: [{ code: "unsignedInt" }] }, max: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionType: { display: "ElementDefinitionType", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "uri" }] }, profile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, targetProfile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, aggregation: { max: "*", type: [{ code: "code" }] }, versioning: { type: [{ code: "code" }] } } }, ElementDefinitionExample: { display: "ElementDefinitionExample", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "ElementDefinitionConstraint", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "ElementDefinitionBinding", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "ElementDefinitionMapping", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, identity: { min: 1, type: [{ code: "id" }] }, language: { type: [{ code: "code" }] }, map: { min: 1, type: [{ code: "string" }] }, comment: { type: [{ code: "string" }] } } }, Expression: { display: "Expression", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Extension", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { display: "HumanName", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: "*", type: [{ code: "string" }] }, prefix: { max: "*", type: [{ code: "string" }] }, suffix: { max: "*", type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { display: "Identifier", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "MarketingStatus", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", 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: { display: "Meta", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: "*", type: [{ code: "Coding" }] }, tag: { max: "*", type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: "*", type: [{ code: "Reference" }] } } }, Money: { display: "Money", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { display: "Narrative", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { display: "ParameterDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Period", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { display: "Population", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { display: "ProdCharacteristic", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", 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: "*", type: [{ code: "string" }] }, imprint: { max: "*", type: [{ code: "string" }] }, image: { max: "*", type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { display: "ProductShelfLife", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: "*", type: [{ code: "CodeableConcept" }] } } }, Quantity: { display: "Quantity", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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" }] } } }, Range: { display: "Range", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Ratio", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { display: "Reference", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { display: "RelatedArtifact", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "SampledData", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: { display: "Signature", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, max: "*", 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: { display: "SubstanceAmount", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "Element" }] } } }, SubstanceAmountReferenceRange: { display: "SubstanceAmountReferenceRange", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, lowLimit: { type: [{ code: "Quantity" }] }, highLimit: { type: [{ code: "Quantity" }] } } }, Timing: { display: "Timing", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, event: { max: "*", type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "Element" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TimingRepeat: { display: "TimingRepeat", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: "*", type: [{ code: "code" }] }, timeOfDay: { max: "*", type: [{ code: "time" }] }, when: { max: "*", type: [{ code: "code" }] }, offset: { type: [{ code: "unsignedInt" }] } } }, TriggerDefinition: { display: "TriggerDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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: "*", type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { display: "UsageContext", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", 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"] }] } } }, MetadataResource: { display: "MetadataResource", properties: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: "*", type: [{ code: "Resource" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: "*", type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: "*", type: [{ code: "UsageContext" }] }, jurisdiction: { max: "*", type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { display: "IdentityProvider", properties: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, useSubject: { type: [{ code: "boolean" }] } } } } };
3577
- function zt(r4, e) {
3578
- let t = [];
3579
- return r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.join(" ").trim();
3575
+ function ln(r4) {
3576
+ let e;
3577
+ return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3580
3578
  }
3581
- function ae(r4) {
3582
- let e = Yt(r4), t = ln(r4);
3579
+ function K(r4) {
3580
+ let e = Jt(r4), t = pn(r4);
3583
3581
  return t === e ? { reference: e } : { reference: e, display: t };
3584
3582
  }
3585
- function Yt(r4) {
3583
+ function Jt(r4) {
3586
3584
  return r4.resourceType + "/" + r4.id;
3587
3585
  }
3588
- function wo(r4) {
3586
+ function _o(r4) {
3589
3587
  return r4?.reference?.split("/")[1];
3590
3588
  }
3591
3589
  function dn(r4) {
3592
3590
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3593
3591
  }
3594
- function ln(r4) {
3592
+ function pn(r4) {
3595
3593
  if (dn(r4)) {
3596
- let e = pn(r4);
3594
+ let e = fn(r4);
3597
3595
  if (e)
3598
3596
  return e;
3599
3597
  }
3600
3598
  if (r4.resourceType === "Device") {
3601
- let e = fn(r4);
3599
+ let e = mn(r4);
3602
3600
  if (e)
3603
3601
  return e;
3604
3602
  }
3605
- return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : Yt(r4);
3603
+ return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : Jt(r4);
3606
3604
  }
3607
- function pn(r4) {
3605
+ function fn(r4) {
3608
3606
  let e = r4.name;
3609
3607
  if (e && e.length > 0)
3610
- return zt(e[0]);
3608
+ return be(e[0]);
3611
3609
  }
3612
- function fn(r4) {
3610
+ function mn(r4) {
3613
3611
  let e = r4.deviceName;
3614
3612
  if (e && e.length > 0)
3615
3613
  return e[0].name;
3616
3614
  }
3617
- function Te(r4, e) {
3615
+ function ge(r4, e) {
3618
3616
  let t = new Date(r4);
3619
3617
  t.setUTCHours(0, 0, 0, 0);
3620
3618
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3621
3619
  n.setUTCHours(0, 0, 0, 0);
3622
- let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), f = n.getUTCDate(), l2 = a - i2;
3623
- (c2 < o || c2 === o && f < s) && l2--;
3624
- let B = a * 12 + c2 - (i2 * 12 + o);
3625
- f < s && B--;
3626
- let Kr = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3627
- return { years: l2, months: B, days: Kr };
3620
+ let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), m2 = n.getUTCDate(), p2 = a - i2;
3621
+ (c2 < o || c2 === o && m2 < s) && p2--;
3622
+ let q = a * 12 + c2 - (i2 * 12 + o);
3623
+ m2 < s && q--;
3624
+ let cn = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3625
+ return { years: p2, months: q, days: cn };
3628
3626
  }
3629
- function tr(r4, e) {
3627
+ function Zt(r4, e) {
3630
3628
  return JSON.stringify(r4, hn, e ? 2 : void 0);
3631
3629
  }
3632
3630
  function hn(r4, e) {
3633
- return !mn(r4) && R(e) ? void 0 : e;
3631
+ return !yn(r4) && b(e) ? void 0 : e;
3634
3632
  }
3635
- function mn(r4) {
3633
+ function yn(r4) {
3636
3634
  return !!/\d+$/.exec(r4);
3637
3635
  }
3638
- function R(r4) {
3636
+ function b(r4) {
3639
3637
  if (r4 == null)
3640
3638
  return true;
3641
3639
  let e = typeof r4;
3642
3640
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3643
3641
  }
3644
- function rr(r4) {
3642
+ function er(r4) {
3645
3643
  return r4.every((e) => typeof e == "string");
3646
3644
  }
3647
- var nr = [];
3645
+ var tr = [];
3648
3646
  for (let r4 = 0; r4 < 256; r4++)
3649
- nr.push(r4.toString(16).padStart(2, "0"));
3650
- function ir(r4) {
3647
+ tr.push(r4.toString(16).padStart(2, "0"));
3648
+ function rr(r4) {
3651
3649
  let e = new Uint8Array(r4), t = new Array(e.length);
3652
3650
  for (let n = 0; n < e.length; n++)
3653
- t[n] = nr[e[n]];
3651
+ t[n] = tr[e[n]];
3654
3652
  return t.join("");
3655
3653
  }
3656
- function or(r4) {
3654
+ function nr(r4) {
3657
3655
  let e = new Uint8Array(r4), t = [];
3658
3656
  for (let n = 0; n < e.length; n++)
3659
3657
  t[n] = String.fromCharCode(e[n]);
3660
3658
  return window.btoa(t.join(""));
3661
3659
  }
3662
- function b(r4) {
3660
+ function A(r4) {
3663
3661
  return r4.charAt(0).toUpperCase() + r4.substring(1);
3664
3662
  }
3665
3663
  var ut = (r4) => new Promise((e) => {
3666
3664
  setTimeout(e, r4);
3667
3665
  });
3668
- var G = ((u2) => (u2.Address = "Address", u2.Age = "Age", u2.Annotation = "Annotation", u2.Attachment = "Attachment", u2.BackboneElement = "BackboneElement", u2.CodeableConcept = "CodeableConcept", u2.Coding = "Coding", u2.ContactDetail = "ContactDetail", u2.ContactPoint = "ContactPoint", u2.Contributor = "Contributor", u2.Count = "Count", u2.DataRequirement = "DataRequirement", u2.Distance = "Distance", u2.Dosage = "Dosage", u2.Duration = "Duration", u2.Expression = "Expression", u2.Extension = "Extension", u2.HumanName = "HumanName", u2.Identifier = "Identifier", u2.MarketingStatus = "MarketingStatus", u2.Meta = "Meta", u2.Money = "Money", u2.Narrative = "Narrative", u2.ParameterDefinition = "ParameterDefinition", u2.Period = "Period", u2.Population = "Population", u2.ProdCharacteristic = "ProdCharacteristic", u2.ProductShelfLife = "ProductShelfLife", u2.Quantity = "Quantity", u2.Range = "Range", u2.Ratio = "Ratio", u2.Reference = "Reference", u2.RelatedArtifact = "RelatedArtifact", u2.SampledData = "SampledData", u2.Signature = "Signature", u2.SubstanceAmount = "SubstanceAmount", u2.SystemString = "http://hl7.org/fhirpath/System.String", u2.Timing = "Timing", u2.TriggerDefinition = "TriggerDefinition", u2.UsageContext = "UsageContext", u2.base64Binary = "base64Binary", u2.boolean = "boolean", u2.canonical = "canonical", u2.code = "code", u2.date = "date", u2.dateTime = "dateTime", u2.decimal = "decimal", u2.id = "id", u2.instant = "instant", u2.integer = "integer", u2.markdown = "markdown", u2.oid = "oid", u2.positiveInt = "positiveInt", u2.string = "string", u2.time = "time", u2.unsignedInt = "unsignedInt", u2.uri = "uri", u2.url = "url", u2.uuid = "uuid", u2))(G || {});
3669
- function dt(r4) {
3670
- if (!r4.name)
3671
- return;
3672
- let t = r4.snapshot?.element;
3673
- if (t) {
3674
- for (let n of t)
3675
- En(r4, n);
3676
- for (let n of t)
3677
- Pn(r4, n);
3666
+ function be(r4, e) {
3667
+ let t = [];
3668
+ return r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0 && r4.text ? r4.text : t.join(" ").trim();
3669
+ }
3670
+ function Fn(r4) {
3671
+ let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
3672
+ return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
3673
+ }
3674
+ function ar(r4) {
3675
+ let e = /* @__PURE__ */ Object.create(null);
3676
+ for (let [t, n] of Object.entries(r4))
3677
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Fn(o)])), constraints: [], innerTypes: [] };
3678
+ return e;
3679
+ }
3680
+ var cr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3681
+ function l(r4) {
3682
+ return [{ type: u.boolean, value: r4 }];
3683
+ }
3684
+ function T(r4) {
3685
+ return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : R(r4) ? { type: u.Quantity, value: r4 } : _(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3686
+ }
3687
+ function N(r4) {
3688
+ return r4.length === 0 ? false : !!r4[0].value;
3689
+ }
3690
+ function V(r4, e) {
3691
+ if (r4.length !== 0) {
3692
+ if (r4.length === 1 && (!e || r4[0].type === e))
3693
+ return r4[0];
3694
+ throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3678
3695
  }
3679
3696
  }
3680
- function En(r4, e) {
3681
- let t = e.path, n = e.type?.[0]?.code;
3682
- if (n !== void 0 && n !== "Element" && n !== "BackboneElement")
3697
+ function w(r4, e) {
3698
+ if (!r4.value)
3683
3699
  return;
3684
- let i2 = t.split(".");
3685
- i2[0] = r4.name;
3686
- let o = ce(i2), s = y.types[o];
3687
- s || (y.types[o] = s = {}), s.parentType = s.parentType ?? ce(i2.slice(0, i2.length - 1)), s.display = s.display ?? o, s.structureDefinition = s.structureDefinition ?? r4, s.elementDefinition = s.elementDefinition ?? e, s.description = s.description ?? e.definition, s.properties = s.properties ?? {};
3700
+ let t = Ae(r4.type, e);
3701
+ return t ? Mn(r4, e, t) : Bn(r4, e);
3688
3702
  }
3689
- function Pn(r4, e) {
3690
- let n = e.path.split(".");
3691
- if (n.length === 1)
3703
+ function Mn(r4, e, t) {
3704
+ let n = t.type;
3705
+ if (!n || n.length === 0)
3692
3706
  return;
3693
- n[0] = r4.name;
3694
- let i2 = ce(n.slice(0, n.length - 1)), o = y.types[i2];
3695
- if (!o)
3707
+ let i2, o = "undefined";
3708
+ if (n.length === 1)
3709
+ i2 = r4.value[e], o = n[0].code;
3710
+ else
3711
+ for (let a of n) {
3712
+ let c2 = e.replace("[x]", "") + A(a.code);
3713
+ if (c2 in r4.value) {
3714
+ i2 = r4.value[c2], o = a.code;
3715
+ break;
3716
+ }
3717
+ }
3718
+ let s = r4.value["_" + e];
3719
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? pr(a ?? {}, s[c2]) : a) : i2 = pr(i2 ?? {}, s)), !b(i2))
3720
+ return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => ur(a, o)) : ur(i2, o);
3721
+ }
3722
+ function ur(r4, e) {
3723
+ return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
3724
+ }
3725
+ function Bn(r4, e) {
3726
+ let t = r4.value;
3727
+ if (!t || typeof t != "object")
3696
3728
  return;
3697
- let s = n[n.length - 1];
3698
- o.properties[s] = e;
3729
+ let n;
3730
+ if (e in t)
3731
+ n = t[e];
3732
+ else
3733
+ for (let i2 in u) {
3734
+ let o = e + A(i2);
3735
+ if (o in t) {
3736
+ n = t[o];
3737
+ break;
3738
+ }
3739
+ }
3740
+ if (!b(n))
3741
+ return Array.isArray(n) ? n.map(T) : T(n);
3699
3742
  }
3700
- function lt(r4) {
3701
- for (let e of r4.base ?? []) {
3702
- let t = y.types[e];
3703
- t && (t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4);
3743
+ function Re(r4) {
3744
+ let e = [];
3745
+ for (let t of r4) {
3746
+ let n = false;
3747
+ for (let i2 of e)
3748
+ if (N(fr(t, i2))) {
3749
+ n = true;
3750
+ break;
3751
+ }
3752
+ n || e.push(t);
3704
3753
  }
3754
+ return e;
3705
3755
  }
3706
- function z(r4) {
3707
- let e = r4.type?.[0]?.code;
3708
- return e === "BackboneElement" || e === "Element" ? ce((r4.base?.path ?? r4.path)?.split(".")) : e;
3756
+ function pt(r4) {
3757
+ return l(!N(r4));
3709
3758
  }
3710
- function ce(r4) {
3711
- return r4.length === 1 ? r4[0] : r4.map(b).join("");
3759
+ function ft(r4, e) {
3760
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => N(fr(t, e[n]))));
3712
3761
  }
3713
- function ue(r4, e) {
3714
- let t = y.types[r4];
3715
- if (!t)
3762
+ function fr(r4, e) {
3763
+ let t = r4.value?.valueOf(), n = e.value?.valueOf();
3764
+ return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(mr(t, n)) : l(typeof t == "object" && typeof n == "object" ? ht(r4, e) : t === n);
3765
+ }
3766
+ function mt(r4, e) {
3767
+ return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(lr), e.sort(lr), l(r4.every((t, n) => N(qn(t, e[n])))));
3768
+ }
3769
+ function qn(r4, e) {
3770
+ let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3771
+ return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(mr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? ht({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3772
+ }
3773
+ function lr(r4, e) {
3774
+ let t = r4.value?.valueOf(), n = e.value?.valueOf();
3775
+ return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3776
+ }
3777
+ function Ee(r4, e) {
3778
+ let { value: t } = r4;
3779
+ if (t == null)
3780
+ return false;
3781
+ switch (e) {
3782
+ case "Boolean":
3783
+ return typeof t == "boolean";
3784
+ case "Decimal":
3785
+ case "Integer":
3786
+ return typeof t == "number";
3787
+ case "Date":
3788
+ return typeof t == "string" && !!/^\d{4}(-\d{2}(-\d{2})?)?/.exec(t);
3789
+ case "DateTime":
3790
+ return typeof t == "string" && !!/^\d{4}(-\d{2}(-\d{2})?)?T/.exec(t);
3791
+ case "Time":
3792
+ return typeof t == "string" && !!/^T\d/.exec(t);
3793
+ case "Period":
3794
+ return $n(t);
3795
+ case "Quantity":
3796
+ return R(t);
3797
+ default:
3798
+ return typeof t == "object" && t?.resourceType === e;
3799
+ }
3800
+ }
3801
+ function $n(r4) {
3802
+ return !!(r4 && typeof r4 == "object" && "start" in r4);
3803
+ }
3804
+ function R(r4) {
3805
+ return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3806
+ }
3807
+ function mr(r4, e) {
3808
+ return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
3809
+ }
3810
+ function ht(r4, e) {
3811
+ let t = Object.keys(r4), n = Object.keys(e);
3812
+ if (t.length !== n.length)
3813
+ return false;
3814
+ for (let i2 of t) {
3815
+ let o = r4[i2], s = e[i2];
3816
+ if (dr(o) && dr(s)) {
3817
+ if (!ht(o, s))
3818
+ return false;
3819
+ } else if (o !== s)
3820
+ return false;
3821
+ }
3822
+ return true;
3823
+ }
3824
+ function dr(r4) {
3825
+ return r4 !== null && typeof r4 == "object";
3826
+ }
3827
+ function pr(r4, e) {
3828
+ return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3829
+ }
3830
+ function Tt(r4) {
3831
+ return new gt(r4).parse();
3832
+ }
3833
+ var j = ar(cr);
3834
+ function xr(r4) {
3835
+ let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3836
+ for (let t of e)
3837
+ jn(t);
3838
+ }
3839
+ function jn(r4) {
3840
+ if (!r4?.name)
3841
+ throw new Error("Failed loading StructureDefinition from bundle");
3842
+ if (r4.resourceType !== "StructureDefinition")
3716
3843
  return;
3717
- let n = t.properties[e] ?? t.properties[e + "[x]"];
3718
- if (n) {
3719
- if (n.contentReference) {
3720
- let i2 = n.contentReference.substring(1).split("."), o = i2.pop(), s = ce(i2);
3721
- return ue(s, o);
3844
+ let e = Tt(r4);
3845
+ j[r4.name] = e;
3846
+ for (let t of e.innerTypes)
3847
+ t.parentType = e, j[t.name] = t;
3848
+ }
3849
+ function vr(r4) {
3850
+ return !!j[r4];
3851
+ }
3852
+ function Sr(r4) {
3853
+ return j[r4];
3854
+ }
3855
+ var gt = class {
3856
+ constructor(e) {
3857
+ if (!e.snapshot?.element || e.snapshot.element.length === 0)
3858
+ throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
3859
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: e.description, elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3860
+ }
3861
+ parse() {
3862
+ let e = this.next();
3863
+ for (; e; ) {
3864
+ if (e.sliceName)
3865
+ this.parseSliceStart(e);
3866
+ else if (e.id?.includes(":")) {
3867
+ if (this.slicingContext?.current) {
3868
+ let t = yt(e, this.slicingContext.path);
3869
+ this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
3870
+ }
3871
+ } else {
3872
+ let t = this.parseElementDefinition(e);
3873
+ this.checkFieldEnter(e, t);
3874
+ let n = this.backboneContext;
3875
+ for (; n; ) {
3876
+ if (e.path?.startsWith(n.path + ".")) {
3877
+ n.type.elements[yt(e, n.path)] = t;
3878
+ break;
3879
+ }
3880
+ n = n.parent;
3881
+ }
3882
+ if (!n) {
3883
+ let i2 = yt(e, this.root.path);
3884
+ e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
3885
+ }
3886
+ this.checkFieldExit(e);
3887
+ }
3888
+ e = this.next();
3889
+ }
3890
+ return this.checkFieldExit(), this.innerTypes.length > 0 && (this.resourceSchema.innerTypes = this.innerTypes), this.resourceSchema;
3891
+ }
3892
+ checkFieldEnter(e, t) {
3893
+ this.isInnerType(e) && this.enterInnerType(e), e.slicing && !this.slicingContext && this.enterSlice(e, t);
3894
+ }
3895
+ enterInnerType(e) {
3896
+ for (; this.backboneContext && !ee(this.backboneContext?.path, e.path); )
3897
+ this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
3898
+ this.backboneContext = { type: { name: xt(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ee(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
3899
+ }
3900
+ enterSlice(e, t) {
3901
+ Wn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
3902
+ if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
3903
+ throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
3904
+ return { path: n.path, type: n.type };
3905
+ }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
3906
+ }
3907
+ checkFieldExit(e = void 0) {
3908
+ if (this.backboneContext && !ee(this.backboneContext.path, e?.path))
3909
+ if (this.backboneContext.parent)
3910
+ do
3911
+ this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
3912
+ while (this.backboneContext && !ee(this.backboneContext.path, e?.path));
3913
+ else
3914
+ this.innerTypes.push(this.backboneContext.type), delete this.backboneContext;
3915
+ this.slicingContext && !ee(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
3916
+ }
3917
+ next() {
3918
+ let e = this.peek();
3919
+ if (e)
3920
+ return this.index++, e;
3921
+ }
3922
+ peek() {
3923
+ let e = this.elements[this.index];
3924
+ if (e) {
3925
+ if (this.elementIndex[e.path ?? ""] = e, e.contentReference) {
3926
+ let t = this.elementIndex[e.contentReference.slice(e.contentReference.indexOf("#") + 1)];
3927
+ return t ? { ...t, id: e.id, path: e.path, min: e.min ?? t.min, max: e.max ?? t.max, contentReference: e.contentReference, definition: e.definition } : void 0;
3928
+ }
3929
+ return e;
3722
3930
  }
3723
- return n;
3724
3931
  }
3932
+ isInnerType(e) {
3933
+ let t = this.peek();
3934
+ return !!(ee(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
3935
+ }
3936
+ parseSliceStart(e) {
3937
+ if (!this.slicingContext)
3938
+ throw new Error("Invalid slice start before discriminator: " + e.sliceName);
3939
+ this.slicingContext.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext.current = { name: e.sliceName ?? "", type: e.type?.map((t) => ({ code: t.code ?? "", targetProfile: t.targetProfile })), elements: {}, min: e.min ?? 0, max: e.max === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(e.max, 10) };
3940
+ }
3941
+ parseElementDefinition(e) {
3942
+ let t = yr(e.max), n = e.base?.max ? yr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
3943
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? xt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: gr(w(i2, "fixed")), pattern: gr(w(i2, "pattern")), binding: e.binding };
3944
+ }
3945
+ };
3946
+ function yr(r4) {
3947
+ return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
3948
+ }
3949
+ function yt(r4, e = "") {
3950
+ return Qn(r4.path, e);
3725
3951
  }
3726
- function L(r4) {
3952
+ function Qn(r4, e) {
3953
+ return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
3954
+ }
3955
+ function ee(r4, e) {
3956
+ return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
3957
+ }
3958
+ function gr(r4) {
3959
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : b(r4) ? void 0 : r4;
3960
+ }
3961
+ function Wn(r4) {
3962
+ let e = r4.slicing?.discriminator;
3963
+ return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
3964
+ }
3965
+ var u = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
3966
+ function St(r4) {
3967
+ for (let e of r4.base ?? []) {
3968
+ let t = I.types[e];
3969
+ t || (t = { searchParamsDetails: {} }, I.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
3970
+ }
3971
+ }
3972
+ function xt(r4) {
3973
+ let e = r4.type?.[0]?.code;
3974
+ return e === "BackboneElement" || e === "Element" ? Gn((r4.base?.path ?? r4.path)?.split(".")) : e;
3975
+ }
3976
+ function Gn(r4) {
3977
+ return r4.length === 1 ? r4[0] : r4.map(A).join("");
3978
+ }
3979
+ function Ae(r4, e) {
3980
+ let t = Sr(r4);
3981
+ if (t)
3982
+ return t.elements[e] ?? t.elements[e + "[x]"];
3983
+ }
3984
+ function _(r4) {
3727
3985
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
3728
3986
  }
3729
- var y = Gt;
3730
- var kn = ((g) => (g.EQUALS = "eq", g.NOT_EQUALS = "ne", g.GREATER_THAN = "gt", g.LESS_THAN = "lt", g.GREATER_THAN_OR_EQUALS = "ge", g.LESS_THAN_OR_EQUALS = "le", g.STARTS_AFTER = "sa", g.ENDS_BEFORE = "eb", g.APPROXIMATELY = "ap", g.CONTAINS = "contains", g.EXACT = "exact", g.TEXT = "text", g.NOT = "not", g.ABOVE = "above", g.BELOW = "below", g.IN = "in", g.NOT_IN = "not-in", g.OF_TYPE = "of-type", g.MISSING = "missing", g.IDENTIFIER = "identifier", g.ITERATE = "iterate", g))(kn || {});
3731
- var Ae = class {
3987
+ var I = { types: {} };
3988
+ var Pe = class {
3732
3989
  constructor(e, t) {
3733
3990
  this.operator = e;
3734
3991
  this.child = t;
@@ -3737,7 +3994,7 @@ var Ae = class {
3737
3994
  return `${this.operator}(${this.child.toString()})`;
3738
3995
  }
3739
3996
  };
3740
- var j = class {
3997
+ var H = class {
3741
3998
  constructor(e, t, n) {
3742
3999
  this.operator = e;
3743
4000
  this.left = t;
@@ -3747,7 +4004,7 @@ var j = class {
3747
4004
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
3748
4005
  }
3749
4006
  };
3750
- var Ee = class {
4007
+ var Ce = class {
3751
4008
  constructor() {
3752
4009
  this.prefixParselets = {};
3753
4010
  this.infixParselets = {};
@@ -3771,10 +4028,10 @@ var Ee = class {
3771
4028
  }, precedence: t });
3772
4029
  }
3773
4030
  construct(e) {
3774
- return new ft(e, this.prefixParselets, this.infixParselets);
4031
+ return new bt(e, this.prefixParselets, this.infixParselets);
3775
4032
  }
3776
4033
  };
3777
- var ft = class {
4034
+ var bt = class {
3778
4035
  constructor(e, t, n) {
3779
4036
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3780
4037
  }
@@ -3825,7 +4082,7 @@ var ft = class {
3825
4082
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
3826
4083
  }
3827
4084
  };
3828
- function te(r4) {
4085
+ function re(r4) {
3829
4086
  if (r4.startsWith("T"))
3830
4087
  return r4 + "T00:00:00.000Z".substring(r4.length);
3831
4088
  if (r4.length <= 10)
@@ -3836,182 +4093,33 @@ function te(r4) {
3836
4093
  return r4;
3837
4094
  }
3838
4095
  }
3839
- function d(r4) {
3840
- return [{ type: "boolean", value: r4 }];
3841
- }
3842
- function x(r4) {
3843
- return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: "integer", value: r4 } : typeof r4 == "number" ? { type: "decimal", value: r4 } : typeof r4 == "boolean" ? { type: "boolean", value: r4 } : typeof r4 == "string" ? { type: "string", value: r4 } : A(r4) ? { type: "Quantity", value: r4 } : L(r4) ? { type: r4.resourceType, value: r4 } : { type: "BackboneElement", value: r4 };
3844
- }
3845
- function _(r4) {
3846
- return r4.length === 0 ? false : !!r4[0].value;
3847
- }
3848
- function O(r4, e) {
3849
- if (r4.length !== 0) {
3850
- if (r4.length === 1 && (!e || r4[0].type === e))
3851
- return r4[0];
3852
- throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3853
- }
3854
- }
3855
- function E(r4, e) {
3856
- if (!r4.value)
3857
- return;
3858
- let t = ue(r4.type, e);
3859
- return t ? $n(r4, e, t) : Qn(r4, e);
3860
- }
3861
- function $n(r4, e, t) {
3862
- let n = t.type;
3863
- if (!n || n.length === 0)
3864
- return;
3865
- let i2, o = "undefined";
3866
- if (n.length === 1)
3867
- i2 = r4.value[e], o = n[0].code;
3868
- else
3869
- for (let a of n) {
3870
- let c2 = e.replace("[x]", "") + b(a.code);
3871
- if (c2 in r4.value) {
3872
- i2 = r4.value[c2], o = a.code;
3873
- break;
3874
- }
3875
- }
3876
- let s = r4.value["_" + e];
3877
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? xr(a ?? {}, s[c2]) : a) : i2 = xr(i2 ?? {}, s)), !R(i2))
3878
- return (o === "Element" || o === "BackboneElement") && (o = z(t)), Array.isArray(i2) ? i2.map((a) => mr(a, o)) : mr(i2, o);
3879
- }
3880
- function mr(r4, e) {
3881
- return e === "Resource" && L(r4) && (e = r4.resourceType), { type: e, value: r4 };
3882
- }
3883
- function Qn(r4, e) {
3884
- let t = r4.value;
3885
- if (!t || typeof t != "object")
3886
- return;
3887
- let n;
3888
- if (e in t)
3889
- n = t[e];
3890
- else
3891
- for (let i2 in G) {
3892
- let o = e + b(i2);
3893
- if (o in t) {
3894
- n = t[o];
3895
- break;
3896
- }
3897
- }
3898
- if (!R(n))
3899
- return Array.isArray(n) ? n.map(x) : x(n);
3900
- }
3901
- function Pe(r4) {
3902
- let e = [];
3903
- for (let t of r4) {
3904
- let n = false;
3905
- for (let i2 of e)
3906
- if (_(Tr(t, i2))) {
3907
- n = true;
3908
- break;
3909
- }
3910
- n || e.push(t);
3911
- }
3912
- return e;
3913
- }
3914
- function ht(r4) {
3915
- return d(!_(r4));
3916
- }
3917
- function mt(r4, e) {
3918
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => _(Tr(t, e[n]))));
3919
- }
3920
- function Tr(r4, e) {
3921
- let t = r4.value?.valueOf(), n = e.value?.valueOf();
3922
- return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : A(t) && A(n) ? d(vr(t, n)) : d(typeof t == "object" && typeof n == "object" ? gt(r4, e) : t === n);
3923
- }
3924
- function yt(r4, e) {
3925
- return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(yr), e.sort(yr), d(r4.every((t, n) => _(Hn(t, e[n])))));
3926
- }
3927
- function Hn(r4, e) {
3928
- let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3929
- return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : A(s) && A(a) ? d(vr(s, a)) : d(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? gt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3930
- }
3931
- function yr(r4, e) {
3932
- let t = r4.value?.valueOf(), n = e.value?.valueOf();
3933
- return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3934
- }
3935
- function Ce(r4, e) {
3936
- let { value: t } = r4;
3937
- if (t == null)
3938
- return false;
3939
- switch (e) {
3940
- case "Boolean":
3941
- return typeof t == "boolean";
3942
- case "Decimal":
3943
- case "Integer":
3944
- return typeof t == "number";
3945
- case "Date":
3946
- return typeof t == "string" && !!/^\d{4}(-\d{2}(-\d{2})?)?/.exec(t);
3947
- case "DateTime":
3948
- return typeof t == "string" && !!/^\d{4}(-\d{2}(-\d{2})?)?T/.exec(t);
3949
- case "Time":
3950
- return typeof t == "string" && !!/^T\d/.exec(t);
3951
- case "Period":
3952
- return Wn(t);
3953
- case "Quantity":
3954
- return A(t);
3955
- default:
3956
- return typeof t == "object" && t?.resourceType === e;
3957
- }
3958
- }
3959
- function Wn(r4) {
3960
- return !!(r4 && typeof r4 == "object" && "start" in r4);
3961
- }
3962
- function A(r4) {
3963
- return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3964
- }
3965
- function vr(r4, e) {
3966
- return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
3967
- }
3968
- function gt(r4, e) {
3969
- let t = Object.keys(r4), n = Object.keys(e);
3970
- if (t.length !== n.length)
3971
- return false;
3972
- for (let i2 of t) {
3973
- let o = r4[i2], s = e[i2];
3974
- if (gr(o) && gr(s)) {
3975
- if (!gt(o, s))
3976
- return false;
3977
- } else if (o !== s)
3978
- return false;
3979
- }
3980
- return true;
3981
- }
3982
- function gr(r4) {
3983
- return r4 !== null && typeof r4 == "object";
3984
- }
3985
- function xr(r4, e) {
3986
- return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3987
- }
3988
- var de = () => [];
3989
- var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => _(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => _(t.eval(r4, [n])))), allTrue: (r4, e) => {
4096
+ var se = () => [];
4097
+ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => N(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => N(t.eval(r4, [n])))), allTrue: (r4, e) => {
3990
4098
  for (let t of e)
3991
4099
  if (!t.value)
3992
- return d(false);
3993
- return d(true);
4100
+ return l(false);
4101
+ return l(true);
3994
4102
  }, anyTrue: (r4, e) => {
3995
4103
  for (let t of e)
3996
4104
  if (t.value)
3997
- return d(true);
3998
- return d(false);
4105
+ return l(true);
4106
+ return l(false);
3999
4107
  }, allFalse: (r4, e) => {
4000
4108
  for (let t of e)
4001
4109
  if (t.value)
4002
- return d(false);
4003
- return d(true);
4110
+ return l(false);
4111
+ return l(true);
4004
4112
  }, anyFalse: (r4, e) => {
4005
4113
  for (let t of e)
4006
4114
  if (!t.value)
4007
- return d(true);
4008
- return d(false);
4009
- }, subsetOf: de, supersetOf: de, count: (r4, e) => [{ type: "integer", value: e.length }], distinct: (r4, e) => {
4115
+ return l(true);
4116
+ return l(false);
4117
+ }, subsetOf: se, supersetOf: se, count: (r4, e) => [{ type: u.integer, value: e.length }], distinct: (r4, e) => {
4010
4118
  let t = [];
4011
4119
  for (let n of e)
4012
4120
  t.some((i2) => i2.value === n.value) || t.push(n);
4013
4121
  return t;
4014
- }, isDistinct: (r4, e) => d(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => _(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: de, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4122
+ }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => N(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: se, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4015
4123
  if (e.length > 1)
4016
4124
  throw new Error("Expected input length one for single()");
4017
4125
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4043,77 +4151,77 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4043
4151
  if (!t)
4044
4152
  return e;
4045
4153
  let n = t.eval(r4, e);
4046
- return Pe([...e, ...n]);
4154
+ return Re([...e, ...n]);
4047
4155
  }, combine: (r4, e, t) => {
4048
4156
  if (!t)
4049
4157
  return e;
4050
4158
  let n = t.eval(r4, e);
4051
4159
  return [...e, ...n];
4052
- }, htmlChecks: (r4, e, t) => [x(true)], iif: (r4, e, t, n, i2) => {
4160
+ }, htmlChecks: (r4, e, t) => [T(true)], iif: (r4, e, t, n, i2) => {
4053
4161
  let o = t.eval(r4, e);
4054
4162
  if (o.length > 1 || o.length === 1 && typeof o[0].value != "boolean")
4055
4163
  throw new Error("Expected criterion to evaluate to a Boolean");
4056
- return _(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4164
+ return N(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4057
4165
  }, toBoolean: (r4, e) => {
4058
4166
  if (e.length === 0)
4059
4167
  return [];
4060
- let [{ value: t }] = U(e, 1);
4168
+ let [{ value: t }] = L(e, 1);
4061
4169
  if (typeof t == "boolean")
4062
- return [{ type: "boolean", value: t }];
4170
+ return [{ type: u.boolean, value: t }];
4063
4171
  if (typeof t == "number" && (t === 0 || t === 1))
4064
- return d(!!t);
4172
+ return l(!!t);
4065
4173
  if (typeof t == "string") {
4066
4174
  let n = t.toLowerCase();
4067
4175
  if (["true", "t", "yes", "y", "1", "1.0"].includes(n))
4068
- return d(true);
4176
+ return l(true);
4069
4177
  if (["false", "f", "no", "n", "0", "0.0"].includes(n))
4070
- return d(false);
4178
+ return l(false);
4071
4179
  }
4072
4180
  return [];
4073
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4181
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4074
4182
  if (e.length === 0)
4075
4183
  return [];
4076
- let [{ value: t }] = U(e, 1);
4077
- return typeof t == "number" ? [{ type: "integer", value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: "integer", value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: "integer", value: t ? 1 : 0 }] : [];
4078
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4184
+ let [{ value: t }] = L(e, 1);
4185
+ return typeof t == "number" ? [{ type: u.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: u.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: u.integer, value: t ? 1 : 0 }] : [];
4186
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4079
4187
  if (e.length === 0)
4080
4188
  return [];
4081
- let [{ value: t }] = U(e, 1);
4082
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "date", value: te(t) }] : [];
4083
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4189
+ let [{ value: t }] = L(e, 1);
4190
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4191
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4084
4192
  if (e.length === 0)
4085
4193
  return [];
4086
- let [{ value: t }] = U(e, 1);
4087
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "dateTime", value: te(t) }] : [];
4088
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4194
+ let [{ value: t }] = L(e, 1);
4195
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4196
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4089
4197
  if (e.length === 0)
4090
4198
  return [];
4091
- let [{ value: t }] = U(e, 1);
4092
- return typeof t == "number" ? [{ type: "decimal", value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: "decimal", value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: "decimal", value: t ? 1 : 0 }] : [];
4093
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4199
+ let [{ value: t }] = L(e, 1);
4200
+ return typeof t == "number" ? [{ type: u.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: u.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: u.decimal, value: t ? 1 : 0 }] : [];
4201
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4094
4202
  if (e.length === 0)
4095
4203
  return [];
4096
- let [{ value: t }] = U(e, 1);
4097
- return A(t) ? [{ type: "Quantity", value: t }] : typeof t == "number" ? [{ type: "Quantity", value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: "Quantity", value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: "Quantity", value: { value: t ? 1 : 0, unit: "1" } }] : [];
4098
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4204
+ let [{ value: t }] = L(e, 1);
4205
+ return R(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4206
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4099
4207
  if (e.length === 0)
4100
4208
  return [];
4101
- let [{ value: t }] = U(e, 1);
4102
- return t == null ? [] : A(t) ? [{ type: "string", value: `${t.value} '${t.unit}'` }] : [{ type: "string", value: t.toString() }];
4103
- }, convertsToString: (r4, e) => e.length === 0 ? [] : d(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4209
+ let [{ value: t }] = L(e, 1);
4210
+ return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4211
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4104
4212
  if (e.length === 0)
4105
4213
  return [];
4106
- let [{ value: t }] = U(e, 1);
4214
+ let [{ value: t }] = L(e, 1);
4107
4215
  if (typeof t == "string") {
4108
4216
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4109
4217
  if (n)
4110
- return [{ type: "time", value: te("T" + n[1]) }];
4218
+ return [{ type: u.time, value: re("T" + n[1]) }];
4111
4219
  }
4112
4220
  return [];
4113
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : d(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => C((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => C((i2, o, s) => {
4221
+ }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => P((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => P((i2, o, s) => {
4114
4222
  let a = o, c2 = s ? a + s : i2.length;
4115
4223
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4116
- }, r4, e, t, n), startsWith: (r4, e, t) => C((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => C((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => C((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => C((t) => t.toUpperCase(), r4, e), lower: (r4, e) => C((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => C((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => C((t) => t.length, r4, e), toChars: (r4, e) => C((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => V(Math.abs, r4, e), ceiling: (r4, e) => V(Math.ceil, r4, e), exp: (r4, e) => V(Math.exp, r4, e), floor: (r4, e) => V(Math.floor, r4, e), ln: (r4, e) => V(Math.log, r4, e), log: (r4, e, t) => V((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => V(Math.pow, r4, e, t), round: (r4, e) => V(Math.round, r4, e), sqrt: (r4, e) => V(Math.sqrt, r4, e), truncate: (r4, e) => V((t) => t | 0, r4, e), children: de, descendants: de, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: "dateTime", value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: "time", value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: "date", value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4224
+ }, r4, e, t, n), startsWith: (r4, e, t) => P((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => P((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => P((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => P((t) => t.toUpperCase(), r4, e), lower: (r4, e) => P((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => P((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => P((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => P((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => P((t) => t.length, r4, e), toChars: (r4, e) => P((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => U(Math.abs, r4, e), ceiling: (r4, e) => U(Math.ceil, r4, e), exp: (r4, e) => U(Math.exp, r4, e), floor: (r4, e) => U(Math.floor, r4, e), ln: (r4, e) => U(Math.log, r4, e), log: (r4, e, t) => U((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => U(Math.pow, r4, e, t), round: (r4, e) => U(Math.round, r4, e), sqrt: (r4, e) => U(Math.sqrt, r4, e), truncate: (r4, e) => U((t) => t | 0, r4, e), children: se, descendants: se, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4117
4225
  let o = S.toDateTime(r4, t.eval(r4, e));
4118
4226
  if (o.length === 0)
4119
4227
  throw new Error("Invalid start date");
@@ -4123,19 +4231,19 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4123
4231
  let a = i2.eval(r4, e)[0]?.value;
4124
4232
  if (a !== "years" && a !== "months" && a !== "days")
4125
4233
  throw new Error("Invalid units");
4126
- let c2 = Te(o[0].value, s[0].value);
4127
- return [{ type: "Quantity", value: { value: c2[a], unit: a } }];
4234
+ let c2 = ge(o[0].value, s[0].value);
4235
+ return [{ type: u.Quantity, value: { value: c2[a], unit: a } }];
4128
4236
  }, is: (r4, e, t) => {
4129
4237
  let n = "";
4130
- return t instanceof M ? n = t.name : t instanceof Q && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: "boolean", value: Ce(i2, n) })) : [];
4131
- }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: "boolean", value: !t.value })), resolve: (r4, e) => e.map((t) => {
4238
+ return t instanceof M ? n = t.name : t instanceof Q && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Ee(i2, n) })) : [];
4239
+ }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4132
4240
  let n = t.value, i2;
4133
4241
  if (typeof n == "string")
4134
4242
  i2 = n;
4135
4243
  else if (typeof n == "object") {
4136
4244
  let o = n;
4137
4245
  if (o.resource)
4138
- return x(o.resource);
4246
+ return T(o.resource);
4139
4247
  o.reference ? i2 = o.reference : o.type && o.identifier && (i2 = `${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`);
4140
4248
  }
4141
4249
  if (i2?.includes("?")) {
@@ -4146,33 +4254,33 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4146
4254
  let [o, s] = i2.split("/");
4147
4255
  return { type: o, value: { resourceType: o, id: s } };
4148
4256
  }
4149
- return { type: "BackboneElement", value: void 0 };
4150
- }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: "BackboneElement", value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: "BackboneElement", value: { namespace: "System", name: "Integer" } } : L(t) ? { type: "BackboneElement", value: { namespace: "FHIR", name: t.resourceType } } : { type: "BackboneElement", value: null }), conformsTo: (r4, e, t) => {
4257
+ return { type: u.BackboneElement, value: void 0 };
4258
+ }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: u.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: u.BackboneElement, value: { namespace: "System", name: "Integer" } } : _(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4151
4259
  let n = t.eval(r4, e)[0].value;
4152
4260
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4153
4261
  throw new Error("Expected a StructureDefinition URL");
4154
4262
  let i2 = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
4155
- return e.map((o) => ({ type: "boolean", value: o.value?.resourceType === i2 }));
4263
+ return e.map((o) => ({ type: u.boolean, value: o.value?.resourceType === i2 }));
4156
4264
  } };
4157
- function C(r4, e, t, ...n) {
4265
+ function P(r4, e, t, ...n) {
4158
4266
  if (t.length === 0)
4159
4267
  return [];
4160
- let [{ value: i2 }] = U(t, 1);
4268
+ let [{ value: i2 }] = L(t, 1);
4161
4269
  if (typeof i2 != "string")
4162
4270
  throw new Error("String function cannot be called with non-string");
4163
4271
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4164
- return o === void 0 ? [] : Array.isArray(o) ? o.map(x) : [x(o)];
4272
+ return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4165
4273
  }
4166
- function V(r4, e, t, ...n) {
4274
+ function U(r4, e, t, ...n) {
4167
4275
  if (t.length === 0)
4168
4276
  return [];
4169
- let [{ value: i2 }] = U(t, 1), o = A(i2), s = o ? i2.value : i2;
4277
+ let [{ value: i2 }] = L(t, 1), o = R(i2), s = o ? i2.value : i2;
4170
4278
  if (typeof s != "number")
4171
4279
  throw new Error("Math function cannot be called with non-number");
4172
- let a = r4(s, ...n.map((l2) => l2.eval(e, t)[0]?.value)), c2 = o ? "Quantity" : t[0].type, f = o ? { ...i2, value: a } : a;
4173
- return [{ type: c2, value: f }];
4280
+ let a = r4(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c2 = o ? u.Quantity : t[0].type, m2 = o ? { ...i2, value: a } : a;
4281
+ return [{ type: c2, value: m2 }];
4174
4282
  }
4175
- function U(r4, e) {
4283
+ function L(r4, e) {
4176
4284
  if (r4.length !== e)
4177
4285
  throw new Error(`Expected ${e} arguments`);
4178
4286
  for (let t of r4)
@@ -4180,7 +4288,7 @@ function U(r4, e) {
4180
4288
  throw new Error("Expected non-null argument");
4181
4289
  return r4;
4182
4290
  }
4183
- var I = class {
4291
+ var k = class {
4184
4292
  constructor(e) {
4185
4293
  this.value = e;
4186
4294
  }
@@ -4210,7 +4318,7 @@ var M = class {
4210
4318
  evalValue(e) {
4211
4319
  let t = e.value;
4212
4320
  if (!(!t || typeof t != "object"))
4213
- return L(t) && t.resourceType === this.name ? e : E(e, this.name);
4321
+ return _(t) && t.resourceType === this.name ? e : w(e, this.name);
4214
4322
  }
4215
4323
  toString() {
4216
4324
  return this.name;
@@ -4224,7 +4332,7 @@ var Ie = class {
4224
4332
  return "{}";
4225
4333
  }
4226
4334
  };
4227
- var ke = class extends Ae {
4335
+ var ke = class extends Pe {
4228
4336
  constructor(t, n, i2) {
4229
4337
  super(t, n);
4230
4338
  this.impl = i2;
@@ -4236,7 +4344,7 @@ var ke = class extends Ae {
4236
4344
  return this.operator + this.child.toString();
4237
4345
  }
4238
4346
  };
4239
- var K = class extends j {
4347
+ var J = class extends H {
4240
4348
  constructor(e, t) {
4241
4349
  super("as", e, t);
4242
4350
  }
@@ -4244,9 +4352,9 @@ var K = class extends j {
4244
4352
  return S.ofType(e, this.left.eval(e, t), this.right);
4245
4353
  }
4246
4354
  };
4247
- var v = class extends j {
4355
+ var v = class extends H {
4248
4356
  };
4249
- var P = class extends v {
4357
+ var E = class extends v {
4250
4358
  constructor(t, n, i2, o) {
4251
4359
  super(t, n, i2);
4252
4360
  this.impl = o;
@@ -4258,26 +4366,26 @@ var P = class extends v {
4258
4366
  let o = this.right.eval(t, n);
4259
4367
  if (o.length !== 1)
4260
4368
  return [];
4261
- let s = i2[0].value, a = o[0].value, c2 = A(s) ? s.value : s, f = A(a) ? a.value : a, l2 = this.impl(c2, f);
4262
- return typeof l2 == "boolean" ? d(l2) : A(s) ? [{ type: "Quantity", value: { ...s, value: l2 } }] : [x(l2)];
4369
+ let s = i2[0].value, a = o[0].value, c2 = R(s) ? s.value : s, m2 = R(a) ? a.value : a, p2 = this.impl(c2, m2);
4370
+ return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4263
4371
  }
4264
4372
  };
4265
- var De = class extends j {
4373
+ var Oe = class extends H {
4266
4374
  constructor(e, t) {
4267
4375
  super("&", e, t);
4268
4376
  }
4269
4377
  eval(e, t) {
4270
4378
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t), o = [...n, ...i2];
4271
- return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: "string", value: o.map((s) => s.value).join("") }] : o;
4379
+ return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: u.string, value: o.map((s) => s.value).join("") }] : o;
4272
4380
  }
4273
4381
  };
4274
- var Oe = class extends v {
4382
+ var De = class extends v {
4275
4383
  constructor(e, t) {
4276
4384
  super("contains", e, t);
4277
4385
  }
4278
4386
  eval(e, t) {
4279
4387
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4280
- return d(n.some((o) => o.value === i2[0].value));
4388
+ return l(n.some((o) => o.value === i2[0].value));
4281
4389
  }
4282
4390
  };
4283
4391
  var Ve = class extends v {
@@ -4285,11 +4393,11 @@ var Ve = class extends v {
4285
4393
  super("in", e, t);
4286
4394
  }
4287
4395
  eval(e, t) {
4288
- let n = O(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4289
- return n ? d(i2.some((o) => o.value === n.value)) : [];
4396
+ let n = V(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4397
+ return n ? l(i2.some((o) => o.value === n.value)) : [];
4290
4398
  }
4291
4399
  };
4292
- var Q = class extends j {
4400
+ var Q = class extends H {
4293
4401
  constructor(e, t) {
4294
4402
  super(".", e, t);
4295
4403
  }
@@ -4300,52 +4408,52 @@ var Q = class extends j {
4300
4408
  return `${this.left.toString()}.${this.right.toString()}`;
4301
4409
  }
4302
4410
  };
4303
- var re = class extends j {
4411
+ var ne = class extends H {
4304
4412
  constructor(e, t) {
4305
4413
  super("|", e, t);
4306
4414
  }
4307
4415
  eval(e, t) {
4308
4416
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4309
- return Pe([...n, ...i2]);
4417
+ return Re([...n, ...i2]);
4310
4418
  }
4311
4419
  };
4312
- var Ue = class extends v {
4420
+ var _e = class extends v {
4313
4421
  constructor(e, t) {
4314
4422
  super("=", e, t);
4315
4423
  }
4316
4424
  eval(e, t) {
4317
4425
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4318
- return mt(n, i2);
4426
+ return ft(n, i2);
4319
4427
  }
4320
4428
  };
4321
- var Le = class extends v {
4429
+ var Ue = class extends v {
4322
4430
  constructor(e, t) {
4323
4431
  super("!=", e, t);
4324
4432
  }
4325
4433
  eval(e, t) {
4326
4434
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4327
- return ht(mt(n, i2));
4435
+ return pt(ft(n, i2));
4328
4436
  }
4329
4437
  };
4330
- var _e = class extends v {
4438
+ var Le = class extends v {
4331
4439
  constructor(e, t) {
4332
4440
  super("~", e, t);
4333
4441
  }
4334
4442
  eval(e, t) {
4335
4443
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4336
- return yt(n, i2);
4444
+ return mt(n, i2);
4337
4445
  }
4338
4446
  };
4339
- var Me = class extends v {
4447
+ var Fe = class extends v {
4340
4448
  constructor(e, t) {
4341
4449
  super("!~", e, t);
4342
4450
  }
4343
4451
  eval(e, t) {
4344
4452
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4345
- return ht(yt(n, i2));
4453
+ return pt(mt(n, i2));
4346
4454
  }
4347
4455
  };
4348
- var J = class extends v {
4456
+ var Y = class extends v {
4349
4457
  constructor(e, t) {
4350
4458
  super("is", e, t);
4351
4459
  }
@@ -4354,7 +4462,7 @@ var J = class extends v {
4354
4462
  if (n.length !== 1)
4355
4463
  return [];
4356
4464
  let i2 = this.right.name;
4357
- return d(Ce(n[0], i2));
4465
+ return l(Ee(n[0], i2));
4358
4466
  }
4359
4467
  };
4360
4468
  var Ne = class extends v {
@@ -4362,26 +4470,26 @@ var Ne = class extends v {
4362
4470
  super("and", e, t);
4363
4471
  }
4364
4472
  eval(e, t) {
4365
- let n = O(this.left.eval(e, t), "boolean"), i2 = O(this.right.eval(e, t), "boolean");
4366
- return n?.value === true && i2?.value === true ? d(true) : n?.value === false || i2?.value === false ? d(false) : [];
4473
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4474
+ return n?.value === true && i2?.value === true ? l(true) : n?.value === false || i2?.value === false ? l(false) : [];
4367
4475
  }
4368
4476
  };
4369
- var Be = class extends v {
4477
+ var Me = class extends v {
4370
4478
  constructor(e, t) {
4371
4479
  super("or", e, t);
4372
4480
  }
4373
4481
  eval(e, t) {
4374
- let n = O(this.left.eval(e, t), "boolean"), i2 = O(this.right.eval(e, t), "boolean");
4375
- return n?.value === false && i2?.value === false ? d(false) : n?.value || i2?.value ? d(true) : [];
4482
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4483
+ return n?.value === false && i2?.value === false ? l(false) : n?.value || i2?.value ? l(true) : [];
4376
4484
  }
4377
4485
  };
4378
- var Fe = class extends v {
4486
+ var Be = class extends v {
4379
4487
  constructor(e, t) {
4380
4488
  super("xor", e, t);
4381
4489
  }
4382
4490
  eval(e, t) {
4383
- let n = O(this.left.eval(e, t), "boolean"), i2 = O(this.right.eval(e, t), "boolean");
4384
- return !n || !i2 ? [] : d(n.value !== i2.value);
4491
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4492
+ return !n || !i2 ? [] : l(n.value !== i2.value);
4385
4493
  }
4386
4494
  };
4387
4495
  var qe = class extends v {
@@ -4389,11 +4497,11 @@ var qe = class extends v {
4389
4497
  super("implies", e, t);
4390
4498
  }
4391
4499
  eval(e, t) {
4392
- let n = O(this.left.eval(e, t), "boolean"), i2 = O(this.right.eval(e, t), "boolean");
4393
- return i2?.value === true || n?.value === false ? d(true) : !n || !i2 ? [] : d(false);
4500
+ let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4501
+ return i2?.value === true || n?.value === false ? l(true) : !n || !i2 ? [] : l(false);
4394
4502
  }
4395
4503
  };
4396
- var N = class {
4504
+ var B = class {
4397
4505
  constructor(e, t) {
4398
4506
  this.name = e;
4399
4507
  this.args = t;
@@ -4408,7 +4516,7 @@ var N = class {
4408
4516
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
4409
4517
  }
4410
4518
  };
4411
- var Y = class {
4519
+ var X = class {
4412
4520
  constructor(e, t) {
4413
4521
  this.left = e;
4414
4522
  this.expr = t;
@@ -4427,60 +4535,67 @@ var Y = class {
4427
4535
  return `${this.left.toString()}[${this.expr.toString()}]`;
4428
4536
  }
4429
4537
  };
4430
- var pe = ["!=", "!~", "<=", ">=", "{}", "->"];
4431
- var p = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
4432
- var Gn = { parse(r4) {
4538
+ var ce = ["!=", "!~", "<=", ">=", "{}", "->"];
4539
+ var f = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
4540
+ var Xn = { parse(r4) {
4433
4541
  let e = r4.consumeAndParse();
4434
4542
  if (!r4.match(")"))
4435
4543
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4436
4544
  return e;
4437
4545
  } };
4438
- var zn = { parse(r4, e) {
4546
+ var Zn = { parse(r4, e) {
4439
4547
  let t = r4.consumeAndParse();
4440
4548
  if (!r4.match("]"))
4441
4549
  throw new Error("Parse error: expected `]`");
4442
- return new Y(e, t);
4443
- }, precedence: p.Indexer };
4444
- var Kn = { parse(r4, e) {
4550
+ return new X(e, t);
4551
+ }, precedence: f.Indexer };
4552
+ var ei = { parse(r4, e) {
4445
4553
  if (!(e instanceof M))
4446
4554
  throw new Error("Unexpected parentheses");
4447
4555
  let t = [];
4448
4556
  for (; !r4.match(")"); )
4449
4557
  t.push(r4.consumeAndParse()), r4.match(",");
4450
- return new N(e.name, t);
4451
- }, precedence: p.FunctionCall };
4452
- function Jn(r4) {
4558
+ return new B(e.name, t);
4559
+ }, precedence: f.FunctionCall };
4560
+ function ti(r4) {
4453
4561
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4454
4562
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4455
4563
  }
4456
- function fe() {
4457
- return new Ee().registerPrefix("String", { parse: (r4, e) => new I({ type: "string", value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new I({ type: "dateTime", value: te(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new I({ type: "Quantity", value: Jn(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new I({ type: "decimal", value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new I({ type: "boolean", value: true }) }).registerPrefix("false", { parse: () => new I({ type: "boolean", value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new Ie() }).registerPrefix("(", Gn).registerInfix("[", zn).registerInfix("(", Kn).prefix("+", p.UnaryAdd, (r4, e) => new ke("+", e, (t) => t)).prefix("-", p.UnarySubtract, (r4, e) => new P("-", e, e, (t, n) => -n)).infixLeft(".", p.Dot, (r4, e, t) => new Q(r4, t)).infixLeft("/", p.Divide, (r4, e, t) => new P("/", r4, t, (n, i2) => n / i2)).infixLeft("*", p.Multiply, (r4, e, t) => new P("*", r4, t, (n, i2) => n * i2)).infixLeft("+", p.Add, (r4, e, t) => new P("+", r4, t, (n, i2) => n + i2)).infixLeft("-", p.Subtract, (r4, e, t) => new P("-", r4, t, (n, i2) => n - i2)).infixLeft("|", p.Union, (r4, e, t) => new re(r4, t)).infixLeft("=", p.Equals, (r4, e, t) => new Ue(r4, t)).infixLeft("!=", p.NotEquals, (r4, e, t) => new Le(r4, t)).infixLeft("~", p.Equivalent, (r4, e, t) => new _e(r4, t)).infixLeft("!~", p.NotEquivalent, (r4, e, t) => new Me(r4, t)).infixLeft("<", p.LessThan, (r4, e, t) => new P("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", p.LessThanOrEquals, (r4, e, t) => new P("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", p.GreaterThan, (r4, e, t) => new P(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", p.GreaterThanOrEquals, (r4, e, t) => new P(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", p.Ampersand, (r4, e, t) => new De(r4, t)).infixLeft("and", p.And, (r4, e, t) => new Ne(r4, t)).infixLeft("as", p.As, (r4, e, t) => new K(r4, t)).infixLeft("contains", p.Contains, (r4, e, t) => new Oe(r4, t)).infixLeft("div", p.Divide, (r4, e, t) => new P("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", p.In, (r4, e, t) => new Ve(r4, t)).infixLeft("is", p.Is, (r4, e, t) => new J(r4, t)).infixLeft("mod", p.Modulo, (r4, e, t) => new P("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", p.Or, (r4, e, t) => new Be(r4, t)).infixLeft("xor", p.Xor, (r4, e, t) => new Fe(r4, t)).infixLeft("implies", p.Implies, (r4, e, t) => new qe(r4, t));
4564
+ function ue() {
4565
+ return new Ce().registerPrefix("String", { parse: (r4, e) => new k({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new k({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new k({ type: u.Quantity, value: ti(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new k({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new k({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new k({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new Ie() }).registerPrefix("(", Xn).registerInfix("[", Zn).registerInfix("(", ei).prefix("+", f.UnaryAdd, (r4, e) => new ke("+", e, (t) => t)).prefix("-", f.UnarySubtract, (r4, e) => new E("-", e, e, (t, n) => -n)).infixLeft(".", f.Dot, (r4, e, t) => new Q(r4, t)).infixLeft("/", f.Divide, (r4, e, t) => new E("/", r4, t, (n, i2) => n / i2)).infixLeft("*", f.Multiply, (r4, e, t) => new E("*", r4, t, (n, i2) => n * i2)).infixLeft("+", f.Add, (r4, e, t) => new E("+", r4, t, (n, i2) => n + i2)).infixLeft("-", f.Subtract, (r4, e, t) => new E("-", r4, t, (n, i2) => n - i2)).infixLeft("|", f.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", f.Equals, (r4, e, t) => new _e(r4, t)).infixLeft("!=", f.NotEquals, (r4, e, t) => new Ue(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Le(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new Fe(r4, t)).infixLeft("<", f.LessThan, (r4, e, t) => new E("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", f.LessThanOrEquals, (r4, e, t) => new E("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", f.GreaterThan, (r4, e, t) => new E(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", f.GreaterThanOrEquals, (r4, e, t) => new E(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", f.Ampersand, (r4, e, t) => new Oe(r4, t)).infixLeft("and", f.And, (r4, e, t) => new Ne(r4, t)).infixLeft("as", f.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", f.Contains, (r4, e, t) => new De(r4, t)).infixLeft("div", f.Divide, (r4, e, t) => new E("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", f.In, (r4, e, t) => new Ve(r4, t)).infixLeft("is", f.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", f.Modulo, (r4, e, t) => new E("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", f.Or, (r4, e, t) => new Me(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new Be(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new qe(r4, t));
4458
4566
  }
4459
- var Yn = fe();
4460
- var Sr = ((l2) => (l2.BOOLEAN = "BOOLEAN", l2.NUMBER = "NUMBER", l2.QUANTITY = "QUANTITY", l2.TEXT = "TEXT", l2.REFERENCE = "REFERENCE", l2.CANONICAL = "CANONICAL", l2.DATE = "DATE", l2.DATETIME = "DATETIME", l2.PERIOD = "PERIOD", l2.UUID = "UUID", l2))(Sr || {});
4461
- var fi = ((T) => (T.READ = "read", T.VREAD = "vread", T.UPDATE = "update", T.PATCH = "patch", T.DELETE = "delete", T.HISTORY = "history", T.HISTORY_INSTANCE = "history-instance", T.HISTORY_TYPE = "history-type", T.HISTORY_SYSTEM = "history-system", T.CREATE = "create", T.SEARCH = "search", T.SEARCH_TYPE = "search-type", T.SEARCH_SYSTEM = "search-system", T.SEARCH_COMPARTMENT = "search-compartment", T.CAPABILITIES = "capabilities", T.TRANSACTION = "transaction", T.BATCH = "batch", T.OPERATION = "operation", T))(fi || {});
4462
- function Ir(r4) {
4567
+ var ri = ue();
4568
+ var ni = ((g) => (g.EQUALS = "eq", g.NOT_EQUALS = "ne", g.GREATER_THAN = "gt", g.LESS_THAN = "lt", g.GREATER_THAN_OR_EQUALS = "ge", g.LESS_THAN_OR_EQUALS = "le", g.STARTS_AFTER = "sa", g.ENDS_BEFORE = "eb", g.APPROXIMATELY = "ap", g.CONTAINS = "contains", g.EXACT = "exact", g.TEXT = "text", g.NOT = "not", g.ABOVE = "above", g.BELOW = "below", g.IN = "in", g.NOT_IN = "not-in", g.OF_TYPE = "of-type", g.MISSING = "missing", g.IDENTIFIER = "identifier", g.ITERATE = "iterate", g))(ni || {});
4569
+ var Dr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(Dr || {});
4570
+ var ki = ((x) => (x.READ = "read", x.VREAD = "vread", x.UPDATE = "update", x.PATCH = "patch", x.DELETE = "delete", x.HISTORY = "history", x.HISTORY_INSTANCE = "history-instance", x.HISTORY_TYPE = "history-type", x.HISTORY_SYSTEM = "history-system", x.CREATE = "create", x.SEARCH = "search", x.SEARCH_TYPE = "search-type", x.SEARCH_SYSTEM = "search-system", x.SEARCH_COMPARTMENT = "search-compartment", x.CAPABILITIES = "capabilities", x.TRANSACTION = "transaction", x.BATCH = "batch", x.OPERATION = "operation", x))(ki || {});
4571
+ function Mr(r4) {
4463
4572
  if (typeof window < "u")
4464
4573
  return window.atob(r4);
4465
4574
  if (typeof Buffer < "u")
4466
4575
  return Buffer.from(r4, "base64").toString("binary");
4467
4576
  throw new Error("Unable to decode base64");
4468
4577
  }
4469
- function kr(r4) {
4578
+ function Br(r4) {
4470
4579
  if (typeof window < "u")
4471
4580
  return window.btoa(r4);
4472
4581
  if (typeof Buffer < "u")
4473
4582
  return Buffer.from(r4, "binary").toString("base64");
4474
4583
  throw new Error("Unable to encode base64");
4475
4584
  }
4476
- function bt() {
4585
+ function It() {
4477
4586
  let r4 = new Uint32Array(28);
4478
- return crypto.getRandomValues(r4), ir(r4.buffer);
4587
+ return crypto.getRandomValues(r4), rr(r4.buffer);
4479
4588
  }
4480
- async function Dr(r4) {
4589
+ async function qr(r4) {
4481
4590
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4482
4591
  }
4483
- var $e = class {
4592
+ function pe() {
4593
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
4594
+ let e = Math.random() * 16 | 0;
4595
+ return (r4 === "x" ? e : e & 3 | 8).toString(16);
4596
+ });
4597
+ }
4598
+ var He = class {
4484
4599
  constructor(e = 10) {
4485
4600
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4486
4601
  }
@@ -4504,8 +4619,8 @@ var $e = class {
4504
4619
  return this.cache.keys().next().value;
4505
4620
  }
4506
4621
  };
4507
- var X = { CSS: "text/css", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
4508
- var Qe = class {
4622
+ var F = { CSS: "text/css", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
4623
+ var fe = class {
4509
4624
  constructor() {
4510
4625
  this.listeners = {};
4511
4626
  }
@@ -4524,34 +4639,139 @@ var Qe = class {
4524
4639
  }
4525
4640
  dispatchEvent(e) {
4526
4641
  let t = this.listeners[e.type];
4527
- return t && t.forEach((n) => n.call(this, e)), !e.defaultPrevented;
4642
+ if (t)
4643
+ for (let n of t)
4644
+ n.call(this, e);
4645
+ return !e.defaultPrevented;
4646
+ }
4647
+ };
4648
+ var Qe = class {
4649
+ constructor() {
4650
+ this.emitter = new fe();
4651
+ }
4652
+ dispatchEvent(e) {
4653
+ this.emitter.dispatchEvent(e);
4654
+ }
4655
+ addEventListener(e, t) {
4656
+ this.emitter.addEventListener(e, t);
4657
+ }
4658
+ removeEventListener(e, t) {
4659
+ this.emitter.removeEventListener(e, t);
4528
4660
  }
4529
4661
  };
4530
- function Si(r4) {
4531
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Ir(e), n = Array.from(t).reduce((o, s) => {
4662
+ var kt = { "patient-open": "patient-open", "patient-close": "patient-close", "imagingstudy-open": "imagingstudy-open", "imagingstudy-close": "imagingstudy-close" };
4663
+ var Mi = ["Patient", "Encounter", "ImagingStudy"];
4664
+ var Bi = { "patient-open": ["Patient"], "patient-close": ["Patient"], "imagingstudy-open": ["Patient", "ImagingStudy"], "imagingstudy-close": ["Patient", "ImagingStudy"] };
4665
+ var qi = { "patient-open": ["Encounter"], "patient-close": ["Encounter"], "imagingstudy-open": [], "imagingstudy-close": [] };
4666
+ function $i(r4) {
4667
+ return Mi.includes(r4);
4668
+ }
4669
+ var ji = { ImagingStudy: "study", Patient: "patient", Encounter: "encounter" };
4670
+ function jr(r4) {
4671
+ return !!r4.endpoint;
4672
+ }
4673
+ function Ot(r4) {
4674
+ if (!Ge(r4))
4675
+ throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4676
+ let { channelType: e, mode: t, topic: n, events: i2 } = r4, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
4677
+ return jr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4678
+ }
4679
+ function Ge(r4) {
4680
+ if (typeof r4 != "object")
4681
+ return false;
4682
+ let { channelType: e, mode: t, topic: n, events: i2 } = r4;
4683
+ if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
4684
+ return false;
4685
+ for (let o of i2)
4686
+ if (!kt[o])
4687
+ return false;
4688
+ return !(jr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4689
+ }
4690
+ function Hi(r4, e, t, n) {
4691
+ if (!(e.key && typeof e.key == "string"))
4692
+ throw new d(h(`context[${t}] is invalid. Context must contain a key.`));
4693
+ if (n.has(e.key))
4694
+ throw new d(h(`context[${t}] is invalid. Key ${e.key} has already been used in a previous context.`));
4695
+ if (n.add(e.key), typeof e.resource != "object")
4696
+ throw new d(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
4697
+ if (!(e.resource.id && typeof e.resource.id == "string"))
4698
+ throw new d(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
4699
+ if (!e.resource.resourceType)
4700
+ throw new d(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4701
+ let i2 = e.resource.resourceType;
4702
+ if (!$i(i2))
4703
+ throw new d(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4704
+ let o = Bi[r4], s = qi[r4], a;
4705
+ if (t < o.length ? a = o[t] : t - o.length < s.length && (a = s[t - o.length]), a && i2 !== a)
4706
+ throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${a}.`));
4707
+ let c2 = ji[i2];
4708
+ if (c2 !== e.key)
4709
+ throw new d(h(`context[${t}] is invalid. Context key for type ${i2} must be ${c2}.`));
4710
+ }
4711
+ function Qi(r4, e) {
4712
+ let t = /* @__PURE__ */ new Set();
4713
+ for (let n = 0; n < e.length; n++)
4714
+ Hi(r4, e[n], n, t);
4715
+ }
4716
+ function Hr(r4, e, t) {
4717
+ if (!(r4 && typeof r4 == "string"))
4718
+ throw new d(h("Must provide a topic."));
4719
+ if (!kt[e])
4720
+ throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(kt).join(", ")}`));
4721
+ if (typeof t != "object")
4722
+ throw new d(h("context must be a context object or array of context objects."));
4723
+ let n = Array.isArray(t) ? t : [t];
4724
+ return Qi(e, n), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: pe(), event: { "hub.topic": r4, "hub.event": e, context: n } };
4725
+ }
4726
+ var We = class extends Qe {
4727
+ constructor(t) {
4728
+ super();
4729
+ if (this.subRequest = t, !t.endpoint)
4730
+ throw new d(h("Subscription request should contain an endpoint."));
4731
+ if (!Ge(t))
4732
+ throw new d(h("Subscription request failed validation."));
4733
+ let n = new WebSocket(t.endpoint);
4734
+ n.addEventListener("open", () => {
4735
+ this.dispatchEvent({ type: "connect" }), n.addEventListener("message", (i2) => {
4736
+ let o = JSON.parse(i2.data);
4737
+ if (o["hub.topic"])
4738
+ return;
4739
+ let s = o;
4740
+ this.dispatchEvent({ type: "message", payload: s }), n.send(JSON.stringify({ id: o?.id, timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
4741
+ }), n.addEventListener("close", () => {
4742
+ this.dispatchEvent({ type: "disconnect" });
4743
+ });
4744
+ }), this.websocket = n;
4745
+ }
4746
+ disconnect() {
4747
+ this.websocket.close();
4748
+ }
4749
+ };
4750
+ function Wi(r4) {
4751
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Mr(e), n = Array.from(t).reduce((o, s) => {
4532
4752
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4533
4753
  return `${o}%${a}`;
4534
4754
  }, ""), i2 = decodeURIComponent(n);
4535
4755
  return JSON.parse(i2);
4536
4756
  }
4537
- function Vr(r4) {
4757
+ function Qr(r4) {
4538
4758
  return r4.split(".").length === 3;
4539
4759
  }
4540
- function Et(r4) {
4760
+ function Dt(r4) {
4541
4761
  let [e, t, n] = r4.split(".");
4542
- return Si(t);
4762
+ return Wi(t);
4543
4763
  }
4544
- function Ur(r4) {
4764
+ function Wr(r4) {
4545
4765
  try {
4546
- return typeof Et(r4).login_id == "string";
4766
+ return typeof Dt(r4).login_id == "string";
4547
4767
  } catch {
4548
4768
  return false;
4549
4769
  }
4550
4770
  }
4551
- var bi;
4552
- var w = class {
4771
+ var Gi;
4772
+ var C = class {
4553
4773
  constructor(e) {
4554
- this[bi] = "ReadablePromise";
4774
+ this[Gi] = "ReadablePromise";
4555
4775
  this.status = "pending";
4556
4776
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4557
4777
  throw this.status = "error", this.error = t, t;
@@ -4583,10 +4803,10 @@ var w = class {
4583
4803
  return this.suspender.finally(e);
4584
4804
  }
4585
4805
  };
4586
- bi = Symbol.toStringTag;
4587
- var He = class {
4806
+ Gi = Symbol.toStringTag;
4807
+ var Ke = class {
4588
4808
  constructor() {
4589
- this.storage = typeof localStorage < "u" ? localStorage : new Pt();
4809
+ this.storage = typeof localStorage < "u" ? localStorage : new Vt();
4590
4810
  }
4591
4811
  clear() {
4592
4812
  this.storage.clear();
@@ -4602,10 +4822,10 @@ var He = class {
4602
4822
  return t ? JSON.parse(t) : void 0;
4603
4823
  }
4604
4824
  setObject(e, t) {
4605
- this.setString(e, t ? tr(t) : void 0);
4825
+ this.setString(e, t ? Zt(t) : void 0);
4606
4826
  }
4607
4827
  };
4608
- var Pt = class {
4828
+ var Vt = class {
4609
4829
  constructor() {
4610
4830
  this.data = /* @__PURE__ */ new Map();
4611
4831
  }
@@ -4628,20 +4848,20 @@ var Pt = class {
4628
4848
  return Array.from(this.data.keys())[e];
4629
4849
  }
4630
4850
  };
4631
- var Ai = "https://api.medplum.com/";
4632
- var Ei = 1e3;
4633
- var Pi = 6e4;
4634
- var Lr = "Binary/";
4635
- var _r = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4636
- var Ci = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Ci || {});
4637
- var wi = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(wi || {});
4638
- var Ii = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Ii || {});
4639
- var Mr = class extends Qe {
4851
+ var Ki = "https://api.medplum.com/";
4852
+ var zi = 1e3;
4853
+ var Ji = 6e4;
4854
+ var Gr = "Binary/";
4855
+ var Kr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4856
+ var Yi = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Yi || {});
4857
+ var Xi = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(Xi || {});
4858
+ var Zi = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Zi || {});
4859
+ var zr = class extends fe {
4640
4860
  constructor(t) {
4641
4861
  super();
4642
4862
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4643
4863
  throw new Error("Base URL must start with http or https");
4644
- this.options = t ?? {}, this.fetch = t?.fetch ?? ki(), this.storage = t?.storage ?? new He(), this.createPdfImpl = t?.createPdf, this.baseUrl = Br(t?.baseUrl ?? Ai), this.fhirBaseUrl = Br(We(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = We(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = We(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = We(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Pi, this.cacheTime > 0 ? this.requestCache = new $e(t?.resourceCacheSize ?? Ei) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0);
4864
+ this.options = t ?? {}, this.fetch = t?.fetch ?? eo(), this.storage = t?.storage ?? new Ke(), this.createPdfImpl = t?.createPdf, this.baseUrl = Yr(t?.baseUrl ?? Ki), this.fhirBaseUrl = Yr(ze(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = ze(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = ze(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = ze(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Ji, this.cacheTime > 0 ? this.requestCache = new He(t?.resourceCacheSize ?? zi) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0);
4645
4865
  let n = this.getActiveLogin();
4646
4866
  n && (this.setAccessToken(n.accessToken, n.refreshToken), this.refreshProfile().catch(console.log)), this.setupStorageListener();
4647
4867
  }
@@ -4684,7 +4904,7 @@ var Mr = class extends Qe {
4684
4904
  t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, c2) => {
4685
4905
  this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a, reject: c2 }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
4686
4906
  }) : o = this.request("GET", t, n);
4687
- let s = new w(o);
4907
+ let s = new C(o);
4688
4908
  return this.setCacheEntry(t, s), s;
4689
4909
  }
4690
4910
  post(t, n, i2, o = {}) {
@@ -4694,7 +4914,7 @@ var Mr = class extends Qe {
4694
4914
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4695
4915
  }
4696
4916
  patch(t, n, i2 = {}) {
4697
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, X.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4917
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, F.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4698
4918
  }
4699
4919
  delete(t, n) {
4700
4920
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -4760,12 +4980,12 @@ var Mr = class extends Qe {
4760
4980
  let o = this.fhirSearchUrl(t, n), s = o.toString() + "-search", a = this.getCacheEntry(s, i2);
4761
4981
  if (a)
4762
4982
  return a.value;
4763
- let c2 = new w((async () => {
4764
- let f = await this.get(o, i2);
4765
- if (f.entry)
4766
- for (let l2 of f.entry)
4767
- this.cacheResource(l2.resource);
4768
- return f;
4983
+ let c2 = new C((async () => {
4984
+ let m2 = await this.get(o, i2);
4985
+ if (m2.entry)
4986
+ for (let p2 of m2.entry)
4987
+ this.cacheResource(p2.resource);
4988
+ return m2;
4769
4989
  })());
4770
4990
  return this.setCacheEntry(s, c2), c2;
4771
4991
  }
@@ -4775,23 +4995,23 @@ var Mr = class extends Qe {
4775
4995
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
4776
4996
  if (a)
4777
4997
  return a.value;
4778
- let c2 = new w(this.search(t, o.searchParams, i2).then((f) => f.entry?.[0]?.resource));
4998
+ let c2 = new C(this.search(t, o.searchParams, i2).then((m2) => m2.entry?.[0]?.resource));
4779
4999
  return this.setCacheEntry(s, c2), c2;
4780
5000
  }
4781
5001
  searchResources(t, n, i2) {
4782
5002
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
4783
5003
  if (a)
4784
5004
  return a.value;
4785
- let c2 = new w(this.search(t, n, i2).then(qr));
5005
+ let c2 = new C(this.search(t, n, i2).then(Zr));
4786
5006
  return this.setCacheEntry(s, c2), c2;
4787
5007
  }
4788
5008
  async *searchResourcePages(t, n, i2) {
4789
5009
  let o = this.fhirSearchUrl(t, n);
4790
5010
  for (; o; ) {
4791
- let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((f) => f.relation === "next");
5011
+ let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((m2) => m2.relation === "next");
4792
5012
  if (!a.entry?.length && !c2)
4793
5013
  break;
4794
- yield qr(a), o = c2?.url ? new URL(c2.url) : void 0;
5014
+ yield Zr(a), o = c2?.url ? new URL(c2.url) : void 0;
4795
5015
  }
4796
5016
  }
4797
5017
  searchValueSet(t, n, i2) {
@@ -4807,7 +5027,7 @@ var Mr = class extends Qe {
4807
5027
  if (!n)
4808
5028
  return;
4809
5029
  if (n === "system")
4810
- return _r;
5030
+ return Kr;
4811
5031
  let [i2, o] = n.split("/");
4812
5032
  if (!(!i2 || !o))
4813
5033
  return this.getCached(i2, o);
@@ -4818,40 +5038,46 @@ var Mr = class extends Qe {
4818
5038
  readReference(t, n) {
4819
5039
  let i2 = t.reference;
4820
5040
  if (!i2)
4821
- return new w(Promise.reject(new Error("Missing reference")));
5041
+ return new C(Promise.reject(new Error("Missing reference")));
4822
5042
  if (i2 === "system")
4823
- return new w(Promise.resolve(_r));
5043
+ return new C(Promise.resolve(Kr));
4824
5044
  let [o, s] = i2.split("/");
4825
- return !o || !s ? new w(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
4826
- }
4827
- getSchema() {
4828
- return y;
5045
+ return !o || !s ? new C(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
4829
5046
  }
4830
5047
  requestSchema(t) {
4831
- if (t in y.types)
4832
- return Promise.resolve(y);
5048
+ if (vr(t))
5049
+ return Promise.resolve();
4833
5050
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
4834
5051
  if (i2)
4835
5052
  return i2.value;
4836
- let o = new w((async () => {
5053
+ let o = new C((async () => {
4837
5054
  let s = `{
4838
5055
  StructureDefinitionList(name: "${t}") {
5056
+ resourceType,
4839
5057
  name,
5058
+ kind,
4840
5059
  description,
4841
5060
  snapshot {
4842
5061
  element {
4843
5062
  id,
4844
5063
  path,
5064
+ definition,
4845
5065
  min,
4846
5066
  max,
5067
+ base {
5068
+ path,
5069
+ min,
5070
+ max
5071
+ },
5072
+ contentReference,
4847
5073
  type {
4848
5074
  code,
4849
5075
  targetProfile
4850
5076
  },
4851
5077
  binding {
5078
+ strength,
4852
5079
  valueSet
4853
- },
4854
- definition
5080
+ }
4855
5081
  }
4856
5082
  }
4857
5083
  }
@@ -4863,11 +5089,9 @@ var Mr = class extends Qe {
4863
5089
  target
4864
5090
  }
4865
5091
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
4866
- for (let c2 of a.data.StructureDefinitionList)
4867
- dt(c2);
5092
+ xr(a.data.StructureDefinitionList);
4868
5093
  for (let c2 of a.data.SearchParameterList)
4869
- lt(c2);
4870
- return y;
5094
+ St(c2);
4871
5095
  })());
4872
5096
  return this.setCacheEntry(n, o), o;
4873
5097
  }
@@ -4899,7 +5123,7 @@ var Mr = class extends Qe {
4899
5123
  uploadwithProgress(t, n, i2, o) {
4900
5124
  return new Promise((s, a) => {
4901
5125
  let c2 = new XMLHttpRequest();
4902
- c2.responseType = "json", c2.onabort = () => a(new Error("Request aborted")), c2.onerror = () => a(new Error("Request error")), o && (c2.upload.onprogress = (f) => o(f), c2.upload.onload = (f) => o(f)), c2.onload = () => {
5126
+ c2.responseType = "json", c2.onabort = () => a(new Error("Request aborted")), c2.onerror = () => a(new Error("Request error")), o && (c2.upload.onprogress = (m2) => o(m2), c2.upload.onload = (m2) => o(m2)), c2.onload = () => {
4903
5127
  c2.status >= 200 && c2.status < 300 ? s(c2.response) : a(new Error(c2.statusText));
4904
5128
  }, c2.open("POST", t), c2.withCredentials = true, c2.setRequestHeader("Authorization", "Bearer " + this.accessToken), c2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), c2.setRequestHeader("Content-Type", i2), c2.setRequestHeader("X-Medplum", "extended"), c2.send(n);
4905
5129
  });
@@ -4912,7 +5136,7 @@ var Mr = class extends Qe {
4912
5136
  }
4913
5137
  createComment(t, n, i2) {
4914
5138
  let o = this.getProfile(), s, a;
4915
- return t.resourceType === "Encounter" && (s = ae(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = ae(t)), this.createResource({ resourceType: "Communication", basedOn: [ae(t)], encounter: s, subject: a, sender: o ? ae(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5139
+ return t.resourceType === "Encounter" && (s = K(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = K(t)), this.createResource({ resourceType: "Communication", basedOn: [K(t)], encounter: s, subject: a, sender: o ? K(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
4916
5140
  }
4917
5141
  async updateResource(t, n) {
4918
5142
  if (!t.resourceType)
@@ -4947,10 +5171,10 @@ var Mr = class extends Qe {
4947
5171
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
4948
5172
  }
4949
5173
  sendEmail(t, n) {
4950
- return this.post("email/v1/send", t, X.JSON, n);
5174
+ return this.post("email/v1/send", t, F.JSON, n);
4951
5175
  }
4952
5176
  graphql(t, n, i2, o) {
4953
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, X.JSON, o);
5177
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, F.JSON, o);
4954
5178
  }
4955
5179
  readResourceGraph(t, n, i2, o) {
4956
5180
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
@@ -4968,7 +5192,7 @@ var Mr = class extends Qe {
4968
5192
  return this.accessToken;
4969
5193
  }
4970
5194
  setAccessToken(t, n) {
4971
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Ur(t);
5195
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Wr(t);
4972
5196
  }
4973
5197
  getLogins() {
4974
5198
  return this.storage.getObject("logins") ?? [];
@@ -5003,7 +5227,7 @@ var Mr = class extends Qe {
5003
5227
  return this.sessionDetails?.profile;
5004
5228
  }
5005
5229
  async getProfileAsync() {
5006
- return this.profilePromise && await this.profilePromise, this.getProfile();
5230
+ return this.profilePromise ? this.profilePromise : this.sessionDetails ? this.sessionDetails.profile : this.refreshProfile();
5007
5231
  }
5008
5232
  getUserConfiguration() {
5009
5233
  return this.sessionDetails?.config;
@@ -5014,11 +5238,11 @@ var Mr = class extends Qe {
5014
5238
  async download(t, n = {}) {
5015
5239
  this.refreshPromise && await this.refreshPromise;
5016
5240
  let i2 = t.toString();
5017
- return i2.startsWith(Lr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5241
+ return i2.startsWith(Gr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5018
5242
  }
5019
5243
  async uploadMedia(t, n, i2, o, s) {
5020
5244
  let a = await this.createBinary(t, i2, n);
5021
- return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Lr + a.id, title: i2 } }, s);
5245
+ return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Gr + a.id, title: i2 } }, s);
5022
5246
  }
5023
5247
  async bulkExport(t = "", n, i2, o) {
5024
5248
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5030,7 +5254,7 @@ var Mr = class extends Qe {
5030
5254
  i2.Prefer = "respond-async";
5031
5255
  let o = await this.fetchWithRetry(t, n);
5032
5256
  if (o.status === 202) {
5033
- let s = await Fr(o);
5257
+ let s = await Xr(o);
5034
5258
  if (s)
5035
5259
  return this.pollStatus(s);
5036
5260
  }
@@ -5047,7 +5271,7 @@ var Mr = class extends Qe {
5047
5271
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
5048
5272
  }
5049
5273
  cacheResource(t) {
5050
- t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new w(Promise.resolve(t)));
5274
+ t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new C(Promise.resolve(t)));
5051
5275
  }
5052
5276
  deleteCacheEntry(t) {
5053
5277
  this.requestCache && this.requestCache.delete(t);
@@ -5064,22 +5288,22 @@ var Mr = class extends Qe {
5064
5288
  return;
5065
5289
  let a = t.headers.get("content-type")?.includes("json");
5066
5290
  if (t.status === 404 && !a)
5067
- throw new h(jt);
5068
- let c2 = t.headers.get("content-location"), f = o.redirect ?? this.options.redirect;
5069
- if (t.status === 201 && c2 && f === "follow")
5291
+ throw new d(Ht);
5292
+ let c2 = t.headers.get("content-location"), m2 = o.redirect ?? this.options.redirect;
5293
+ if (t.status === 201 && c2 && m2 === "follow")
5070
5294
  return this.request("GET", c2, { ...o, body: void 0 });
5071
- let l2;
5295
+ let p2;
5072
5296
  if (a)
5073
5297
  try {
5074
- l2 = await t.json();
5075
- } catch (B) {
5076
- throw console.error("Error parsing response", t.status, B), B;
5298
+ p2 = await t.json();
5299
+ } catch (q) {
5300
+ throw console.error("Error parsing response", t.status, q), q;
5077
5301
  }
5078
5302
  else
5079
- l2 = await t.text();
5303
+ p2 = await t.text();
5080
5304
  if (t.status >= 400)
5081
- throw new h(nt(l2));
5082
- return l2;
5305
+ throw new d(ot(p2));
5306
+ return p2;
5083
5307
  }
5084
5308
  async fetchWithRetry(t, n) {
5085
5309
  t.startsWith("http") || (t = new URL(t, this.baseUrl).href);
@@ -5112,7 +5336,7 @@ var Mr = class extends Qe {
5112
5336
  this.addFetchOptionsDefaults(s);
5113
5337
  let a = await this.fetchWithRetry(t, s);
5114
5338
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5115
- let c2 = await Fr(a);
5339
+ let c2 = await Xr(a);
5116
5340
  c2 && (i2 = await this.fetchWithRetry(c2, s));
5117
5341
  }
5118
5342
  await ut(o);
@@ -5126,19 +5350,19 @@ var Mr = class extends Qe {
5126
5350
  try {
5127
5351
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
5128
5352
  } catch (s) {
5129
- o.reject(new h(nt(s)));
5353
+ o.reject(new d(ot(s)));
5130
5354
  }
5131
5355
  return;
5132
5356
  }
5133
5357
  let n = { resourceType: "Bundle", type: "batch", entry: t.map((o) => ({ request: { method: o.method, url: o.url }, resource: o.options.body ? JSON.parse(o.options.body) : void 0 })) }, i2 = await this.post(this.fhirBaseUrl.slice(0, -1), n);
5134
5358
  for (let o = 0; o < t.length; o++) {
5135
5359
  let s = t[o], a = i2.entry?.[o];
5136
- a?.response?.outcome && !rt(a.response.outcome) ? s.reject(new h(a.response.outcome)) : s.resolve(a?.resource);
5360
+ a?.response?.outcome && !it(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5137
5361
  }
5138
5362
  }
5139
5363
  addFetchOptionsDefaults(t) {
5140
5364
  let n = t.headers;
5141
- n || (n = {}, t.headers = n), n.Accept = X.FHIR_JSON, n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = X.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
5365
+ n || (n = {}, t.headers = n), n.Accept = F.FHIR_JSON, n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = F.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
5142
5366
  }
5143
5367
  setRequestContentType(t, n) {
5144
5368
  t.headers || (t.headers = {});
@@ -5152,20 +5376,20 @@ var Mr = class extends Qe {
5152
5376
  return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
5153
5377
  }
5154
5378
  async startPkce() {
5155
- let t = bt();
5379
+ let t = It();
5156
5380
  sessionStorage.setItem("pkceState", t);
5157
- let n = bt();
5381
+ let n = It();
5158
5382
  sessionStorage.setItem("codeVerifier", n);
5159
- let i2 = await Dr(n), o = or(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5383
+ let i2 = await qr(n), o = nr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5160
5384
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5161
5385
  }
5162
5386
  async requestAuthorization(t) {
5163
5387
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
5164
- i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Nr()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
5388
+ i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Jr()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
5165
5389
  }
5166
5390
  processCode(t, n) {
5167
5391
  let i2 = new URLSearchParams();
5168
- if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Nr()), typeof sessionStorage < "u") {
5392
+ if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Jr()), typeof sessionStorage < "u") {
5169
5393
  let o = sessionStorage.getItem("codeVerifier");
5170
5394
  o && i2.set("code_verifier", o);
5171
5395
  }
@@ -5196,22 +5420,45 @@ var Mr = class extends Qe {
5196
5420
  return n.append("grant_type", "client_credentials"), n.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.append("client_assertion", t), this.fetchTokens(n);
5197
5421
  }
5198
5422
  setBasicAuth(t, n) {
5199
- this.clientId = t, this.clientSecret = n, this.basicAuth = kr(t + ":" + n);
5423
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Br(t + ":" + n);
5424
+ }
5425
+ async fhircastSubscribe(t, n) {
5426
+ if (!(typeof t == "string" && t !== ""))
5427
+ throw new d(h("Invalid topic provided. Topic must be a valid string."));
5428
+ if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
5429
+ throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5430
+ let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU2", Ot(i2), F.FORM_URL_ENCODED))["hub.channel.endpoint"];
5431
+ if (!s)
5432
+ throw new Error("Invalid response!");
5433
+ return i2.endpoint = s, i2;
5434
+ }
5435
+ async fhircastUnsubscribe(t) {
5436
+ if (!Ge(t))
5437
+ throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5438
+ if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
5439
+ throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5440
+ t.mode = "unsubscribe", await this.post("/fhircast/STU2", Ot(t), F.FORM_URL_ENCODED);
5441
+ }
5442
+ fhircastConnect(t) {
5443
+ return new We(t);
5444
+ }
5445
+ async fhircastPublish(t, n, i2) {
5446
+ return this.post(`/fhircast/STU2/${t}`, Hr(t, n, i2), F.JSON);
5200
5447
  }
5201
5448
  async invite(t, n) {
5202
5449
  return this.post("admin/projects/" + t + "/invite", n);
5203
5450
  }
5204
5451
  async fetchTokens(t) {
5205
- let n = { method: "POST", headers: { "Content-Type": X.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5452
+ let n = { method: "POST", headers: { "Content-Type": F.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5206
5453
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5207
5454
  let o = await this.fetchWithRetry(this.tokenUrl, n);
5208
5455
  if (!o.ok) {
5209
5456
  this.clearActiveLogin();
5210
5457
  try {
5211
5458
  let a = await o.json();
5212
- throw new h(k(a.error_description));
5459
+ throw new d(O(a.error_description));
5213
5460
  } catch (a) {
5214
- throw new h(k("Failed to fetch tokens"), a);
5461
+ throw new d(O("Failed to fetch tokens"), a);
5215
5462
  }
5216
5463
  }
5217
5464
  let s = await o.json();
@@ -5219,8 +5466,8 @@ var Mr = class extends Qe {
5219
5466
  }
5220
5467
  async verifyTokens(t) {
5221
5468
  let n = t.access_token;
5222
- if (Vr(n)) {
5223
- let i2 = Et(n);
5469
+ if (Qr(n)) {
5470
+ let i2 = Dt(n);
5224
5471
  if (Date.now() >= i2.exp * 1e3)
5225
5472
  throw this.clearActiveLogin(), new Error("Token expired");
5226
5473
  if (i2.cid) {
@@ -5244,21 +5491,21 @@ var Mr = class extends Qe {
5244
5491
  throw i2;
5245
5492
  }
5246
5493
  };
5247
- function ki() {
5494
+ function eo() {
5248
5495
  if (!globalThis.fetch)
5249
5496
  throw new Error("Fetch not available in this environment");
5250
5497
  return globalThis.fetch.bind(globalThis);
5251
5498
  }
5252
- function Nr() {
5499
+ function Jr() {
5253
5500
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5254
5501
  }
5255
- function Br(r4) {
5502
+ function Yr(r4) {
5256
5503
  return r4.endsWith("/") ? r4 : r4 + "/";
5257
5504
  }
5258
- function We(r4, e) {
5505
+ function ze(r4, e) {
5259
5506
  return new URL(e, r4).toString();
5260
5507
  }
5261
- async function Fr(r4) {
5508
+ async function Xr(r4) {
5262
5509
  let e = r4.headers.get("content-location");
5263
5510
  if (e)
5264
5511
  return e;
@@ -5266,18 +5513,18 @@ async function Fr(r4) {
5266
5513
  if (t)
5267
5514
  return t;
5268
5515
  let n = await r4.json();
5269
- if (xe(n) && n.issue?.[0]?.diagnostics)
5516
+ if (ye(n) && n.issue?.[0]?.diagnostics)
5270
5517
  return n.issue[0].diagnostics;
5271
5518
  }
5272
- function qr(r4) {
5519
+ function Zr(r4) {
5273
5520
  let e = r4.entry?.map((t) => t.resource) ?? [];
5274
5521
  return Object.assign(e, { bundle: r4 });
5275
5522
  }
5276
- var Di = [...pe, "->", "<<", ">>"];
5277
- var Oi = fe().registerInfix("->", { precedence: p.Arrow }).registerInfix(";", { precedence: p.Semicolon });
5278
- var Vi = [...pe, "eq", "ne", "co"];
5279
- var _i = fe();
5280
- var H = class {
5523
+ var to = [...ce, "->", "<<", ">>"];
5524
+ var ro = ue().registerInfix("->", { precedence: f.Arrow }).registerInfix(";", { precedence: f.Semicolon });
5525
+ var no = [...ce, "eq", "ne", "co"];
5526
+ var so = ue();
5527
+ var G = class {
5281
5528
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5282
5529
  this.segmentSeparator = e;
5283
5530
  this.fieldSeparator = t;
@@ -5293,8 +5540,8 @@ var H = class {
5293
5540
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5294
5541
  }
5295
5542
  };
5296
- var Qr = class r {
5297
- constructor(e, t = new H()) {
5543
+ var nn = class r {
5544
+ constructor(e, t = new G()) {
5298
5545
  this.context = t, this.segments = e;
5299
5546
  }
5300
5547
  get header() {
@@ -5317,7 +5564,7 @@ var Qr = class r {
5317
5564
  }
5318
5565
  buildAck() {
5319
5566
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i2 = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a = t?.getField(10)?.toString() ?? "", c2 = t?.getField(12)?.toString() ?? "2.5.1";
5320
- return new r([new me(["MSH", this.context.getMsh2(), o, s, n, i2, Ni(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new me(["MSA", "AA", a, "OK"], this.context)]);
5567
+ return new r([new me(["MSH", this.context.getMsh2(), o, s, n, i2, co(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new me(["MSA", "AA", a, "OK"], this.context)]);
5321
5568
  }
5322
5569
  buildAckMessageType(e) {
5323
5570
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5328,13 +5575,13 @@ var Qr = class r {
5328
5575
  let n = new Error("Invalid HL7 message");
5329
5576
  throw n.type = "entity.parse.failed", n;
5330
5577
  }
5331
- let t = new H("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5578
+ let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5332
5579
  return new r(e.split(/[\r\n]+/).map((n) => me.parse(n, t)), t);
5333
5580
  }
5334
5581
  };
5335
5582
  var me = class r2 {
5336
- constructor(e, t = new H()) {
5337
- this.context = t, rr(e) ? this.fields = e.map((n) => ie.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5583
+ constructor(e, t = new G()) {
5584
+ this.context = t, er(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5338
5585
  }
5339
5586
  get(e) {
5340
5587
  return this.fields[e];
@@ -5342,9 +5589,9 @@ var me = class r2 {
5342
5589
  getField(e) {
5343
5590
  if (this.name === "MSH") {
5344
5591
  if (e === 1)
5345
- return new ie([[this.context.getMsh1()]], this.context);
5592
+ return new oe([[this.context.getMsh1()]], this.context);
5346
5593
  if (e === 2)
5347
- return new ie([[this.context.getMsh2()]], this.context);
5594
+ return new oe([[this.context.getMsh2()]], this.context);
5348
5595
  if (e > 2)
5349
5596
  return this.fields[e - 1];
5350
5597
  }
@@ -5356,12 +5603,12 @@ var me = class r2 {
5356
5603
  toString() {
5357
5604
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
5358
5605
  }
5359
- static parse(e, t = new H()) {
5360
- return new r2(e.split(t.fieldSeparator).map((n) => ie.parse(n, t)), t);
5606
+ static parse(e, t = new G()) {
5607
+ return new r2(e.split(t.fieldSeparator).map((n) => oe.parse(n, t)), t);
5361
5608
  }
5362
5609
  };
5363
- var ie = class r3 {
5364
- constructor(e, t = new H()) {
5610
+ var oe = class r3 {
5611
+ constructor(e, t = new G()) {
5365
5612
  this.context = t, this.components = e;
5366
5613
  }
5367
5614
  get(e, t, n = 0) {
@@ -5374,11 +5621,11 @@ var ie = class r3 {
5374
5621
  toString() {
5375
5622
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
5376
5623
  }
5377
- static parse(e, t = new H()) {
5624
+ static parse(e, t = new G()) {
5378
5625
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5379
5626
  }
5380
5627
  };
5381
- function Ni(r4) {
5628
+ function co(r4) {
5382
5629
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5383
5630
  return i2 > 0 && (n += "." + i2.toString()), n;
5384
5631
  }
@@ -5394,7 +5641,7 @@ var i = class extends EventTarget {
5394
5641
  }
5395
5642
  };
5396
5643
  var m = String.fromCharCode(11);
5397
- var p2 = String.fromCharCode(28);
5644
+ var p = String.fromCharCode(28);
5398
5645
  var v2 = String.fromCharCode(13);
5399
5646
  var d2 = class extends Event {
5400
5647
  constructor(e, t) {
@@ -5403,7 +5650,7 @@ var d2 = class extends Event {
5403
5650
  this.message = t;
5404
5651
  }
5405
5652
  };
5406
- var l = class extends Event {
5653
+ var l2 = class extends Event {
5407
5654
  constructor(e) {
5408
5655
  super("error");
5409
5656
  this.error = e;
@@ -5417,19 +5664,19 @@ var c = class extends i {
5417
5664
  let o = "";
5418
5665
  e.on("data", (s) => {
5419
5666
  try {
5420
- if (o += s.toString(), o.endsWith(p2 + v2)) {
5421
- let r4 = Qr.parse(o.substring(1, o.length - 2));
5667
+ if (o += s.toString(), o.endsWith(p + v2)) {
5668
+ let r4 = nn.parse(o.substring(1, o.length - 2));
5422
5669
  this.dispatchEvent(new d2(this, r4)), o = "";
5423
5670
  }
5424
5671
  } catch (r4) {
5425
- this.dispatchEvent(new l(r4));
5672
+ this.dispatchEvent(new l2(r4));
5426
5673
  }
5427
5674
  }).setEncoding(t ?? "utf-8"), e.on("error", (s) => {
5428
- o = "", this.dispatchEvent(new l(s));
5675
+ o = "", this.dispatchEvent(new l2(s));
5429
5676
  });
5430
5677
  }
5431
5678
  send(e) {
5432
- this.socket.write(m + e.toString() + p2 + v2);
5679
+ this.socket.write(m + e.toString() + p + v2);
5433
5680
  }
5434
5681
  async sendAndWait(e) {
5435
5682
  let t = new Promise((o) => {
@@ -5546,7 +5793,7 @@ var AgentHl7ChannelConnection = class {
5546
5793
  type: "connect",
5547
5794
  accessToken: medplum.getAccessToken(),
5548
5795
  agentId: channel.app.agentId,
5549
- botId: wo(channel.definition.targetReference)
5796
+ botId: _o(channel.definition.targetReference)
5550
5797
  })
5551
5798
  );
5552
5799
  });
@@ -5562,7 +5809,7 @@ var AgentHl7ChannelConnection = class {
5562
5809
  this.trySendToWebSocket();
5563
5810
  break;
5564
5811
  case "transmit":
5565
- this.hl7ConnectionQueue.push(Qr.parse(command.message));
5812
+ this.hl7ConnectionQueue.push(nn.parse(command.message));
5566
5813
  this.trySendToHl7Connection();
5567
5814
  break;
5568
5815
  }
@@ -5616,7 +5863,7 @@ if (typeof require !== "undefined" && require.main === module) {
5616
5863
  process.exit(1);
5617
5864
  }
5618
5865
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
5619
- const medplum = new Mr({ baseUrl, clientId });
5866
+ const medplum = new zr({ baseUrl, clientId });
5620
5867
  medplum.startClientLogin(clientId, clientSecret).then(() => new App(medplum, agentId).start()).catch(console.error);
5621
5868
  }
5622
5869
  // Annotate the CommonJS export names for ESM import in node: