@medplum/agent 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/cjs/index.cjs +405 -364
  2. package/package.json +4 -4
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // node_modules/ws/lib/stream.js
33
+ // ../../node_modules/ws/lib/stream.js
34
34
  var require_stream = __commonJS({
35
- "node_modules/ws/lib/stream.js"(exports, module2) {
35
+ "../../node_modules/ws/lib/stream.js"(exports, module2) {
36
36
  "use strict";
37
37
  var { Duplex } = require("stream");
38
38
  function emitClose(stream) {
@@ -135,9 +135,9 @@ var require_stream = __commonJS({
135
135
  }
136
136
  });
137
137
 
138
- // node_modules/ws/lib/constants.js
138
+ // ../../node_modules/ws/lib/constants.js
139
139
  var require_constants = __commonJS({
140
- "node_modules/ws/lib/constants.js"(exports, module2) {
140
+ "../../node_modules/ws/lib/constants.js"(exports, module2) {
141
141
  "use strict";
142
142
  module2.exports = {
143
143
  BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
@@ -153,9 +153,9 @@ var require_constants = __commonJS({
153
153
  }
154
154
  });
155
155
 
156
- // node_modules/ws/lib/buffer-util.js
156
+ // ../../node_modules/ws/lib/buffer-util.js
157
157
  var require_buffer_util = __commonJS({
158
- "node_modules/ws/lib/buffer-util.js"(exports, module2) {
158
+ "../../node_modules/ws/lib/buffer-util.js"(exports, module2) {
159
159
  "use strict";
160
160
  var { EMPTY_BUFFER } = require_constants();
161
161
  var FastBuffer = Buffer[Symbol.species];
@@ -235,9 +235,9 @@ var require_buffer_util = __commonJS({
235
235
  }
236
236
  });
237
237
 
238
- // node_modules/ws/lib/limiter.js
238
+ // ../../node_modules/ws/lib/limiter.js
239
239
  var require_limiter = __commonJS({
240
- "node_modules/ws/lib/limiter.js"(exports, module2) {
240
+ "../../node_modules/ws/lib/limiter.js"(exports, module2) {
241
241
  "use strict";
242
242
  var kDone = Symbol("kDone");
243
243
  var kRun = Symbol("kRun");
@@ -286,9 +286,9 @@ var require_limiter = __commonJS({
286
286
  }
287
287
  });
288
288
 
289
- // node_modules/ws/lib/permessage-deflate.js
289
+ // ../../node_modules/ws/lib/permessage-deflate.js
290
290
  var require_permessage_deflate = __commonJS({
291
- "node_modules/ws/lib/permessage-deflate.js"(exports, module2) {
291
+ "../../node_modules/ws/lib/permessage-deflate.js"(exports, module2) {
292
292
  "use strict";
293
293
  var zlib = require("zlib");
294
294
  var bufferUtil = require_buffer_util();
@@ -666,9 +666,9 @@ var require_permessage_deflate = __commonJS({
666
666
  }
667
667
  });
668
668
 
669
- // node_modules/ws/lib/validation.js
669
+ // ../../node_modules/ws/lib/validation.js
670
670
  var require_validation = __commonJS({
671
- "node_modules/ws/lib/validation.js"(exports, module2) {
671
+ "../../node_modules/ws/lib/validation.js"(exports, module2) {
672
672
  "use strict";
673
673
  var { isUtf8 } = require("buffer");
674
674
  var tokenChars = [
@@ -862,9 +862,9 @@ var require_validation = __commonJS({
862
862
  }
863
863
  });
864
864
 
865
- // node_modules/ws/lib/receiver.js
865
+ // ../../node_modules/ws/lib/receiver.js
866
866
  var require_receiver = __commonJS({
867
- "node_modules/ws/lib/receiver.js"(exports, module2) {
867
+ "../../node_modules/ws/lib/receiver.js"(exports, module2) {
868
868
  "use strict";
869
869
  var { Writable } = require("stream");
870
870
  var PerMessageDeflate = require_permessage_deflate();
@@ -877,12 +877,14 @@ var require_receiver = __commonJS({
877
877
  var { concat, toArrayBuffer, unmask } = require_buffer_util();
878
878
  var { isValidStatusCode, isValidUTF8 } = require_validation();
879
879
  var FastBuffer = Buffer[Symbol.species];
880
+ var promise = Promise.resolve();
880
881
  var GET_INFO = 0;
881
882
  var GET_PAYLOAD_LENGTH_16 = 1;
882
883
  var GET_PAYLOAD_LENGTH_64 = 2;
883
884
  var GET_MASK = 3;
884
885
  var GET_DATA = 4;
885
886
  var INFLATING = 5;
887
+ var WAIT_MICROTASK = 6;
886
888
  var Receiver2 = class extends Writable {
887
889
  /**
888
890
  * Creates a Receiver instance.
@@ -999,8 +1001,15 @@ var require_receiver = __commonJS({
999
1001
  case GET_DATA:
1000
1002
  err = this.getData(cb);
1001
1003
  break;
1004
+ case INFLATING:
1005
+ this._loop = false;
1006
+ return;
1002
1007
  default:
1003
1008
  this._loop = false;
1009
+ promise.then(() => {
1010
+ this._state = GET_INFO;
1011
+ this.startLoop(cb);
1012
+ });
1004
1013
  return;
1005
1014
  }
1006
1015
  } while (this._loop);
@@ -1330,7 +1339,7 @@ var require_receiver = __commonJS({
1330
1339
  this.emit("message", buf, false);
1331
1340
  }
1332
1341
  }
1333
- this._state = GET_INFO;
1342
+ this._state = WAIT_MICROTASK;
1334
1343
  }
1335
1344
  /**
1336
1345
  * Handles a control message.
@@ -1345,6 +1354,7 @@ var require_receiver = __commonJS({
1345
1354
  if (data.length === 0) {
1346
1355
  this.emit("conclude", 1005, EMPTY_BUFFER);
1347
1356
  this.end();
1357
+ this._state = GET_INFO;
1348
1358
  } else {
1349
1359
  const code = data.readUInt16BE(0);
1350
1360
  if (!isValidStatusCode(code)) {
@@ -1372,13 +1382,15 @@ var require_receiver = __commonJS({
1372
1382
  }
1373
1383
  this.emit("conclude", code, buf);
1374
1384
  this.end();
1385
+ this._state = GET_INFO;
1375
1386
  }
1376
1387
  } else if (this._opcode === 9) {
1377
1388
  this.emit("ping", data);
1389
+ this._state = WAIT_MICROTASK;
1378
1390
  } else {
1379
1391
  this.emit("pong", data);
1392
+ this._state = WAIT_MICROTASK;
1380
1393
  }
1381
- this._state = GET_INFO;
1382
1394
  }
1383
1395
  };
1384
1396
  module2.exports = Receiver2;
@@ -1394,12 +1406,11 @@ var require_receiver = __commonJS({
1394
1406
  }
1395
1407
  });
1396
1408
 
1397
- // node_modules/ws/lib/sender.js
1409
+ // ../../node_modules/ws/lib/sender.js
1398
1410
  var require_sender = __commonJS({
1399
- "node_modules/ws/lib/sender.js"(exports, module2) {
1411
+ "../../node_modules/ws/lib/sender.js"(exports, module2) {
1400
1412
  "use strict";
1401
- var net = require("net");
1402
- var tls = require("tls");
1413
+ var { Duplex } = require("stream");
1403
1414
  var { randomFillSync } = require("crypto");
1404
1415
  var PerMessageDeflate = require_permessage_deflate();
1405
1416
  var { EMPTY_BUFFER } = require_constants();
@@ -1411,7 +1422,7 @@ var require_sender = __commonJS({
1411
1422
  /**
1412
1423
  * Creates a Sender instance.
1413
1424
  *
1414
- * @param {(net.Socket|tls.Socket)} socket The connection socket
1425
+ * @param {Duplex} socket The connection socket
1415
1426
  * @param {Object} [extensions] An object containing the negotiated extensions
1416
1427
  * @param {Function} [generateMask] The function used to generate the masking
1417
1428
  * key
@@ -1806,9 +1817,9 @@ var require_sender = __commonJS({
1806
1817
  }
1807
1818
  });
1808
1819
 
1809
- // node_modules/ws/lib/event-target.js
1820
+ // ../../node_modules/ws/lib/event-target.js
1810
1821
  var require_event_target = __commonJS({
1811
- "node_modules/ws/lib/event-target.js"(exports, module2) {
1822
+ "../../node_modules/ws/lib/event-target.js"(exports, module2) {
1812
1823
  "use strict";
1813
1824
  var { kForOnEventAttribute, kListener } = require_constants();
1814
1825
  var kCode = Symbol("kCode");
@@ -2035,9 +2046,9 @@ var require_event_target = __commonJS({
2035
2046
  }
2036
2047
  });
2037
2048
 
2038
- // node_modules/ws/lib/extension.js
2049
+ // ../../node_modules/ws/lib/extension.js
2039
2050
  var require_extension = __commonJS({
2040
- "node_modules/ws/lib/extension.js"(exports, module2) {
2051
+ "../../node_modules/ws/lib/extension.js"(exports, module2) {
2041
2052
  "use strict";
2042
2053
  var { tokenChars } = require_validation();
2043
2054
  function push(dest, name, elem) {
@@ -2205,9 +2216,9 @@ var require_extension = __commonJS({
2205
2216
  }
2206
2217
  });
2207
2218
 
2208
- // node_modules/ws/lib/websocket.js
2219
+ // ../../node_modules/ws/lib/websocket.js
2209
2220
  var require_websocket = __commonJS({
2210
- "node_modules/ws/lib/websocket.js"(exports, module2) {
2221
+ "../../node_modules/ws/lib/websocket.js"(exports, module2) {
2211
2222
  "use strict";
2212
2223
  var EventEmitter = require("events");
2213
2224
  var https = require("https");
@@ -2215,7 +2226,7 @@ var require_websocket = __commonJS({
2215
2226
  var net = require("net");
2216
2227
  var tls = require("tls");
2217
2228
  var { randomBytes, createHash } = require("crypto");
2218
- var { Readable } = require("stream");
2229
+ var { Duplex, Readable } = require("stream");
2219
2230
  var { URL: URL2 } = require("url");
2220
2231
  var PerMessageDeflate = require_permessage_deflate();
2221
2232
  var Receiver2 = require_receiver();
@@ -2368,8 +2379,7 @@ var require_websocket = __commonJS({
2368
2379
  /**
2369
2380
  * Set up the socket and the internal resources.
2370
2381
  *
2371
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
2372
- * server and client
2382
+ * @param {Duplex} socket The network socket between the server and client
2373
2383
  * @param {Buffer} head The first packet of the upgraded stream
2374
2384
  * @param {Object} options Options object
2375
2385
  * @param {Function} [options.generateMask] The function used to generate the
@@ -2398,8 +2408,10 @@ var require_websocket = __commonJS({
2398
2408
  receiver.on("message", receiverOnMessage);
2399
2409
  receiver.on("ping", receiverOnPing);
2400
2410
  receiver.on("pong", receiverOnPong);
2401
- socket.setTimeout(0);
2402
- socket.setNoDelay();
2411
+ if (socket.setTimeout)
2412
+ socket.setTimeout(0);
2413
+ if (socket.setNoDelay)
2414
+ socket.setNoDelay();
2403
2415
  if (head.length > 0)
2404
2416
  socket.unshift(head);
2405
2417
  socket.on("close", socketOnClose);
@@ -2716,20 +2728,24 @@ var require_websocket = __commonJS({
2716
2728
  let parsedUrl;
2717
2729
  if (address instanceof URL2) {
2718
2730
  parsedUrl = address;
2719
- websocket._url = address.href;
2720
2731
  } else {
2721
2732
  try {
2722
2733
  parsedUrl = new URL2(address);
2723
2734
  } catch (e) {
2724
2735
  throw new SyntaxError(`Invalid URL: ${address}`);
2725
2736
  }
2726
- websocket._url = address;
2727
2737
  }
2738
+ if (parsedUrl.protocol === "http:") {
2739
+ parsedUrl.protocol = "ws:";
2740
+ } else if (parsedUrl.protocol === "https:") {
2741
+ parsedUrl.protocol = "wss:";
2742
+ }
2743
+ websocket._url = parsedUrl.href;
2728
2744
  const isSecure = parsedUrl.protocol === "wss:";
2729
2745
  const isIpcUrl = parsedUrl.protocol === "ws+unix:";
2730
2746
  let invalidUrlMessage;
2731
2747
  if (parsedUrl.protocol !== "ws:" && !isSecure && !isIpcUrl) {
2732
- invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", or "ws+unix:"`;
2748
+ invalidUrlMessage = `The URL's protocol must be one of "ws:", "wss:", "http:", "https", or "ws+unix:"`;
2733
2749
  } else if (isIpcUrl && !parsedUrl.pathname) {
2734
2750
  invalidUrlMessage = "The URL's pathname is empty";
2735
2751
  } else if (parsedUrl.hash) {
@@ -3077,9 +3093,9 @@ var require_websocket = __commonJS({
3077
3093
  }
3078
3094
  });
3079
3095
 
3080
- // node_modules/ws/lib/subprotocol.js
3096
+ // ../../node_modules/ws/lib/subprotocol.js
3081
3097
  var require_subprotocol = __commonJS({
3082
- "node_modules/ws/lib/subprotocol.js"(exports, module2) {
3098
+ "../../node_modules/ws/lib/subprotocol.js"(exports, module2) {
3083
3099
  "use strict";
3084
3100
  var { tokenChars } = require_validation();
3085
3101
  function parse(header) {
@@ -3125,15 +3141,13 @@ var require_subprotocol = __commonJS({
3125
3141
  }
3126
3142
  });
3127
3143
 
3128
- // node_modules/ws/lib/websocket-server.js
3144
+ // ../../node_modules/ws/lib/websocket-server.js
3129
3145
  var require_websocket_server = __commonJS({
3130
- "node_modules/ws/lib/websocket-server.js"(exports, module2) {
3146
+ "../../node_modules/ws/lib/websocket-server.js"(exports, module2) {
3131
3147
  "use strict";
3132
3148
  var EventEmitter = require("events");
3133
3149
  var http = require("http");
3134
- var https = require("https");
3135
- var net = require("net");
3136
- var tls = require("tls");
3150
+ var { Duplex } = require("stream");
3137
3151
  var { createHash } = require("crypto");
3138
3152
  var extension = require_extension();
3139
3153
  var PerMessageDeflate = require_permessage_deflate();
@@ -3314,8 +3328,7 @@ var require_websocket_server = __commonJS({
3314
3328
  * Handle a HTTP Upgrade request.
3315
3329
  *
3316
3330
  * @param {http.IncomingMessage} req The request object
3317
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
3318
- * server and client
3331
+ * @param {Duplex} socket The network socket between the server and client
3319
3332
  * @param {Buffer} head The first packet of the upgraded stream
3320
3333
  * @param {Function} cb Callback
3321
3334
  * @public
@@ -3414,8 +3427,7 @@ var require_websocket_server = __commonJS({
3414
3427
  * @param {String} key The value of the `Sec-WebSocket-Key` header
3415
3428
  * @param {Set} protocols The subprotocols
3416
3429
  * @param {http.IncomingMessage} req The request object
3417
- * @param {(net.Socket|tls.Socket)} socket The network socket between the
3418
- * server and client
3430
+ * @param {Duplex} socket The network socket between the server and client
3419
3431
  * @param {Buffer} head The first packet of the upgraded stream
3420
3432
  * @param {Function} cb Callback
3421
3433
  * @throws {Error} If called more than once with the same socket
@@ -3501,7 +3513,7 @@ var require_websocket_server = __commonJS({
3501
3513
  socket.once("finish", socket.destroy);
3502
3514
  socket.end(
3503
3515
  `HTTP/1.1 ${code} ${http.STATUS_CODES[code]}\r
3504
- ` + Object.keys(headers).map((h) => `${h}: ${headers[h]}`).join("\r\n") + "\r\n\r\n" + message
3516
+ ` + Object.keys(headers).map((h2) => `${h2}: ${headers[h2]}`).join("\r\n") + "\r\n\r\n" + message
3505
3517
  );
3506
3518
  }
3507
3519
  function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
@@ -3526,193 +3538,197 @@ __export(main_exports, {
3526
3538
  module.exports = __toCommonJS(main_exports);
3527
3539
 
3528
3540
  // ../core/dist/esm/index.mjs
3529
- var Je = "ok";
3530
- var Ye = "created";
3531
- var Ze = "not-modified";
3532
- var et = "not-found";
3533
- var he = "accepted";
3534
- var Lt = { resourceType: "OperationOutcome", id: et, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3535
- function I(r4, e) {
3541
+ var Ye = "ok";
3542
+ var Xe = "created";
3543
+ var et = "not-modified";
3544
+ var tt = "not-found";
3545
+ var ge = "accepted";
3546
+ var jt = { resourceType: "OperationOutcome", id: tt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3547
+ function k(r4, e) {
3536
3548
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3537
3549
  }
3538
- function ye(r4) {
3550
+ function xe(r4) {
3539
3551
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3540
3552
  }
3541
- function tt(r4) {
3542
- return r4.id === Je || r4.id === Ye || r4.id === Ze || r4.id === he;
3553
+ function rt(r4) {
3554
+ return r4.id === Ye || r4.id === Xe || r4.id === et || r4.id === ge;
3543
3555
  }
3544
- var m = class extends Error {
3556
+ var h = class extends Error {
3545
3557
  constructor(t, n) {
3546
- super(Nt(t));
3558
+ super(Qt(t));
3547
3559
  this.outcome = t, this.cause = n;
3548
3560
  }
3549
3561
  };
3550
- function rt(r4) {
3551
- return r4 instanceof m ? r4.outcome : ye(r4) ? r4 : I(Gr(r4));
3562
+ function nt(r4) {
3563
+ return r4 instanceof h ? r4.outcome : xe(r4) ? r4 : k(Jr(r4));
3552
3564
  }
3553
- function Gr(r4) {
3554
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ye(r4) ? Nt(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3565
+ function Jr(r4) {
3566
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : xe(r4) ? Qt(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3555
3567
  }
3556
- function Nt(r4) {
3557
- let e = r4.issue?.map(zr) ?? [];
3568
+ function Qt(r4) {
3569
+ let e = r4.issue?.map(Yr) ?? [];
3558
3570
  return e.length > 0 ? e.join("; ") : "Unknown error";
3559
3571
  }
3560
- function zr(r4) {
3572
+ function Yr(r4) {
3561
3573
  let e = r4.details?.text ?? r4.diagnostics ?? "Unknown error";
3562
3574
  return r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3563
3575
  }
3564
- var Ft = { 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" }] } } } } };
3565
- function qt(r4, e) {
3576
+ var Gt = { types: { Element: { display: "Element", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] } } }, BackboneElement: { display: "BackboneElement", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] } } }, Address: { display: "Address", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: "*", type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { display: "Age", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { display: "Annotation", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { display: "Attachment", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { display: "CodeableConcept", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, coding: { max: "*", type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { display: "Coding", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { display: "ContactDetail", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: "*", type: [{ code: "ContactPoint" }] } } }, ContactPoint: { display: "ContactPoint", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { display: "Contributor", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: "*", type: [{ code: "ContactDetail" }] } } }, Count: { display: "Count", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { display: "DataRequirement", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: "*", type: [{ code: "string" }] }, codeFilter: { max: "*", type: [{ code: "Element" }] }, dateFilter: { max: "*", type: [{ code: "Element" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: "*", type: [{ code: "Element" }] } } }, DataRequirementCodeFilter: { display: "DataRequirementCodeFilter", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] }, code: { max: "*", type: [{ code: "Coding" }] } } }, DataRequirementDateFilter: { display: "DataRequirementDateFilter", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, "value[x]": { type: [{ code: "dateTime" }, { code: "Period" }, { code: "Duration" }] } } }, DataRequirementSort: { display: "DataRequirementSort", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, direction: { min: 1, type: [{ code: "code" }] } } }, Distance: { display: "Distance", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { display: "Dosage", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: "*", type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: "*", type: [{ code: "Element" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, DosageDoseAndRate: { display: "DosageDoseAndRate", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { type: [{ code: "CodeableConcept" }] }, "dose[x]": { type: [{ code: "Range" }, { code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, "rate[x]": { type: [{ code: "Ratio" }, { code: "Range" }, { code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { display: "Duration", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { display: "ElementDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: "*", type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: "*", type: [{ code: "Coding" }] }, slicing: { type: [{ code: "Element" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: "*", type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "Element" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: "*", type: [{ code: "Element" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: "*", type: [{ code: "Element" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: "*", type: [{ code: "id" }] }, constraint: { max: "*", type: [{ code: "Element" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "Element" }] }, mapping: { max: "*", type: [{ code: "Element" }] } } }, ElementDefinitionSlicing: { display: "ElementDefinitionSlicing", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, discriminator: { max: "*", type: [{ code: "Element" }] }, description: { type: [{ code: "string" }] }, ordered: { type: [{ code: "boolean" }] }, rules: { min: 1, type: [{ code: "code" }] } } }, ElementDefinitionSlicingDiscriminator: { display: "ElementDefinitionSlicingDiscriminator", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, path: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionBase: { display: "ElementDefinitionBase", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, min: { min: 1, type: [{ code: "unsignedInt" }] }, max: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionType: { display: "ElementDefinitionType", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "uri" }] }, profile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, targetProfile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, aggregation: { max: "*", type: [{ code: "code" }] }, versioning: { type: [{ code: "code" }] } } }, ElementDefinitionExample: { display: "ElementDefinitionExample", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, label: { min: 1, type: [{ code: "string" }] }, "value[x]": { min: 1, type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, ElementDefinitionConstraint: { display: "ElementDefinitionConstraint", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, key: { min: 1, type: [{ code: "id" }] }, requirements: { type: [{ code: "string" }] }, severity: { min: 1, type: [{ code: "code" }] }, human: { min: 1, type: [{ code: "string" }] }, expression: { type: [{ code: "string" }] }, xpath: { type: [{ code: "string" }] }, source: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, ElementDefinitionBinding: { display: "ElementDefinitionBinding", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, strength: { min: 1, type: [{ code: "code" }] }, description: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] } } }, ElementDefinitionMapping: { display: "ElementDefinitionMapping", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, identity: { min: 1, type: [{ code: "id" }] }, language: { type: [{ code: "code" }] }, map: { min: 1, type: [{ code: "string" }] }, comment: { type: [{ code: "string" }] } } }, Expression: { display: "Expression", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { display: "Extension", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { display: "HumanName", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: "*", type: [{ code: "string" }] }, prefix: { max: "*", type: [{ code: "string" }] }, suffix: { max: "*", type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { display: "Identifier", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { display: "MarketingStatus", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { display: "Meta", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: "*", type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: "*", type: [{ code: "Coding" }] }, tag: { max: "*", type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: "*", type: [{ code: "Reference" }] } } }, Money: { display: "Money", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { display: "Narrative", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { display: "ParameterDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { display: "Period", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { display: "Population", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { display: "ProdCharacteristic", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: "*", type: [{ code: "string" }] }, imprint: { max: "*", type: [{ code: "string" }] }, image: { max: "*", type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { display: "ProductShelfLife", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: "*", type: [{ code: "CodeableConcept" }] } } }, Quantity: { display: "Quantity", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: "0", type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { display: "Range", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { display: "Ratio", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { display: "Reference", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { display: "RelatedArtifact", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { display: "SampledData", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { display: "Signature", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, max: "*", type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { display: "SubstanceAmount", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "Element" }] } } }, SubstanceAmountReferenceRange: { display: "SubstanceAmountReferenceRange", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, lowLimit: { type: [{ code: "Quantity" }] }, highLimit: { type: [{ code: "Quantity" }] } } }, Timing: { display: "Timing", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, event: { max: "*", type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "Element" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TimingRepeat: { display: "TimingRepeat", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, "bounds[x]": { type: [{ code: "Duration" }, { code: "Range" }, { code: "Period" }] }, count: { type: [{ code: "positiveInt" }] }, countMax: { type: [{ code: "positiveInt" }] }, duration: { type: [{ code: "decimal" }] }, durationMax: { type: [{ code: "decimal" }] }, durationUnit: { type: [{ code: "code" }] }, frequency: { type: [{ code: "positiveInt" }] }, frequencyMax: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "decimal" }] }, periodMax: { type: [{ code: "decimal" }] }, periodUnit: { type: [{ code: "code" }] }, dayOfWeek: { max: "*", type: [{ code: "code" }] }, timeOfDay: { max: "*", type: [{ code: "time" }] }, when: { max: "*", type: [{ code: "code" }] }, offset: { type: [{ code: "unsignedInt" }] } } }, TriggerDefinition: { display: "TriggerDefinition", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: "*", type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { display: "UsageContext", properties: { id: { type: [{ code: "string" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MetadataResource: { display: "MetadataResource", properties: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: "*", type: [{ code: "Resource" }] }, extension: { max: "*", type: [{ code: "Extension" }] }, modifierExtension: { max: "*", type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: "*", type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: "*", type: [{ code: "UsageContext" }] }, jurisdiction: { max: "*", type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { display: "IdentityProvider", properties: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, useSubject: { type: [{ code: "boolean" }] } } } } };
3577
+ function zt(r4, e) {
3566
3578
  let t = [];
3567
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();
3568
3580
  }
3569
- function ie(r4) {
3570
- let e = $t(r4), t = cn(r4);
3581
+ function ae(r4) {
3582
+ let e = Yt(r4), t = ln(r4);
3571
3583
  return t === e ? { reference: e } : { reference: e, display: t };
3572
3584
  }
3573
- function $t(r4) {
3585
+ function Yt(r4) {
3574
3586
  return r4.resourceType + "/" + r4.id;
3575
3587
  }
3576
- function Ro(r4) {
3588
+ function wo(r4) {
3577
3589
  return r4?.reference?.split("/")[1];
3578
3590
  }
3579
- function an(r4) {
3591
+ function dn(r4) {
3580
3592
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3581
3593
  }
3582
- function cn(r4) {
3583
- if (an(r4)) {
3584
- let e = un(r4);
3594
+ function ln(r4) {
3595
+ if (dn(r4)) {
3596
+ let e = pn(r4);
3585
3597
  if (e)
3586
3598
  return e;
3587
3599
  }
3588
3600
  if (r4.resourceType === "Device") {
3589
- let e = dn(r4);
3601
+ let e = fn(r4);
3590
3602
  if (e)
3591
3603
  return e;
3592
3604
  }
3593
- 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);
3605
+ return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : Yt(r4);
3594
3606
  }
3595
- function un(r4) {
3607
+ function pn(r4) {
3596
3608
  let e = r4.name;
3597
3609
  if (e && e.length > 0)
3598
- return qt(e[0]);
3610
+ return zt(e[0]);
3599
3611
  }
3600
- function dn(r4) {
3612
+ function fn(r4) {
3601
3613
  let e = r4.deviceName;
3602
3614
  if (e && e.length > 0)
3603
3615
  return e[0].name;
3604
3616
  }
3605
- function ge(r4, e) {
3617
+ function Te(r4, e) {
3606
3618
  let t = new Date(r4);
3607
3619
  t.setUTCHours(0, 0, 0, 0);
3608
3620
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3609
3621
  n.setUTCHours(0, 0, 0, 0);
3610
- let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), p2 = n.getUTCDate(), l2 = a - i2;
3611
- (c2 < o || c2 === o && p2 < s) && l2--;
3612
- let ne = a * 12 + c2 - (i2 * 12 + o);
3613
- p2 < s && ne--;
3614
- let me = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3615
- return { years: l2, months: ne, days: me };
3622
+ let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), f = n.getUTCDate(), l2 = a - i2;
3623
+ (c2 < o || c2 === o && f < s) && l2--;
3624
+ let B = a * 12 + c2 - (i2 * 12 + o);
3625
+ f < s && B--;
3626
+ let Kr = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3627
+ return { years: l2, months: B, days: Kr };
3616
3628
  }
3617
- function zt(r4, e) {
3618
- return JSON.stringify(r4, ln, e ? 2 : void 0);
3629
+ function tr(r4, e) {
3630
+ return JSON.stringify(r4, hn, e ? 2 : void 0);
3619
3631
  }
3620
- function ln(r4, e) {
3621
- return !pn(r4) && b(e) ? void 0 : e;
3632
+ function hn(r4, e) {
3633
+ return !mn(r4) && R(e) ? void 0 : e;
3622
3634
  }
3623
- function pn(r4) {
3635
+ function mn(r4) {
3624
3636
  return !!/\d+$/.exec(r4);
3625
3637
  }
3626
- function b(r4) {
3638
+ function R(r4) {
3627
3639
  if (r4 == null)
3628
3640
  return true;
3629
3641
  let e = typeof r4;
3630
3642
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3631
3643
  }
3632
- function Jt(r4) {
3644
+ function rr(r4) {
3633
3645
  return r4.every((e) => typeof e == "string");
3634
3646
  }
3635
- var Yt = [];
3647
+ var nr = [];
3636
3648
  for (let r4 = 0; r4 < 256; r4++)
3637
- Yt.push(r4.toString(16).padStart(2, "0"));
3638
- function Xt(r4) {
3649
+ nr.push(r4.toString(16).padStart(2, "0"));
3650
+ function ir(r4) {
3639
3651
  let e = new Uint8Array(r4), t = new Array(e.length);
3640
3652
  for (let n = 0; n < e.length; n++)
3641
- t[n] = Yt[e[n]];
3653
+ t[n] = nr[e[n]];
3642
3654
  return t.join("");
3643
3655
  }
3644
- function Zt(r4) {
3656
+ function or(r4) {
3645
3657
  let e = new Uint8Array(r4), t = [];
3646
3658
  for (let n = 0; n < e.length; n++)
3647
3659
  t[n] = String.fromCharCode(e[n]);
3648
3660
  return window.btoa(t.join(""));
3649
3661
  }
3650
- function S(r4) {
3662
+ function b(r4) {
3651
3663
  return r4.charAt(0).toUpperCase() + r4.substring(1);
3652
3664
  }
3653
- var at = (r4) => new Promise((e) => {
3665
+ var ut = (r4) => new Promise((e) => {
3654
3666
  setTimeout(e, r4);
3655
3667
  });
3656
- var j = ((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))(j || {});
3657
- function ct(r4) {
3668
+ var G = ((u2) => (u2.Address = "Address", u2.Age = "Age", u2.Annotation = "Annotation", u2.Attachment = "Attachment", u2.BackboneElement = "BackboneElement", u2.CodeableConcept = "CodeableConcept", u2.Coding = "Coding", u2.ContactDetail = "ContactDetail", u2.ContactPoint = "ContactPoint", u2.Contributor = "Contributor", u2.Count = "Count", u2.DataRequirement = "DataRequirement", u2.Distance = "Distance", u2.Dosage = "Dosage", u2.Duration = "Duration", u2.Expression = "Expression", u2.Extension = "Extension", u2.HumanName = "HumanName", u2.Identifier = "Identifier", u2.MarketingStatus = "MarketingStatus", u2.Meta = "Meta", u2.Money = "Money", u2.Narrative = "Narrative", u2.ParameterDefinition = "ParameterDefinition", u2.Period = "Period", u2.Population = "Population", u2.ProdCharacteristic = "ProdCharacteristic", u2.ProductShelfLife = "ProductShelfLife", u2.Quantity = "Quantity", u2.Range = "Range", u2.Ratio = "Ratio", u2.Reference = "Reference", u2.RelatedArtifact = "RelatedArtifact", u2.SampledData = "SampledData", u2.Signature = "Signature", u2.SubstanceAmount = "SubstanceAmount", u2.SystemString = "http://hl7.org/fhirpath/System.String", u2.Timing = "Timing", u2.TriggerDefinition = "TriggerDefinition", u2.UsageContext = "UsageContext", u2.base64Binary = "base64Binary", u2.boolean = "boolean", u2.canonical = "canonical", u2.code = "code", u2.date = "date", u2.dateTime = "dateTime", u2.decimal = "decimal", u2.id = "id", u2.instant = "instant", u2.integer = "integer", u2.markdown = "markdown", u2.oid = "oid", u2.positiveInt = "positiveInt", u2.string = "string", u2.time = "time", u2.unsignedInt = "unsignedInt", u2.uri = "uri", u2.url = "url", u2.uuid = "uuid", u2))(G || {});
3669
+ function dt(r4) {
3658
3670
  if (!r4.name)
3659
3671
  return;
3660
3672
  let t = r4.snapshot?.element;
3661
3673
  if (t) {
3662
3674
  for (let n of t)
3663
- Sn(r4, n);
3675
+ En(r4, n);
3664
3676
  for (let n of t)
3665
- Rn(r4, n);
3677
+ Pn(r4, n);
3666
3678
  }
3667
3679
  }
3668
- function Sn(r4, e) {
3680
+ function En(r4, e) {
3669
3681
  let t = e.path, n = e.type?.[0]?.code;
3670
3682
  if (n !== void 0 && n !== "Element" && n !== "BackboneElement")
3671
3683
  return;
3672
3684
  let i2 = t.split(".");
3673
3685
  i2[0] = r4.name;
3674
- let o = L(i2), s = y.types[o];
3675
- s || (y.types[o] = s = {}), s.parentType = s.parentType ?? L(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 ?? {};
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 ?? {};
3676
3688
  }
3677
- function Rn(r4, e) {
3689
+ function Pn(r4, e) {
3678
3690
  let n = e.path.split(".");
3679
3691
  if (n.length === 1)
3680
3692
  return;
3681
3693
  n[0] = r4.name;
3682
- let i2 = L(n.slice(0, n.length - 1)), o = y.types[i2];
3694
+ let i2 = ce(n.slice(0, n.length - 1)), o = y.types[i2];
3683
3695
  if (!o)
3684
3696
  return;
3685
3697
  let s = n[n.length - 1];
3686
3698
  o.properties[s] = e;
3687
3699
  }
3688
- function ut(r4) {
3700
+ function lt(r4) {
3689
3701
  for (let e of r4.base ?? []) {
3690
3702
  let t = y.types[e];
3691
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);
3692
3704
  }
3693
3705
  }
3694
- function L(r4) {
3695
- return r4.length === 1 ? r4[0] : r4.map(S).join("");
3706
+ function z(r4) {
3707
+ let e = r4.type?.[0]?.code;
3708
+ return e === "BackboneElement" || e === "Element" ? ce((r4.base?.path ?? r4.path)?.split(".")) : e;
3709
+ }
3710
+ function ce(r4) {
3711
+ return r4.length === 1 ? r4[0] : r4.map(b).join("");
3696
3712
  }
3697
- function oe(r4, e) {
3713
+ function ue(r4, e) {
3698
3714
  let t = y.types[r4];
3699
3715
  if (!t)
3700
3716
  return;
3701
3717
  let n = t.properties[e] ?? t.properties[e + "[x]"];
3702
3718
  if (n) {
3703
3719
  if (n.contentReference) {
3704
- let i2 = n.contentReference.substring(1).split("."), o = i2.pop(), s = L(i2);
3705
- return oe(s, o);
3720
+ let i2 = n.contentReference.substring(1).split("."), o = i2.pop(), s = ce(i2);
3721
+ return ue(s, o);
3706
3722
  }
3707
3723
  return n;
3708
3724
  }
3709
3725
  }
3710
- function _(r4) {
3726
+ function L(r4) {
3711
3727
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
3712
3728
  }
3713
- var y = Ft;
3714
- var Cn = ((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))(Cn || {});
3715
- var Se = class {
3729
+ var y = Gt;
3730
+ var kn = ((g) => (g.EQUALS = "eq", g.NOT_EQUALS = "ne", g.GREATER_THAN = "gt", g.LESS_THAN = "lt", g.GREATER_THAN_OR_EQUALS = "ge", g.LESS_THAN_OR_EQUALS = "le", g.STARTS_AFTER = "sa", g.ENDS_BEFORE = "eb", g.APPROXIMATELY = "ap", g.CONTAINS = "contains", g.EXACT = "exact", g.TEXT = "text", g.NOT = "not", g.ABOVE = "above", g.BELOW = "below", g.IN = "in", g.NOT_IN = "not-in", g.OF_TYPE = "of-type", g.MISSING = "missing", g.IDENTIFIER = "identifier", g.ITERATE = "iterate", g))(kn || {});
3731
+ var Ae = class {
3716
3732
  constructor(e, t) {
3717
3733
  this.operator = e;
3718
3734
  this.child = t;
@@ -3721,7 +3737,7 @@ var Se = class {
3721
3737
  return `${this.operator}(${this.child.toString()})`;
3722
3738
  }
3723
3739
  };
3724
- var Q = class {
3740
+ var j = class {
3725
3741
  constructor(e, t, n) {
3726
3742
  this.operator = e;
3727
3743
  this.left = t;
@@ -3731,7 +3747,7 @@ var Q = class {
3731
3747
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
3732
3748
  }
3733
3749
  };
3734
- var Re = class {
3750
+ var Ee = class {
3735
3751
  constructor() {
3736
3752
  this.prefixParselets = {};
3737
3753
  this.infixParselets = {};
@@ -3755,10 +3771,10 @@ var Re = class {
3755
3771
  }, precedence: t });
3756
3772
  }
3757
3773
  construct(e) {
3758
- return new lt(e, this.prefixParselets, this.infixParselets);
3774
+ return new ft(e, this.prefixParselets, this.infixParselets);
3759
3775
  }
3760
3776
  };
3761
- var lt = class {
3777
+ var ft = class {
3762
3778
  constructor(e, t, n) {
3763
3779
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3764
3780
  }
@@ -3809,7 +3825,7 @@ var lt = class {
3809
3825
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
3810
3826
  }
3811
3827
  };
3812
- function Z(r4) {
3828
+ function te(r4) {
3813
3829
  if (r4.startsWith("T"))
3814
3830
  return r4 + "T00:00:00.000Z".substring(r4.length);
3815
3831
  if (r4.length <= 10)
@@ -3823,10 +3839,10 @@ function Z(r4) {
3823
3839
  function d(r4) {
3824
3840
  return [{ type: "boolean", value: r4 }];
3825
3841
  }
3826
- function T(r4) {
3827
- 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 } : _(r4) ? { type: r4.resourceType, value: r4 } : { type: "BackboneElement", value: r4 };
3842
+ function x(r4) {
3843
+ return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: "integer", value: r4 } : typeof r4 == "number" ? { type: "decimal", value: r4 } : typeof r4 == "boolean" ? { type: "boolean", value: r4 } : typeof r4 == "string" ? { type: "string", value: r4 } : A(r4) ? { type: "Quantity", value: r4 } : L(r4) ? { type: r4.resourceType, value: r4 } : { type: "BackboneElement", value: r4 };
3828
3844
  }
3829
- function N(r4) {
3845
+ function _(r4) {
3830
3846
  return r4.length === 0 ? false : !!r4[0].value;
3831
3847
  }
3832
3848
  function O(r4, e) {
@@ -3836,13 +3852,13 @@ function O(r4, e) {
3836
3852
  throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3837
3853
  }
3838
3854
  }
3839
- function P(r4, e) {
3855
+ function E(r4, e) {
3840
3856
  if (!r4.value)
3841
3857
  return;
3842
- let t = oe(r4.type, e);
3843
- return t ? Fn(r4, e, t) : qn(r4, e);
3858
+ let t = ue(r4.type, e);
3859
+ return t ? $n(r4, e, t) : Qn(r4, e);
3844
3860
  }
3845
- function Fn(r4, e, t) {
3861
+ function $n(r4, e, t) {
3846
3862
  let n = t.type;
3847
3863
  if (!n || n.length === 0)
3848
3864
  return;
@@ -3851,20 +3867,20 @@ function Fn(r4, e, t) {
3851
3867
  i2 = r4.value[e], o = n[0].code;
3852
3868
  else
3853
3869
  for (let a of n) {
3854
- let c2 = e.replace("[x]", "") + S(a.code);
3870
+ let c2 = e.replace("[x]", "") + b(a.code);
3855
3871
  if (c2 in r4.value) {
3856
3872
  i2 = r4.value[c2], o = a.code;
3857
3873
  break;
3858
3874
  }
3859
3875
  }
3860
3876
  let s = r4.value["_" + e];
3861
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? fr(a ?? {}, s[c2]) : a) : i2 = fr(i2 ?? {}, s)), !b(i2))
3862
- return (o === "Element" || o === "BackboneElement") && (o = L(t.path?.split("."))), Array.isArray(i2) ? i2.map((a) => dr(a, o)) : dr(i2, o);
3877
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? xr(a ?? {}, s[c2]) : a) : i2 = xr(i2 ?? {}, s)), !R(i2))
3878
+ return (o === "Element" || o === "BackboneElement") && (o = z(t)), Array.isArray(i2) ? i2.map((a) => mr(a, o)) : mr(i2, o);
3863
3879
  }
3864
- function dr(r4, e) {
3865
- return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
3880
+ function mr(r4, e) {
3881
+ return e === "Resource" && L(r4) && (e = r4.resourceType), { type: e, value: r4 };
3866
3882
  }
3867
- function qn(r4, e) {
3883
+ function Qn(r4, e) {
3868
3884
  let t = r4.value;
3869
3885
  if (!t || typeof t != "object")
3870
3886
  return;
@@ -3872,22 +3888,22 @@ function qn(r4, e) {
3872
3888
  if (e in t)
3873
3889
  n = t[e];
3874
3890
  else
3875
- for (let i2 in j) {
3876
- let o = e + S(i2);
3891
+ for (let i2 in G) {
3892
+ let o = e + b(i2);
3877
3893
  if (o in t) {
3878
3894
  n = t[o];
3879
3895
  break;
3880
3896
  }
3881
3897
  }
3882
- if (!b(n))
3883
- return Array.isArray(n) ? n.map(T) : T(n);
3898
+ if (!R(n))
3899
+ return Array.isArray(n) ? n.map(x) : x(n);
3884
3900
  }
3885
- function Ae(r4) {
3901
+ function Pe(r4) {
3886
3902
  let e = [];
3887
3903
  for (let t of r4) {
3888
3904
  let n = false;
3889
3905
  for (let i2 of e)
3890
- if (N(mr(t, i2))) {
3906
+ if (_(Tr(t, i2))) {
3891
3907
  n = true;
3892
3908
  break;
3893
3909
  }
@@ -3895,28 +3911,28 @@ function Ae(r4) {
3895
3911
  }
3896
3912
  return e;
3897
3913
  }
3898
- function pt(r4) {
3899
- return d(!N(r4));
3914
+ function ht(r4) {
3915
+ return d(!_(r4));
3900
3916
  }
3901
- function ft(r4, e) {
3902
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => N(mr(t, e[n]))));
3917
+ function mt(r4, e) {
3918
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => _(Tr(t, e[n]))));
3903
3919
  }
3904
- function mr(r4, e) {
3920
+ function Tr(r4, e) {
3905
3921
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3906
- return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : A(t) && A(n) ? d(hr(t, n)) : d(typeof t == "object" && typeof n == "object" ? ht(r4, e) : t === n);
3922
+ return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : A(t) && A(n) ? d(vr(t, n)) : d(typeof t == "object" && typeof n == "object" ? gt(r4, e) : t === n);
3907
3923
  }
3908
- function mt(r4, e) {
3909
- return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(lr), e.sort(lr), d(r4.every((t, n) => N(jn(t, e[n])))));
3924
+ function yt(r4, e) {
3925
+ return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(yr), e.sort(yr), d(r4.every((t, n) => _(Hn(t, e[n])))));
3910
3926
  }
3911
- function jn(r4, e) {
3927
+ function Hn(r4, e) {
3912
3928
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3913
- return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : A(s) && A(a) ? d(hr(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" ? ht({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3929
+ return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : A(s) && A(a) ? d(vr(s, a)) : d(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? gt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3914
3930
  }
3915
- function lr(r4, e) {
3931
+ function yr(r4, e) {
3916
3932
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3917
3933
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3918
3934
  }
3919
- function Ee(r4, e) {
3935
+ function Ce(r4, e) {
3920
3936
  let { value: t } = r4;
3921
3937
  if (t == null)
3922
3938
  return false;
@@ -3933,44 +3949,44 @@ function Ee(r4, e) {
3933
3949
  case "Time":
3934
3950
  return typeof t == "string" && !!/^T\d/.exec(t);
3935
3951
  case "Period":
3936
- return Qn(t);
3952
+ return Wn(t);
3937
3953
  case "Quantity":
3938
3954
  return A(t);
3939
3955
  default:
3940
3956
  return typeof t == "object" && t?.resourceType === e;
3941
3957
  }
3942
3958
  }
3943
- function Qn(r4) {
3959
+ function Wn(r4) {
3944
3960
  return !!(r4 && typeof r4 == "object" && "start" in r4);
3945
3961
  }
3946
3962
  function A(r4) {
3947
3963
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3948
3964
  }
3949
- function hr(r4, e) {
3965
+ function vr(r4, e) {
3950
3966
  return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
3951
3967
  }
3952
- function ht(r4, e) {
3968
+ function gt(r4, e) {
3953
3969
  let t = Object.keys(r4), n = Object.keys(e);
3954
3970
  if (t.length !== n.length)
3955
3971
  return false;
3956
3972
  for (let i2 of t) {
3957
3973
  let o = r4[i2], s = e[i2];
3958
- if (pr(o) && pr(s)) {
3959
- if (!ht(o, s))
3974
+ if (gr(o) && gr(s)) {
3975
+ if (!gt(o, s))
3960
3976
  return false;
3961
3977
  } else if (o !== s)
3962
3978
  return false;
3963
3979
  }
3964
3980
  return true;
3965
3981
  }
3966
- function pr(r4) {
3982
+ function gr(r4) {
3967
3983
  return r4 !== null && typeof r4 == "object";
3968
3984
  }
3969
- function fr(r4, e) {
3985
+ function xr(r4, e) {
3970
3986
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3971
3987
  }
3972
- var se = () => [];
3973
- var R = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => N(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => N(t.eval(r4, [n])))), allTrue: (r4, e) => {
3988
+ var de = () => [];
3989
+ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => _(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => _(t.eval(r4, [n])))), allTrue: (r4, e) => {
3974
3990
  for (let t of e)
3975
3991
  if (!t.value)
3976
3992
  return d(false);
@@ -3990,12 +4006,12 @@ var R = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
3990
4006
  if (!t.value)
3991
4007
  return d(true);
3992
4008
  return d(false);
3993
- }, subsetOf: se, supersetOf: se, count: (r4, e) => [{ type: "integer", value: e.length }], distinct: (r4, e) => {
4009
+ }, subsetOf: de, supersetOf: de, count: (r4, e) => [{ type: "integer", value: e.length }], distinct: (r4, e) => {
3994
4010
  let t = [];
3995
4011
  for (let n of e)
3996
4012
  t.some((i2) => i2.value === n.value) || t.push(n);
3997
4013
  return t;
3998
- }, isDistinct: (r4, e) => d(e.length === R.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
+ }, 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) => {
3999
4015
  if (e.length > 1)
4000
4016
  throw new Error("Expected input length one for single()");
4001
4017
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4027,17 +4043,17 @@ var R = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4027
4043
  if (!t)
4028
4044
  return e;
4029
4045
  let n = t.eval(r4, e);
4030
- return Ae([...e, ...n]);
4046
+ return Pe([...e, ...n]);
4031
4047
  }, combine: (r4, e, t) => {
4032
4048
  if (!t)
4033
4049
  return e;
4034
4050
  let n = t.eval(r4, e);
4035
4051
  return [...e, ...n];
4036
- }, htmlChecks: (r4, e, t) => [T(true)], iif: (r4, e, t, n, i2) => {
4052
+ }, htmlChecks: (r4, e, t) => [x(true)], iif: (r4, e, t, n, i2) => {
4037
4053
  let o = t.eval(r4, e);
4038
4054
  if (o.length > 1 || o.length === 1 && typeof o[0].value != "boolean")
4039
4055
  throw new Error("Expected criterion to evaluate to a Boolean");
4040
- return N(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4056
+ return _(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4041
4057
  }, toBoolean: (r4, e) => {
4042
4058
  if (e.length === 0)
4043
4059
  return [];
@@ -4054,72 +4070,72 @@ var R = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4054
4070
  return d(false);
4055
4071
  }
4056
4072
  return [];
4057
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(R.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4073
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4058
4074
  if (e.length === 0)
4059
4075
  return [];
4060
4076
  let [{ value: t }] = U(e, 1);
4061
4077
  return typeof t == "number" ? [{ type: "integer", value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: "integer", value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: "integer", value: t ? 1 : 0 }] : [];
4062
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(R.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4078
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4063
4079
  if (e.length === 0)
4064
4080
  return [];
4065
4081
  let [{ value: t }] = U(e, 1);
4066
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "date", value: Z(t) }] : [];
4067
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(R.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4082
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "date", value: te(t) }] : [];
4083
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4068
4084
  if (e.length === 0)
4069
4085
  return [];
4070
4086
  let [{ value: t }] = U(e, 1);
4071
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "dateTime", value: Z(t) }] : [];
4072
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(R.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4087
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: "dateTime", value: te(t) }] : [];
4088
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4073
4089
  if (e.length === 0)
4074
4090
  return [];
4075
4091
  let [{ value: t }] = U(e, 1);
4076
4092
  return typeof t == "number" ? [{ type: "decimal", value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: "decimal", value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: "decimal", value: t ? 1 : 0 }] : [];
4077
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(R.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4093
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4078
4094
  if (e.length === 0)
4079
4095
  return [];
4080
4096
  let [{ value: t }] = U(e, 1);
4081
4097
  return A(t) ? [{ type: "Quantity", value: t }] : typeof t == "number" ? [{ type: "Quantity", value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: "Quantity", value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: "Quantity", value: { value: t ? 1 : 0, unit: "1" } }] : [];
4082
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(R.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4098
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4083
4099
  if (e.length === 0)
4084
4100
  return [];
4085
4101
  let [{ value: t }] = U(e, 1);
4086
4102
  return t == null ? [] : A(t) ? [{ type: "string", value: `${t.value} '${t.unit}'` }] : [{ type: "string", value: t.toString() }];
4087
- }, convertsToString: (r4, e) => e.length === 0 ? [] : d(R.toString(r4, e).length === 1), toTime: (r4, e) => {
4103
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : d(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4088
4104
  if (e.length === 0)
4089
4105
  return [];
4090
4106
  let [{ value: t }] = U(e, 1);
4091
4107
  if (typeof t == "string") {
4092
4108
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4093
4109
  if (n)
4094
- return [{ type: "time", value: Z("T" + n[1]) }];
4110
+ return [{ type: "time", value: te("T" + n[1]) }];
4095
4111
  }
4096
4112
  return [];
4097
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : d(R.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) => {
4113
+ }, convertsToTime: (r4, e) => e.length === 0 ? [] : d(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => C((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => C((i2, o, s) => {
4098
4114
  let a = o, c2 = s ? a + s : i2.length;
4099
4115
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4100
- }, r4, e, t, n), startsWith: (r4, e, t) => C((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => C((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => C((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => C((t) => t.toUpperCase(), r4, e), lower: (r4, e) => C((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => C((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => C((t) => t.length, r4, e), toChars: (r4, e) => C((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => V(Math.abs, r4, e), ceiling: (r4, e) => V(Math.ceil, r4, e), exp: (r4, e) => V(Math.exp, r4, e), floor: (r4, e) => V(Math.floor, r4, e), ln: (r4, e) => V(Math.log, r4, e), log: (r4, e, t) => V((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => V(Math.pow, r4, e, t), round: (r4, e) => V(Math.round, r4, e), sqrt: (r4, e) => V(Math.sqrt, r4, e), truncate: (r4, e) => V((t) => t | 0, r4, e), children: se, descendants: se, 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) => {
4101
- let o = R.toDateTime(r4, t.eval(r4, e));
4116
+ }, r4, e, t, n), startsWith: (r4, e, t) => C((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => C((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => C((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => C((t) => t.toUpperCase(), r4, e), lower: (r4, e) => C((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => C((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => C((t) => t.length, r4, e), toChars: (r4, e) => C((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => V(Math.abs, r4, e), ceiling: (r4, e) => V(Math.ceil, r4, e), exp: (r4, e) => V(Math.exp, r4, e), floor: (r4, e) => V(Math.floor, r4, e), ln: (r4, e) => V(Math.log, r4, e), log: (r4, e, t) => V((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => V(Math.pow, r4, e, t), round: (r4, e) => V(Math.round, r4, e), sqrt: (r4, e) => V(Math.sqrt, r4, e), truncate: (r4, e) => V((t) => t | 0, r4, e), children: de, descendants: de, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: "dateTime", value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: "time", value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: "date", value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4117
+ let o = S.toDateTime(r4, t.eval(r4, e));
4102
4118
  if (o.length === 0)
4103
4119
  throw new Error("Invalid start date");
4104
- let s = R.toDateTime(r4, n.eval(r4, e));
4120
+ let s = S.toDateTime(r4, n.eval(r4, e));
4105
4121
  if (s.length === 0)
4106
4122
  throw new Error("Invalid end date");
4107
4123
  let a = i2.eval(r4, e)[0]?.value;
4108
4124
  if (a !== "years" && a !== "months" && a !== "days")
4109
4125
  throw new Error("Invalid units");
4110
- let c2 = ge(o[0].value, s[0].value);
4126
+ let c2 = Te(o[0].value, s[0].value);
4111
4127
  return [{ type: "Quantity", value: { value: c2[a], unit: a } }];
4112
4128
  }, is: (r4, e, t) => {
4113
4129
  let n = "";
4114
- return t instanceof M ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: "boolean", value: Ee(i2, n) })) : [];
4115
- }, not: (r4, e) => R.toBoolean(r4, e).map((t) => ({ type: "boolean", value: !t.value })), resolve: (r4, e) => e.map((t) => {
4130
+ return t instanceof M ? n = t.name : t instanceof Q && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: "boolean", value: Ce(i2, n) })) : [];
4131
+ }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: "boolean", value: !t.value })), resolve: (r4, e) => e.map((t) => {
4116
4132
  let n = t.value, i2;
4117
4133
  if (typeof n == "string")
4118
4134
  i2 = n;
4119
4135
  else if (typeof n == "object") {
4120
4136
  let o = n;
4121
4137
  if (o.resource)
4122
- return T(o.resource);
4138
+ return x(o.resource);
4123
4139
  o.reference ? i2 = o.reference : o.type && o.identifier && (i2 = `${o.type}?identifier=${o.identifier.system}|${o.identifier.value}`);
4124
4140
  }
4125
4141
  if (i2?.includes("?")) {
@@ -4131,7 +4147,7 @@ var R = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
4131
4147
  return { type: o, value: { resourceType: o, id: s } };
4132
4148
  }
4133
4149
  return { type: "BackboneElement", value: void 0 };
4134
- }).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" } } : _(t) ? { type: "BackboneElement", value: { namespace: "FHIR", name: t.resourceType } } : { type: "BackboneElement", value: null }), conformsTo: (r4, e, t) => {
4150
+ }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: "BackboneElement", value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: "BackboneElement", value: { namespace: "System", name: "Integer" } } : L(t) ? { type: "BackboneElement", value: { namespace: "FHIR", name: t.resourceType } } : { type: "BackboneElement", value: null }), conformsTo: (r4, e, t) => {
4135
4151
  let n = t.eval(r4, e)[0].value;
4136
4152
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4137
4153
  throw new Error("Expected a StructureDefinition URL");
@@ -4145,7 +4161,7 @@ function C(r4, e, t, ...n) {
4145
4161
  if (typeof i2 != "string")
4146
4162
  throw new Error("String function cannot be called with non-string");
4147
4163
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4148
- return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4164
+ return o === void 0 ? [] : Array.isArray(o) ? o.map(x) : [x(o)];
4149
4165
  }
4150
4166
  function V(r4, e, t, ...n) {
4151
4167
  if (t.length === 0)
@@ -4153,8 +4169,8 @@ function V(r4, e, t, ...n) {
4153
4169
  let [{ value: i2 }] = U(t, 1), o = A(i2), s = o ? i2.value : i2;
4154
4170
  if (typeof s != "number")
4155
4171
  throw new Error("Math function cannot be called with non-number");
4156
- let a = r4(s, ...n.map((l2) => l2.eval(e, t)[0]?.value)), c2 = o ? "Quantity" : t[0].type, p2 = o ? { ...i2, value: a } : a;
4157
- return [{ type: c2, value: p2 }];
4172
+ let a = r4(s, ...n.map((l2) => l2.eval(e, t)[0]?.value)), c2 = o ? "Quantity" : t[0].type, f = o ? { ...i2, value: a } : a;
4173
+ return [{ type: c2, value: f }];
4158
4174
  }
4159
4175
  function U(r4, e) {
4160
4176
  if (r4.length !== e)
@@ -4164,7 +4180,7 @@ function U(r4, e) {
4164
4180
  throw new Error("Expected non-null argument");
4165
4181
  return r4;
4166
4182
  }
4167
- var k = class {
4183
+ var I = class {
4168
4184
  constructor(e) {
4169
4185
  this.value = e;
4170
4186
  }
@@ -4194,13 +4210,13 @@ var M = class {
4194
4210
  evalValue(e) {
4195
4211
  let t = e.value;
4196
4212
  if (!(!t || typeof t != "object"))
4197
- return _(t) && t.resourceType === this.name ? e : P(e, this.name);
4213
+ return L(t) && t.resourceType === this.name ? e : E(e, this.name);
4198
4214
  }
4199
4215
  toString() {
4200
4216
  return this.name;
4201
4217
  }
4202
4218
  };
4203
- var Ce = class {
4219
+ var Ie = class {
4204
4220
  eval() {
4205
4221
  return [];
4206
4222
  }
@@ -4208,7 +4224,7 @@ var Ce = class {
4208
4224
  return "{}";
4209
4225
  }
4210
4226
  };
4211
- var we = class extends Se {
4227
+ var ke = class extends Ae {
4212
4228
  constructor(t, n, i2) {
4213
4229
  super(t, n);
4214
4230
  this.impl = i2;
@@ -4220,17 +4236,17 @@ var we = class extends Se {
4220
4236
  return this.operator + this.child.toString();
4221
4237
  }
4222
4238
  };
4223
- var z = class extends Q {
4239
+ var K = class extends j {
4224
4240
  constructor(e, t) {
4225
4241
  super("as", e, t);
4226
4242
  }
4227
4243
  eval(e, t) {
4228
- return R.ofType(e, this.left.eval(e, t), this.right);
4244
+ return S.ofType(e, this.left.eval(e, t), this.right);
4229
4245
  }
4230
4246
  };
4231
- var v = class extends Q {
4247
+ var v = class extends j {
4232
4248
  };
4233
- var E = class extends v {
4249
+ var P = class extends v {
4234
4250
  constructor(t, n, i2, o) {
4235
4251
  super(t, n, i2);
4236
4252
  this.impl = o;
@@ -4242,11 +4258,11 @@ var E = class extends v {
4242
4258
  let o = this.right.eval(t, n);
4243
4259
  if (o.length !== 1)
4244
4260
  return [];
4245
- let s = i2[0].value, a = o[0].value, c2 = A(s) ? s.value : s, p2 = A(a) ? a.value : a, l2 = this.impl(c2, p2);
4246
- return typeof l2 == "boolean" ? d(l2) : A(s) ? [{ type: "Quantity", value: { ...s, value: l2 } }] : [T(l2)];
4261
+ let s = i2[0].value, a = o[0].value, c2 = A(s) ? s.value : s, f = A(a) ? a.value : a, l2 = this.impl(c2, f);
4262
+ return typeof l2 == "boolean" ? d(l2) : A(s) ? [{ type: "Quantity", value: { ...s, value: l2 } }] : [x(l2)];
4247
4263
  }
4248
4264
  };
4249
- var ke = class extends Q {
4265
+ var De = class extends j {
4250
4266
  constructor(e, t) {
4251
4267
  super("&", e, t);
4252
4268
  }
@@ -4255,7 +4271,7 @@ var ke = class extends Q {
4255
4271
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: "string", value: o.map((s) => s.value).join("") }] : o;
4256
4272
  }
4257
4273
  };
4258
- var Ie = class extends v {
4274
+ var Oe = class extends v {
4259
4275
  constructor(e, t) {
4260
4276
  super("contains", e, t);
4261
4277
  }
@@ -4264,7 +4280,7 @@ var Ie = class extends v {
4264
4280
  return d(n.some((o) => o.value === i2[0].value));
4265
4281
  }
4266
4282
  };
4267
- var De = class extends v {
4283
+ var Ve = class extends v {
4268
4284
  constructor(e, t) {
4269
4285
  super("in", e, t);
4270
4286
  }
@@ -4273,7 +4289,7 @@ var De = class extends v {
4273
4289
  return n ? d(i2.some((o) => o.value === n.value)) : [];
4274
4290
  }
4275
4291
  };
4276
- var H = class extends Q {
4292
+ var Q = class extends j {
4277
4293
  constructor(e, t) {
4278
4294
  super(".", e, t);
4279
4295
  }
@@ -4284,52 +4300,52 @@ var H = class extends Q {
4284
4300
  return `${this.left.toString()}.${this.right.toString()}`;
4285
4301
  }
4286
4302
  };
4287
- var ee = class extends Q {
4303
+ var re = class extends j {
4288
4304
  constructor(e, t) {
4289
4305
  super("|", e, t);
4290
4306
  }
4291
4307
  eval(e, t) {
4292
4308
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4293
- return Ae([...n, ...i2]);
4309
+ return Pe([...n, ...i2]);
4294
4310
  }
4295
4311
  };
4296
- var Oe = class extends v {
4312
+ var Ue = class extends v {
4297
4313
  constructor(e, t) {
4298
4314
  super("=", e, t);
4299
4315
  }
4300
4316
  eval(e, t) {
4301
4317
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4302
- return ft(n, i2);
4318
+ return mt(n, i2);
4303
4319
  }
4304
4320
  };
4305
- var Ve = class extends v {
4321
+ var Le = class extends v {
4306
4322
  constructor(e, t) {
4307
4323
  super("!=", e, t);
4308
4324
  }
4309
4325
  eval(e, t) {
4310
4326
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4311
- return pt(ft(n, i2));
4327
+ return ht(mt(n, i2));
4312
4328
  }
4313
4329
  };
4314
- var Ue = class extends v {
4330
+ var _e = class extends v {
4315
4331
  constructor(e, t) {
4316
4332
  super("~", e, t);
4317
4333
  }
4318
4334
  eval(e, t) {
4319
4335
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4320
- return mt(n, i2);
4336
+ return yt(n, i2);
4321
4337
  }
4322
4338
  };
4323
- var Le = class extends v {
4339
+ var Me = class extends v {
4324
4340
  constructor(e, t) {
4325
4341
  super("!~", e, t);
4326
4342
  }
4327
4343
  eval(e, t) {
4328
4344
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4329
- return pt(mt(n, i2));
4345
+ return ht(yt(n, i2));
4330
4346
  }
4331
4347
  };
4332
- var K = class extends v {
4348
+ var J = class extends v {
4333
4349
  constructor(e, t) {
4334
4350
  super("is", e, t);
4335
4351
  }
@@ -4338,10 +4354,10 @@ var K = class extends v {
4338
4354
  if (n.length !== 1)
4339
4355
  return [];
4340
4356
  let i2 = this.right.name;
4341
- return d(Ee(n[0], i2));
4357
+ return d(Ce(n[0], i2));
4342
4358
  }
4343
4359
  };
4344
- var _e = class extends v {
4360
+ var Ne = class extends v {
4345
4361
  constructor(e, t) {
4346
4362
  super("and", e, t);
4347
4363
  }
@@ -4350,7 +4366,7 @@ var _e = class extends v {
4350
4366
  return n?.value === true && i2?.value === true ? d(true) : n?.value === false || i2?.value === false ? d(false) : [];
4351
4367
  }
4352
4368
  };
4353
- var Ne = class extends v {
4369
+ var Be = class extends v {
4354
4370
  constructor(e, t) {
4355
4371
  super("or", e, t);
4356
4372
  }
@@ -4359,7 +4375,7 @@ var Ne = class extends v {
4359
4375
  return n?.value === false && i2?.value === false ? d(false) : n?.value || i2?.value ? d(true) : [];
4360
4376
  }
4361
4377
  };
4362
- var Me = class extends v {
4378
+ var Fe = class extends v {
4363
4379
  constructor(e, t) {
4364
4380
  super("xor", e, t);
4365
4381
  }
@@ -4368,7 +4384,7 @@ var Me = class extends v {
4368
4384
  return !n || !i2 ? [] : d(n.value !== i2.value);
4369
4385
  }
4370
4386
  };
4371
- var Be = class extends v {
4387
+ var qe = class extends v {
4372
4388
  constructor(e, t) {
4373
4389
  super("implies", e, t);
4374
4390
  }
@@ -4377,13 +4393,13 @@ var Be = class extends v {
4377
4393
  return i2?.value === true || n?.value === false ? d(true) : !n || !i2 ? [] : d(false);
4378
4394
  }
4379
4395
  };
4380
- var B = class {
4396
+ var N = class {
4381
4397
  constructor(e, t) {
4382
4398
  this.name = e;
4383
4399
  this.args = t;
4384
4400
  }
4385
4401
  eval(e, t) {
4386
- let n = R[this.name];
4402
+ let n = S[this.name];
4387
4403
  if (!n)
4388
4404
  throw new Error("Unrecognized function: " + this.name);
4389
4405
  return n(e, t, ...this.args);
@@ -4392,7 +4408,7 @@ var B = class {
4392
4408
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
4393
4409
  }
4394
4410
  };
4395
- var J = class {
4411
+ var Y = class {
4396
4412
  constructor(e, t) {
4397
4413
  this.left = e;
4398
4414
  this.expr = t;
@@ -4411,46 +4427,46 @@ var J = class {
4411
4427
  return `${this.left.toString()}[${this.expr.toString()}]`;
4412
4428
  }
4413
4429
  };
4414
- var ce = ["!=", "!~", "<=", ">=", "{}", "->"];
4415
- 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 };
4416
- var $n = { parse(r4) {
4430
+ var pe = ["!=", "!~", "<=", ">=", "{}", "->"];
4431
+ var p = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
4432
+ var Gn = { parse(r4) {
4417
4433
  let e = r4.consumeAndParse();
4418
4434
  if (!r4.match(")"))
4419
4435
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4420
4436
  return e;
4421
4437
  } };
4422
- var Hn = { parse(r4, e) {
4438
+ var zn = { parse(r4, e) {
4423
4439
  let t = r4.consumeAndParse();
4424
4440
  if (!r4.match("]"))
4425
4441
  throw new Error("Parse error: expected `]`");
4426
- return new J(e, t);
4427
- }, precedence: f.Indexer };
4428
- var Wn = { parse(r4, e) {
4442
+ return new Y(e, t);
4443
+ }, precedence: p.Indexer };
4444
+ var Kn = { parse(r4, e) {
4429
4445
  if (!(e instanceof M))
4430
4446
  throw new Error("Unexpected parentheses");
4431
4447
  let t = [];
4432
4448
  for (; !r4.match(")"); )
4433
4449
  t.push(r4.consumeAndParse()), r4.match(",");
4434
- return new B(e.name, t);
4435
- }, precedence: f.FunctionCall };
4436
- function Gn(r4) {
4450
+ return new N(e.name, t);
4451
+ }, precedence: p.FunctionCall };
4452
+ function Jn(r4) {
4437
4453
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4438
4454
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4439
4455
  }
4440
- function ue() {
4441
- return new Re().registerPrefix("String", { parse: (r4, e) => new k({ type: "string", value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new k({ type: "dateTime", value: Z(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new k({ type: "Quantity", value: Gn(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new k({ type: "decimal", value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new k({ type: "boolean", value: true }) }).registerPrefix("false", { parse: () => new k({ type: "boolean", value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new Ce() }).registerPrefix("(", $n).registerInfix("[", Hn).registerInfix("(", Wn).prefix("+", f.UnaryAdd, (r4, e) => new we("+", e, (t) => t)).prefix("-", f.UnarySubtract, (r4, e) => new E("-", e, e, (t, n) => -n)).infixLeft(".", f.Dot, (r4, e, t) => new H(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 ee(r4, t)).infixLeft("=", f.Equals, (r4, e, t) => new Oe(r4, t)).infixLeft("!=", f.NotEquals, (r4, e, t) => new Ve(r4, t)).infixLeft("~", f.Equivalent, (r4, e, t) => new Ue(r4, t)).infixLeft("!~", f.NotEquivalent, (r4, e, t) => new Le(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 ke(r4, t)).infixLeft("and", f.And, (r4, e, t) => new _e(r4, t)).infixLeft("as", f.As, (r4, e, t) => new z(r4, t)).infixLeft("contains", f.Contains, (r4, e, t) => new Ie(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 De(r4, t)).infixLeft("is", f.Is, (r4, e, t) => new K(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 Ne(r4, t)).infixLeft("xor", f.Xor, (r4, e, t) => new Me(r4, t)).infixLeft("implies", f.Implies, (r4, e, t) => new Be(r4, t));
4456
+ function fe() {
4457
+ return new Ee().registerPrefix("String", { parse: (r4, e) => new I({ type: "string", value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new I({ type: "dateTime", value: te(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new I({ type: "Quantity", value: Jn(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new I({ type: "decimal", value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new I({ type: "boolean", value: true }) }).registerPrefix("false", { parse: () => new I({ type: "boolean", value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new Ie() }).registerPrefix("(", Gn).registerInfix("[", zn).registerInfix("(", Kn).prefix("+", p.UnaryAdd, (r4, e) => new ke("+", e, (t) => t)).prefix("-", p.UnarySubtract, (r4, e) => new P("-", e, e, (t, n) => -n)).infixLeft(".", p.Dot, (r4, e, t) => new Q(r4, t)).infixLeft("/", p.Divide, (r4, e, t) => new P("/", r4, t, (n, i2) => n / i2)).infixLeft("*", p.Multiply, (r4, e, t) => new P("*", r4, t, (n, i2) => n * i2)).infixLeft("+", p.Add, (r4, e, t) => new P("+", r4, t, (n, i2) => n + i2)).infixLeft("-", p.Subtract, (r4, e, t) => new P("-", r4, t, (n, i2) => n - i2)).infixLeft("|", p.Union, (r4, e, t) => new re(r4, t)).infixLeft("=", p.Equals, (r4, e, t) => new Ue(r4, t)).infixLeft("!=", p.NotEquals, (r4, e, t) => new Le(r4, t)).infixLeft("~", p.Equivalent, (r4, e, t) => new _e(r4, t)).infixLeft("!~", p.NotEquivalent, (r4, e, t) => new Me(r4, t)).infixLeft("<", p.LessThan, (r4, e, t) => new P("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", p.LessThanOrEquals, (r4, e, t) => new P("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", p.GreaterThan, (r4, e, t) => new P(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", p.GreaterThanOrEquals, (r4, e, t) => new P(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", p.Ampersand, (r4, e, t) => new De(r4, t)).infixLeft("and", p.And, (r4, e, t) => new Ne(r4, t)).infixLeft("as", p.As, (r4, e, t) => new K(r4, t)).infixLeft("contains", p.Contains, (r4, e, t) => new Oe(r4, t)).infixLeft("div", p.Divide, (r4, e, t) => new P("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", p.In, (r4, e, t) => new Ve(r4, t)).infixLeft("is", p.Is, (r4, e, t) => new J(r4, t)).infixLeft("mod", p.Modulo, (r4, e, t) => new P("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", p.Or, (r4, e, t) => new Be(r4, t)).infixLeft("xor", p.Xor, (r4, e, t) => new Fe(r4, t)).infixLeft("implies", p.Implies, (r4, e, t) => new qe(r4, t));
4442
4458
  }
4443
- var zn = ue();
4444
- var gr = ((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))(gr || {});
4445
- var di = ((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))(di || {});
4446
- function Ar(r4) {
4459
+ var Yn = fe();
4460
+ var Sr = ((l2) => (l2.BOOLEAN = "BOOLEAN", l2.NUMBER = "NUMBER", l2.QUANTITY = "QUANTITY", l2.TEXT = "TEXT", l2.REFERENCE = "REFERENCE", l2.CANONICAL = "CANONICAL", l2.DATE = "DATE", l2.DATETIME = "DATETIME", l2.PERIOD = "PERIOD", l2.UUID = "UUID", l2))(Sr || {});
4461
+ var fi = ((T) => (T.READ = "read", T.VREAD = "vread", T.UPDATE = "update", T.PATCH = "patch", T.DELETE = "delete", T.HISTORY = "history", T.HISTORY_INSTANCE = "history-instance", T.HISTORY_TYPE = "history-type", T.HISTORY_SYSTEM = "history-system", T.CREATE = "create", T.SEARCH = "search", T.SEARCH_TYPE = "search-type", T.SEARCH_SYSTEM = "search-system", T.SEARCH_COMPARTMENT = "search-compartment", T.CAPABILITIES = "capabilities", T.TRANSACTION = "transaction", T.BATCH = "batch", T.OPERATION = "operation", T))(fi || {});
4462
+ function Ir(r4) {
4447
4463
  if (typeof window < "u")
4448
4464
  return window.atob(r4);
4449
4465
  if (typeof Buffer < "u")
4450
4466
  return Buffer.from(r4, "base64").toString("binary");
4451
4467
  throw new Error("Unable to decode base64");
4452
4468
  }
4453
- function Er(r4) {
4469
+ function kr(r4) {
4454
4470
  if (typeof window < "u")
4455
4471
  return window.btoa(r4);
4456
4472
  if (typeof Buffer < "u")
@@ -4459,12 +4475,12 @@ function Er(r4) {
4459
4475
  }
4460
4476
  function bt() {
4461
4477
  let r4 = new Uint32Array(28);
4462
- return crypto.getRandomValues(r4), Xt(r4.buffer);
4478
+ return crypto.getRandomValues(r4), ir(r4.buffer);
4463
4479
  }
4464
- async function Pr(r4) {
4480
+ async function Dr(r4) {
4465
4481
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4466
4482
  }
4467
- var qe = class {
4483
+ var $e = class {
4468
4484
  constructor(e = 10) {
4469
4485
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4470
4486
  }
@@ -4488,8 +4504,8 @@ var qe = class {
4488
4504
  return this.cache.keys().next().value;
4489
4505
  }
4490
4506
  };
4491
- var Y = { 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" };
4492
- var je = class {
4507
+ var X = { CSS: "text/css", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
4508
+ var Qe = class {
4493
4509
  constructor() {
4494
4510
  this.listeners = {};
4495
4511
  }
@@ -4511,31 +4527,31 @@ var je = class {
4511
4527
  return t && t.forEach((n) => n.call(this, e)), !e.defaultPrevented;
4512
4528
  }
4513
4529
  };
4514
- function xi(r4) {
4515
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Ar(e), n = Array.from(t).reduce((o, s) => {
4530
+ function Si(r4) {
4531
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Ir(e), n = Array.from(t).reduce((o, s) => {
4516
4532
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4517
4533
  return `${o}%${a}`;
4518
4534
  }, ""), i2 = decodeURIComponent(n);
4519
4535
  return JSON.parse(i2);
4520
4536
  }
4521
- function kr(r4) {
4537
+ function Vr(r4) {
4522
4538
  return r4.split(".").length === 3;
4523
4539
  }
4524
- function St(r4) {
4540
+ function Et(r4) {
4525
4541
  let [e, t, n] = r4.split(".");
4526
- return xi(t);
4542
+ return Si(t);
4527
4543
  }
4528
- function Ir(r4) {
4544
+ function Ur(r4) {
4529
4545
  try {
4530
- return typeof St(r4).login_id == "string";
4546
+ return typeof Et(r4).login_id == "string";
4531
4547
  } catch {
4532
4548
  return false;
4533
4549
  }
4534
4550
  }
4535
- var Ti;
4551
+ var bi;
4536
4552
  var w = class {
4537
4553
  constructor(e) {
4538
- this[Ti] = "ReadablePromise";
4554
+ this[bi] = "ReadablePromise";
4539
4555
  this.status = "pending";
4540
4556
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4541
4557
  throw this.status = "error", this.error = t, t;
@@ -4567,10 +4583,10 @@ var w = class {
4567
4583
  return this.suspender.finally(e);
4568
4584
  }
4569
4585
  };
4570
- Ti = Symbol.toStringTag;
4571
- var Qe = class {
4586
+ bi = Symbol.toStringTag;
4587
+ var He = class {
4572
4588
  constructor() {
4573
- this.storage = typeof localStorage < "u" ? localStorage : new Rt();
4589
+ this.storage = typeof localStorage < "u" ? localStorage : new Pt();
4574
4590
  }
4575
4591
  clear() {
4576
4592
  this.storage.clear();
@@ -4586,10 +4602,10 @@ var Qe = class {
4586
4602
  return t ? JSON.parse(t) : void 0;
4587
4603
  }
4588
4604
  setObject(e, t) {
4589
- this.setString(e, t ? zt(t) : void 0);
4605
+ this.setString(e, t ? tr(t) : void 0);
4590
4606
  }
4591
4607
  };
4592
- var Rt = class {
4608
+ var Pt = class {
4593
4609
  constructor() {
4594
4610
  this.data = /* @__PURE__ */ new Map();
4595
4611
  }
@@ -4612,19 +4628,20 @@ var Rt = class {
4612
4628
  return Array.from(this.data.keys())[e];
4613
4629
  }
4614
4630
  };
4615
- var vi = "https://api.medplum.com/";
4616
- var bi = 1e3;
4617
- var Si = 6e4;
4618
- var Dr = "Binary/";
4619
- var Or = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4620
- var Ri = ((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))(Ri || {});
4621
- var Ai = ((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))(Ai || {});
4622
- var Vr = class extends je {
4631
+ var Ai = "https://api.medplum.com/";
4632
+ var Ei = 1e3;
4633
+ var Pi = 6e4;
4634
+ var Lr = "Binary/";
4635
+ var _r = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4636
+ var Ci = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(Ci || {});
4637
+ var wi = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(wi || {});
4638
+ var Ii = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Ii || {});
4639
+ var Mr = class extends Qe {
4623
4640
  constructor(t) {
4624
4641
  super();
4625
4642
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4626
4643
  throw new Error("Base URL must start with http or https");
4627
- this.fetch = t?.fetch ?? Ei(), this.storage = t?.storage ?? new Qe(), this.createPdfImpl = t?.createPdf, this.baseUrl = Lr(t?.baseUrl) ?? vi, this.fhirBaseUrl = this.baseUrl + (Lr(t?.fhirUrlPath) ?? "fhir/R4/"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.authorizeUrl = t?.authorizeUrl ?? this.baseUrl + "oauth2/authorize", this.tokenUrl = t?.tokenUrl ?? this.baseUrl + "oauth2/token", this.logoutUrl = t?.logoutUrl ?? this.baseUrl + "oauth2/logout", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Si, this.cacheTime > 0 ? this.requestCache = new qe(t?.resourceCacheSize ?? bi) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0);
4644
+ this.options = t ?? {}, this.fetch = t?.fetch ?? ki(), this.storage = t?.storage ?? new He(), this.createPdfImpl = t?.createPdf, this.baseUrl = Br(t?.baseUrl ?? Ai), this.fhirBaseUrl = Br(We(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = We(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = We(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = We(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? Pi, this.cacheTime > 0 ? this.requestCache = new $e(t?.resourceCacheSize ?? Ei) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0);
4628
4645
  let n = this.getActiveLogin();
4629
4646
  n && (this.setAccessToken(n.accessToken, n.refreshToken), this.refreshProfile().catch(console.log)), this.setupStorageListener();
4630
4647
  }
@@ -4634,6 +4651,12 @@ var Vr = class extends je {
4634
4651
  getAuthorizeUrl() {
4635
4652
  return this.authorizeUrl;
4636
4653
  }
4654
+ getTokenUrl() {
4655
+ return this.tokenUrl;
4656
+ }
4657
+ getLogoutUrl() {
4658
+ return this.logoutUrl;
4659
+ }
4637
4660
  clear() {
4638
4661
  this.storage.clear(), this.clearActiveLogin();
4639
4662
  }
@@ -4665,13 +4688,13 @@ var Vr = class extends je {
4665
4688
  return this.setCacheEntry(t, s), s;
4666
4689
  }
4667
4690
  post(t, n, i2, o = {}) {
4668
- return t = t.toString(), n && this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("POST", t, o);
4691
+ return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("POST", t, o);
4669
4692
  }
4670
4693
  put(t, n, i2, o = {}) {
4671
- return t = t.toString(), n && this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4694
+ return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4672
4695
  }
4673
4696
  patch(t, n, i2 = {}) {
4674
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, Y.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4697
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, X.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4675
4698
  }
4676
4699
  delete(t, n) {
4677
4700
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -4727,7 +4750,7 @@ var Vr = class extends je {
4727
4750
  return c2.searchParams.set("response_type", "code"), c2.searchParams.set("client_id", n), c2.searchParams.set("redirect_uri", i2), c2.searchParams.set("scope", "openid profile email"), c2.searchParams.set("state", JSON.stringify(o)), c2.searchParams.set("code_challenge_method", a), c2.searchParams.set("code_challenge", s), c2.toString();
4728
4751
  }
4729
4752
  fhirUrl(...t) {
4730
- return new URL(this.fhirBaseUrl + t.join("/"));
4753
+ return new URL(t.join("/"), this.fhirBaseUrl);
4731
4754
  }
4732
4755
  fhirSearchUrl(t, n) {
4733
4756
  let i2 = this.fhirUrl(t);
@@ -4738,11 +4761,11 @@ var Vr = class extends je {
4738
4761
  if (a)
4739
4762
  return a.value;
4740
4763
  let c2 = new w((async () => {
4741
- let p2 = await this.get(o, i2);
4742
- if (p2.entry)
4743
- for (let l2 of p2.entry)
4764
+ let f = await this.get(o, i2);
4765
+ if (f.entry)
4766
+ for (let l2 of f.entry)
4744
4767
  this.cacheResource(l2.resource);
4745
- return p2;
4768
+ return f;
4746
4769
  })());
4747
4770
  return this.setCacheEntry(s, c2), c2;
4748
4771
  }
@@ -4752,23 +4775,23 @@ var Vr = class extends je {
4752
4775
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
4753
4776
  if (a)
4754
4777
  return a.value;
4755
- let c2 = new w(this.search(t, o.searchParams, i2).then((p2) => p2.entry?.[0]?.resource));
4778
+ let c2 = new w(this.search(t, o.searchParams, i2).then((f) => f.entry?.[0]?.resource));
4756
4779
  return this.setCacheEntry(s, c2), c2;
4757
4780
  }
4758
4781
  searchResources(t, n, i2) {
4759
4782
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
4760
4783
  if (a)
4761
4784
  return a.value;
4762
- let c2 = new w(this.search(t, n, i2).then(Nr));
4785
+ let c2 = new w(this.search(t, n, i2).then(qr));
4763
4786
  return this.setCacheEntry(s, c2), c2;
4764
4787
  }
4765
4788
  async *searchResourcePages(t, n, i2) {
4766
4789
  let o = this.fhirSearchUrl(t, n);
4767
4790
  for (; o; ) {
4768
- let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((p2) => p2.relation === "next");
4791
+ let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((f) => f.relation === "next");
4769
4792
  if (!a.entry?.length && !c2)
4770
4793
  break;
4771
- yield Nr(a), o = c2?.url ? new URL(c2.url) : void 0;
4794
+ yield qr(a), o = c2?.url ? new URL(c2.url) : void 0;
4772
4795
  }
4773
4796
  }
4774
4797
  searchValueSet(t, n, i2) {
@@ -4784,7 +4807,7 @@ var Vr = class extends je {
4784
4807
  if (!n)
4785
4808
  return;
4786
4809
  if (n === "system")
4787
- return Or;
4810
+ return _r;
4788
4811
  let [i2, o] = n.split("/");
4789
4812
  if (!(!i2 || !o))
4790
4813
  return this.getCached(i2, o);
@@ -4797,7 +4820,7 @@ var Vr = class extends je {
4797
4820
  if (!i2)
4798
4821
  return new w(Promise.reject(new Error("Missing reference")));
4799
4822
  if (i2 === "system")
4800
- return new w(Promise.resolve(Or));
4823
+ return new w(Promise.resolve(_r));
4801
4824
  let [o, s] = i2.split("/");
4802
4825
  return !o || !s ? new w(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
4803
4826
  }
@@ -4841,9 +4864,9 @@ var Vr = class extends je {
4841
4864
  }
4842
4865
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
4843
4866
  for (let c2 of a.data.StructureDefinitionList)
4844
- ct(c2);
4867
+ dt(c2);
4845
4868
  for (let c2 of a.data.SearchParameterList)
4846
- ut(c2);
4869
+ lt(c2);
4847
4870
  return y;
4848
4871
  })());
4849
4872
  return this.setCacheEntry(n, o), o;
@@ -4876,7 +4899,7 @@ var Vr = class extends je {
4876
4899
  uploadwithProgress(t, n, i2, o) {
4877
4900
  return new Promise((s, a) => {
4878
4901
  let c2 = new XMLHttpRequest();
4879
- c2.responseType = "json", c2.onabort = () => a(new Error("Request aborted")), c2.onerror = () => a(new Error("Request error")), o && (c2.upload.onprogress = (p2) => o(p2), c2.upload.onload = (p2) => o(p2)), c2.onload = () => {
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 = () => {
4880
4903
  c2.status >= 200 && c2.status < 300 ? s(c2.response) : a(new Error(c2.statusText));
4881
4904
  }, 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);
4882
4905
  });
@@ -4889,7 +4912,7 @@ var Vr = class extends je {
4889
4912
  }
4890
4913
  createComment(t, n, i2) {
4891
4914
  let o = this.getProfile(), s, a;
4892
- return t.resourceType === "Encounter" && (s = ie(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = ie(t)), this.createResource({ resourceType: "Communication", basedOn: [ie(t)], encounter: s, subject: a, sender: o ? ie(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
4915
+ return t.resourceType === "Encounter" && (s = ae(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = ae(t)), this.createResource({ resourceType: "Communication", basedOn: [ae(t)], encounter: s, subject: a, sender: o ? ae(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
4893
4916
  }
4894
4917
  async updateResource(t, n) {
4895
4918
  if (!t.resourceType)
@@ -4924,14 +4947,17 @@ var Vr = class extends je {
4924
4947
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
4925
4948
  }
4926
4949
  sendEmail(t, n) {
4927
- return this.post("email/v1/send", t, Y.JSON, n);
4950
+ return this.post("email/v1/send", t, X.JSON, n);
4928
4951
  }
4929
4952
  graphql(t, n, i2, o) {
4930
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, Y.JSON, o);
4953
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, X.JSON, o);
4931
4954
  }
4932
4955
  readResourceGraph(t, n, i2, o) {
4933
4956
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
4934
4957
  }
4958
+ pushToAgent(t, n, i2, o) {
4959
+ return this.post(this.fhirUrl("Agent", t.id, "$push"), n, i2, o);
4960
+ }
4935
4961
  getActiveLogin() {
4936
4962
  return this.storage.getObject("activeLogin");
4937
4963
  }
@@ -4942,7 +4968,7 @@ var Vr = class extends je {
4942
4968
  return this.accessToken;
4943
4969
  }
4944
4970
  setAccessToken(t, n) {
4945
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Ir(t);
4971
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Ur(t);
4946
4972
  }
4947
4973
  getLogins() {
4948
4974
  return this.storage.getObject("logins") ?? [];
@@ -4985,16 +5011,14 @@ var Vr = class extends je {
4985
5011
  getAccessPolicy() {
4986
5012
  return this.sessionDetails?.accessPolicy;
4987
5013
  }
4988
- normalizeFetchUrl(t) {
4989
- let n = t.toString();
4990
- return n.startsWith(Dr) && (n = this.fhirUrl(n).toString()), n;
4991
- }
4992
5014
  async download(t, n = {}) {
4993
- return this.refreshPromise && await this.refreshPromise, this.addFetchOptionsDefaults(n), (await this.fetch(this.normalizeFetchUrl(t), n)).blob();
5015
+ this.refreshPromise && await this.refreshPromise;
5016
+ let i2 = t.toString();
5017
+ return i2.startsWith(Lr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
4994
5018
  }
4995
5019
  async uploadMedia(t, n, i2, o, s) {
4996
5020
  let a = await this.createBinary(t, i2, n);
4997
- return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Dr + a.id, title: i2 } }, s);
5021
+ return this.createResource({ ...o, resourceType: "Media", content: { contentType: n, url: Lr + a.id, title: i2 } }, s);
4998
5022
  }
4999
5023
  async bulkExport(t = "", n, i2, o) {
5000
5024
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5006,7 +5030,7 @@ var Vr = class extends je {
5006
5030
  i2.Prefer = "respond-async";
5007
5031
  let o = await this.fetchWithRetry(t, n);
5008
5032
  if (o.status === 202) {
5009
- let s = await _r(o);
5033
+ let s = await Fr(o);
5010
5034
  if (s)
5011
5035
  return this.pollStatus(s);
5012
5036
  }
@@ -5040,37 +5064,47 @@ var Vr = class extends je {
5040
5064
  return;
5041
5065
  let a = t.headers.get("content-type")?.includes("json");
5042
5066
  if (t.status === 404 && !a)
5043
- throw new m(Lt);
5044
- let c2 = t.headers.get("content-location");
5045
- if (t.status === 201 && c2 && o.redirect === "follow")
5067
+ throw new h(jt);
5068
+ let c2 = t.headers.get("content-location"), f = o.redirect ?? this.options.redirect;
5069
+ if (t.status === 201 && c2 && f === "follow")
5046
5070
  return this.request("GET", c2, { ...o, body: void 0 });
5047
- let p2;
5071
+ let l2;
5048
5072
  if (a)
5049
5073
  try {
5050
- p2 = await t.json();
5051
- } catch (l2) {
5052
- throw console.error("Error parsing response", t.status, l2), l2;
5074
+ l2 = await t.json();
5075
+ } catch (B) {
5076
+ throw console.error("Error parsing response", t.status, B), B;
5053
5077
  }
5054
5078
  else
5055
- p2 = await t.text();
5079
+ l2 = await t.text();
5056
5080
  if (t.status >= 400)
5057
- throw new m(rt(p2));
5058
- return p2;
5081
+ throw new h(nt(l2));
5082
+ return l2;
5059
5083
  }
5060
5084
  async fetchWithRetry(t, n) {
5061
5085
  t.startsWith("http") || (t = new URL(t, this.baseUrl).href);
5062
5086
  let i2 = 3, o = 200, s;
5063
5087
  for (let a = 0; a < i2; a++) {
5064
5088
  try {
5065
- if (s = await this.fetch(t, n), s.status < 500)
5089
+ if (this.options.verbose && this.logRequest(t, n), s = await this.fetch(t, n), this.options.verbose && this.logResponse(s), s.status < 500)
5066
5090
  return s;
5067
5091
  } catch (c2) {
5068
5092
  this.retryCatch(a, i2, c2);
5069
5093
  }
5070
- await at(o);
5094
+ await ut(o);
5071
5095
  }
5072
5096
  return s;
5073
5097
  }
5098
+ logRequest(t, n) {
5099
+ if (console.log(`> ${n.method} ${t}`), n.headers) {
5100
+ let i2 = n.headers, o = Object.entries(i2).sort((s, a) => s[0].localeCompare(a[0]));
5101
+ for (let [s, a] of o)
5102
+ console.log(`> ${s}: ${a}`);
5103
+ }
5104
+ }
5105
+ logResponse(t) {
5106
+ console.log(`< ${t.status} ${t.statusText}`), t.headers && t.headers.forEach((n, i2) => console.log(`< ${i2}: ${n}`));
5107
+ }
5074
5108
  async pollStatus(t) {
5075
5109
  let n = true, i2, o = 2e3;
5076
5110
  for (; n; ) {
@@ -5078,10 +5112,10 @@ var Vr = class extends je {
5078
5112
  this.addFetchOptionsDefaults(s);
5079
5113
  let a = await this.fetchWithRetry(t, s);
5080
5114
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5081
- let c2 = await _r(a);
5115
+ let c2 = await Fr(a);
5082
5116
  c2 && (i2 = await this.fetchWithRetry(c2, s));
5083
5117
  }
5084
- await at(o);
5118
+ await ut(o);
5085
5119
  }
5086
5120
  return this.parseResponse(i2, "POST", t);
5087
5121
  }
@@ -5092,19 +5126,19 @@ var Vr = class extends je {
5092
5126
  try {
5093
5127
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
5094
5128
  } catch (s) {
5095
- o.reject(new m(rt(s)));
5129
+ o.reject(new h(nt(s)));
5096
5130
  }
5097
5131
  return;
5098
5132
  }
5099
5133
  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);
5100
5134
  for (let o = 0; o < t.length; o++) {
5101
5135
  let s = t[o], a = i2.entry?.[o];
5102
- a?.response?.outcome && !tt(a.response.outcome) ? s.reject(new m(a.response.outcome)) : s.resolve(a?.resource);
5136
+ a?.response?.outcome && !rt(a.response.outcome) ? s.reject(new h(a.response.outcome)) : s.resolve(a?.resource);
5103
5137
  }
5104
5138
  }
5105
5139
  addFetchOptionsDefaults(t) {
5106
5140
  let n = t.headers;
5107
- n || (n = {}, t.headers = n), n.Accept = Y.FHIR_JSON, n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = Y.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");
5141
+ n || (n = {}, t.headers = n), n.Accept = X.FHIR_JSON, n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = X.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
5108
5142
  }
5109
5143
  setRequestContentType(t, n) {
5110
5144
  t.headers || (t.headers = {});
@@ -5122,16 +5156,16 @@ var Vr = class extends je {
5122
5156
  sessionStorage.setItem("pkceState", t);
5123
5157
  let n = bt();
5124
5158
  sessionStorage.setItem("codeVerifier", n);
5125
- let i2 = await Pr(n), o = Zt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5159
+ let i2 = await Dr(n), o = or(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5126
5160
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5127
5161
  }
5128
5162
  async requestAuthorization(t) {
5129
5163
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
5130
- 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 ?? Ur()), 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());
5164
+ i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? Nr()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
5131
5165
  }
5132
5166
  processCode(t, n) {
5133
5167
  let i2 = new URLSearchParams();
5134
- 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 ?? Ur()), typeof sessionStorage < "u") {
5168
+ if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? Nr()), typeof sessionStorage < "u") {
5135
5169
  let o = sessionStorage.getItem("codeVerifier");
5136
5170
  o && i2.set("code_verifier", o);
5137
5171
  }
@@ -5157,23 +5191,27 @@ var Vr = class extends je {
5157
5191
  let o = new URLSearchParams();
5158
5192
  return o.set("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer"), o.set("client_id", t), o.set("assertion", n), o.set("scope", i2), this.fetchTokens(o);
5159
5193
  }
5194
+ async startJwtAssertionLogin(t) {
5195
+ let n = new URLSearchParams();
5196
+ 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
+ }
5160
5198
  setBasicAuth(t, n) {
5161
- this.clientId = t, this.clientSecret = n, this.basicAuth = Er(t + ":" + n);
5199
+ this.clientId = t, this.clientSecret = n, this.basicAuth = kr(t + ":" + n);
5162
5200
  }
5163
5201
  async invite(t, n) {
5164
5202
  return this.post("admin/projects/" + t + "/invite", n);
5165
5203
  }
5166
5204
  async fetchTokens(t) {
5167
- let n = { method: "POST", headers: { "Content-Type": Y.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5205
+ let n = { method: "POST", headers: { "Content-Type": X.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5168
5206
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5169
- let o = await this.fetch(this.tokenUrl, n);
5207
+ let o = await this.fetchWithRetry(this.tokenUrl, n);
5170
5208
  if (!o.ok) {
5171
5209
  this.clearActiveLogin();
5172
5210
  try {
5173
5211
  let a = await o.json();
5174
- throw new m(I(a.error_description));
5212
+ throw new h(k(a.error_description));
5175
5213
  } catch (a) {
5176
- throw new m(I("Failed to fetch tokens"), a);
5214
+ throw new h(k("Failed to fetch tokens"), a);
5177
5215
  }
5178
5216
  }
5179
5217
  let s = await o.json();
@@ -5181,8 +5219,8 @@ var Vr = class extends je {
5181
5219
  }
5182
5220
  async verifyTokens(t) {
5183
5221
  let n = t.access_token;
5184
- if (kr(n)) {
5185
- let i2 = St(n);
5222
+ if (Vr(n)) {
5223
+ let i2 = Et(n);
5186
5224
  if (Date.now() >= i2.exp * 1e3)
5187
5225
  throw this.clearActiveLogin(), new Error("Token expired");
5188
5226
  if (i2.cid) {
@@ -5206,18 +5244,21 @@ var Vr = class extends je {
5206
5244
  throw i2;
5207
5245
  }
5208
5246
  };
5209
- function Ei() {
5247
+ function ki() {
5210
5248
  if (!globalThis.fetch)
5211
5249
  throw new Error("Fetch not available in this environment");
5212
5250
  return globalThis.fetch.bind(globalThis);
5213
5251
  }
5214
- function Ur() {
5252
+ function Nr() {
5215
5253
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5216
5254
  }
5217
- function Lr(r4) {
5218
- return r4 && (r4.endsWith("/") ? r4 : r4 + "/");
5255
+ function Br(r4) {
5256
+ return r4.endsWith("/") ? r4 : r4 + "/";
5257
+ }
5258
+ function We(r4, e) {
5259
+ return new URL(e, r4).toString();
5219
5260
  }
5220
- async function _r(r4) {
5261
+ async function Fr(r4) {
5221
5262
  let e = r4.headers.get("content-location");
5222
5263
  if (e)
5223
5264
  return e;
@@ -5225,18 +5266,18 @@ async function _r(r4) {
5225
5266
  if (t)
5226
5267
  return t;
5227
5268
  let n = await r4.json();
5228
- if (ye(n) && n.issue?.[0]?.diagnostics)
5269
+ if (xe(n) && n.issue?.[0]?.diagnostics)
5229
5270
  return n.issue[0].diagnostics;
5230
5271
  }
5231
- function Nr(r4) {
5272
+ function qr(r4) {
5232
5273
  let e = r4.entry?.map((t) => t.resource) ?? [];
5233
5274
  return Object.assign(e, { bundle: r4 });
5234
5275
  }
5235
- var Pi = [...ce, "->", "<<", ">>"];
5236
- var Ci = ue().registerInfix("->", { precedence: f.Arrow }).registerInfix(";", { precedence: f.Semicolon });
5237
- var wi = [...ce, "eq", "ne", "co"];
5238
- var Di = ue();
5239
- var W = class {
5276
+ var Di = [...pe, "->", "<<", ">>"];
5277
+ var Oi = fe().registerInfix("->", { precedence: p.Arrow }).registerInfix(";", { precedence: p.Semicolon });
5278
+ var Vi = [...pe, "eq", "ne", "co"];
5279
+ var _i = fe();
5280
+ var H = class {
5240
5281
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5241
5282
  this.segmentSeparator = e;
5242
5283
  this.fieldSeparator = t;
@@ -5252,8 +5293,8 @@ var W = class {
5252
5293
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5253
5294
  }
5254
5295
  };
5255
- var Fr = class r {
5256
- constructor(e, t = new W()) {
5296
+ var Qr = class r {
5297
+ constructor(e, t = new H()) {
5257
5298
  this.context = t, this.segments = e;
5258
5299
  }
5259
5300
  get header() {
@@ -5276,7 +5317,7 @@ var Fr = class r {
5276
5317
  }
5277
5318
  buildAck() {
5278
5319
  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";
5279
- return new r([new pe(["MSH", this.context.getMsh2(), o, s, n, i2, Vi(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new pe(["MSA", "AA", a, "OK"], this.context)]);
5320
+ return new r([new me(["MSH", this.context.getMsh2(), o, s, n, i2, Ni(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new me(["MSA", "AA", a, "OK"], this.context)]);
5280
5321
  }
5281
5322
  buildAckMessageType(e) {
5282
5323
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5287,13 +5328,13 @@ var Fr = class r {
5287
5328
  let n = new Error("Invalid HL7 message");
5288
5329
  throw n.type = "entity.parse.failed", n;
5289
5330
  }
5290
- let t = new W("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5291
- return new r(e.split(/[\r\n]+/).map((n) => pe.parse(n, t)), t);
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) => me.parse(n, t)), t);
5292
5333
  }
5293
5334
  };
5294
- var pe = class r2 {
5295
- constructor(e, t = new W()) {
5296
- this.context = t, Jt(e) ? this.fields = e.map((n) => te.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5335
+ var me = class r2 {
5336
+ constructor(e, t = new H()) {
5337
+ this.context = t, rr(e) ? this.fields = e.map((n) => ie.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5297
5338
  }
5298
5339
  get(e) {
5299
5340
  return this.fields[e];
@@ -5301,9 +5342,9 @@ var pe = class r2 {
5301
5342
  getField(e) {
5302
5343
  if (this.name === "MSH") {
5303
5344
  if (e === 1)
5304
- return new te([[this.context.getMsh1()]], this.context);
5345
+ return new ie([[this.context.getMsh1()]], this.context);
5305
5346
  if (e === 2)
5306
- return new te([[this.context.getMsh2()]], this.context);
5347
+ return new ie([[this.context.getMsh2()]], this.context);
5307
5348
  if (e > 2)
5308
5349
  return this.fields[e - 1];
5309
5350
  }
@@ -5315,12 +5356,12 @@ var pe = class r2 {
5315
5356
  toString() {
5316
5357
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
5317
5358
  }
5318
- static parse(e, t = new W()) {
5319
- return new r2(e.split(t.fieldSeparator).map((n) => te.parse(n, t)), t);
5359
+ static parse(e, t = new H()) {
5360
+ return new r2(e.split(t.fieldSeparator).map((n) => ie.parse(n, t)), t);
5320
5361
  }
5321
5362
  };
5322
- var te = class r3 {
5323
- constructor(e, t = new W()) {
5363
+ var ie = class r3 {
5364
+ constructor(e, t = new H()) {
5324
5365
  this.context = t, this.components = e;
5325
5366
  }
5326
5367
  get(e, t, n = 0) {
@@ -5333,11 +5374,11 @@ var te = class r3 {
5333
5374
  toString() {
5334
5375
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
5335
5376
  }
5336
- static parse(e, t = new W()) {
5377
+ static parse(e, t = new H()) {
5337
5378
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5338
5379
  }
5339
5380
  };
5340
- function Vi(r4) {
5381
+ function Ni(r4) {
5341
5382
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5342
5383
  return i2 > 0 && (n += "." + i2.toString()), n;
5343
5384
  }
@@ -5352,8 +5393,8 @@ var i = class extends EventTarget {
5352
5393
  super.removeEventListener(n, e, t);
5353
5394
  }
5354
5395
  };
5355
- var m2 = String.fromCharCode(11);
5356
- var p = String.fromCharCode(28);
5396
+ var m = String.fromCharCode(11);
5397
+ var p2 = String.fromCharCode(28);
5357
5398
  var v2 = String.fromCharCode(13);
5358
5399
  var d2 = class extends Event {
5359
5400
  constructor(e, t) {
@@ -5376,8 +5417,8 @@ var c = class extends i {
5376
5417
  let o = "";
5377
5418
  e.on("data", (s) => {
5378
5419
  try {
5379
- if (o += s.toString(), o.endsWith(p + v2)) {
5380
- let r4 = Fr.parse(o.substring(1, o.length - 2));
5420
+ if (o += s.toString(), o.endsWith(p2 + v2)) {
5421
+ let r4 = Qr.parse(o.substring(1, o.length - 2));
5381
5422
  this.dispatchEvent(new d2(this, r4)), o = "";
5382
5423
  }
5383
5424
  } catch (r4) {
@@ -5388,7 +5429,7 @@ var c = class extends i {
5388
5429
  });
5389
5430
  }
5390
5431
  send(e) {
5391
- this.socket.write(m2 + e.toString() + p + v2);
5432
+ this.socket.write(m + e.toString() + p2 + v2);
5392
5433
  }
5393
5434
  async sendAndWait(e) {
5394
5435
  let t = new Promise((o) => {
@@ -5419,7 +5460,7 @@ var E2 = class {
5419
5460
  }
5420
5461
  };
5421
5462
 
5422
- // node_modules/ws/wrapper.mjs
5463
+ // ../../node_modules/ws/wrapper.mjs
5423
5464
  var import_stream = __toESM(require_stream(), 1);
5424
5465
  var import_receiver = __toESM(require_receiver(), 1);
5425
5466
  var import_sender = __toESM(require_sender(), 1);
@@ -5505,7 +5546,7 @@ var AgentHl7ChannelConnection = class {
5505
5546
  type: "connect",
5506
5547
  accessToken: medplum.getAccessToken(),
5507
5548
  agentId: channel.app.agentId,
5508
- botId: Ro(channel.definition.targetReference)
5549
+ botId: wo(channel.definition.targetReference)
5509
5550
  })
5510
5551
  );
5511
5552
  });
@@ -5521,7 +5562,7 @@ var AgentHl7ChannelConnection = class {
5521
5562
  this.trySendToWebSocket();
5522
5563
  break;
5523
5564
  case "transmit":
5524
- this.hl7ConnectionQueue.push(Fr.parse(command.message));
5565
+ this.hl7ConnectionQueue.push(Qr.parse(command.message));
5525
5566
  this.trySendToHl7Connection();
5526
5567
  break;
5527
5568
  }
@@ -5575,7 +5616,7 @@ if (typeof require !== "undefined" && require.main === module) {
5575
5616
  process.exit(1);
5576
5617
  }
5577
5618
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = process.argv;
5578
- const medplum = new Vr({ baseUrl, clientId });
5619
+ const medplum = new Mr({ baseUrl, clientId });
5579
5620
  medplum.startClientLogin(clientId, clientSecret).then(() => new App(medplum, agentId).start()).catch(console.error);
5580
5621
  }
5581
5622
  // Annotate the CommonJS export names for ESM import in node: