@medplum/agent 2.1.4 → 2.1.6

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.
@@ -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
@@ -878,6 +878,7 @@ var require_receiver = __commonJS({
878
878
  var { isValidStatusCode, isValidUTF8 } = require_validation();
879
879
  var FastBuffer = Buffer[Symbol.species];
880
880
  var promise = Promise.resolve();
881
+ var queueTask = typeof queueMicrotask === "function" ? queueMicrotask : queueMicrotaskShim;
881
882
  var GET_INFO = 0;
882
883
  var GET_PAYLOAD_LENGTH_16 = 1;
883
884
  var GET_PAYLOAD_LENGTH_64 = 2;
@@ -1006,7 +1007,7 @@ var require_receiver = __commonJS({
1006
1007
  return;
1007
1008
  default:
1008
1009
  this._loop = false;
1009
- promise.then(() => {
1010
+ queueTask(() => {
1010
1011
  this._state = GET_INFO;
1011
1012
  this.startLoop(cb);
1012
1013
  });
@@ -1294,9 +1295,9 @@ var require_receiver = __commonJS({
1294
1295
  }
1295
1296
  this._fragments.push(buf);
1296
1297
  }
1297
- const er = this.dataMessage();
1298
- if (er)
1299
- return cb(er);
1298
+ const er2 = this.dataMessage();
1299
+ if (er2)
1300
+ return cb(er2);
1300
1301
  this.startLoop(cb);
1301
1302
  });
1302
1303
  }
@@ -1403,6 +1404,15 @@ var require_receiver = __commonJS({
1403
1404
  err[kStatusCode] = statusCode;
1404
1405
  return err;
1405
1406
  }
1407
+ function queueMicrotaskShim(cb) {
1408
+ promise.then(cb).catch(throwErrorNextTick);
1409
+ }
1410
+ function throwError(err) {
1411
+ throw err;
1412
+ }
1413
+ function throwErrorNextTick(err) {
1414
+ process.nextTick(throwError, err);
1415
+ }
1406
1416
  }
1407
1417
  });
1408
1418
 
@@ -2251,7 +2261,7 @@ var require_websocket = __commonJS({
2251
2261
  var protocolVersions = [8, 13];
2252
2262
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
2253
2263
  var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
2254
- var WebSocket2 = class _WebSocket extends EventEmitter {
2264
+ var WebSocket3 = class _WebSocket extends EventEmitter {
2255
2265
  /**
2256
2266
  * Create a new `WebSocket`.
2257
2267
  *
@@ -2630,35 +2640,35 @@ var require_websocket = __commonJS({
2630
2640
  }
2631
2641
  }
2632
2642
  };
2633
- Object.defineProperty(WebSocket2, "CONNECTING", {
2643
+ Object.defineProperty(WebSocket3, "CONNECTING", {
2634
2644
  enumerable: true,
2635
2645
  value: readyStates.indexOf("CONNECTING")
2636
2646
  });
2637
- Object.defineProperty(WebSocket2.prototype, "CONNECTING", {
2647
+ Object.defineProperty(WebSocket3.prototype, "CONNECTING", {
2638
2648
  enumerable: true,
2639
2649
  value: readyStates.indexOf("CONNECTING")
2640
2650
  });
2641
- Object.defineProperty(WebSocket2, "OPEN", {
2651
+ Object.defineProperty(WebSocket3, "OPEN", {
2642
2652
  enumerable: true,
2643
2653
  value: readyStates.indexOf("OPEN")
2644
2654
  });
2645
- Object.defineProperty(WebSocket2.prototype, "OPEN", {
2655
+ Object.defineProperty(WebSocket3.prototype, "OPEN", {
2646
2656
  enumerable: true,
2647
2657
  value: readyStates.indexOf("OPEN")
2648
2658
  });
2649
- Object.defineProperty(WebSocket2, "CLOSING", {
2659
+ Object.defineProperty(WebSocket3, "CLOSING", {
2650
2660
  enumerable: true,
2651
2661
  value: readyStates.indexOf("CLOSING")
2652
2662
  });
2653
- Object.defineProperty(WebSocket2.prototype, "CLOSING", {
2663
+ Object.defineProperty(WebSocket3.prototype, "CLOSING", {
2654
2664
  enumerable: true,
2655
2665
  value: readyStates.indexOf("CLOSING")
2656
2666
  });
2657
- Object.defineProperty(WebSocket2, "CLOSED", {
2667
+ Object.defineProperty(WebSocket3, "CLOSED", {
2658
2668
  enumerable: true,
2659
2669
  value: readyStates.indexOf("CLOSED")
2660
2670
  });
2661
- Object.defineProperty(WebSocket2.prototype, "CLOSED", {
2671
+ Object.defineProperty(WebSocket3.prototype, "CLOSED", {
2662
2672
  enumerable: true,
2663
2673
  value: readyStates.indexOf("CLOSED")
2664
2674
  });
@@ -2671,10 +2681,10 @@ var require_websocket = __commonJS({
2671
2681
  "readyState",
2672
2682
  "url"
2673
2683
  ].forEach((property) => {
2674
- Object.defineProperty(WebSocket2.prototype, property, { enumerable: true });
2684
+ Object.defineProperty(WebSocket3.prototype, property, { enumerable: true });
2675
2685
  });
2676
2686
  ["open", "error", "close", "message"].forEach((method) => {
2677
- Object.defineProperty(WebSocket2.prototype, `on${method}`, {
2687
+ Object.defineProperty(WebSocket3.prototype, `on${method}`, {
2678
2688
  enumerable: true,
2679
2689
  get() {
2680
2690
  for (const listener of this.listeners(method)) {
@@ -2698,9 +2708,9 @@ var require_websocket = __commonJS({
2698
2708
  }
2699
2709
  });
2700
2710
  });
2701
- WebSocket2.prototype.addEventListener = addEventListener;
2702
- WebSocket2.prototype.removeEventListener = removeEventListener;
2703
- module2.exports = WebSocket2;
2711
+ WebSocket3.prototype.addEventListener = addEventListener;
2712
+ WebSocket3.prototype.removeEventListener = removeEventListener;
2713
+ module2.exports = WebSocket3;
2704
2714
  function initAsClient(websocket, address, protocols, options) {
2705
2715
  const opts = {
2706
2716
  protocolVersion: protocolVersions[1],
@@ -2886,7 +2896,7 @@ var require_websocket = __commonJS({
2886
2896
  });
2887
2897
  req.on("upgrade", (res, socket, head) => {
2888
2898
  websocket.emit("upgrade", res);
2889
- if (websocket.readyState !== WebSocket2.CONNECTING)
2899
+ if (websocket.readyState !== WebSocket3.CONNECTING)
2890
2900
  return;
2891
2901
  req = websocket._req = null;
2892
2902
  if (res.headers.upgrade.toLowerCase() !== "websocket") {
@@ -2958,7 +2968,7 @@ var require_websocket = __commonJS({
2958
2968
  }
2959
2969
  }
2960
2970
  function emitErrorAndClose(websocket, err) {
2961
- websocket._readyState = WebSocket2.CLOSING;
2971
+ websocket._readyState = WebSocket3.CLOSING;
2962
2972
  websocket.emit("error", err);
2963
2973
  websocket.emitClose();
2964
2974
  }
@@ -2974,7 +2984,7 @@ var require_websocket = __commonJS({
2974
2984
  return tls.connect(options);
2975
2985
  }
2976
2986
  function abortHandshake(websocket, stream, message) {
2977
- websocket._readyState = WebSocket2.CLOSING;
2987
+ websocket._readyState = WebSocket3.CLOSING;
2978
2988
  const err = new Error(message);
2979
2989
  Error.captureStackTrace(err, abortHandshake);
2980
2990
  if (stream.setHeader) {
@@ -3055,7 +3065,7 @@ var require_websocket = __commonJS({
3055
3065
  this.removeListener("close", socketOnClose);
3056
3066
  this.removeListener("data", socketOnData);
3057
3067
  this.removeListener("end", socketOnEnd);
3058
- websocket._readyState = WebSocket2.CLOSING;
3068
+ websocket._readyState = WebSocket3.CLOSING;
3059
3069
  let chunk;
3060
3070
  if (!this._readableState.endEmitted && !websocket._closeFrameReceived && !websocket._receiver._writableState.errorEmitted && (chunk = websocket._socket.read()) !== null) {
3061
3071
  websocket._receiver.write(chunk);
@@ -3077,7 +3087,7 @@ var require_websocket = __commonJS({
3077
3087
  }
3078
3088
  function socketOnEnd() {
3079
3089
  const websocket = this[kWebSocket];
3080
- websocket._readyState = WebSocket2.CLOSING;
3090
+ websocket._readyState = WebSocket3.CLOSING;
3081
3091
  websocket._receiver.end();
3082
3092
  this.end();
3083
3093
  }
@@ -3086,7 +3096,7 @@ var require_websocket = __commonJS({
3086
3096
  this.removeListener("error", socketOnError);
3087
3097
  this.on("error", NOOP);
3088
3098
  if (websocket) {
3089
- websocket._readyState = WebSocket2.CLOSING;
3099
+ websocket._readyState = WebSocket3.CLOSING;
3090
3100
  this.destroy();
3091
3101
  }
3092
3102
  }
@@ -3152,7 +3162,7 @@ var require_websocket_server = __commonJS({
3152
3162
  var extension = require_extension();
3153
3163
  var PerMessageDeflate = require_permessage_deflate();
3154
3164
  var subprotocol = require_subprotocol();
3155
- var WebSocket2 = require_websocket();
3165
+ var WebSocket3 = require_websocket();
3156
3166
  var { GUID, kWebSocket } = require_constants();
3157
3167
  var keyRegex = /^[+/0-9A-Za-z]{22}==$/;
3158
3168
  var RUNNING = 0;
@@ -3201,7 +3211,7 @@ var require_websocket_server = __commonJS({
3201
3211
  host: null,
3202
3212
  path: null,
3203
3213
  port: null,
3204
- WebSocket: WebSocket2,
3214
+ WebSocket: WebSocket3,
3205
3215
  ...options
3206
3216
  };
3207
3217
  if (options.port == null && !options.server && !options.noServer || options.port != null && (options.server || options.noServer) || options.server && options.noServer) {
@@ -3513,7 +3523,7 @@ var require_websocket_server = __commonJS({
3513
3523
  socket.once("finish", socket.destroy);
3514
3524
  socket.end(
3515
3525
  `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
3516
- ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
3526
+ ` + Object.keys(headers).map((h2) => `${h2}: ${headers[h2]}`).join("\r\n") + "\r\n\r\n" + message
3517
3527
  );
3518
3528
  }
3519
3529
  function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
@@ -3538,196 +3548,7 @@ __export(main_exports, {
3538
3548
  module.exports = __toCommonJS(main_exports);
3539
3549
 
3540
3550
  // ../core/dist/esm/index.mjs
3541
- var Ze = "ok";
3542
- var et = "created";
3543
- var rt = "not-modified";
3544
- var nt = "not-found";
3545
- var xe = "accepted";
3546
- var Qt = { resourceType: "OperationOutcome", id: nt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3547
- function k(r4, e) {
3548
- return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3549
- }
3550
- function Te(r4) {
3551
- return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3552
- }
3553
- function it(r4) {
3554
- return r4.id === Ze || r4.id === et || r4.id === rt || r4.id === xe;
3555
- }
3556
- var m = class extends Error {
3557
- constructor(t, n) {
3558
- super(Wt(t));
3559
- this.outcome = t, this.cause = n;
3560
- }
3561
- };
3562
- function ot(r4) {
3563
- return r4 instanceof m ? r4.outcome : Te(r4) ? r4 : k(Zr(r4));
3564
- }
3565
- function Zr(r4) {
3566
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : Te(r4) ? Wt(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3567
- }
3568
- function Wt(r4) {
3569
- let e = r4.issue?.map(en) ?? [];
3570
- return e.length > 0 ? e.join("; ") : "Unknown error";
3571
- }
3572
- function en(r4) {
3573
- let e = r4.details?.text ?? r4.diagnostics ?? "Unknown error";
3574
- return r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3575
- }
3576
- var Kt = { 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 ve(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();
3580
- }
3581
- function G(r4) {
3582
- let e = Xt(r4), t = mn(r4);
3583
- return t === e ? { reference: e } : { reference: e, display: t };
3584
- }
3585
- function Xt(r4) {
3586
- return r4.resourceType + "/" + r4.id;
3587
- }
3588
- function Oo(r4) {
3589
- return r4?.reference?.split("/")[1];
3590
- }
3591
- function fn(r4) {
3592
- return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3593
- }
3594
- function mn(r4) {
3595
- if (fn(r4)) {
3596
- let e = hn(r4);
3597
- if (e)
3598
- return e;
3599
- }
3600
- if (r4.resourceType === "Device") {
3601
- let e = yn(r4);
3602
- if (e)
3603
- return e;
3604
- }
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 : Xt(r4);
3606
- }
3607
- function hn(r4) {
3608
- let e = r4.name;
3609
- if (e && e.length > 0)
3610
- return ve(e[0]);
3611
- }
3612
- function yn(r4) {
3613
- let e = r4.deviceName;
3614
- if (e && e.length > 0)
3615
- return e[0].name;
3616
- }
3617
- function Re(r4, e) {
3618
- let t = new Date(r4);
3619
- t.setUTCHours(0, 0, 0, 0);
3620
- let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3621
- 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 Xr = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3627
- return { years: l2, months: B, days: Xr };
3628
- }
3629
- function rr(r4, e) {
3630
- return JSON.stringify(r4, gn, e ? 2 : void 0);
3631
- }
3632
- function gn(r4, e) {
3633
- return !xn(r4) && R(e) ? void 0 : e;
3634
- }
3635
- function xn(r4) {
3636
- return !!/\d+$/.exec(r4);
3637
- }
3638
- function R(r4) {
3639
- if (r4 == null)
3640
- return true;
3641
- let e = typeof r4;
3642
- return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3643
- }
3644
- function nr(r4) {
3645
- return r4.every((e) => typeof e == "string");
3646
- }
3647
- var ir = [];
3648
- for (let r4 = 0; r4 < 256; r4++)
3649
- ir.push(r4.toString(16).padStart(2, "0"));
3650
- function or(r4) {
3651
- let e = new Uint8Array(r4), t = new Array(e.length);
3652
- for (let n = 0; n < e.length; n++)
3653
- t[n] = ir[e[n]];
3654
- return t.join("");
3655
- }
3656
- function sr(r4) {
3657
- let e = new Uint8Array(r4), t = [];
3658
- for (let n = 0; n < e.length; n++)
3659
- t[n] = String.fromCharCode(e[n]);
3660
- return window.btoa(t.join(""));
3661
- }
3662
- function b(r4) {
3663
- return r4.charAt(0).toUpperCase() + r4.substring(1);
3664
- }
3665
- var lt = (r4) => new Promise((e) => {
3666
- setTimeout(e, r4);
3667
- });
3668
- var z = ((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))(z || {});
3669
- function pt(r4) {
3670
- if (!r4.name)
3671
- return;
3672
- let t = r4.snapshot?.element;
3673
- if (t) {
3674
- for (let n of t)
3675
- wn(r4, n);
3676
- for (let n of t)
3677
- In(r4, n);
3678
- }
3679
- }
3680
- function wn(r4, e) {
3681
- let t = e.path, n = e.type?.[0]?.code;
3682
- if (n !== void 0 && n !== "Element" && n !== "BackboneElement")
3683
- 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 ?? {};
3688
- }
3689
- function In(r4, e) {
3690
- let n = e.path.split(".");
3691
- if (n.length === 1)
3692
- return;
3693
- n[0] = r4.name;
3694
- let i2 = ce(n.slice(0, n.length - 1)), o = y.types[i2];
3695
- if (!o)
3696
- return;
3697
- let s = n[n.length - 1];
3698
- o.properties[s] = e;
3699
- }
3700
- function ft(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);
3704
- }
3705
- }
3706
- function K(r4) {
3707
- let e = r4.type?.[0]?.code;
3708
- return e === "BackboneElement" || e === "Element" ? ce((r4.base?.path ?? r4.path)?.split(".")) : e;
3709
- }
3710
- function ce(r4) {
3711
- return r4.length === 1 ? r4[0] : r4.map(b).join("");
3712
- }
3713
- function ue(r4, e) {
3714
- let t = y.types[r4];
3715
- if (!t)
3716
- 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);
3722
- }
3723
- return n;
3724
- }
3725
- }
3726
- function O(r4) {
3727
- return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
3728
- }
3729
- var y = Kt;
3730
- var Ee = class {
3551
+ var he = class {
3731
3552
  constructor(e, t) {
3732
3553
  this.operator = e;
3733
3554
  this.child = t;
@@ -3736,7 +3557,7 @@ var Ee = class {
3736
3557
  return `${this.operator}(${this.child.toString()})`;
3737
3558
  }
3738
3559
  };
3739
- var j = class {
3560
+ var $ = class {
3740
3561
  constructor(e, t, n) {
3741
3562
  this.operator = e;
3742
3563
  this.left = t;
@@ -3746,7 +3567,7 @@ var j = class {
3746
3567
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
3747
3568
  }
3748
3569
  };
3749
- var Pe = class {
3570
+ var ye = class {
3750
3571
  constructor() {
3751
3572
  this.prefixParselets = {};
3752
3573
  this.infixParselets = {};
@@ -3770,10 +3591,10 @@ var Pe = class {
3770
3591
  }, precedence: t });
3771
3592
  }
3772
3593
  construct(e) {
3773
- return new mt(e, this.prefixParselets, this.infixParselets);
3594
+ return new et(e, this.prefixParselets, this.infixParselets);
3774
3595
  }
3775
3596
  };
3776
- var mt = class {
3597
+ var et = class {
3777
3598
  constructor(e, t, n) {
3778
3599
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3779
3600
  }
@@ -3824,40 +3645,131 @@ var mt = class {
3824
3645
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
3825
3646
  }
3826
3647
  };
3827
- function re(r4) {
3828
- if (r4.startsWith("T"))
3829
- return r4 + "T00:00:00.000Z".substring(r4.length);
3830
- if (r4.length <= 10)
3831
- return r4;
3832
- try {
3833
- return new Date(r4).toISOString();
3834
- } catch {
3835
- return r4;
3648
+ function K(r4) {
3649
+ let e = $t(r4), t = ln(r4);
3650
+ return t === e ? { reference: e } : { reference: e, display: t };
3651
+ }
3652
+ function $t(r4) {
3653
+ return r4.resourceType + "/" + r4.id;
3654
+ }
3655
+ function So(r4) {
3656
+ return r4?.reference?.split("/")[1];
3657
+ }
3658
+ function un(r4) {
3659
+ return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3660
+ }
3661
+ function ln(r4) {
3662
+ if (un(r4)) {
3663
+ let e = dn(r4);
3664
+ if (e)
3665
+ return e;
3836
3666
  }
3667
+ if (r4.resourceType === "Device") {
3668
+ let e = pn(r4);
3669
+ if (e)
3670
+ return e;
3671
+ }
3672
+ return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : $t(r4);
3673
+ }
3674
+ function dn(r4) {
3675
+ let e = r4.name;
3676
+ if (e && e.length > 0)
3677
+ return be(e[0]);
3678
+ }
3679
+ function pn(r4) {
3680
+ let e = r4.deviceName;
3681
+ if (e && e.length > 0)
3682
+ return e[0].name;
3683
+ }
3684
+ function ge(r4, e) {
3685
+ let t = new Date(r4);
3686
+ t.setUTCHours(0, 0, 0, 0);
3687
+ let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3688
+ n.setUTCHours(0, 0, 0, 0);
3689
+ let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), m2 = n.getUTCDate(), p2 = a - i2;
3690
+ (c2 < o || c2 === o && m2 < s) && p2--;
3691
+ let q = a * 12 + c2 - (i2 * 12 + o);
3692
+ m2 < s && q--;
3693
+ let cn = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3694
+ return { years: p2, months: q, days: cn };
3695
+ }
3696
+ function Qt(r4, e) {
3697
+ return JSON.stringify(r4, fn, e ? 2 : void 0);
3698
+ }
3699
+ function fn(r4, e) {
3700
+ return !mn(r4) && b(e) ? void 0 : e;
3701
+ }
3702
+ function mn(r4) {
3703
+ return !!/\d+$/.exec(r4);
3704
+ }
3705
+ function b(r4) {
3706
+ if (r4 == null)
3707
+ return true;
3708
+ let e = typeof r4;
3709
+ return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3710
+ }
3711
+ function Wt(r4) {
3712
+ return r4.every((e) => typeof e == "string");
3713
+ }
3714
+ var Gt = [];
3715
+ for (let r4 = 0; r4 < 256; r4++)
3716
+ Gt.push(r4.toString(16).padStart(2, "0"));
3717
+ function Kt(r4) {
3718
+ let e = new Uint8Array(r4), t = new Array(e.length);
3719
+ for (let n = 0; n < e.length; n++)
3720
+ t[n] = Gt[e[n]];
3721
+ return t.join("");
3722
+ }
3723
+ function zt(r4) {
3724
+ let e = new Uint8Array(r4), t = [];
3725
+ for (let n = 0; n < e.length; n++)
3726
+ t[n] = String.fromCharCode(e[n]);
3727
+ return window.btoa(t.join(""));
3728
+ }
3729
+ function A(r4) {
3730
+ return r4.charAt(0).toUpperCase() + r4.substring(1);
3837
3731
  }
3838
- function d(r4) {
3839
- return [{ type: "boolean", value: r4 }];
3732
+ var nt = (r4) => new Promise((e) => {
3733
+ setTimeout(e, r4);
3734
+ });
3735
+ function be(r4, e) {
3736
+ let t = [];
3737
+ 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();
3738
+ }
3739
+ function Un(r4) {
3740
+ let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
3741
+ return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
3742
+ }
3743
+ function Zt(r4) {
3744
+ let e = /* @__PURE__ */ Object.create(null);
3745
+ for (let [t, n] of Object.entries(r4))
3746
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Un(o)])), constraints: [], innerTypes: [] };
3747
+ return e;
3748
+ }
3749
+ var er = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3750
+ function l(r4) {
3751
+ return [{ type: u.boolean, value: r4 }];
3840
3752
  }
3841
- function x(r4) {
3842
- 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 } : O(r4) ? { type: r4.resourceType, value: r4 } : { type: "BackboneElement", value: r4 };
3753
+ function T(r4) {
3754
+ return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : R(r4) ? { type: u.Quantity, value: r4 } : V(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3843
3755
  }
3844
- function _(r4) {
3756
+ function N(r4) {
3845
3757
  return r4.length === 0 ? false : !!r4[0].value;
3846
3758
  }
3847
- function V(r4, e) {
3759
+ function D(r4, e) {
3848
3760
  if (r4.length !== 0) {
3849
3761
  if (r4.length === 1 && (!e || r4[0].type === e))
3850
3762
  return r4[0];
3851
3763
  throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3852
3764
  }
3853
3765
  }
3854
- function E(r4, e) {
3766
+ function w(r4, e) {
3855
3767
  if (!r4.value)
3856
3768
  return;
3857
- let t = ue(r4.type, e);
3858
- return t ? Ln(r4, e, t) : _n(r4, e);
3769
+ let t = Ae(r4.type, e);
3770
+ return t ? Fn(r4, e, t) : Nn(r4, e);
3859
3771
  }
3860
- function Ln(r4, e, t) {
3772
+ function Fn(r4, e, t) {
3861
3773
  let n = t.type;
3862
3774
  if (!n || n.length === 0)
3863
3775
  return;
@@ -3866,20 +3778,20 @@ function Ln(r4, e, t) {
3866
3778
  i2 = r4.value[e], o = n[0].code;
3867
3779
  else
3868
3780
  for (let a of n) {
3869
- let c2 = e.replace("[x]", "") + b(a.code);
3781
+ let c2 = e.replace("[x]", "") + A(a.code);
3870
3782
  if (c2 in r4.value) {
3871
3783
  i2 = r4.value[c2], o = a.code;
3872
3784
  break;
3873
3785
  }
3874
3786
  }
3875
3787
  let s = r4.value["_" + e];
3876
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? hr(a ?? {}, s[c2]) : a) : i2 = hr(i2 ?? {}, s)), !R(i2))
3877
- return (o === "Element" || o === "BackboneElement") && (o = K(t)), Array.isArray(i2) ? i2.map((a) => pr(a, o)) : pr(i2, o);
3788
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? ir(a ?? {}, s[c2]) : a) : i2 = ir(i2 ?? {}, s)), !b(i2))
3789
+ return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => tr(a, o)) : tr(i2, o);
3878
3790
  }
3879
- function pr(r4, e) {
3880
- return e === "Resource" && O(r4) && (e = r4.resourceType), { type: e, value: r4 };
3791
+ function tr(r4, e) {
3792
+ return e === "Resource" && V(r4) && (e = r4.resourceType), { type: e, value: r4 };
3881
3793
  }
3882
- function _n(r4, e) {
3794
+ function Nn(r4, e) {
3883
3795
  let t = r4.value;
3884
3796
  if (!t || typeof t != "object")
3885
3797
  return;
@@ -3887,22 +3799,22 @@ function _n(r4, e) {
3887
3799
  if (e in t)
3888
3800
  n = t[e];
3889
3801
  else
3890
- for (let i2 in z) {
3891
- let o = e + b(i2);
3802
+ for (let i2 in u) {
3803
+ let o = e + A(i2);
3892
3804
  if (o in t) {
3893
3805
  n = t[o];
3894
3806
  break;
3895
3807
  }
3896
3808
  }
3897
- if (!R(n))
3898
- return Array.isArray(n) ? n.map(x) : x(n);
3809
+ if (!b(n))
3810
+ return Array.isArray(n) ? n.map(T) : T(n);
3899
3811
  }
3900
- function Ce(r4) {
3812
+ function Re(r4) {
3901
3813
  let e = [];
3902
3814
  for (let t of r4) {
3903
3815
  let n = false;
3904
3816
  for (let i2 of e)
3905
- if (_(yr(t, i2))) {
3817
+ if (N(or(t, i2))) {
3906
3818
  n = true;
3907
3819
  break;
3908
3820
  }
@@ -3910,28 +3822,28 @@ function Ce(r4) {
3910
3822
  }
3911
3823
  return e;
3912
3824
  }
3913
- function ht(r4) {
3914
- return d(!_(r4));
3825
+ function st(r4) {
3826
+ return l(!N(r4));
3915
3827
  }
3916
- function yt(r4, e) {
3917
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => _(yr(t, e[n]))));
3828
+ function at(r4, e) {
3829
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => N(or(t, e[n]))));
3918
3830
  }
3919
- function yr(r4, e) {
3831
+ function or(r4, e) {
3920
3832
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3921
- return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : A(t) && A(n) ? d(gr(t, n)) : d(typeof t == "object" && typeof n == "object" ? xt(r4, e) : t === n);
3833
+ return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(sr(t, n)) : l(typeof t == "object" && typeof n == "object" ? ut(r4, e) : t === n);
3922
3834
  }
3923
- function gt(r4, e) {
3924
- return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(fr), e.sort(fr), d(r4.every((t, n) => _(Nn(t, e[n])))));
3835
+ function ct(r4, e) {
3836
+ return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(rr), e.sort(rr), l(r4.every((t, n) => N(Mn(t, e[n])))));
3925
3837
  }
3926
- function Nn(r4, e) {
3838
+ function Mn(r4, e) {
3927
3839
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3928
- return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : A(s) && A(a) ? d(gr(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" ? xt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3840
+ return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(sr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? ut({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3929
3841
  }
3930
- function fr(r4, e) {
3842
+ function rr(r4, e) {
3931
3843
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3932
3844
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3933
3845
  }
3934
- function we(r4, e) {
3846
+ function Ee(r4, e) {
3935
3847
  let { value: t } = r4;
3936
3848
  if (t == null)
3937
3849
  return false;
@@ -3948,69 +3860,276 @@ function we(r4, e) {
3948
3860
  case "Time":
3949
3861
  return typeof t == "string" && !!/^T\d/.exec(t);
3950
3862
  case "Period":
3951
- return Mn(t);
3863
+ return Bn(t);
3952
3864
  case "Quantity":
3953
- return A(t);
3865
+ return R(t);
3954
3866
  default:
3955
3867
  return typeof t == "object" && t?.resourceType === e;
3956
3868
  }
3957
3869
  }
3958
- function Mn(r4) {
3870
+ function Bn(r4) {
3959
3871
  return !!(r4 && typeof r4 == "object" && "start" in r4);
3960
3872
  }
3961
- function A(r4) {
3873
+ function R(r4) {
3962
3874
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3963
3875
  }
3964
- function gr(r4, e) {
3876
+ function sr(r4, e) {
3965
3877
  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);
3966
3878
  }
3967
- function xt(r4, e) {
3879
+ function ut(r4, e) {
3968
3880
  let t = Object.keys(r4), n = Object.keys(e);
3969
3881
  if (t.length !== n.length)
3970
3882
  return false;
3971
3883
  for (let i2 of t) {
3972
3884
  let o = r4[i2], s = e[i2];
3973
- if (mr(o) && mr(s)) {
3974
- if (!xt(o, s))
3885
+ if (nr(o) && nr(s)) {
3886
+ if (!ut(o, s))
3975
3887
  return false;
3976
3888
  } else if (o !== s)
3977
3889
  return false;
3978
3890
  }
3979
3891
  return true;
3980
3892
  }
3981
- function mr(r4) {
3893
+ function nr(r4) {
3982
3894
  return r4 !== null && typeof r4 == "object";
3983
3895
  }
3984
- function hr(r4, e) {
3896
+ function ir(r4, e) {
3985
3897
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3986
3898
  }
3987
- var de = () => [];
3988
- 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) => {
3899
+ var lt = "ok";
3900
+ var Pe = "created";
3901
+ var pt = "not-modified";
3902
+ var ft = "not-found";
3903
+ var Ce = "accepted";
3904
+ var lr = { resourceType: "OperationOutcome", id: ft, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3905
+ function _(r4, e) {
3906
+ return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3907
+ }
3908
+ function h(r4) {
3909
+ return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
3910
+ }
3911
+ function we(r4) {
3912
+ return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3913
+ }
3914
+ function mt(r4) {
3915
+ return r4.id === lt || r4.id === Pe || r4.id === pt || r4.id === Ce;
3916
+ }
3917
+ var d = class extends Error {
3918
+ constructor(t, n) {
3919
+ super(pr(t));
3920
+ this.outcome = t, this.cause = n;
3921
+ }
3922
+ };
3923
+ function ht(r4) {
3924
+ return r4 instanceof d ? r4.outcome : we(r4) ? r4 : _(qn(r4));
3925
+ }
3926
+ function qn(r4) {
3927
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : we(r4) ? pr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3928
+ }
3929
+ function pr(r4) {
3930
+ let e = r4.issue?.map($n) ?? [];
3931
+ return e.length > 0 ? e.join("; ") : "Unknown error";
3932
+ }
3933
+ function $n(r4) {
3934
+ let e;
3935
+ 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;
3936
+ }
3937
+ function vt(r4) {
3938
+ return new xt(r4).parse();
3939
+ }
3940
+ var H = Zt(er);
3941
+ function xr(r4) {
3942
+ let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3943
+ for (let t of e)
3944
+ jn(t);
3945
+ }
3946
+ function jn(r4) {
3947
+ if (!r4?.name)
3948
+ throw new Error("Failed loading StructureDefinition from bundle");
3949
+ if (r4.resourceType !== "StructureDefinition")
3950
+ return;
3951
+ let e = vt(r4);
3952
+ H[r4.name] = e;
3953
+ for (let t of e.innerTypes)
3954
+ t.parentType = e, H[t.name] = t;
3955
+ }
3956
+ function vr(r4) {
3957
+ return !!H[r4];
3958
+ }
3959
+ function Sr(r4) {
3960
+ return H[r4];
3961
+ }
3962
+ var xt = class {
3963
+ constructor(e) {
3964
+ if (!e.snapshot?.element || e.snapshot.element.length === 0)
3965
+ throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
3966
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: e.description, elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3967
+ }
3968
+ parse() {
3969
+ let e = this.next();
3970
+ for (; e; ) {
3971
+ if (e.sliceName)
3972
+ this.parseSliceStart(e);
3973
+ else if (e.id?.includes(":")) {
3974
+ if (this.slicingContext?.current) {
3975
+ let t = gt(e, this.slicingContext.path);
3976
+ this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
3977
+ }
3978
+ } else {
3979
+ let t = this.parseElementDefinition(e);
3980
+ this.checkFieldEnter(e, t);
3981
+ let n = this.backboneContext;
3982
+ for (; n; ) {
3983
+ if (e.path?.startsWith(n.path + ".")) {
3984
+ n.type.elements[gt(e, n.path)] = t;
3985
+ break;
3986
+ }
3987
+ n = n.parent;
3988
+ }
3989
+ if (!n) {
3990
+ let i2 = gt(e, this.root.path);
3991
+ e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
3992
+ }
3993
+ this.checkFieldExit(e);
3994
+ }
3995
+ e = this.next();
3996
+ }
3997
+ return this.checkFieldExit(), this.innerTypes.length > 0 && (this.resourceSchema.innerTypes = this.innerTypes), this.resourceSchema;
3998
+ }
3999
+ checkFieldEnter(e, t) {
4000
+ this.isInnerType(e) && this.enterInnerType(e), e.slicing && !this.slicingContext && this.enterSlice(e, t);
4001
+ }
4002
+ enterInnerType(e) {
4003
+ for (; this.backboneContext && !ee(this.backboneContext?.path, e.path); )
4004
+ this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4005
+ this.backboneContext = { type: { name: Tt(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ee(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
4006
+ }
4007
+ enterSlice(e, t) {
4008
+ Wn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4009
+ if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
4010
+ throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
4011
+ return { path: n.path, type: n.type };
4012
+ }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
4013
+ }
4014
+ checkFieldExit(e = void 0) {
4015
+ if (this.backboneContext && !ee(this.backboneContext.path, e?.path))
4016
+ if (this.backboneContext.parent)
4017
+ do
4018
+ this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4019
+ while (this.backboneContext && !ee(this.backboneContext.path, e?.path));
4020
+ else
4021
+ this.innerTypes.push(this.backboneContext.type), delete this.backboneContext;
4022
+ this.slicingContext && !ee(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
4023
+ }
4024
+ next() {
4025
+ let e = this.peek();
4026
+ if (e)
4027
+ return this.index++, e;
4028
+ }
4029
+ peek() {
4030
+ let e = this.elements[this.index];
4031
+ if (e) {
4032
+ if (this.elementIndex[e.path ?? ""] = e, e.contentReference) {
4033
+ let t = this.elementIndex[e.contentReference.slice(e.contentReference.indexOf("#") + 1)];
4034
+ 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;
4035
+ }
4036
+ return e;
4037
+ }
4038
+ }
4039
+ isInnerType(e) {
4040
+ let t = this.peek();
4041
+ return !!(ee(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
4042
+ }
4043
+ parseSliceStart(e) {
4044
+ if (!this.slicingContext)
4045
+ throw new Error("Invalid slice start before discriminator: " + e.sliceName);
4046
+ 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) };
4047
+ }
4048
+ parseElementDefinition(e) {
4049
+ let t = yr(e.max), n = e.base?.max ? yr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4050
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? Tt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: gr(w(i2, "fixed")), pattern: gr(w(i2, "pattern")), binding: e.binding };
4051
+ }
4052
+ };
4053
+ function yr(r4) {
4054
+ return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
4055
+ }
4056
+ function gt(r4, e = "") {
4057
+ return Qn(r4.path, e);
4058
+ }
4059
+ function Qn(r4, e) {
4060
+ return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
4061
+ }
4062
+ function ee(r4, e) {
4063
+ return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
4064
+ }
4065
+ function gr(r4) {
4066
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : b(r4) ? void 0 : r4;
4067
+ }
4068
+ function Wn(r4) {
4069
+ let e = r4.slicing?.discriminator;
4070
+ return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
4071
+ }
4072
+ 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" };
4073
+ function bt(r4) {
4074
+ for (let e of r4.base ?? []) {
4075
+ let t = I.types[e];
4076
+ 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;
4077
+ }
4078
+ }
4079
+ function Tt(r4) {
4080
+ let e = r4.type?.[0]?.code;
4081
+ return e === "BackboneElement" || e === "Element" ? Gn((r4.base?.path ?? r4.path)?.split(".")) : e;
4082
+ }
4083
+ function Gn(r4) {
4084
+ return r4.length === 1 ? r4[0] : r4.map(A).join("");
4085
+ }
4086
+ function Ae(r4, e) {
4087
+ let t = Sr(r4);
4088
+ if (t)
4089
+ return t.elements[e] ?? t.elements[e + "[x]"];
4090
+ }
4091
+ function V(r4) {
4092
+ return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
4093
+ }
4094
+ var I = { types: {} };
4095
+ function re(r4) {
4096
+ if (r4.startsWith("T"))
4097
+ return r4 + "T00:00:00.000Z".substring(r4.length);
4098
+ if (r4.length <= 10)
4099
+ return r4;
4100
+ try {
4101
+ return new Date(r4).toISOString();
4102
+ } catch {
4103
+ return r4;
4104
+ }
4105
+ }
4106
+ var se = () => [];
4107
+ 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) => {
3989
4108
  for (let t of e)
3990
4109
  if (!t.value)
3991
- return d(false);
3992
- return d(true);
4110
+ return l(false);
4111
+ return l(true);
3993
4112
  }, anyTrue: (r4, e) => {
3994
4113
  for (let t of e)
3995
4114
  if (t.value)
3996
- return d(true);
3997
- return d(false);
4115
+ return l(true);
4116
+ return l(false);
3998
4117
  }, allFalse: (r4, e) => {
3999
4118
  for (let t of e)
4000
4119
  if (t.value)
4001
- return d(false);
4002
- return d(true);
4120
+ return l(false);
4121
+ return l(true);
4003
4122
  }, anyFalse: (r4, e) => {
4004
4123
  for (let t of e)
4005
4124
  if (!t.value)
4006
- return d(true);
4007
- return d(false);
4008
- }, subsetOf: de, supersetOf: de, count: (r4, e) => [{ type: "integer", value: e.length }], distinct: (r4, e) => {
4125
+ return l(true);
4126
+ return l(false);
4127
+ }, subsetOf: se, supersetOf: se, count: (r4, e) => [{ type: u.integer, value: e.length }], distinct: (r4, e) => {
4009
4128
  let t = [];
4010
4129
  for (let n of e)
4011
4130
  t.some((i2) => i2.value === n.value) || t.push(n);
4012
4131
  return t;
4013
- }, 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) => {
4132
+ }, 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) => {
4014
4133
  if (e.length > 1)
4015
4134
  throw new Error("Expected input length one for single()");
4016
4135
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4042,77 +4161,77 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4042
4161
  if (!t)
4043
4162
  return e;
4044
4163
  let n = t.eval(r4, e);
4045
- return Ce([...e, ...n]);
4164
+ return Re([...e, ...n]);
4046
4165
  }, combine: (r4, e, t) => {
4047
4166
  if (!t)
4048
4167
  return e;
4049
4168
  let n = t.eval(r4, e);
4050
4169
  return [...e, ...n];
4051
- }, htmlChecks: (r4, e, t) => [x(true)], iif: (r4, e, t, n, i2) => {
4170
+ }, htmlChecks: (r4, e, t) => [T(true)], iif: (r4, e, t, n, i2) => {
4052
4171
  let o = t.eval(r4, e);
4053
4172
  if (o.length > 1 || o.length === 1 && typeof o[0].value != "boolean")
4054
4173
  throw new Error("Expected criterion to evaluate to a Boolean");
4055
- return _(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4174
+ return N(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4056
4175
  }, toBoolean: (r4, e) => {
4057
4176
  if (e.length === 0)
4058
4177
  return [];
4059
4178
  let [{ value: t }] = L(e, 1);
4060
4179
  if (typeof t == "boolean")
4061
- return [{ type: "boolean", value: t }];
4180
+ return [{ type: u.boolean, value: t }];
4062
4181
  if (typeof t == "number" && (t === 0 || t === 1))
4063
- return d(!!t);
4182
+ return l(!!t);
4064
4183
  if (typeof t == "string") {
4065
4184
  let n = t.toLowerCase();
4066
4185
  if (["true", "t", "yes", "y", "1", "1.0"].includes(n))
4067
- return d(true);
4186
+ return l(true);
4068
4187
  if (["false", "f", "no", "n", "0", "0.0"].includes(n))
4069
- return d(false);
4188
+ return l(false);
4070
4189
  }
4071
4190
  return [];
4072
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4191
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4073
4192
  if (e.length === 0)
4074
4193
  return [];
4075
4194
  let [{ value: t }] = L(e, 1);
4076
- 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 }] : [];
4077
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4195
+ 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 }] : [];
4196
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4078
4197
  if (e.length === 0)
4079
4198
  return [];
4080
4199
  let [{ value: t }] = L(e, 1);
4081
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "date", value: re(t) }] : [];
4082
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4200
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4201
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4083
4202
  if (e.length === 0)
4084
4203
  return [];
4085
4204
  let [{ value: t }] = L(e, 1);
4086
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "dateTime", value: re(t) }] : [];
4087
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4205
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4206
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4088
4207
  if (e.length === 0)
4089
4208
  return [];
4090
4209
  let [{ value: t }] = L(e, 1);
4091
- 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 }] : [];
4092
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4210
+ 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 }] : [];
4211
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4093
4212
  if (e.length === 0)
4094
4213
  return [];
4095
4214
  let [{ value: t }] = L(e, 1);
4096
- 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" } }] : [];
4097
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4215
+ 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" } }] : [];
4216
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4098
4217
  if (e.length === 0)
4099
4218
  return [];
4100
4219
  let [{ value: t }] = L(e, 1);
4101
- return t == null ? [] : A(t) ? [{ type: "string", value: `${t.value} '${t.unit}'` }] : [{ type: "string", value: t.toString() }];
4102
- }, convertsToString: (r4, e) => e.length === 0 ? [] : d(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4220
+ return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4221
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4103
4222
  if (e.length === 0)
4104
4223
  return [];
4105
4224
  let [{ value: t }] = L(e, 1);
4106
4225
  if (typeof t == "string") {
4107
4226
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4108
4227
  if (n)
4109
- return [{ type: "time", value: re("T" + n[1]) }];
4228
+ return [{ type: u.time, value: re("T" + n[1]) }];
4110
4229
  }
4111
4230
  return [];
4112
- }, 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) => {
4231
+ }, 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) => {
4113
4232
  let a = o, c2 = s ? a + s : i2.length;
4114
4233
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4115
- }, 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) => 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: 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) => {
4234
+ }, 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) => {
4116
4235
  let o = S.toDateTime(r4, t.eval(r4, e));
4117
4236
  if (o.length === 0)
4118
4237
  throw new Error("Invalid start date");
@@ -4122,19 +4241,19 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4122
4241
  let a = i2.eval(r4, e)[0]?.value;
4123
4242
  if (a !== "years" && a !== "months" && a !== "days")
4124
4243
  throw new Error("Invalid units");
4125
- let c2 = Re(o[0].value, s[0].value);
4126
- return [{ type: "Quantity", value: { value: c2[a], unit: a } }];
4244
+ let c2 = ge(o[0].value, s[0].value);
4245
+ return [{ type: u.Quantity, value: { value: c2[a], unit: a } }];
4127
4246
  }, is: (r4, e, t) => {
4128
4247
  let n = "";
4129
- return t instanceof N ? n = t.name : t instanceof Q && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: "boolean", value: we(i2, n) })) : [];
4130
- }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: "boolean", value: !t.value })), resolve: (r4, e) => e.map((t) => {
4248
+ 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) })) : [];
4249
+ }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4131
4250
  let n = t.value, i2;
4132
4251
  if (typeof n == "string")
4133
4252
  i2 = n;
4134
4253
  else if (typeof n == "object") {
4135
4254
  let o = n;
4136
4255
  if (o.resource)
4137
- return x(o.resource);
4256
+ return T(o.resource);
4138
4257
  o.reference ? i2 = o.reference : o.type && o.identifier && (i2 = `${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`);
4139
4258
  }
4140
4259
  if (i2?.includes("?")) {
@@ -4145,31 +4264,31 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4145
4264
  let [o, s] = i2.split("/");
4146
4265
  return { type: o, value: { resourceType: o, id: s } };
4147
4266
  }
4148
- return { type: "BackboneElement", value: void 0 };
4149
- }).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" } } : O(t) ? { type: "BackboneElement", value: { namespace: "FHIR", name: t.resourceType } } : { type: "BackboneElement", value: null }), conformsTo: (r4, e, t) => {
4267
+ return { type: u.BackboneElement, value: void 0 };
4268
+ }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: u.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: u.BackboneElement, value: { namespace: "System", name: "Integer" } } : V(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4150
4269
  let n = t.eval(r4, e)[0].value;
4151
4270
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4152
4271
  throw new Error("Expected a StructureDefinition URL");
4153
4272
  let i2 = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
4154
- return e.map((o) => ({ type: "boolean", value: o.value?.resourceType === i2 }));
4273
+ return e.map((o) => ({ type: u.boolean, value: o.value?.resourceType === i2 }));
4155
4274
  } };
4156
- function C(r4, e, t, ...n) {
4275
+ function P(r4, e, t, ...n) {
4157
4276
  if (t.length === 0)
4158
4277
  return [];
4159
4278
  let [{ value: i2 }] = L(t, 1);
4160
4279
  if (typeof i2 != "string")
4161
4280
  throw new Error("String function cannot be called with non-string");
4162
4281
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4163
- return o === void 0 ? [] : Array.isArray(o) ? o.map(x) : [x(o)];
4282
+ return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4164
4283
  }
4165
4284
  function U(r4, e, t, ...n) {
4166
4285
  if (t.length === 0)
4167
4286
  return [];
4168
- let [{ value: i2 }] = L(t, 1), o = A(i2), s = o ? i2.value : i2;
4287
+ let [{ value: i2 }] = L(t, 1), o = R(i2), s = o ? i2.value : i2;
4169
4288
  if (typeof s != "number")
4170
4289
  throw new Error("Math function cannot be called with non-number");
4171
- 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;
4172
- return [{ type: c2, value: f }];
4290
+ 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;
4291
+ return [{ type: c2, value: m2 }];
4173
4292
  }
4174
4293
  function L(r4, e) {
4175
4294
  if (r4.length !== e)
@@ -4179,7 +4298,7 @@ function L(r4, e) {
4179
4298
  throw new Error("Expected non-null argument");
4180
4299
  return r4;
4181
4300
  }
4182
- var I = class {
4301
+ var k = class {
4183
4302
  constructor(e) {
4184
4303
  this.value = e;
4185
4304
  }
@@ -4191,7 +4310,7 @@ var I = class {
4191
4310
  return typeof e == "string" ? `'${e}'` : e.toString();
4192
4311
  }
4193
4312
  };
4194
- var N = class {
4313
+ var M = class {
4195
4314
  constructor(e) {
4196
4315
  this.name = e;
4197
4316
  }
@@ -4209,7 +4328,7 @@ var N = class {
4209
4328
  evalValue(e) {
4210
4329
  let t = e.value;
4211
4330
  if (!(!t || typeof t != "object"))
4212
- return O(t) && t.resourceType === this.name ? e : E(e, this.name);
4331
+ return V(t) && t.resourceType === this.name ? e : w(e, this.name);
4213
4332
  }
4214
4333
  toString() {
4215
4334
  return this.name;
@@ -4223,7 +4342,7 @@ var ke = class {
4223
4342
  return "{}";
4224
4343
  }
4225
4344
  };
4226
- var De = class extends Ee {
4345
+ var Oe = class extends he {
4227
4346
  constructor(t, n, i2) {
4228
4347
  super(t, n);
4229
4348
  this.impl = i2;
@@ -4235,7 +4354,7 @@ var De = class extends Ee {
4235
4354
  return this.operator + this.child.toString();
4236
4355
  }
4237
4356
  };
4238
- var J = class extends j {
4357
+ var J = class extends $ {
4239
4358
  constructor(e, t) {
4240
4359
  super("as", e, t);
4241
4360
  }
@@ -4243,9 +4362,9 @@ var J = class extends j {
4243
4362
  return S.ofType(e, this.left.eval(e, t), this.right);
4244
4363
  }
4245
4364
  };
4246
- var v = class extends j {
4365
+ var v = class extends $ {
4247
4366
  };
4248
- var P = class extends v {
4367
+ var E = class extends v {
4249
4368
  constructor(t, n, i2, o) {
4250
4369
  super(t, n, i2);
4251
4370
  this.impl = o;
@@ -4257,17 +4376,17 @@ var P = class extends v {
4257
4376
  let o = this.right.eval(t, n);
4258
4377
  if (o.length !== 1)
4259
4378
  return [];
4260
- 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);
4261
- return typeof l2 == "boolean" ? d(l2) : A(s) ? [{ type: "Quantity", value: { ...s, value: l2 } }] : [x(l2)];
4379
+ 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);
4380
+ return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4262
4381
  }
4263
4382
  };
4264
- var Oe = class extends j {
4383
+ var De = class extends $ {
4265
4384
  constructor(e, t) {
4266
4385
  super("&", e, t);
4267
4386
  }
4268
4387
  eval(e, t) {
4269
4388
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t), o = [...n, ...i2];
4270
- return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: "string", value: o.map((s) => s.value).join("") }] : o;
4389
+ return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: u.string, value: o.map((s) => s.value).join("") }] : o;
4271
4390
  }
4272
4391
  };
4273
4392
  var Ve = class extends v {
@@ -4276,19 +4395,19 @@ var Ve = class extends v {
4276
4395
  }
4277
4396
  eval(e, t) {
4278
4397
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4279
- return d(n.some((o) => o.value === i2[0].value));
4398
+ return l(n.some((o) => o.value === i2[0].value));
4280
4399
  }
4281
4400
  };
4282
- var Ue = class extends v {
4401
+ var _e = class extends v {
4283
4402
  constructor(e, t) {
4284
4403
  super("in", e, t);
4285
4404
  }
4286
4405
  eval(e, t) {
4287
- let n = V(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4288
- return n ? d(i2.some((o) => o.value === n.value)) : [];
4406
+ let n = D(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4407
+ return n ? l(i2.some((o) => o.value === n.value)) : [];
4289
4408
  }
4290
4409
  };
4291
- var Q = class extends j {
4410
+ var Q = class extends $ {
4292
4411
  constructor(e, t) {
4293
4412
  super(".", e, t);
4294
4413
  }
@@ -4299,49 +4418,49 @@ var Q = class extends j {
4299
4418
  return `${this.left.toString()}.${this.right.toString()}`;
4300
4419
  }
4301
4420
  };
4302
- var ne = class extends j {
4421
+ var ne = class extends $ {
4303
4422
  constructor(e, t) {
4304
4423
  super("|", e, t);
4305
4424
  }
4306
4425
  eval(e, t) {
4307
4426
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4308
- return Ce([...n, ...i2]);
4427
+ return Re([...n, ...i2]);
4309
4428
  }
4310
4429
  };
4311
- var Le = class extends v {
4430
+ var Ue = class extends v {
4312
4431
  constructor(e, t) {
4313
4432
  super("=", e, t);
4314
4433
  }
4315
4434
  eval(e, t) {
4316
4435
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4317
- return yt(n, i2);
4436
+ return at(n, i2);
4318
4437
  }
4319
4438
  };
4320
- var _e = class extends v {
4439
+ var Le = class extends v {
4321
4440
  constructor(e, t) {
4322
4441
  super("!=", e, t);
4323
4442
  }
4324
4443
  eval(e, t) {
4325
4444
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4326
- return ht(yt(n, i2));
4445
+ return st(at(n, i2));
4327
4446
  }
4328
4447
  };
4329
- var Ne = class extends v {
4448
+ var Fe = class extends v {
4330
4449
  constructor(e, t) {
4331
4450
  super("~", e, t);
4332
4451
  }
4333
4452
  eval(e, t) {
4334
4453
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4335
- return gt(n, i2);
4454
+ return ct(n, i2);
4336
4455
  }
4337
4456
  };
4338
- var Me = class extends v {
4457
+ var Ne = class extends v {
4339
4458
  constructor(e, t) {
4340
4459
  super("!~", e, t);
4341
4460
  }
4342
4461
  eval(e, t) {
4343
4462
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4344
- return ht(gt(n, i2));
4463
+ return st(ct(n, i2));
4345
4464
  }
4346
4465
  };
4347
4466
  var Y = class extends v {
@@ -4353,25 +4472,25 @@ var Y = class extends v {
4353
4472
  if (n.length !== 1)
4354
4473
  return [];
4355
4474
  let i2 = this.right.name;
4356
- return d(we(n[0], i2));
4475
+ return l(Ee(n[0], i2));
4357
4476
  }
4358
4477
  };
4359
- var Be = class extends v {
4478
+ var Me = class extends v {
4360
4479
  constructor(e, t) {
4361
4480
  super("and", e, t);
4362
4481
  }
4363
4482
  eval(e, t) {
4364
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4365
- return n?.value === true && i2?.value === true ? d(true) : n?.value === false || i2?.value === false ? d(false) : [];
4483
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4484
+ return n?.value === true && i2?.value === true ? l(true) : n?.value === false || i2?.value === false ? l(false) : [];
4366
4485
  }
4367
4486
  };
4368
- var Fe = class extends v {
4487
+ var Be = class extends v {
4369
4488
  constructor(e, t) {
4370
4489
  super("or", e, t);
4371
4490
  }
4372
4491
  eval(e, t) {
4373
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4374
- return n?.value === false && i2?.value === false ? d(false) : n?.value || i2?.value ? d(true) : [];
4492
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4493
+ return n?.value === false && i2?.value === false ? l(false) : n?.value || i2?.value ? l(true) : [];
4375
4494
  }
4376
4495
  };
4377
4496
  var qe = class extends v {
@@ -4379,20 +4498,20 @@ var qe = class extends v {
4379
4498
  super("xor", e, t);
4380
4499
  }
4381
4500
  eval(e, t) {
4382
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4383
- return !n || !i2 ? [] : d(n.value !== i2.value);
4501
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4502
+ return !n || !i2 ? [] : l(n.value !== i2.value);
4384
4503
  }
4385
4504
  };
4386
- var je = class extends v {
4505
+ var $e = class extends v {
4387
4506
  constructor(e, t) {
4388
4507
  super("implies", e, t);
4389
4508
  }
4390
4509
  eval(e, t) {
4391
- let n = V(this.left.eval(e, t), "boolean"), i2 = V(this.right.eval(e, t), "boolean");
4392
- return i2?.value === true || n?.value === false ? d(true) : !n || !i2 ? [] : d(false);
4510
+ let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4511
+ return i2?.value === true || n?.value === false ? l(true) : !n || !i2 ? [] : l(false);
4393
4512
  }
4394
4513
  };
4395
- var M = class {
4514
+ var B = class {
4396
4515
  constructor(e, t) {
4397
4516
  this.name = e;
4398
4517
  this.args = t;
@@ -4426,61 +4545,67 @@ var X = class {
4426
4545
  return `${this.left.toString()}[${this.expr.toString()}]`;
4427
4546
  }
4428
4547
  };
4429
- var pe = ["!=", "!~", "<=", ">=", "{}", "->"];
4430
- 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 };
4431
- var Bn = { parse(r4) {
4548
+ var ce = ["!=", "!~", "<=", ">=", "{}", "->"];
4549
+ 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 };
4550
+ var Xn = { parse(r4) {
4432
4551
  let e = r4.consumeAndParse();
4433
4552
  if (!r4.match(")"))
4434
4553
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4435
4554
  return e;
4436
4555
  } };
4437
- var Fn = { parse(r4, e) {
4556
+ var Zn = { parse(r4, e) {
4438
4557
  let t = r4.consumeAndParse();
4439
4558
  if (!r4.match("]"))
4440
4559
  throw new Error("Parse error: expected `]`");
4441
4560
  return new X(e, t);
4442
- }, precedence: p.Indexer };
4443
- var qn = { parse(r4, e) {
4444
- if (!(e instanceof N))
4561
+ }, precedence: f.Indexer };
4562
+ var ei = { parse(r4, e) {
4563
+ if (!(e instanceof M))
4445
4564
  throw new Error("Unexpected parentheses");
4446
4565
  let t = [];
4447
4566
  for (; !r4.match(")"); )
4448
4567
  t.push(r4.consumeAndParse()), r4.match(",");
4449
- return new M(e.name, t);
4450
- }, precedence: p.FunctionCall };
4451
- function jn(r4) {
4568
+ return new B(e.name, t);
4569
+ }, precedence: f.FunctionCall };
4570
+ function ti(r4) {
4452
4571
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4453
4572
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4454
4573
  }
4455
- function fe() {
4456
- return new Pe().registerPrefix("String", { parse: (r4, e) => new I({ type: "string", value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new I({ type: "dateTime", value: re(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 N(e.value) }).registerPrefix("{}", { parse: () => new ke() }).registerPrefix("(", Bn).registerInfix("[", Fn).registerInfix("(", qn).prefix("+", p.UnaryAdd, (r4, e) => new De("+", 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 ne(r4, t)).infixLeft("=", p.Equals, (r4, e, t) => new Le(r4, t)).infixLeft("!=", p.NotEquals, (r4, e, t) => new _e(r4, t)).infixLeft("~", p.Equivalent, (r4, e, t) => new Ne(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 Oe(r4, t)).infixLeft("and", p.And, (r4, e, t) => new Be(r4, t)).infixLeft("as", p.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", p.Contains, (r4, e, t) => new Ve(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 Ue(r4, t)).infixLeft("is", p.Is, (r4, e, t) => new Y(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 Fe(r4, t)).infixLeft("xor", p.Xor, (r4, e, t) => new qe(r4, t)).infixLeft("implies", p.Implies, (r4, e, t) => new je(r4, t));
4574
+ function ue() {
4575
+ return new ye().registerPrefix("String", { parse: (r4, e) => new k({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new k({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new k({ type: u.Quantity, value: ti(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new k({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new k({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new k({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new ke() }).registerPrefix("(", Xn).registerInfix("[", Zn).registerInfix("(", ei).prefix("+", f.UnaryAdd, (r4, e) => new Oe("+", e, (t) => t)).prefix("-", f.UnarySubtract, (r4, e) => new E("-", e, e, (t, n) => -n)).infixLeft(".", f.Dot, (r4, e, t) => new Q(r4, t)).infixLeft("/", f.Divide, (r4, e, t) => new E("/", r4, t, (n, i2) => n / i2)).infixLeft("*", f.Multiply, (r4, e, t) => new E("*", r4, t, (n, i2) => n * i2)).infixLeft("+", f.Add, (r4, e, t) => new E("+", r4, t, (n, i2) => n + i2)).infixLeft("-", f.Subtract, (r4, e, t) => new E("-", r4, t, (n, i2) => n - i2)).infixLeft("|", f.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", f.Equals, (r4, e, t) => new Ue(r4, t)).infixLeft("!=", f.NotEquals, (r4, e, t) => new Le(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Fe(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new Ne(r4, t)).infixLeft("<", f.LessThan, (r4, e, t) => new E("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", f.LessThanOrEquals, (r4, e, t) => new E("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", f.GreaterThan, (r4, e, t) => new E(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", f.GreaterThanOrEquals, (r4, e, t) => new E(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", f.Ampersand, (r4, e, t) => new De(r4, t)).infixLeft("and", f.And, (r4, e, t) => new Me(r4, t)).infixLeft("as", f.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", f.Contains, (r4, e, t) => new Ve(r4, t)).infixLeft("div", f.Divide, (r4, e, t) => new E("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", f.In, (r4, e, t) => new _e(r4, t)).infixLeft("is", f.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", f.Modulo, (r4, e, t) => new E("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", f.Or, (r4, e, t) => new Be(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new qe(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new $e(r4, t));
4457
4576
  }
4458
- var $n = fe();
4459
- var Qn = ((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))(Qn || {});
4460
- var Ar = ((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))(Ar || {});
4461
- var gi = ((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))(gi || {});
4462
- function Dr(r4) {
4577
+ var ri = ue();
4578
+ var Cr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(Cr || {});
4579
+ var ui = ((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))(ui || {});
4580
+ 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 || {});
4581
+ function Mr(r4) {
4463
4582
  if (typeof window < "u")
4464
4583
  return window.atob(r4);
4465
4584
  if (typeof Buffer < "u")
4466
4585
  return Buffer.from(r4, "base64").toString("binary");
4467
4586
  throw new Error("Unable to decode base64");
4468
4587
  }
4469
- function Or(r4) {
4588
+ function Br(r4) {
4470
4589
  if (typeof window < "u")
4471
4590
  return window.btoa(r4);
4472
4591
  if (typeof Buffer < "u")
4473
4592
  return Buffer.from(r4, "binary").toString("base64");
4474
4593
  throw new Error("Unable to encode base64");
4475
4594
  }
4476
- function Et() {
4595
+ function It() {
4477
4596
  let r4 = new Uint32Array(28);
4478
- return crypto.getRandomValues(r4), or(r4.buffer);
4597
+ return crypto.getRandomValues(r4), Kt(r4.buffer);
4479
4598
  }
4480
- async function Vr(r4) {
4599
+ async function qr(r4) {
4481
4600
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4482
4601
  }
4483
- var He = class {
4602
+ function pe() {
4603
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
4604
+ let e = Math.random() * 16 | 0;
4605
+ return (r4 === "x" ? e : e & 3 | 8).toString(16);
4606
+ });
4607
+ }
4608
+ var Qe = class {
4484
4609
  constructor(e = 10) {
4485
4610
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4486
4611
  }
@@ -4504,8 +4629,8 @@ var He = class {
4504
4629
  return this.cache.keys().next().value;
4505
4630
  }
4506
4631
  };
4507
- var Z = { 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 We = class {
4632
+ 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" };
4633
+ var fe = class {
4509
4634
  constructor() {
4510
4635
  this.listeners = {};
4511
4636
  }
@@ -4524,34 +4649,139 @@ var We = class {
4524
4649
  }
4525
4650
  dispatchEvent(e) {
4526
4651
  let t = this.listeners[e.type];
4527
- return t && t.forEach((n) => n.call(this, e)), !e.defaultPrevented;
4652
+ if (t)
4653
+ for (let n of t)
4654
+ n.call(this, e);
4655
+ return !e.defaultPrevented;
4528
4656
  }
4529
4657
  };
4530
- function Pi(r4) {
4531
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Dr(e), n = Array.from(t).reduce((o, s) => {
4658
+ var We = class {
4659
+ constructor() {
4660
+ this.emitter = new fe();
4661
+ }
4662
+ dispatchEvent(e) {
4663
+ this.emitter.dispatchEvent(e);
4664
+ }
4665
+ addEventListener(e, t) {
4666
+ this.emitter.addEventListener(e, t);
4667
+ }
4668
+ removeEventListener(e, t) {
4669
+ this.emitter.removeEventListener(e, t);
4670
+ }
4671
+ };
4672
+ var kt = { "patient-open": "patient-open", "patient-close": "patient-close", "imagingstudy-open": "imagingstudy-open", "imagingstudy-close": "imagingstudy-close" };
4673
+ var Mi = ["Patient", "Encounter", "ImagingStudy"];
4674
+ var Bi = { "patient-open": ["Patient"], "patient-close": ["Patient"], "imagingstudy-open": ["Patient", "ImagingStudy"], "imagingstudy-close": ["Patient", "ImagingStudy"] };
4675
+ var qi = { "patient-open": ["Encounter"], "patient-close": ["Encounter"], "imagingstudy-open": [], "imagingstudy-close": [] };
4676
+ function $i(r4) {
4677
+ return Mi.includes(r4);
4678
+ }
4679
+ var ji = { ImagingStudy: "study", Patient: "patient", Encounter: "encounter" };
4680
+ function jr(r4) {
4681
+ return !!r4.endpoint;
4682
+ }
4683
+ function Ot(r4) {
4684
+ if (!Ke(r4))
4685
+ throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4686
+ 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(",") };
4687
+ return jr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4688
+ }
4689
+ function Ke(r4) {
4690
+ if (typeof r4 != "object")
4691
+ return false;
4692
+ let { channelType: e, mode: t, topic: n, events: i2 } = r4;
4693
+ if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
4694
+ return false;
4695
+ for (let o of i2)
4696
+ if (!kt[o])
4697
+ return false;
4698
+ return !(jr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4699
+ }
4700
+ function Hi(r4, e, t, n) {
4701
+ if (!(e.key && typeof e.key == "string"))
4702
+ throw new d(h(`context[${t}] is invalid. Context must contain a key.`));
4703
+ if (n.has(e.key))
4704
+ throw new d(h(`context[${t}] is invalid. Key ${e.key} has already been used in a previous context.`));
4705
+ if (n.add(e.key), typeof e.resource != "object")
4706
+ throw new d(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
4707
+ if (!(e.resource.id && typeof e.resource.id == "string"))
4708
+ throw new d(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
4709
+ if (!e.resource.resourceType)
4710
+ throw new d(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4711
+ let i2 = e.resource.resourceType;
4712
+ if (!$i(i2))
4713
+ throw new d(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4714
+ let o = Bi[r4], s = qi[r4], a;
4715
+ if (t < o.length ? a = o[t] : t - o.length < s.length && (a = s[t - o.length]), a && i2 !== a)
4716
+ throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${a}.`));
4717
+ let c2 = ji[i2];
4718
+ if (c2 !== e.key)
4719
+ throw new d(h(`context[${t}] is invalid. Context key for type ${i2} must be ${c2}.`));
4720
+ }
4721
+ function Qi(r4, e) {
4722
+ let t = /* @__PURE__ */ new Set();
4723
+ for (let n = 0; n < e.length; n++)
4724
+ Hi(r4, e[n], n, t);
4725
+ }
4726
+ function Hr(r4, e, t) {
4727
+ if (!(r4 && typeof r4 == "string"))
4728
+ throw new d(h("Must provide a topic."));
4729
+ if (!kt[e])
4730
+ throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(kt).join(", ")}`));
4731
+ if (typeof t != "object")
4732
+ throw new d(h("context must be a context object or array of context objects."));
4733
+ let n = Array.isArray(t) ? t : [t];
4734
+ return Qi(e, n), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: pe(), event: { "hub.topic": r4, "hub.event": e, context: n } };
4735
+ }
4736
+ var Ge = class extends We {
4737
+ constructor(t) {
4738
+ super();
4739
+ if (this.subRequest = t, !t.endpoint)
4740
+ throw new d(h("Subscription request should contain an endpoint."));
4741
+ if (!Ke(t))
4742
+ throw new d(h("Subscription request failed validation."));
4743
+ let n = new WebSocket(t.endpoint);
4744
+ n.addEventListener("open", () => {
4745
+ this.dispatchEvent({ type: "connect" }), n.addEventListener("message", (i2) => {
4746
+ let o = JSON.parse(i2.data);
4747
+ if (o["hub.topic"])
4748
+ return;
4749
+ let s = o;
4750
+ this.dispatchEvent({ type: "message", payload: s }), n.send(JSON.stringify({ id: o?.id, timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
4751
+ }), n.addEventListener("close", () => {
4752
+ this.dispatchEvent({ type: "disconnect" });
4753
+ });
4754
+ }), this.websocket = n;
4755
+ }
4756
+ disconnect() {
4757
+ this.websocket.close();
4758
+ }
4759
+ };
4760
+ function Wi(r4) {
4761
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Mr(e), n = Array.from(t).reduce((o, s) => {
4532
4762
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4533
4763
  return `${o}%${a}`;
4534
4764
  }, ""), i2 = decodeURIComponent(n);
4535
4765
  return JSON.parse(i2);
4536
4766
  }
4537
- function Lr(r4) {
4767
+ function Qr(r4) {
4538
4768
  return r4.split(".").length === 3;
4539
4769
  }
4540
- function Ct(r4) {
4770
+ function Dt(r4) {
4541
4771
  let [e, t, n] = r4.split(".");
4542
- return Pi(t);
4772
+ return Wi(t);
4543
4773
  }
4544
- function _r(r4) {
4774
+ function Wr(r4) {
4545
4775
  try {
4546
- return typeof Ct(r4).login_id == "string";
4776
+ return typeof Dt(r4).login_id == "string";
4547
4777
  } catch {
4548
4778
  return false;
4549
4779
  }
4550
4780
  }
4551
- var Ci;
4552
- var w = class {
4781
+ var Gi;
4782
+ var C = class {
4553
4783
  constructor(e) {
4554
- this[Ci] = "ReadablePromise";
4784
+ this[Gi] = "ReadablePromise";
4555
4785
  this.status = "pending";
4556
4786
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4557
4787
  throw this.status = "error", this.error = t, t;
@@ -4583,10 +4813,10 @@ var w = class {
4583
4813
  return this.suspender.finally(e);
4584
4814
  }
4585
4815
  };
4586
- Ci = Symbol.toStringTag;
4587
- var Ge = class {
4816
+ Gi = Symbol.toStringTag;
4817
+ var ze = class {
4588
4818
  constructor() {
4589
- this.storage = typeof localStorage < "u" ? localStorage : new wt();
4819
+ this.storage = typeof localStorage < "u" ? localStorage : new Vt();
4590
4820
  }
4591
4821
  clear() {
4592
4822
  this.storage.clear();
@@ -4602,10 +4832,10 @@ var Ge = class {
4602
4832
  return t ? JSON.parse(t) : void 0;
4603
4833
  }
4604
4834
  setObject(e, t) {
4605
- this.setString(e, t ? rr(t) : void 0);
4835
+ this.setString(e, t ? Qt(t) : void 0);
4606
4836
  }
4607
4837
  };
4608
- var wt = class {
4838
+ var Vt = class {
4609
4839
  constructor() {
4610
4840
  this.data = /* @__PURE__ */ new Map();
4611
4841
  }
@@ -4628,22 +4858,26 @@ var wt = class {
4628
4858
  return Array.from(this.data.keys())[e];
4629
4859
  }
4630
4860
  };
4631
- var wi = "https://api.medplum.com/";
4632
- var Ii = 1e3;
4633
- var ki = 6e4;
4634
- var Nr = "Binary/";
4635
- var Mr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4636
- var Di = ((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))(Di || {});
4637
- var Oi = ((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))(Oi || {});
4638
- var Vi = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Vi || {});
4639
- var Br = class extends We {
4861
+ var Ki = "https://api.medplum.com/";
4862
+ var zi = 1e3;
4863
+ var Ji = 6e4;
4864
+ var Gr = "Binary/";
4865
+ var Kr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4866
+ 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 || {});
4867
+ 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 || {});
4868
+ var Zi = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Zi || {});
4869
+ var zr = class extends fe {
4640
4870
  constructor(t) {
4641
4871
  super();
4642
4872
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4643
4873
  throw new Error("Base URL must start with http or https");
4644
- this.options = t ?? {}, this.fetch = t?.fetch ?? Ui(), this.storage = t?.storage ?? new Ge(), this.createPdfImpl = t?.createPdf, this.baseUrl = qr(t?.baseUrl ?? wi), this.fhirBaseUrl = qr(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 ?? ki, this.cacheTime > 0 ? this.requestCache = new He(t?.resourceCacheSize ?? Ii) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0);
4645
- let n = this.getActiveLogin();
4646
- n && (this.setAccessToken(n.accessToken, n.refreshToken), this.refreshProfile().catch(console.log)), this.setupStorageListener();
4874
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? eo(), this.storage = t?.storage ?? new ze(), this.createPdfImpl = t?.createPdf, this.baseUrl = Yr(t?.baseUrl ?? Ki), this.fhirBaseUrl = Yr(Je(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Je(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Je(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Je(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Ji, this.cacheTime > 0 ? this.requestCache = new Qe(t?.resourceCacheSize ?? zi) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4875
+ this.setAccessToken(t.accessToken);
4876
+ else {
4877
+ let n = this.getActiveLogin();
4878
+ n && (this.setAccessToken(n.accessToken, n.refreshToken), this.refreshProfile().catch(console.log));
4879
+ }
4880
+ this.setupStorageListener();
4647
4881
  }
4648
4882
  getBaseUrl() {
4649
4883
  return this.baseUrl;
@@ -4684,7 +4918,7 @@ var Br = class extends We {
4684
4918
  t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, c2) => {
4685
4919
  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
4920
  }) : o = this.request("GET", t, n);
4687
- let s = new w(o);
4921
+ let s = new C(o);
4688
4922
  return this.setCacheEntry(t, s), s;
4689
4923
  }
4690
4924
  post(t, n, i2, o = {}) {
@@ -4694,7 +4928,7 @@ var Br = class extends We {
4694
4928
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4695
4929
  }
4696
4930
  patch(t, n, i2 = {}) {
4697
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, Z.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4931
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, F.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4698
4932
  }
4699
4933
  delete(t, n) {
4700
4934
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -4760,12 +4994,12 @@ var Br = class extends We {
4760
4994
  let o = this.fhirSearchUrl(t, n), s = o.toString() + "-search", a = this.getCacheEntry(s, i2);
4761
4995
  if (a)
4762
4996
  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;
4997
+ let c2 = new C((async () => {
4998
+ let m2 = await this.get(o, i2);
4999
+ if (m2.entry)
5000
+ for (let p2 of m2.entry)
5001
+ this.cacheResource(p2.resource);
5002
+ return m2;
4769
5003
  })());
4770
5004
  return this.setCacheEntry(s, c2), c2;
4771
5005
  }
@@ -4775,23 +5009,23 @@ var Br = class extends We {
4775
5009
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
4776
5010
  if (a)
4777
5011
  return a.value;
4778
- let c2 = new w(this.search(t, o.searchParams, i2).then((f) => f.entry?.[0]?.resource));
5012
+ let c2 = new C(this.search(t, o.searchParams, i2).then((m2) => m2.entry?.[0]?.resource));
4779
5013
  return this.setCacheEntry(s, c2), c2;
4780
5014
  }
4781
5015
  searchResources(t, n, i2) {
4782
5016
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
4783
5017
  if (a)
4784
5018
  return a.value;
4785
- let c2 = new w(this.search(t, n, i2).then($r));
5019
+ let c2 = new C(this.search(t, n, i2).then(Zr));
4786
5020
  return this.setCacheEntry(s, c2), c2;
4787
5021
  }
4788
5022
  async *searchResourcePages(t, n, i2) {
4789
5023
  let o = this.fhirSearchUrl(t, n);
4790
5024
  for (; o; ) {
4791
- let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((f) => f.relation === "next");
5025
+ let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((m2) => m2.relation === "next");
4792
5026
  if (!a.entry?.length && !c2)
4793
5027
  break;
4794
- yield $r(a), o = c2?.url ? new URL(c2.url) : void 0;
5028
+ yield Zr(a), o = c2?.url ? new URL(c2.url) : void 0;
4795
5029
  }
4796
5030
  }
4797
5031
  searchValueSet(t, n, i2) {
@@ -4807,7 +5041,7 @@ var Br = class extends We {
4807
5041
  if (!n)
4808
5042
  return;
4809
5043
  if (n === "system")
4810
- return Mr;
5044
+ return Kr;
4811
5045
  let [i2, o] = n.split("/");
4812
5046
  if (!(!i2 || !o))
4813
5047
  return this.getCached(i2, o);
@@ -4818,40 +5052,46 @@ var Br = class extends We {
4818
5052
  readReference(t, n) {
4819
5053
  let i2 = t.reference;
4820
5054
  if (!i2)
4821
- return new w(Promise.reject(new Error("Missing reference")));
5055
+ return new C(Promise.reject(new Error("Missing reference")));
4822
5056
  if (i2 === "system")
4823
- return new w(Promise.resolve(Mr));
5057
+ return new C(Promise.resolve(Kr));
4824
5058
  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;
5059
+ return !o || !s ? new C(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
4829
5060
  }
4830
5061
  requestSchema(t) {
4831
- if (t in y.types)
4832
- return Promise.resolve(y);
5062
+ if (vr(t))
5063
+ return Promise.resolve();
4833
5064
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
4834
5065
  if (i2)
4835
5066
  return i2.value;
4836
- let o = new w((async () => {
5067
+ let o = new C((async () => {
4837
5068
  let s = `{
4838
5069
  StructureDefinitionList(name: "${t}") {
5070
+ resourceType,
4839
5071
  name,
5072
+ kind,
4840
5073
  description,
4841
5074
  snapshot {
4842
5075
  element {
4843
5076
  id,
4844
5077
  path,
5078
+ definition,
4845
5079
  min,
4846
5080
  max,
5081
+ base {
5082
+ path,
5083
+ min,
5084
+ max
5085
+ },
5086
+ contentReference,
4847
5087
  type {
4848
5088
  code,
4849
5089
  targetProfile
4850
5090
  },
4851
5091
  binding {
5092
+ strength,
4852
5093
  valueSet
4853
- },
4854
- definition
5094
+ }
4855
5095
  }
4856
5096
  }
4857
5097
  }
@@ -4863,11 +5103,9 @@ var Br = class extends We {
4863
5103
  target
4864
5104
  }
4865
5105
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
4866
- for (let c2 of a.data.StructureDefinitionList)
4867
- pt(c2);
5106
+ xr(a.data.StructureDefinitionList);
4868
5107
  for (let c2 of a.data.SearchParameterList)
4869
- ft(c2);
4870
- return y;
5108
+ bt(c2);
4871
5109
  })());
4872
5110
  return this.setCacheEntry(n, o), o;
4873
5111
  }
@@ -4899,7 +5137,7 @@ var Br = class extends We {
4899
5137
  uploadwithProgress(t, n, i2, o) {
4900
5138
  return new Promise((s, a) => {
4901
5139
  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 = () => {
5140
+ 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
5141
  c2.status >= 200 && c2.status < 300 ? s(c2.response) : a(new Error(c2.statusText));
4904
5142
  }, 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
5143
  });
@@ -4912,7 +5150,7 @@ var Br = class extends We {
4912
5150
  }
4913
5151
  createComment(t, n, i2) {
4914
5152
  let o = this.getProfile(), s, a;
4915
- return t.resourceType === "Encounter" && (s = G(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = G(t)), this.createResource({ resourceType: "Communication", basedOn: [G(t)], encounter: s, subject: a, sender: o ? G(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5153
+ 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
5154
  }
4917
5155
  async updateResource(t, n) {
4918
5156
  if (!t.resourceType)
@@ -4947,10 +5185,10 @@ var Br = class extends We {
4947
5185
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
4948
5186
  }
4949
5187
  sendEmail(t, n) {
4950
- return this.post("email/v1/send", t, Z.JSON, n);
5188
+ return this.post("email/v1/send", t, F.JSON, n);
4951
5189
  }
4952
5190
  graphql(t, n, i2, o) {
4953
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, Z.JSON, o);
5191
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, F.JSON, o);
4954
5192
  }
4955
5193
  readResourceGraph(t, n, i2, o) {
4956
5194
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
@@ -4968,7 +5206,7 @@ var Br = class extends We {
4968
5206
  return this.accessToken;
4969
5207
  }
4970
5208
  setAccessToken(t, n) {
4971
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = _r(t);
5209
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Wr(t);
4972
5210
  }
4973
5211
  getLogins() {
4974
5212
  return this.storage.getObject("logins") ?? [];
@@ -5003,7 +5241,7 @@ var Br = class extends We {
5003
5241
  return this.sessionDetails?.profile;
5004
5242
  }
5005
5243
  async getProfileAsync() {
5006
- return this.profilePromise && await this.profilePromise, this.getProfile();
5244
+ return this.profilePromise ? this.profilePromise : this.sessionDetails ? this.sessionDetails.profile : this.refreshProfile();
5007
5245
  }
5008
5246
  getUserConfiguration() {
5009
5247
  return this.sessionDetails?.config;
@@ -5014,11 +5252,11 @@ var Br = class extends We {
5014
5252
  async download(t, n = {}) {
5015
5253
  this.refreshPromise && await this.refreshPromise;
5016
5254
  let i2 = t.toString();
5017
- return i2.startsWith(Nr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5255
+ return i2.startsWith(Gr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5018
5256
  }
5019
5257
  async uploadMedia(t, n, i2, o, s) {
5020
5258
  let a = await this.createBinary(t, i2, n);
5021
- return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Nr + a.id, title: i2 } }, s);
5259
+ return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Gr + a.id, title: i2 } }, s);
5022
5260
  }
5023
5261
  async bulkExport(t = "", n, i2, o) {
5024
5262
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5030,7 +5268,7 @@ var Br = class extends We {
5030
5268
  i2.Prefer = "respond-async";
5031
5269
  let o = await this.fetchWithRetry(t, n);
5032
5270
  if (o.status === 202) {
5033
- let s = await jr(o);
5271
+ let s = await Xr(o);
5034
5272
  if (s)
5035
5273
  return this.pollStatus(s);
5036
5274
  }
@@ -5047,7 +5285,7 @@ var Br = class extends We {
5047
5285
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
5048
5286
  }
5049
5287
  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)));
5288
+ 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
5289
  }
5052
5290
  deleteCacheEntry(t) {
5053
5291
  this.requestCache && this.requestCache.delete(t);
@@ -5064,22 +5302,22 @@ var Br = class extends We {
5064
5302
  return;
5065
5303
  let a = t.headers.get("content-type")?.includes("json");
5066
5304
  if (t.status === 404 && !a)
5067
- throw new m(Qt);
5068
- let c2 = t.headers.get("content-location"), f = o.redirect ?? this.options.redirect;
5069
- if (t.status === 201 && c2 && f === "follow")
5305
+ throw new d(lr);
5306
+ let c2 = t.headers.get("content-location"), m2 = o.redirect ?? this.options.redirect;
5307
+ if (t.status === 201 && c2 && m2 === "follow")
5070
5308
  return this.request("GET", c2, { ...o, body: void 0 });
5071
- let l2;
5309
+ let p2;
5072
5310
  if (a)
5073
5311
  try {
5074
- l2 = await t.json();
5075
- } catch (B) {
5076
- throw console.error("Error parsing response", t.status, B), B;
5312
+ p2 = await t.json();
5313
+ } catch (q) {
5314
+ throw console.error("Error parsing response", t.status, q), q;
5077
5315
  }
5078
5316
  else
5079
- l2 = await t.text();
5317
+ p2 = await t.text();
5080
5318
  if (t.status >= 400)
5081
- throw new m(ot(l2));
5082
- return l2;
5319
+ throw new d(ht(p2));
5320
+ return p2;
5083
5321
  }
5084
5322
  async fetchWithRetry(t, n) {
5085
5323
  t.startsWith("http") || (t = new URL(t, this.baseUrl).href);
@@ -5091,7 +5329,7 @@ var Br = class extends We {
5091
5329
  } catch (c2) {
5092
5330
  this.retryCatch(a, i2, c2);
5093
5331
  }
5094
- await lt(o);
5332
+ await nt(o);
5095
5333
  }
5096
5334
  return s;
5097
5335
  }
@@ -5112,10 +5350,10 @@ var Br = class extends We {
5112
5350
  this.addFetchOptionsDefaults(s);
5113
5351
  let a = await this.fetchWithRetry(t, s);
5114
5352
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5115
- let c2 = await jr(a);
5353
+ let c2 = await Xr(a);
5116
5354
  c2 && (i2 = await this.fetchWithRetry(c2, s));
5117
5355
  }
5118
- await lt(o);
5356
+ await nt(o);
5119
5357
  }
5120
5358
  return this.parseResponse(i2, "POST", t);
5121
5359
  }
@@ -5126,19 +5364,19 @@ var Br = class extends We {
5126
5364
  try {
5127
5365
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
5128
5366
  } catch (s) {
5129
- o.reject(new m(ot(s)));
5367
+ o.reject(new d(ht(s)));
5130
5368
  }
5131
5369
  return;
5132
5370
  }
5133
5371
  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
5372
  for (let o = 0; o < t.length; o++) {
5135
5373
  let s = t[o], a = i2.entry?.[o];
5136
- a?.response?.outcome && !it(a.response.outcome) ? s.reject(new m(a.response.outcome)) : s.resolve(a?.resource);
5374
+ a?.response?.outcome && !mt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5137
5375
  }
5138
5376
  }
5139
5377
  addFetchOptionsDefaults(t) {
5140
5378
  let n = t.headers;
5141
- n || (n = {}, t.headers = n), n.Accept = Z.FHIR_JSON, n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = Z.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");
5379
+ 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
5380
  }
5143
5381
  setRequestContentType(t, n) {
5144
5382
  t.headers || (t.headers = {});
@@ -5152,20 +5390,20 @@ var Br = class extends We {
5152
5390
  return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
5153
5391
  }
5154
5392
  async startPkce() {
5155
- let t = Et();
5393
+ let t = It();
5156
5394
  sessionStorage.setItem("pkceState", t);
5157
- let n = Et();
5395
+ let n = It();
5158
5396
  sessionStorage.setItem("codeVerifier", n);
5159
- let i2 = await Vr(n), o = sr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5397
+ let i2 = await qr(n), o = zt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5160
5398
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5161
5399
  }
5162
5400
  async requestAuthorization(t) {
5163
5401
  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 ?? Fr()), 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());
5402
+ 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
5403
  }
5166
5404
  processCode(t, n) {
5167
5405
  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 ?? Fr()), typeof sessionStorage < "u") {
5406
+ 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
5407
  let o = sessionStorage.getItem("codeVerifier");
5170
5408
  o && i2.set("code_verifier", o);
5171
5409
  }
@@ -5196,22 +5434,45 @@ var Br = class extends We {
5196
5434
  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
5435
  }
5198
5436
  setBasicAuth(t, n) {
5199
- this.clientId = t, this.clientSecret = n, this.basicAuth = Or(t + ":" + n);
5437
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Br(t + ":" + n);
5438
+ }
5439
+ async fhircastSubscribe(t, n) {
5440
+ if (!(typeof t == "string" && t !== ""))
5441
+ throw new d(h("Invalid topic provided. Topic must be a valid string."));
5442
+ if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
5443
+ throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5444
+ 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"];
5445
+ if (!s)
5446
+ throw new Error("Invalid response!");
5447
+ return i2.endpoint = s, i2;
5448
+ }
5449
+ async fhircastUnsubscribe(t) {
5450
+ if (!Ke(t))
5451
+ throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5452
+ if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
5453
+ throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5454
+ t.mode = "unsubscribe", await this.post("/fhircast/STU2", Ot(t), F.FORM_URL_ENCODED);
5455
+ }
5456
+ fhircastConnect(t) {
5457
+ return new Ge(t);
5458
+ }
5459
+ async fhircastPublish(t, n, i2) {
5460
+ return this.post(`/fhircast/STU2/${t}`, Hr(t, n, i2), F.JSON);
5200
5461
  }
5201
5462
  async invite(t, n) {
5202
5463
  return this.post("admin/projects/" + t + "/invite", n);
5203
5464
  }
5204
5465
  async fetchTokens(t) {
5205
- let n = { method: "POST", headers: { "Content-Type": Z.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5466
+ let n = { method: "POST", headers: { "Content-Type": F.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5206
5467
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5207
5468
  let o = await this.fetchWithRetry(this.tokenUrl, n);
5208
5469
  if (!o.ok) {
5209
5470
  this.clearActiveLogin();
5210
5471
  try {
5211
5472
  let a = await o.json();
5212
- throw new m(k(a.error_description));
5473
+ throw new d(_(a.error_description));
5213
5474
  } catch (a) {
5214
- throw new m(k("Failed to fetch tokens"), a);
5475
+ throw new d(_("Failed to fetch tokens"), a);
5215
5476
  }
5216
5477
  }
5217
5478
  let s = await o.json();
@@ -5219,8 +5480,8 @@ var Br = class extends We {
5219
5480
  }
5220
5481
  async verifyTokens(t) {
5221
5482
  let n = t.access_token;
5222
- if (Lr(n)) {
5223
- let i2 = Ct(n);
5483
+ if (Qr(n)) {
5484
+ let i2 = Dt(n);
5224
5485
  if (Date.now() >= i2.exp * 1e3)
5225
5486
  throw this.clearActiveLogin(), new Error("Token expired");
5226
5487
  if (i2.cid) {
@@ -5244,21 +5505,21 @@ var Br = class extends We {
5244
5505
  throw i2;
5245
5506
  }
5246
5507
  };
5247
- function Ui() {
5508
+ function eo() {
5248
5509
  if (!globalThis.fetch)
5249
5510
  throw new Error("Fetch not available in this environment");
5250
5511
  return globalThis.fetch.bind(globalThis);
5251
5512
  }
5252
- function Fr() {
5513
+ function Jr() {
5253
5514
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5254
5515
  }
5255
- function qr(r4) {
5516
+ function Yr(r4) {
5256
5517
  return r4.endsWith("/") ? r4 : r4 + "/";
5257
5518
  }
5258
- function ze(r4, e) {
5519
+ function Je(r4, e) {
5259
5520
  return new URL(e, r4).toString();
5260
5521
  }
5261
- async function jr(r4) {
5522
+ async function Xr(r4) {
5262
5523
  let e = r4.headers.get("content-location");
5263
5524
  if (e)
5264
5525
  return e;
@@ -5266,18 +5527,18 @@ async function jr(r4) {
5266
5527
  if (t)
5267
5528
  return t;
5268
5529
  let n = await r4.json();
5269
- if (Te(n) && n.issue?.[0]?.diagnostics)
5530
+ if (we(n) && n.issue?.[0]?.diagnostics)
5270
5531
  return n.issue[0].diagnostics;
5271
5532
  }
5272
- function $r(r4) {
5533
+ function Zr(r4) {
5273
5534
  let e = r4.entry?.map((t) => t.resource) ?? [];
5274
5535
  return Object.assign(e, { bundle: r4 });
5275
5536
  }
5276
- var Li = [...pe, "->", "<<", ">>"];
5277
- var _i = fe().registerInfix("->", { precedence: p.Arrow }).registerInfix(";", { precedence: p.Semicolon });
5278
- var Ni = [...pe, "eq", "ne", "co"];
5279
- var Fi = fe();
5280
- var H = class {
5537
+ var to = [...ce, "->", "<<", ">>"];
5538
+ var ro = ue().registerInfix("->", { precedence: f.Arrow }).registerInfix(";", { precedence: f.Semicolon });
5539
+ var no = [...ce, "eq", "ne", "co"];
5540
+ var so = ue();
5541
+ var G = class {
5281
5542
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5282
5543
  this.segmentSeparator = e;
5283
5544
  this.fieldSeparator = t;
@@ -5293,8 +5554,8 @@ var H = class {
5293
5554
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5294
5555
  }
5295
5556
  };
5296
- var Gr = class r {
5297
- constructor(e, t = new H()) {
5557
+ var nn = class r {
5558
+ constructor(e, t = new G()) {
5298
5559
  this.context = t, this.segments = e;
5299
5560
  }
5300
5561
  get header() {
@@ -5317,7 +5578,7 @@ var Gr = class r {
5317
5578
  }
5318
5579
  buildAck() {
5319
5580
  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 ye(["MSH", this.context.getMsh2(), o, s, n, i2, ji(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new ye(["MSA", "AA", a, "OK"], this.context)]);
5581
+ 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
5582
  }
5322
5583
  buildAckMessageType(e) {
5323
5584
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5328,13 +5589,13 @@ var Gr = class r {
5328
5589
  let n = new Error("Invalid HL7 message");
5329
5590
  throw n.type = "entity.parse.failed", n;
5330
5591
  }
5331
- let t = new H("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5332
- return new r(e.split(/[\r\n]+/).map((n) => ye.parse(n, t)), t);
5592
+ let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5593
+ return new r(e.split(/[\r\n]+/).map((n) => me.parse(n, t)), t);
5333
5594
  }
5334
5595
  };
5335
- var ye = class r2 {
5336
- constructor(e, t = new H()) {
5337
- this.context = t, nr(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5596
+ var me = class r2 {
5597
+ constructor(e, t = new G()) {
5598
+ this.context = t, Wt(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5338
5599
  }
5339
5600
  get(e) {
5340
5601
  return this.fields[e];
@@ -5356,12 +5617,12 @@ var ye = class r2 {
5356
5617
  toString() {
5357
5618
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
5358
5619
  }
5359
- static parse(e, t = new H()) {
5620
+ static parse(e, t = new G()) {
5360
5621
  return new r2(e.split(t.fieldSeparator).map((n) => oe.parse(n, t)), t);
5361
5622
  }
5362
5623
  };
5363
5624
  var oe = class r3 {
5364
- constructor(e, t = new H()) {
5625
+ constructor(e, t = new G()) {
5365
5626
  this.context = t, this.components = e;
5366
5627
  }
5367
5628
  get(e, t, n = 0) {
@@ -5374,11 +5635,11 @@ var oe = class r3 {
5374
5635
  toString() {
5375
5636
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
5376
5637
  }
5377
- static parse(e, t = new H()) {
5638
+ static parse(e, t = new G()) {
5378
5639
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5379
5640
  }
5380
5641
  };
5381
- function ji(r4) {
5642
+ function co(r4) {
5382
5643
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5383
5644
  return i2 > 0 && (n += "." + i2.toString()), n;
5384
5645
  }
@@ -5393,8 +5654,8 @@ var i = class extends EventTarget {
5393
5654
  super.removeEventListener(n, e, t);
5394
5655
  }
5395
5656
  };
5396
- var m2 = String.fromCharCode(11);
5397
- var p2 = String.fromCharCode(28);
5657
+ var m = String.fromCharCode(11);
5658
+ var p = String.fromCharCode(28);
5398
5659
  var v2 = String.fromCharCode(13);
5399
5660
  var d2 = class extends Event {
5400
5661
  constructor(e, t) {
@@ -5403,7 +5664,7 @@ var d2 = class extends Event {
5403
5664
  this.message = t;
5404
5665
  }
5405
5666
  };
5406
- var l = class extends Event {
5667
+ var l2 = class extends Event {
5407
5668
  constructor(e) {
5408
5669
  super("error");
5409
5670
  this.error = e;
@@ -5417,19 +5678,19 @@ var c = class extends i {
5417
5678
  let o = "";
5418
5679
  e.on("data", (s) => {
5419
5680
  try {
5420
- if (o += s.toString(), o.endsWith(p2 + v2)) {
5421
- let r4 = Gr.parse(o.substring(1, o.length - 2));
5681
+ if (o += s.toString(), o.endsWith(p + v2)) {
5682
+ let r4 = nn.parse(o.substring(1, o.length - 2));
5422
5683
  this.dispatchEvent(new d2(this, r4)), o = "";
5423
5684
  }
5424
5685
  } catch (r4) {
5425
- this.dispatchEvent(new l(r4));
5686
+ this.dispatchEvent(new l2(r4));
5426
5687
  }
5427
5688
  }).setEncoding(t ?? "utf-8"), e.on("error", (s) => {
5428
- o = "", this.dispatchEvent(new l(s));
5689
+ o = "", this.dispatchEvent(new l2(s));
5429
5690
  });
5430
5691
  }
5431
5692
  send(e) {
5432
- this.socket.write(m2 + e.toString() + p2 + v2);
5693
+ this.socket.write(m + e.toString() + p + v2);
5433
5694
  }
5434
5695
  async sendAndWait(e) {
5435
5696
  let t = new Promise((o) => {
@@ -5546,7 +5807,7 @@ var AgentHl7ChannelConnection = class {
5546
5807
  type: "connect",
5547
5808
  accessToken: medplum.getAccessToken(),
5548
5809
  agentId: channel.app.agentId,
5549
- botId: Oo(channel.definition.targetReference)
5810
+ botId: So(channel.definition.targetReference)
5550
5811
  })
5551
5812
  );
5552
5813
  });
@@ -5562,7 +5823,7 @@ var AgentHl7ChannelConnection = class {
5562
5823
  this.trySendToWebSocket();
5563
5824
  break;
5564
5825
  case "transmit":
5565
- this.hl7ConnectionQueue.push(Gr.parse(command.message));
5826
+ this.hl7ConnectionQueue.push(nn.parse(command.message));
5566
5827
  this.trySendToHl7Connection();
5567
5828
  break;
5568
5829
  }
@@ -5616,7 +5877,7 @@ if (typeof require !== "undefined" && require.main === module) {
5616
5877
  process.exit(1);
5617
5878
  }
5618
5879
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
5619
- const medplum = new Br({ baseUrl, clientId });
5880
+ const medplum = new zr({ baseUrl, clientId });
5620
5881
  medplum.startClientLogin(clientId, clientSecret).then(() => new App(medplum, agentId).start()).catch(console.error);
5621
5882
  }
5622
5883
  // Annotate the CommonJS export names for ESM import in node: