@medplum/agent 2.1.20 → 2.1.21

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 +588 -589
  2. package/package.json +2 -2
@@ -8,10 +8,6 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJS = (cb, mod) => function __require() {
9
9
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
10
  };
11
- var __export = (target, all) => {
12
- for (var name in all)
13
- __defProp(target, name, { get: all[name], enumerable: true });
14
- };
15
11
  var __copyProps = (to2, from, except, desc) => {
16
12
  if (from && typeof from === "object" || typeof from === "function") {
17
13
  for (let key of __getOwnPropNames(from))
@@ -28,11 +24,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
24
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
25
  mod
30
26
  ));
31
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
27
 
33
28
  // ../../node_modules/ws/lib/stream.js
34
29
  var require_stream = __commonJS({
35
- "../../node_modules/ws/lib/stream.js"(exports, module2) {
30
+ "../../node_modules/ws/lib/stream.js"(exports2, module2) {
36
31
  "use strict";
37
32
  var { Duplex } = require("stream");
38
33
  function emitClose(stream) {
@@ -137,7 +132,7 @@ var require_stream = __commonJS({
137
132
 
138
133
  // ../../node_modules/ws/lib/constants.js
139
134
  var require_constants = __commonJS({
140
- "../../node_modules/ws/lib/constants.js"(exports, module2) {
135
+ "../../node_modules/ws/lib/constants.js"(exports2, module2) {
141
136
  "use strict";
142
137
  module2.exports = {
143
138
  BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
@@ -155,7 +150,7 @@ var require_constants = __commonJS({
155
150
 
156
151
  // ../../node_modules/ws/lib/buffer-util.js
157
152
  var require_buffer_util = __commonJS({
158
- "../../node_modules/ws/lib/buffer-util.js"(exports, module2) {
153
+ "../../node_modules/ws/lib/buffer-util.js"(exports2, module2) {
159
154
  "use strict";
160
155
  var { EMPTY_BUFFER } = require_constants();
161
156
  var FastBuffer = Buffer[Symbol.species];
@@ -237,7 +232,7 @@ var require_buffer_util = __commonJS({
237
232
 
238
233
  // ../../node_modules/ws/lib/limiter.js
239
234
  var require_limiter = __commonJS({
240
- "../../node_modules/ws/lib/limiter.js"(exports, module2) {
235
+ "../../node_modules/ws/lib/limiter.js"(exports2, module2) {
241
236
  "use strict";
242
237
  var kDone = Symbol("kDone");
243
238
  var kRun = Symbol("kRun");
@@ -288,7 +283,7 @@ var require_limiter = __commonJS({
288
283
 
289
284
  // ../../node_modules/ws/lib/permessage-deflate.js
290
285
  var require_permessage_deflate = __commonJS({
291
- "../../node_modules/ws/lib/permessage-deflate.js"(exports, module2) {
286
+ "../../node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
292
287
  "use strict";
293
288
  var zlib = require("zlib");
294
289
  var bufferUtil = require_buffer_util();
@@ -668,7 +663,7 @@ var require_permessage_deflate = __commonJS({
668
663
 
669
664
  // ../../node_modules/ws/lib/validation.js
670
665
  var require_validation = __commonJS({
671
- "../../node_modules/ws/lib/validation.js"(exports, module2) {
666
+ "../../node_modules/ws/lib/validation.js"(exports2, module2) {
672
667
  "use strict";
673
668
  var { isUtf8 } = require("buffer");
674
669
  var tokenChars = [
@@ -864,7 +859,7 @@ var require_validation = __commonJS({
864
859
 
865
860
  // ../../node_modules/ws/lib/receiver.js
866
861
  var require_receiver = __commonJS({
867
- "../../node_modules/ws/lib/receiver.js"(exports, module2) {
862
+ "../../node_modules/ws/lib/receiver.js"(exports2, module2) {
868
863
  "use strict";
869
864
  var { Writable } = require("stream");
870
865
  var PerMessageDeflate = require_permessage_deflate();
@@ -1295,9 +1290,9 @@ var require_receiver = __commonJS({
1295
1290
  }
1296
1291
  this._fragments.push(buf);
1297
1292
  }
1298
- const er = this.dataMessage();
1299
- if (er)
1300
- return cb(er);
1293
+ const er2 = this.dataMessage();
1294
+ if (er2)
1295
+ return cb(er2);
1301
1296
  this.startLoop(cb);
1302
1297
  });
1303
1298
  }
@@ -1418,7 +1413,7 @@ var require_receiver = __commonJS({
1418
1413
 
1419
1414
  // ../../node_modules/ws/lib/sender.js
1420
1415
  var require_sender = __commonJS({
1421
- "../../node_modules/ws/lib/sender.js"(exports, module2) {
1416
+ "../../node_modules/ws/lib/sender.js"(exports2, module2) {
1422
1417
  "use strict";
1423
1418
  var { Duplex } = require("stream");
1424
1419
  var { randomFillSync } = require("crypto");
@@ -1829,7 +1824,7 @@ var require_sender = __commonJS({
1829
1824
 
1830
1825
  // ../../node_modules/ws/lib/event-target.js
1831
1826
  var require_event_target = __commonJS({
1832
- "../../node_modules/ws/lib/event-target.js"(exports, module2) {
1827
+ "../../node_modules/ws/lib/event-target.js"(exports2, module2) {
1833
1828
  "use strict";
1834
1829
  var { kForOnEventAttribute, kListener } = require_constants();
1835
1830
  var kCode = Symbol("kCode");
@@ -2058,7 +2053,7 @@ var require_event_target = __commonJS({
2058
2053
 
2059
2054
  // ../../node_modules/ws/lib/extension.js
2060
2055
  var require_extension = __commonJS({
2061
- "../../node_modules/ws/lib/extension.js"(exports, module2) {
2056
+ "../../node_modules/ws/lib/extension.js"(exports2, module2) {
2062
2057
  "use strict";
2063
2058
  var { tokenChars } = require_validation();
2064
2059
  function push(dest, name, elem) {
@@ -2228,7 +2223,7 @@ var require_extension = __commonJS({
2228
2223
 
2229
2224
  // ../../node_modules/ws/lib/websocket.js
2230
2225
  var require_websocket = __commonJS({
2231
- "../../node_modules/ws/lib/websocket.js"(exports, module2) {
2226
+ "../../node_modules/ws/lib/websocket.js"(exports2, module2) {
2232
2227
  "use strict";
2233
2228
  var EventEmitter = require("events");
2234
2229
  var https = require("https");
@@ -3105,7 +3100,7 @@ var require_websocket = __commonJS({
3105
3100
 
3106
3101
  // ../../node_modules/ws/lib/subprotocol.js
3107
3102
  var require_subprotocol = __commonJS({
3108
- "../../node_modules/ws/lib/subprotocol.js"(exports, module2) {
3103
+ "../../node_modules/ws/lib/subprotocol.js"(exports2, module2) {
3109
3104
  "use strict";
3110
3105
  var { tokenChars } = require_validation();
3111
3106
  function parse(header) {
@@ -3153,7 +3148,7 @@ var require_subprotocol = __commonJS({
3153
3148
 
3154
3149
  // ../../node_modules/ws/lib/websocket-server.js
3155
3150
  var require_websocket_server = __commonJS({
3156
- "../../node_modules/ws/lib/websocket-server.js"(exports, module2) {
3151
+ "../../node_modules/ws/lib/websocket-server.js"(exports2, module2) {
3157
3152
  "use strict";
3158
3153
  var EventEmitter = require("events");
3159
3154
  var http = require("http");
@@ -3538,17 +3533,8 @@ var require_websocket_server = __commonJS({
3538
3533
  }
3539
3534
  });
3540
3535
 
3541
- // src/main.ts
3542
- var main_exports = {};
3543
- __export(main_exports, {
3544
- AgentHl7Channel: () => AgentHl7Channel,
3545
- AgentHl7ChannelConnection: () => AgentHl7ChannelConnection,
3546
- App: () => App
3547
- });
3548
- module.exports = __toCommonJS(main_exports);
3549
-
3550
3536
  // ../core/dist/esm/index.mjs
3551
- var ge = class {
3537
+ var Te = class {
3552
3538
  constructor(e, t) {
3553
3539
  this.operator = e;
3554
3540
  this.child = t;
@@ -3557,7 +3543,7 @@ var ge = class {
3557
3543
  return `${this.operator}(${this.child.toString()})`;
3558
3544
  }
3559
3545
  };
3560
- var $ = class {
3546
+ var j = class {
3561
3547
  constructor(e, t, n) {
3562
3548
  this.operator = e;
3563
3549
  this.left = t;
@@ -3567,7 +3553,7 @@ var $ = class {
3567
3553
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
3568
3554
  }
3569
3555
  };
3570
- var xe = class {
3556
+ var ve = class {
3571
3557
  constructor() {
3572
3558
  this.prefixParselets = {};
3573
3559
  this.infixParselets = {};
@@ -3591,10 +3577,10 @@ var xe = class {
3591
3577
  }, precedence: t });
3592
3578
  }
3593
3579
  construct(e) {
3594
- return new rt(e, this.prefixParselets, this.infixParselets);
3580
+ return new it(e, this.prefixParselets, this.infixParselets);
3595
3581
  }
3596
3582
  };
3597
- var rt = class {
3583
+ var it = class {
3598
3584
  constructor(e, t, n) {
3599
3585
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
3600
3586
  }
@@ -3645,62 +3631,62 @@ var rt = class {
3645
3631
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
3646
3632
  }
3647
3633
  };
3648
- function G(r4) {
3649
- let e = se(r4), t = hn(r4);
3634
+ function z(r4) {
3635
+ let e = ce(r4), t = yn(r4);
3650
3636
  return t === e ? { reference: e } : { reference: e, display: t };
3651
3637
  }
3652
- function se(r4) {
3653
- return ae(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
3638
+ function ce(r4) {
3639
+ return ue(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
3654
3640
  }
3655
- function Kt(r4) {
3641
+ function Gt(r4) {
3656
3642
  if (r4)
3657
- return ae(r4) ? r4.reference.split("/")[1] : r4.id;
3643
+ return ue(r4) ? r4.reference.split("/")[1] : r4.id;
3658
3644
  }
3659
- function mn(r4) {
3645
+ function hn(r4) {
3660
3646
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
3661
3647
  }
3662
- function hn(r4) {
3663
- if (mn(r4)) {
3664
- let e = yn(r4);
3648
+ function yn(r4) {
3649
+ if (hn(r4)) {
3650
+ let e = gn(r4);
3665
3651
  if (e)
3666
3652
  return e;
3667
3653
  }
3668
3654
  if (r4.resourceType === "Device") {
3669
- let e = gn(r4);
3655
+ let e = xn(r4);
3670
3656
  if (e)
3671
3657
  return e;
3672
3658
  }
3673
- 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 : se(r4);
3659
+ 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 : ce(r4);
3674
3660
  }
3675
- function yn(r4) {
3661
+ function gn(r4) {
3676
3662
  let e = r4.name;
3677
3663
  if (e && e.length > 0)
3678
- return be(e[0]);
3664
+ return Ae(e[0]);
3679
3665
  }
3680
- function gn(r4) {
3666
+ function xn(r4) {
3681
3667
  let e = r4.deviceName;
3682
3668
  if (e && e.length > 0)
3683
3669
  return e[0].name;
3684
3670
  }
3685
- function Te(r4, e) {
3671
+ function Se(r4, e) {
3686
3672
  let t = new Date(r4);
3687
3673
  t.setUTCHours(0, 0, 0, 0);
3688
3674
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
3689
3675
  n.setUTCHours(0, 0, 0, 0);
3690
- let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), c2 = n.getUTCMonth(), f = n.getUTCDate(), p2 = a - i2;
3691
- (c2 < o || c2 === o && f < s) && p2--;
3692
- let q = a * 12 + c2 - (i2 * 12 + o);
3693
- f < s && q--;
3694
- let fn = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3695
- return { years: p2, months: q, days: fn };
3676
+ let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a = n.getUTCFullYear(), u2 = n.getUTCMonth(), l2 = n.getUTCDate(), f = a - i2;
3677
+ (u2 < o || u2 === o && l2 < s) && f--;
3678
+ let P = a * 12 + u2 - (i2 * 12 + o);
3679
+ l2 < s && P--;
3680
+ let M = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
3681
+ return { years: f, months: P, days: M };
3696
3682
  }
3697
- function zt(r4, e) {
3698
- return JSON.stringify(r4, xn, e ? 2 : void 0);
3683
+ function Yt(r4, e) {
3684
+ return JSON.stringify(r4, Tn, e ? 2 : void 0);
3699
3685
  }
3700
- function xn(r4, e) {
3701
- return !Tn(r4) && E(e) ? void 0 : e;
3686
+ function Tn(r4, e) {
3687
+ return !vn(r4) && E(e) ? void 0 : e;
3702
3688
  }
3703
- function Tn(r4) {
3689
+ function vn(r4) {
3704
3690
  return !!/\d+$/.exec(r4);
3705
3691
  }
3706
3692
  function E(r4) {
@@ -3709,68 +3695,76 @@ function E(r4) {
3709
3695
  let e = typeof r4;
3710
3696
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
3711
3697
  }
3712
- function Jt(r4) {
3698
+ function Xt(r4) {
3713
3699
  return r4.every((e) => typeof e == "string");
3714
3700
  }
3715
- var Yt = [];
3701
+ var Zt = [];
3716
3702
  for (let r4 = 0; r4 < 256; r4++)
3717
- Yt.push(r4.toString(16).padStart(2, "0"));
3718
- function Xt(r4) {
3703
+ Zt.push(r4.toString(16).padStart(2, "0"));
3704
+ function er(r4) {
3719
3705
  let e = new Uint8Array(r4), t = new Array(e.length);
3720
3706
  for (let n = 0; n < e.length; n++)
3721
- t[n] = Yt[e[n]];
3707
+ t[n] = Zt[e[n]];
3722
3708
  return t.join("");
3723
3709
  }
3724
- function Zt(r4) {
3710
+ function tr(r4) {
3725
3711
  let e = new Uint8Array(r4), t = [];
3726
3712
  for (let n = 0; n < e.length; n++)
3727
3713
  t[n] = String.fromCharCode(e[n]);
3728
3714
  return window.btoa(t.join(""));
3729
3715
  }
3730
- function P(r4) {
3716
+ function A(r4) {
3731
3717
  return r4.charAt(0).toUpperCase() + r4.substring(1);
3732
3718
  }
3733
- var ot = (r4) => new Promise((e) => {
3719
+ var at = (r4) => new Promise((e) => {
3734
3720
  setTimeout(e, r4);
3735
3721
  });
3736
- function be(r4, e) {
3722
+ function Ae(r4, e) {
3737
3723
  let t = [];
3738
- return r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0 && r4.text ? r4.text : t.join(" ").trim();
3724
+ if (r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0) {
3725
+ let n = te(r4.text);
3726
+ if (n)
3727
+ return n;
3728
+ }
3729
+ return t.join(" ").trim();
3730
+ }
3731
+ function te(r4) {
3732
+ return typeof r4 == "string" ? r4 : void 0;
3739
3733
  }
3740
- function Bn(r4) {
3734
+ function qn(r4) {
3741
3735
  let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
3742
3736
  return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
3743
3737
  }
3744
- function nr(r4) {
3738
+ function or(r4) {
3745
3739
  let e = /* @__PURE__ */ Object.create(null);
3746
3740
  for (let [t, n] of Object.entries(r4))
3747
- e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Bn(o)])), constraints: [], innerTypes: [] };
3741
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, qn(o)])), constraints: [], innerTypes: [] };
3748
3742
  return e;
3749
3743
  }
3750
- var ir = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3751
- function l(r4) {
3752
- return [{ type: u.boolean, value: r4 }];
3744
+ var sr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
3745
+ function d(r4) {
3746
+ return [{ type: c.boolean, value: r4 }];
3753
3747
  }
3754
3748
  function T(r4) {
3755
- return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: u.integer, value: r4 } : typeof r4 == "number" ? { type: u.decimal, value: r4 } : typeof r4 == "boolean" ? { type: u.boolean, value: r4 } : typeof r4 == "string" ? { type: u.string, value: r4 } : R(r4) ? { type: u.Quantity, value: r4 } : N(r4) ? { type: r4.resourceType, value: r4 } : { type: u.BackboneElement, value: r4 };
3749
+ return r4 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r4) ? { type: c.integer, value: r4 } : typeof r4 == "number" ? { type: c.decimal, value: r4 } : typeof r4 == "boolean" ? { type: c.boolean, value: r4 } : typeof r4 == "string" ? { type: c.string, value: r4 } : b(r4) ? { type: c.Quantity, value: r4 } : F(r4) ? { type: r4.resourceType, value: r4 } : { type: c.BackboneElement, value: r4 };
3756
3750
  }
3757
- function L(r4) {
3751
+ function B(r4) {
3758
3752
  return r4.length === 0 ? false : !!r4[0].value;
3759
3753
  }
3760
- function D(r4, e) {
3754
+ function N(r4, e) {
3761
3755
  if (r4.length !== 0) {
3762
3756
  if (r4.length === 1 && (!e || r4[0].type === e))
3763
3757
  return r4[0];
3764
3758
  throw new Error(`Expected singleton of type ${e}, but found ${JSON.stringify(r4)}`);
3765
3759
  }
3766
3760
  }
3767
- function I(r4, e) {
3761
+ function k(r4, e) {
3768
3762
  if (!r4.value)
3769
3763
  return;
3770
- let t = Ce(r4.type, e);
3771
- return t ? $n(r4, e, t) : jn(r4, e);
3764
+ let t = Ie(r4.type, e);
3765
+ return t ? jn(r4, e, t) : Qn(r4, e);
3772
3766
  }
3773
- function $n(r4, e, t) {
3767
+ function jn(r4, e, t) {
3774
3768
  let n = t.type;
3775
3769
  if (!n || n.length === 0)
3776
3770
  return;
@@ -3779,20 +3773,20 @@ function $n(r4, e, t) {
3779
3773
  i2 = r4.value[e], o = n[0].code;
3780
3774
  else
3781
3775
  for (let a of n) {
3782
- let c2 = e.replace("[x]", "") + P(a.code);
3783
- if (c2 in r4.value) {
3784
- i2 = r4.value[c2], o = a.code;
3776
+ let u2 = e.replace("[x]", "") + A(a.code);
3777
+ if (u2 in r4.value) {
3778
+ i2 = r4.value[u2], o = a.code;
3785
3779
  break;
3786
3780
  }
3787
3781
  }
3788
3782
  let s = r4.value["_" + e];
3789
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !E(i2))
3790
- return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => or(a, o)) : or(i2, o);
3783
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, u2) => s[u2] ? lr(a ?? {}, s[u2]) : a) : i2 = lr(i2 ?? {}, s)), !E(i2))
3784
+ return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => ar(a, o)) : ar(i2, o);
3791
3785
  }
3792
- function or(r4, e) {
3793
- return e === "Resource" && N(r4) && (e = r4.resourceType), { type: e, value: r4 };
3786
+ function ar(r4, e) {
3787
+ return e === "Resource" && F(r4) && (e = r4.resourceType), { type: e, value: r4 };
3794
3788
  }
3795
- function jn(r4, e) {
3789
+ function Qn(r4, e) {
3796
3790
  let t = r4.value;
3797
3791
  if (!t || typeof t != "object")
3798
3792
  return;
@@ -3800,8 +3794,8 @@ function jn(r4, e) {
3800
3794
  if (e in t)
3801
3795
  n = t[e];
3802
3796
  else
3803
- for (let i2 in u) {
3804
- let o = e + P(i2);
3797
+ for (let i2 in c) {
3798
+ let o = e + A(i2);
3805
3799
  if (o in t) {
3806
3800
  n = t[o];
3807
3801
  break;
@@ -3810,12 +3804,12 @@ function jn(r4, e) {
3810
3804
  if (!E(n))
3811
3805
  return Array.isArray(n) ? n.map(T) : T(n);
3812
3806
  }
3813
- function Pe(r4) {
3807
+ function Ce(r4) {
3814
3808
  let e = [];
3815
3809
  for (let t of r4) {
3816
3810
  let n = false;
3817
3811
  for (let i2 of e)
3818
- if (L(ur(t, i2))) {
3812
+ if (B(dr(t, i2))) {
3819
3813
  n = true;
3820
3814
  break;
3821
3815
  }
@@ -3823,28 +3817,28 @@ function Pe(r4) {
3823
3817
  }
3824
3818
  return e;
3825
3819
  }
3826
- function ct(r4) {
3827
- return l(!L(r4));
3820
+ function lt(r4) {
3821
+ return d(!B(r4));
3828
3822
  }
3829
- function ut(r4, e) {
3830
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? l(false) : l(r4.every((t, n) => L(ur(t, e[n]))));
3823
+ function dt(r4, e) {
3824
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => B(dr(t, e[n]))));
3831
3825
  }
3832
- function ur(r4, e) {
3826
+ function dr(r4, e) {
3833
3827
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3834
- return typeof t == "number" && typeof n == "number" ? l(Math.abs(t - n) < 1e-8) : R(t) && R(n) ? l(lr(t, n)) : l(typeof t == "object" && typeof n == "object" ? dt(r4, e) : t === n);
3828
+ return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : b(t) && b(n) ? d(pr(t, n)) : d(typeof t == "object" && typeof n == "object" ? ft(r4, e) : t === n);
3835
3829
  }
3836
- function lt(r4, e) {
3837
- return r4.length === 0 && e.length === 0 ? l(true) : r4.length !== e.length ? l(false) : (r4.sort(sr), e.sort(sr), l(r4.every((t, n) => L(Qn(t, e[n])))));
3830
+ function pt(r4, e) {
3831
+ return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(cr), e.sort(cr), d(r4.every((t, n) => B(Hn(t, e[n])))));
3838
3832
  }
3839
- function Qn(r4, e) {
3833
+ function Hn(r4, e) {
3840
3834
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
3841
- return typeof s == "number" && typeof a == "number" ? l(Math.abs(s - a) < 0.01) : R(s) && R(a) ? l(lr(s, a)) : l(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? dt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3835
+ return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : b(s) && b(a) ? d(pr(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" ? ft({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
3842
3836
  }
3843
- function sr(r4, e) {
3837
+ function cr(r4, e) {
3844
3838
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
3845
3839
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
3846
3840
  }
3847
- function Ae(r4, e) {
3841
+ function we(r4, e) {
3848
3842
  let { value: t } = r4;
3849
3843
  if (t == null)
3850
3844
  return false;
@@ -3861,110 +3855,110 @@ function Ae(r4, e) {
3861
3855
  case "Time":
3862
3856
  return typeof t == "string" && !!/^T\d/.exec(t);
3863
3857
  case "Period":
3864
- return Hn(t);
3858
+ return Kn(t);
3865
3859
  case "Quantity":
3866
- return R(t);
3860
+ return b(t);
3867
3861
  default:
3868
3862
  return typeof t == "object" && t?.resourceType === e;
3869
3863
  }
3870
3864
  }
3871
- function Hn(r4) {
3865
+ function Kn(r4) {
3872
3866
  return !!(r4 && typeof r4 == "object" && "start" in r4);
3873
3867
  }
3874
- function R(r4) {
3868
+ function b(r4) {
3875
3869
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
3876
3870
  }
3877
- function lr(r4, e) {
3871
+ function pr(r4, e) {
3878
3872
  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);
3879
3873
  }
3880
- function dt(r4, e) {
3874
+ function ft(r4, e) {
3881
3875
  let t = Object.keys(r4), n = Object.keys(e);
3882
3876
  if (t.length !== n.length)
3883
3877
  return false;
3884
3878
  for (let i2 of t) {
3885
3879
  let o = r4[i2], s = e[i2];
3886
- if (ar(o) && ar(s)) {
3887
- if (!dt(o, s))
3880
+ if (ur(o) && ur(s)) {
3881
+ if (!ft(o, s))
3888
3882
  return false;
3889
3883
  } else if (o !== s)
3890
3884
  return false;
3891
3885
  }
3892
3886
  return true;
3893
3887
  }
3894
- function ar(r4) {
3888
+ function ur(r4) {
3895
3889
  return r4 !== null && typeof r4 == "object";
3896
3890
  }
3897
- function cr(r4, e) {
3891
+ function lr(r4, e) {
3898
3892
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
3899
3893
  }
3900
- var pt = "ok";
3901
- var we = "created";
3902
- var mt = "not-modified";
3903
- var ht = "not-found";
3904
- var Ie = "accepted";
3905
- var mr = { resourceType: "OperationOutcome", id: ht, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3906
- function F(r4, e) {
3894
+ var mt = "ok";
3895
+ var ke = "created";
3896
+ var yt = "not-modified";
3897
+ var gt = "not-found";
3898
+ var Oe = "accepted";
3899
+ var yr = { resourceType: "OperationOutcome", id: gt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
3900
+ function _(r4, e) {
3907
3901
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
3908
3902
  }
3909
3903
  function h(r4) {
3910
3904
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
3911
3905
  }
3912
- function ke(r4) {
3906
+ function Ve(r4) {
3913
3907
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
3914
3908
  }
3915
- function yt(r4) {
3916
- return r4.id === pt || r4.id === we || r4.id === mt || r4.id === Ie;
3909
+ function xt(r4) {
3910
+ return r4.id === mt || r4.id === ke || r4.id === yt || r4.id === Oe;
3917
3911
  }
3918
- var d = class extends Error {
3912
+ var p = class extends Error {
3919
3913
  constructor(t, n) {
3920
- super(yr(t));
3914
+ super(xr(t));
3921
3915
  this.outcome = t, this.cause = n;
3922
3916
  }
3923
3917
  };
3924
- function Oe(r4) {
3925
- return r4 instanceof d ? r4.outcome : ke(r4) ? r4 : F(Kn(r4));
3918
+ function De(r4) {
3919
+ return r4 instanceof p ? r4.outcome : Ve(r4) ? r4 : _(Wn(r4));
3926
3920
  }
3927
- function Kn(r4) {
3928
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ke(r4) ? yr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3921
+ function Wn(r4) {
3922
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : Ve(r4) ? xr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
3929
3923
  }
3930
- function yr(r4) {
3931
- let e = r4.issue?.map(Wn) ?? [];
3924
+ function xr(r4) {
3925
+ let e = r4.issue?.map(Gn) ?? [];
3932
3926
  return e.length > 0 ? e.join("; ") : "Unknown error";
3933
3927
  }
3934
- function Wn(r4) {
3928
+ function Gn(r4) {
3935
3929
  let e;
3936
3930
  return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3937
3931
  }
3938
- function St(r4) {
3939
- return new Tt(r4).parse();
3932
+ function bt(r4) {
3933
+ return new St(r4).parse();
3940
3934
  }
3941
- var Q = nr(ir);
3942
- function Er(r4) {
3935
+ var H = or(sr);
3936
+ function Rr(r4) {
3943
3937
  let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3944
3938
  for (let t of e)
3945
- Gn(t);
3939
+ zn(t);
3946
3940
  }
3947
- function Gn(r4) {
3941
+ function zn(r4) {
3948
3942
  if (!r4?.name)
3949
3943
  throw new Error("Failed loading StructureDefinition from bundle");
3950
3944
  if (r4.resourceType !== "StructureDefinition")
3951
3945
  return;
3952
- let e = St(r4);
3953
- Q[r4.name] = e;
3946
+ let e = bt(r4);
3947
+ H[r4.name] = e;
3954
3948
  for (let t of e.innerTypes)
3955
- t.parentType = e, Q[t.name] = t;
3949
+ t.parentType = e, H[t.name] = t;
3956
3950
  }
3957
- function br(r4) {
3958
- return !!Q[r4];
3951
+ function Ar(r4) {
3952
+ return !!H[r4];
3959
3953
  }
3960
- function Pr(r4) {
3961
- return Q[r4];
3954
+ function Cr(r4) {
3955
+ return H[r4];
3962
3956
  }
3963
- var Tt = class {
3957
+ var St = class {
3964
3958
  constructor(e) {
3965
3959
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
3966
3960
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
3967
- this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: Xn(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3961
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: Zn(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
3968
3962
  }
3969
3963
  parse() {
3970
3964
  let e = this.next();
@@ -3973,7 +3967,7 @@ var Tt = class {
3973
3967
  this.parseSliceStart(e);
3974
3968
  else if (e.id?.includes(":")) {
3975
3969
  if (this.slicingContext?.current) {
3976
- let t = xt(e, this.slicingContext.path);
3970
+ let t = vt(e, this.slicingContext.path);
3977
3971
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
3978
3972
  }
3979
3973
  } else {
@@ -3982,13 +3976,13 @@ var Tt = class {
3982
3976
  let n = this.backboneContext;
3983
3977
  for (; n; ) {
3984
3978
  if (e.path?.startsWith(n.path + ".")) {
3985
- n.type.elements[xt(e, n.path)] = t;
3979
+ n.type.elements[vt(e, n.path)] = t;
3986
3980
  break;
3987
3981
  }
3988
3982
  n = n.parent;
3989
3983
  }
3990
3984
  if (!n) {
3991
- let i2 = xt(e, this.root.path);
3985
+ let i2 = vt(e, this.root.path);
3992
3986
  e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
3993
3987
  }
3994
3988
  this.checkFieldExit(e);
@@ -4001,26 +3995,26 @@ var Tt = class {
4001
3995
  this.isInnerType(e) && this.enterInnerType(e), e.slicing && !this.slicingContext && this.enterSlice(e, t);
4002
3996
  }
4003
3997
  enterInnerType(e) {
4004
- for (; this.backboneContext && !ee(this.backboneContext?.path, e.path); )
3998
+ for (; this.backboneContext && !re(this.backboneContext?.path, e.path); )
4005
3999
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4006
- this.backboneContext = { type: { name: vt(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ee(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
4000
+ this.backboneContext = { type: { name: Et(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: re(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
4007
4001
  }
4008
4002
  enterSlice(e, t) {
4009
- Yn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4003
+ Xn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
4010
4004
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
4011
4005
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
4012
4006
  return { path: n.path, type: n.type };
4013
4007
  }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
4014
4008
  }
4015
4009
  checkFieldExit(e = void 0) {
4016
- if (this.backboneContext && !ee(this.backboneContext.path, e?.path))
4010
+ if (this.backboneContext && !re(this.backboneContext.path, e?.path))
4017
4011
  if (this.backboneContext.parent)
4018
4012
  do
4019
4013
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
4020
- while (this.backboneContext && !ee(this.backboneContext.path, e?.path));
4014
+ while (this.backboneContext && !re(this.backboneContext.path, e?.path));
4021
4015
  else
4022
4016
  this.innerTypes.push(this.backboneContext.type), delete this.backboneContext;
4023
- this.slicingContext && !ee(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
4017
+ this.slicingContext && !re(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
4024
4018
  }
4025
4019
  next() {
4026
4020
  let e = this.peek();
@@ -4039,7 +4033,7 @@ var Tt = class {
4039
4033
  }
4040
4034
  isInnerType(e) {
4041
4035
  let t = this.peek();
4042
- return !!(ee(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
4036
+ return !!(re(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
4043
4037
  }
4044
4038
  parseSliceStart(e) {
4045
4039
  if (!this.slicingContext)
@@ -4047,60 +4041,60 @@ var Tt = class {
4047
4041
  this.slicingContext.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext.current = { name: e.sliceName ?? "", type: e.type?.map((t) => ({ code: t.code ?? "", targetProfile: t.targetProfile })), elements: {}, min: e.min ?? 0, max: e.max === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(e.max, 10) };
4048
4042
  }
4049
4043
  parseElementDefinition(e) {
4050
- let t = vr(e.max), n = e.base?.max ? vr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4051
- return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Sr(I(i2, "fixed")), pattern: Sr(I(i2, "pattern")), binding: e.binding };
4044
+ let t = Er(e.max), n = e.base?.max ? Er(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4045
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? Et(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: br(k(i2, "fixed")), pattern: br(k(i2, "pattern")), binding: e.binding };
4052
4046
  }
4053
4047
  };
4054
- function vr(r4) {
4048
+ function Er(r4) {
4055
4049
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
4056
4050
  }
4057
- function xt(r4, e = "") {
4058
- return Jn(r4.path, e);
4051
+ function vt(r4, e = "") {
4052
+ return Yn(r4.path, e);
4059
4053
  }
4060
- function Jn(r4, e) {
4054
+ function Yn(r4, e) {
4061
4055
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
4062
4056
  }
4063
- function ee(r4, e) {
4057
+ function re(r4, e) {
4064
4058
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
4065
4059
  }
4066
- function Sr(r4) {
4060
+ function br(r4) {
4067
4061
  return Array.isArray(r4) && r4.length > 0 ? r4[0] : E(r4) ? void 0 : r4;
4068
4062
  }
4069
- function Yn(r4) {
4063
+ function Xn(r4) {
4070
4064
  let e = r4.slicing?.discriminator;
4071
4065
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
4072
4066
  }
4073
- function Xn(r4) {
4067
+ function Zn(r4) {
4074
4068
  let e = r4.description;
4075
4069
  return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
4076
4070
  }
4077
- var u = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
4078
- function Rt(r4) {
4071
+ var c = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
4072
+ function Pt(r4) {
4079
4073
  for (let e of r4.base ?? []) {
4080
- let t = k.types[e];
4081
- t || (t = { searchParamsDetails: {} }, k.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
4074
+ let t = O.types[e];
4075
+ t || (t = { searchParamsDetails: {} }, O.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
4082
4076
  }
4083
4077
  }
4084
- function vt(r4) {
4078
+ function Et(r4) {
4085
4079
  let e = r4.type?.[0]?.code;
4086
- return e === "BackboneElement" || e === "Element" ? Zn((r4.base?.path ?? r4.path)?.split(".")) : e;
4080
+ return e === "BackboneElement" || e === "Element" ? ei((r4.base?.path ?? r4.path)?.split(".")) : e;
4087
4081
  }
4088
- function Zn(r4) {
4089
- return r4.length === 1 ? r4[0] : r4.map(P).join("");
4082
+ function ei(r4) {
4083
+ return r4.length === 1 ? r4[0] : r4.map(A).join("");
4090
4084
  }
4091
- function Ce(r4, e) {
4092
- let t = Pr(r4);
4085
+ function Ie(r4, e) {
4086
+ let t = Cr(r4);
4093
4087
  if (t)
4094
4088
  return t.elements[e] ?? t.elements[e + "[x]"];
4095
4089
  }
4096
- function N(r4) {
4090
+ function F(r4) {
4097
4091
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
4098
4092
  }
4099
- function ae(r4) {
4093
+ function ue(r4) {
4100
4094
  return !!(r4 && typeof r4 == "object" && "reference" in r4);
4101
4095
  }
4102
- var k = { types: {} };
4103
- function re(r4) {
4096
+ var O = { types: {} };
4097
+ function ie(r4) {
4104
4098
  if (r4.startsWith("T"))
4105
4099
  return r4 + "T00:00:00.000Z".substring(r4.length);
4106
4100
  if (r4.length <= 10)
@@ -4111,33 +4105,33 @@ function re(r4) {
4111
4105
  return r4;
4112
4106
  }
4113
4107
  }
4114
- var ce = () => [];
4115
- var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => L(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => L(t.eval(r4, [n])))), allTrue: (r4, e) => {
4108
+ var le = () => [];
4109
+ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => B(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => B(t.eval(r4, [n])))), allTrue: (r4, e) => {
4116
4110
  for (let t of e)
4117
4111
  if (!t.value)
4118
- return l(false);
4119
- return l(true);
4112
+ return d(false);
4113
+ return d(true);
4120
4114
  }, anyTrue: (r4, e) => {
4121
4115
  for (let t of e)
4122
4116
  if (t.value)
4123
- return l(true);
4124
- return l(false);
4117
+ return d(true);
4118
+ return d(false);
4125
4119
  }, allFalse: (r4, e) => {
4126
4120
  for (let t of e)
4127
4121
  if (t.value)
4128
- return l(false);
4129
- return l(true);
4122
+ return d(false);
4123
+ return d(true);
4130
4124
  }, anyFalse: (r4, e) => {
4131
4125
  for (let t of e)
4132
4126
  if (!t.value)
4133
- return l(true);
4134
- return l(false);
4135
- }, subsetOf: ce, supersetOf: ce, count: (r4, e) => [{ type: u.integer, value: e.length }], distinct: (r4, e) => {
4127
+ return d(true);
4128
+ return d(false);
4129
+ }, subsetOf: le, supersetOf: le, count: (r4, e) => [{ type: c.integer, value: e.length }], distinct: (r4, e) => {
4136
4130
  let t = [];
4137
4131
  for (let n of e)
4138
4132
  t.some((i2) => i2.value === n.value) || t.push(n);
4139
4133
  return t;
4140
- }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => L(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4134
+ }, isDistinct: (r4, e) => d(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => B(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: le, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4141
4135
  if (e.length > 1)
4142
4136
  throw new Error("Expected input length one for single()");
4143
4137
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4169,7 +4163,7 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4169
4163
  if (!t)
4170
4164
  return e;
4171
4165
  let n = t.eval(r4, e);
4172
- return Pe([...e, ...n]);
4166
+ return Ce([...e, ...n]);
4173
4167
  }, combine: (r4, e, t) => {
4174
4168
  if (!t)
4175
4169
  return e;
@@ -4179,67 +4173,67 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4179
4173
  let o = t.eval(r4, e);
4180
4174
  if (o.length > 1 || o.length === 1 && typeof o[0].value != "boolean")
4181
4175
  throw new Error("Expected criterion to evaluate to a Boolean");
4182
- return L(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4176
+ return B(o) ? n.eval(r4, e) : i2 ? i2.eval(r4, e) : [];
4183
4177
  }, toBoolean: (r4, e) => {
4184
4178
  if (e.length === 0)
4185
4179
  return [];
4186
- let [{ value: t }] = U(e, 1);
4180
+ let [{ value: t }] = L(e, 1);
4187
4181
  if (typeof t == "boolean")
4188
- return [{ type: u.boolean, value: t }];
4182
+ return [{ type: c.boolean, value: t }];
4189
4183
  if (typeof t == "number" && (t === 0 || t === 1))
4190
- return l(!!t);
4184
+ return d(!!t);
4191
4185
  if (typeof t == "string") {
4192
4186
  let n = t.toLowerCase();
4193
4187
  if (["true", "t", "yes", "y", "1", "1.0"].includes(n))
4194
- return l(true);
4188
+ return d(true);
4195
4189
  if (["false", "f", "no", "n", "0", "0.0"].includes(n))
4196
- return l(false);
4190
+ return d(false);
4197
4191
  }
4198
4192
  return [];
4199
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4193
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4200
4194
  if (e.length === 0)
4201
4195
  return [];
4202
- let [{ value: t }] = U(e, 1);
4203
- return typeof t == "number" ? [{ type: u.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: u.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: u.integer, value: t ? 1 : 0 }] : [];
4204
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4196
+ let [{ value: t }] = L(e, 1);
4197
+ return typeof t == "number" ? [{ type: c.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: c.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: c.integer, value: t ? 1 : 0 }] : [];
4198
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4205
4199
  if (e.length === 0)
4206
4200
  return [];
4207
- let [{ value: t }] = U(e, 1);
4208
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4209
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4201
+ let [{ value: t }] = L(e, 1);
4202
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.date, value: ie(t) }] : [];
4203
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4210
4204
  if (e.length === 0)
4211
4205
  return [];
4212
- let [{ value: t }] = U(e, 1);
4213
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4214
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4206
+ let [{ value: t }] = L(e, 1);
4207
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.dateTime, value: ie(t) }] : [];
4208
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4215
4209
  if (e.length === 0)
4216
4210
  return [];
4217
- let [{ value: t }] = U(e, 1);
4218
- return typeof t == "number" ? [{ type: u.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: u.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: u.decimal, value: t ? 1 : 0 }] : [];
4219
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4211
+ let [{ value: t }] = L(e, 1);
4212
+ return typeof t == "number" ? [{ type: c.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: c.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: c.decimal, value: t ? 1 : 0 }] : [];
4213
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4220
4214
  if (e.length === 0)
4221
4215
  return [];
4222
- let [{ value: t }] = U(e, 1);
4223
- return R(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4224
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4216
+ let [{ value: t }] = L(e, 1);
4217
+ return b(t) ? [{ type: c.Quantity, value: t }] : typeof t == "number" ? [{ type: c.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: c.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: c.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4218
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4225
4219
  if (e.length === 0)
4226
4220
  return [];
4227
- let [{ value: t }] = U(e, 1);
4228
- return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4229
- }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4221
+ let [{ value: t }] = L(e, 1);
4222
+ return t == null ? [] : b(t) ? [{ type: c.string, value: `${t.value} '${t.unit}'` }] : [{ type: c.string, value: t.toString() }];
4223
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : d(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4230
4224
  if (e.length === 0)
4231
4225
  return [];
4232
- let [{ value: t }] = U(e, 1);
4226
+ let [{ value: t }] = L(e, 1);
4233
4227
  if (typeof t == "string") {
4234
4228
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
4235
4229
  if (n)
4236
- return [{ type: u.time, value: re("T" + n[1]) }];
4230
+ return [{ type: c.time, value: ie("T" + n[1]) }];
4237
4231
  }
4238
4232
  return [];
4239
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => A((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => A((i2, o, s) => {
4240
- let a = o, c2 = s ? a + s : i2.length;
4241
- return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4242
- }, r4, e, t, n), startsWith: (r4, e, t) => A((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => A((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => A((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => A((t) => t.toUpperCase(), r4, e), lower: (r4, e) => A((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => A((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => A((t) => t.length, r4, e), toChars: (r4, e) => A((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => _(Math.abs, r4, e), ceiling: (r4, e) => _(Math.ceil, r4, e), exp: (r4, e) => _(Math.exp, r4, e), floor: (r4, e) => _(Math.floor, r4, e), ln: (r4, e) => _(Math.log, r4, e), log: (r4, e, t) => _((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => _(Math.pow, r4, e, t), round: (r4, e) => _(Math.round, r4, e), sqrt: (r4, e) => _(Math.sqrt, r4, e), truncate: (r4, e) => _((t) => t | 0, r4, e), children: ce, descendants: ce, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4233
+ }, 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) => {
4234
+ let a = o, u2 = s ? a + s : i2.length;
4235
+ return a < 0 || a >= i2.length ? void 0 : i2.substring(a, u2);
4236
+ }, r4, e, t, n), startsWith: (r4, e, t) => C((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => C((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => C((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => C((t) => t.toUpperCase(), r4, e), lower: (r4, e) => C((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => C((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => C((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => C((t) => t.length, r4, e), toChars: (r4, e) => C((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => U(Math.abs, r4, e), ceiling: (r4, e) => U(Math.ceil, r4, e), exp: (r4, e) => U(Math.exp, r4, e), floor: (r4, e) => U(Math.floor, r4, e), ln: (r4, e) => U(Math.log, r4, e), log: (r4, e, t) => U((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => U(Math.pow, r4, e, t), round: (r4, e) => U(Math.round, r4, e), sqrt: (r4, e) => U(Math.sqrt, r4, e), truncate: (r4, e) => U((t) => t | 0, r4, e), children: le, descendants: le, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: c.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: c.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: c.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4243
4237
  let o = S.toDateTime(r4, t.eval(r4, e));
4244
4238
  if (o.length === 0)
4245
4239
  throw new Error("Invalid start date");
@@ -4249,12 +4243,12 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4249
4243
  let a = i2.eval(r4, e)[0]?.value;
4250
4244
  if (a !== "years" && a !== "months" && a !== "days")
4251
4245
  throw new Error("Invalid units");
4252
- let c2 = Te(o[0].value, s[0].value);
4253
- return [{ type: u.Quantity, value: { value: c2[a], unit: a } }];
4246
+ let u2 = Se(o[0].value, s[0].value);
4247
+ return [{ type: c.Quantity, value: { value: u2[a], unit: a } }];
4254
4248
  }, is: (r4, e, t) => {
4255
4249
  let n = "";
4256
- return t instanceof M ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Ae(i2, n) })) : [];
4257
- }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4250
+ return t instanceof q ? n = t.name : t instanceof K && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: c.boolean, value: we(i2, n) })) : [];
4251
+ }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: c.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4258
4252
  let n = t.value, i2;
4259
4253
  if (typeof n == "string")
4260
4254
  i2 = n;
@@ -4272,33 +4266,33 @@ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4272
4266
  let [o, s] = i2.split("/");
4273
4267
  return { type: o, value: { resourceType: o, id: s } };
4274
4268
  }
4275
- return { type: u.BackboneElement, value: void 0 };
4276
- }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: u.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: u.BackboneElement, value: { namespace: "System", name: "Integer" } } : N(t) ? { type: u.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: u.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4269
+ return { type: c.BackboneElement, value: void 0 };
4270
+ }).filter((t) => !!t.value), as: (r4, e) => e, type: (r4, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: c.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: c.BackboneElement, value: { namespace: "System", name: "Integer" } } : F(t) ? { type: c.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: c.BackboneElement, value: null }), conformsTo: (r4, e, t) => {
4277
4271
  let n = t.eval(r4, e)[0].value;
4278
4272
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/"))
4279
4273
  throw new Error("Expected a StructureDefinition URL");
4280
4274
  let i2 = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
4281
- return e.map((o) => ({ type: u.boolean, value: o.value?.resourceType === i2 }));
4275
+ return e.map((o) => ({ type: c.boolean, value: o.value?.resourceType === i2 }));
4282
4276
  } };
4283
- function A(r4, e, t, ...n) {
4277
+ function C(r4, e, t, ...n) {
4284
4278
  if (t.length === 0)
4285
4279
  return [];
4286
- let [{ value: i2 }] = U(t, 1);
4280
+ let [{ value: i2 }] = L(t, 1);
4287
4281
  if (typeof i2 != "string")
4288
4282
  throw new Error("String function cannot be called with non-string");
4289
4283
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
4290
4284
  return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
4291
4285
  }
4292
- function _(r4, e, t, ...n) {
4286
+ function U(r4, e, t, ...n) {
4293
4287
  if (t.length === 0)
4294
4288
  return [];
4295
- let [{ value: i2 }] = U(t, 1), o = R(i2), s = o ? i2.value : i2;
4289
+ let [{ value: i2 }] = L(t, 1), o = b(i2), s = o ? i2.value : i2;
4296
4290
  if (typeof s != "number")
4297
4291
  throw new Error("Math function cannot be called with non-number");
4298
- let a = r4(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c2 = o ? u.Quantity : t[0].type, f = o ? { ...i2, value: a } : a;
4299
- return [{ type: c2, value: f }];
4292
+ let a = r4(s, ...n.map((f) => f.eval(e, t)[0]?.value)), u2 = o ? c.Quantity : t[0].type, l2 = o ? { ...i2, value: a } : a;
4293
+ return [{ type: u2, value: l2 }];
4300
4294
  }
4301
- function U(r4, e) {
4295
+ function L(r4, e) {
4302
4296
  if (r4.length !== e)
4303
4297
  throw new Error(`Expected ${e} arguments`);
4304
4298
  for (let t of r4)
@@ -4306,7 +4300,7 @@ function U(r4, e) {
4306
4300
  throw new Error("Expected non-null argument");
4307
4301
  return r4;
4308
4302
  }
4309
- var O = class {
4303
+ var V = class {
4310
4304
  constructor(e) {
4311
4305
  this.value = e;
4312
4306
  }
@@ -4318,7 +4312,7 @@ var O = class {
4318
4312
  return typeof e == "string" ? `'${e}'` : e.toString();
4319
4313
  }
4320
4314
  };
4321
- var M = class {
4315
+ var q = class {
4322
4316
  constructor(e) {
4323
4317
  this.name = e;
4324
4318
  }
@@ -4336,13 +4330,13 @@ var M = class {
4336
4330
  evalValue(e) {
4337
4331
  let t = e.value;
4338
4332
  if (!(!t || typeof t != "object"))
4339
- return N(t) && t.resourceType === this.name ? e : I(e, this.name);
4333
+ return F(t) && t.resourceType === this.name ? e : k(e, this.name);
4340
4334
  }
4341
4335
  toString() {
4342
4336
  return this.name;
4343
4337
  }
4344
4338
  };
4345
- var De = class {
4339
+ var Fe = class {
4346
4340
  eval() {
4347
4341
  return [];
4348
4342
  }
@@ -4350,7 +4344,7 @@ var De = class {
4350
4344
  return "{}";
4351
4345
  }
4352
4346
  };
4353
- var Ne = class extends ge {
4347
+ var _e = class extends Te {
4354
4348
  constructor(t, n, i2) {
4355
4349
  super(t, n);
4356
4350
  this.impl = i2;
@@ -4362,7 +4356,7 @@ var Ne = class extends ge {
4362
4356
  return this.operator + this.child.toString();
4363
4357
  }
4364
4358
  };
4365
- var J = class extends $ {
4359
+ var Y = class extends j {
4366
4360
  constructor(e, t) {
4367
4361
  super("as", e, t);
4368
4362
  }
@@ -4370,9 +4364,9 @@ var J = class extends $ {
4370
4364
  return S.ofType(e, this.left.eval(e, t), this.right);
4371
4365
  }
4372
4366
  };
4373
- var v = class extends $ {
4367
+ var v = class extends j {
4374
4368
  };
4375
- var b = class extends v {
4369
+ var R = class extends v {
4376
4370
  constructor(t, n, i2, o) {
4377
4371
  super(t, n, i2);
4378
4372
  this.impl = o;
@@ -4384,38 +4378,38 @@ var b = class extends v {
4384
4378
  let o = this.right.eval(t, n);
4385
4379
  if (o.length !== 1)
4386
4380
  return [];
4387
- let s = i2[0].value, a = o[0].value, c2 = R(s) ? s.value : s, f = R(a) ? a.value : a, p2 = this.impl(c2, f);
4388
- return typeof p2 == "boolean" ? l(p2) : R(s) ? [{ type: u.Quantity, value: { ...s, value: p2 } }] : [T(p2)];
4381
+ let s = i2[0].value, a = o[0].value, u2 = b(s) ? s.value : s, l2 = b(a) ? a.value : a, f = this.impl(u2, l2);
4382
+ return typeof f == "boolean" ? d(f) : b(s) ? [{ type: c.Quantity, value: { ...s, value: f } }] : [T(f)];
4389
4383
  }
4390
4384
  };
4391
- var Fe = class extends $ {
4385
+ var Ue = class extends j {
4392
4386
  constructor(e, t) {
4393
4387
  super("&", e, t);
4394
4388
  }
4395
4389
  eval(e, t) {
4396
4390
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t), o = [...n, ...i2];
4397
- return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: u.string, value: o.map((s) => s.value).join("") }] : o;
4391
+ return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: c.string, value: o.map((s) => s.value).join("") }] : o;
4398
4392
  }
4399
4393
  };
4400
- var _e = class extends v {
4394
+ var Le = class extends v {
4401
4395
  constructor(e, t) {
4402
4396
  super("contains", e, t);
4403
4397
  }
4404
4398
  eval(e, t) {
4405
4399
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4406
- return l(n.some((o) => o.value === i2[0].value));
4400
+ return d(n.some((o) => o.value === i2[0].value));
4407
4401
  }
4408
4402
  };
4409
- var Ue = class extends v {
4403
+ var Me = class extends v {
4410
4404
  constructor(e, t) {
4411
4405
  super("in", e, t);
4412
4406
  }
4413
4407
  eval(e, t) {
4414
- let n = D(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4415
- return n ? l(i2.some((o) => o.value === n.value)) : [];
4408
+ let n = N(this.left.eval(e, t)), i2 = this.right.eval(e, t);
4409
+ return n ? d(i2.some((o) => o.value === n.value)) : [];
4416
4410
  }
4417
4411
  };
4418
- var H = class extends $ {
4412
+ var K = class extends j {
4419
4413
  constructor(e, t) {
4420
4414
  super(".", e, t);
4421
4415
  }
@@ -4426,52 +4420,52 @@ var H = class extends $ {
4426
4420
  return `${this.left.toString()}.${this.right.toString()}`;
4427
4421
  }
4428
4422
  };
4429
- var ne = class extends $ {
4423
+ var oe = class extends j {
4430
4424
  constructor(e, t) {
4431
4425
  super("|", e, t);
4432
4426
  }
4433
4427
  eval(e, t) {
4434
4428
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4435
- return Pe([...n, ...i2]);
4429
+ return Ce([...n, ...i2]);
4436
4430
  }
4437
4431
  };
4438
- var Le = class extends v {
4432
+ var Be = class extends v {
4439
4433
  constructor(e, t) {
4440
4434
  super("=", e, t);
4441
4435
  }
4442
4436
  eval(e, t) {
4443
4437
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4444
- return ut(n, i2);
4438
+ return dt(n, i2);
4445
4439
  }
4446
4440
  };
4447
- var Me = class extends v {
4441
+ var qe = class extends v {
4448
4442
  constructor(e, t) {
4449
4443
  super("!=", e, t);
4450
4444
  }
4451
4445
  eval(e, t) {
4452
4446
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4453
- return ct(ut(n, i2));
4447
+ return lt(dt(n, i2));
4454
4448
  }
4455
4449
  };
4456
- var Be = class extends v {
4450
+ var $e = class extends v {
4457
4451
  constructor(e, t) {
4458
4452
  super("~", e, t);
4459
4453
  }
4460
4454
  eval(e, t) {
4461
4455
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4462
- return lt(n, i2);
4456
+ return pt(n, i2);
4463
4457
  }
4464
4458
  };
4465
- var qe = class extends v {
4459
+ var je = class extends v {
4466
4460
  constructor(e, t) {
4467
4461
  super("!~", e, t);
4468
4462
  }
4469
4463
  eval(e, t) {
4470
4464
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
4471
- return ct(lt(n, i2));
4465
+ return lt(pt(n, i2));
4472
4466
  }
4473
4467
  };
4474
- var Y = class extends v {
4468
+ var X = class extends v {
4475
4469
  constructor(e, t) {
4476
4470
  super("is", e, t);
4477
4471
  }
@@ -4480,46 +4474,46 @@ var Y = class extends v {
4480
4474
  if (n.length !== 1)
4481
4475
  return [];
4482
4476
  let i2 = this.right.name;
4483
- return l(Ae(n[0], i2));
4477
+ return d(we(n[0], i2));
4484
4478
  }
4485
4479
  };
4486
- var $e = class extends v {
4480
+ var Qe = class extends v {
4487
4481
  constructor(e, t) {
4488
4482
  super("and", e, t);
4489
4483
  }
4490
4484
  eval(e, t) {
4491
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4492
- return n?.value === true && i2?.value === true ? l(true) : n?.value === false || i2?.value === false ? l(false) : [];
4485
+ let n = N(this.left.eval(e, t), "boolean"), i2 = N(this.right.eval(e, t), "boolean");
4486
+ return n?.value === true && i2?.value === true ? d(true) : n?.value === false || i2?.value === false ? d(false) : [];
4493
4487
  }
4494
4488
  };
4495
- var je = class extends v {
4489
+ var He = class extends v {
4496
4490
  constructor(e, t) {
4497
4491
  super("or", e, t);
4498
4492
  }
4499
4493
  eval(e, t) {
4500
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4501
- return n?.value === false && i2?.value === false ? l(false) : n?.value || i2?.value ? l(true) : [];
4494
+ let n = N(this.left.eval(e, t), "boolean"), i2 = N(this.right.eval(e, t), "boolean");
4495
+ return n?.value === false && i2?.value === false ? d(false) : n?.value || i2?.value ? d(true) : [];
4502
4496
  }
4503
4497
  };
4504
- var Qe = class extends v {
4498
+ var Ke = class extends v {
4505
4499
  constructor(e, t) {
4506
4500
  super("xor", e, t);
4507
4501
  }
4508
4502
  eval(e, t) {
4509
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4510
- return !n || !i2 ? [] : l(n.value !== i2.value);
4503
+ let n = N(this.left.eval(e, t), "boolean"), i2 = N(this.right.eval(e, t), "boolean");
4504
+ return !n || !i2 ? [] : d(n.value !== i2.value);
4511
4505
  }
4512
4506
  };
4513
- var He = class extends v {
4507
+ var We = class extends v {
4514
4508
  constructor(e, t) {
4515
4509
  super("implies", e, t);
4516
4510
  }
4517
4511
  eval(e, t) {
4518
- let n = D(this.left.eval(e, t), "boolean"), i2 = D(this.right.eval(e, t), "boolean");
4519
- return i2?.value === true || n?.value === false ? l(true) : !n || !i2 ? [] : l(false);
4512
+ let n = N(this.left.eval(e, t), "boolean"), i2 = N(this.right.eval(e, t), "boolean");
4513
+ return i2?.value === true || n?.value === false ? d(true) : !n || !i2 ? [] : d(false);
4520
4514
  }
4521
4515
  };
4522
- var B = class {
4516
+ var $ = class {
4523
4517
  constructor(e, t) {
4524
4518
  this.name = e;
4525
4519
  this.args = t;
@@ -4534,7 +4528,7 @@ var B = class {
4534
4528
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
4535
4529
  }
4536
4530
  };
4537
- var X = class {
4531
+ var Z = class {
4538
4532
  constructor(e, t) {
4539
4533
  this.left = e;
4540
4534
  this.expr = t;
@@ -4553,67 +4547,67 @@ var X = class {
4553
4547
  return `${this.left.toString()}[${this.expr.toString()}]`;
4554
4548
  }
4555
4549
  };
4556
- var le = ["!=", "!~", "<=", ">=", "{}", "->"];
4550
+ var pe = ["!=", "!~", "<=", ">=", "{}", "->"];
4557
4551
  var m = { 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 };
4558
- var ii = { parse(r4) {
4552
+ var oi = { parse(r4) {
4559
4553
  let e = r4.consumeAndParse();
4560
4554
  if (!r4.match(")"))
4561
4555
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
4562
4556
  return e;
4563
4557
  } };
4564
- var oi = { parse(r4, e) {
4558
+ var si = { parse(r4, e) {
4565
4559
  let t = r4.consumeAndParse();
4566
4560
  if (!r4.match("]"))
4567
4561
  throw new Error("Parse error: expected `]`");
4568
- return new X(e, t);
4562
+ return new Z(e, t);
4569
4563
  }, precedence: m.Indexer };
4570
- var si = { parse(r4, e) {
4571
- if (!(e instanceof M))
4564
+ var ai = { parse(r4, e) {
4565
+ if (!(e instanceof q))
4572
4566
  throw new Error("Unexpected parentheses");
4573
4567
  let t = [];
4574
4568
  for (; !r4.match(")"); )
4575
4569
  t.push(r4.consumeAndParse()), r4.match(",");
4576
- return new B(e.name, t);
4570
+ return new $(e.name, t);
4577
4571
  }, precedence: m.FunctionCall };
4578
- function ai(r4) {
4572
+ function ci(r4) {
4579
4573
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
4580
4574
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
4581
4575
  }
4582
- function de() {
4583
- return new xe().registerPrefix("String", { parse: (r4, e) => new O({ type: u.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new O({ type: u.dateTime, value: re(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new O({ type: u.Quantity, value: ai(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new O({ type: u.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new O({ type: u.boolean, value: true }) }).registerPrefix("false", { parse: () => new O({ type: u.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new M(e.value) }).registerPrefix("{}", { parse: () => new De() }).registerPrefix("(", ii).registerInfix("[", oi).registerInfix("(", si).prefix("+", m.UnaryAdd, (r4, e) => new Ne("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new b("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new H(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new b("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new b("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new b("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new b("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new ne(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Le(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new Me(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new Be(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new qe(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new b("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new b("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new b(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new b(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Fe(r4, t)).infixLeft("and", m.And, (r4, e, t) => new $e(r4, t)).infixLeft("as", m.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new _e(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new b("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Ue(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new b("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new je(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Qe(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new He(r4, t));
4576
+ function fe() {
4577
+ return new ve().registerPrefix("String", { parse: (r4, e) => new V({ type: c.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new V({ type: c.dateTime, value: ie(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new V({ type: c.Quantity, value: ci(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new V({ type: c.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new V({ type: c.boolean, value: true }) }).registerPrefix("false", { parse: () => new V({ type: c.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new q(e.value) }).registerPrefix("{}", { parse: () => new Fe() }).registerPrefix("(", oi).registerInfix("[", si).registerInfix("(", ai).prefix("+", m.UnaryAdd, (r4, e) => new _e("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new R("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new K(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new R("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new R("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new R("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new R("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new oe(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Be(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new qe(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new $e(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new je(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new R("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new R("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new R(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new R(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Ue(r4, t)).infixLeft("and", m.And, (r4, e, t) => new Qe(r4, t)).infixLeft("as", m.As, (r4, e, t) => new Y(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new Le(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new R("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Me(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new X(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new R("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new He(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Ke(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new We(r4, t));
4584
4578
  }
4585
- var ci = de();
4586
- var kr = ((p2) => (p2.BOOLEAN = "BOOLEAN", p2.NUMBER = "NUMBER", p2.QUANTITY = "QUANTITY", p2.TEXT = "TEXT", p2.REFERENCE = "REFERENCE", p2.CANONICAL = "CANONICAL", p2.DATE = "DATE", p2.DATETIME = "DATETIME", p2.PERIOD = "PERIOD", p2.UUID = "UUID", p2))(kr || {});
4587
- var hi = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(hi || {});
4588
- var _i = ((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))(_i || {});
4589
- function $r(r4) {
4579
+ var ui = fe();
4580
+ var Vr = ((f) => (f.BOOLEAN = "BOOLEAN", f.NUMBER = "NUMBER", f.QUANTITY = "QUANTITY", f.TEXT = "TEXT", f.REFERENCE = "REFERENCE", f.CANONICAL = "CANONICAL", f.DATE = "DATE", f.DATETIME = "DATETIME", f.PERIOD = "PERIOD", f.UUID = "UUID", f))(Vr || {});
4581
+ var yi = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(yi || {});
4582
+ var Ui = ((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))(Ui || {});
4583
+ function Qr(r4) {
4590
4584
  if (typeof window < "u")
4591
4585
  return window.atob(r4);
4592
4586
  if (typeof Buffer < "u")
4593
4587
  return Buffer.from(r4, "base64").toString("binary");
4594
4588
  throw new Error("Unable to decode base64");
4595
4589
  }
4596
- function jr(r4) {
4590
+ function Hr(r4) {
4597
4591
  if (typeof window < "u")
4598
4592
  return window.btoa(r4);
4599
4593
  if (typeof Buffer < "u")
4600
4594
  return Buffer.from(r4, "binary").toString("base64");
4601
4595
  throw new Error("Unable to encode base64");
4602
4596
  }
4603
- function Ot() {
4597
+ function Dt() {
4604
4598
  let r4 = new Uint32Array(28);
4605
- return crypto.getRandomValues(r4), Xt(r4.buffer);
4599
+ return crypto.getRandomValues(r4), er(r4.buffer);
4606
4600
  }
4607
- async function Qr(r4) {
4601
+ async function Kr(r4) {
4608
4602
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
4609
4603
  }
4610
- function me() {
4604
+ function ye() {
4611
4605
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r4) => {
4612
4606
  let e = Math.random() * 16 | 0;
4613
4607
  return (r4 === "x" ? e : e & 3 | 8).toString(16);
4614
4608
  });
4615
4609
  }
4616
- var We = class {
4610
+ var ze = class {
4617
4611
  constructor(e = 10) {
4618
4612
  this.max = e, this.cache = /* @__PURE__ */ new Map();
4619
4613
  }
@@ -4637,8 +4631,8 @@ var We = class {
4637
4631
  return this.cache.keys().next().value;
4638
4632
  }
4639
4633
  };
4640
- var C = { 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" };
4641
- var he = class {
4634
+ var w = { 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" };
4635
+ var ge = class {
4642
4636
  constructor() {
4643
4637
  this.listeners = {};
4644
4638
  }
@@ -4663,9 +4657,9 @@ var he = class {
4663
4657
  return !e.defaultPrevented;
4664
4658
  }
4665
4659
  };
4666
- var Ge = class {
4660
+ var Je = class {
4667
4661
  constructor() {
4668
- this.emitter = new he();
4662
+ this.emitter = new ge();
4669
4663
  }
4670
4664
  dispatchEvent(e) {
4671
4665
  this.emitter.dispatchEvent(e);
@@ -4677,100 +4671,100 @@ var Ge = class {
4677
4671
  this.emitter.removeEventListener(e, t);
4678
4672
  }
4679
4673
  };
4680
- var Vt = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
4681
- var Hi = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
4682
- var Dt = ["DiagnosticReport-update"];
4683
- function Wr(r4) {
4684
- return Dt.includes(r4);
4674
+ var Nt = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
4675
+ var Ki = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
4676
+ var Ft = ["DiagnosticReport-update"];
4677
+ function zr(r4) {
4678
+ return Ft.includes(r4);
4685
4679
  }
4686
- function Gr(r4) {
4687
- if (Dt.includes(r4))
4688
- throw new d(h(`'context.version' is required for '${r4}'.`));
4680
+ function Jr(r4) {
4681
+ if (Ft.includes(r4))
4682
+ throw new p(h(`'context.version' is required for '${r4}'.`));
4689
4683
  }
4690
- var Ki = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
4691
- function Wi(r4) {
4692
- return Hi.includes(r4);
4684
+ var Wi = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
4685
+ function Gi(r4) {
4686
+ return Ki.includes(r4);
4693
4687
  }
4694
- function zr(r4) {
4688
+ function Yr(r4) {
4695
4689
  return !!r4.endpoint;
4696
4690
  }
4697
- function Nt(r4) {
4698
- if (!Je(r4))
4699
- throw new d(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4691
+ function _t(r4) {
4692
+ if (!Xe(r4))
4693
+ throw new p(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
4700
4694
  let { channelType: e, mode: t, topic: n, events: i2 } = r4, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
4701
- return zr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4695
+ return Yr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
4702
4696
  }
4703
- function Je(r4) {
4697
+ function Xe(r4) {
4704
4698
  if (typeof r4 != "object")
4705
4699
  return false;
4706
4700
  let { channelType: e, mode: t, topic: n, events: i2 } = r4;
4707
4701
  if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
4708
4702
  return false;
4709
4703
  for (let o of i2)
4710
- if (!Vt[o])
4704
+ if (!Nt[o])
4711
4705
  return false;
4712
- return !(zr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4706
+ return !(Yr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
4713
4707
  }
4714
- function Kr(r4, e, t, n) {
4708
+ function Gr(r4, e, t, n) {
4715
4709
  if (typeof e != "object")
4716
- throw new d(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
4710
+ throw new p(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
4717
4711
  if (!(e.id && typeof e.id == "string"))
4718
- throw new d(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
4712
+ throw new p(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
4719
4713
  if (!e.resourceType)
4720
- throw new d(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4714
+ throw new p(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
4721
4715
  let i2 = n.resourceType;
4722
4716
  if (i2 !== "*") {
4723
- if (!Wi(e.resourceType))
4724
- throw new d(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4717
+ if (!Gi(e.resourceType))
4718
+ throw new p(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
4725
4719
  if (i2 && e.resourceType !== i2)
4726
- throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
4720
+ throw new p(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
4727
4721
  }
4728
4722
  }
4729
- function Gi(r4, e, t, n, i2) {
4723
+ function zi(r4, e, t, n, i2) {
4730
4724
  if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), !n.isArray)
4731
- Kr(r4, e.resource, t, n);
4725
+ Gr(r4, e.resource, t, n);
4732
4726
  else {
4733
4727
  let { resources: o } = e;
4734
4728
  if (!o)
4735
- throw new d(h(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
4729
+ throw new p(h(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
4736
4730
  for (let s of o)
4737
- Kr(r4, s, t, n);
4731
+ Gr(r4, s, t, n);
4738
4732
  }
4739
4733
  }
4740
- function zi(r4, e) {
4741
- let t = /* @__PURE__ */ new Map(), n = Ki[r4];
4734
+ function Ji(r4, e) {
4735
+ let t = /* @__PURE__ */ new Map(), n = Wi[r4];
4742
4736
  for (let i2 = 0; i2 < e.length; i2++) {
4743
4737
  let o = e[i2].key;
4744
4738
  if (!n[o])
4745
- throw new d(h(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
4746
- Gi(r4, e[i2], i2, n[o], t);
4739
+ throw new p(h(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
4740
+ zi(r4, e[i2], i2, n[o], t);
4747
4741
  }
4748
4742
  for (let [i2, o] of Object.entries(n)) {
4749
4743
  if (!(o.optional || t.has(i2)))
4750
- throw new d(h(`Missing required key '${i2}' on context for '${r4}' event.`));
4744
+ throw new p(h(`Missing required key '${i2}' on context for '${r4}' event.`));
4751
4745
  if (!o.manyAllowed && (t.get(i2) || 0) > 1)
4752
- throw new d(h(`${t.get(i2)} context entries with key '${i2}' found for the '${r4}' event when schema only allows for 1.`));
4746
+ throw new p(h(`${t.get(i2)} context entries with key '${i2}' found for the '${r4}' event when schema only allows for 1.`));
4753
4747
  }
4754
4748
  }
4755
- function Ft(r4, e, t, n) {
4749
+ function Ut(r4, e, t, n) {
4756
4750
  if (!(r4 && typeof r4 == "string"))
4757
- throw new d(h("Must provide a topic."));
4758
- if (!Vt[e])
4759
- throw new d(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Vt).join(", ")}`));
4751
+ throw new p(h("Must provide a topic."));
4752
+ if (!Nt[e])
4753
+ throw new p(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Nt).join(", ")}`));
4760
4754
  if (typeof t != "object")
4761
- throw new d(h("context must be a context object or array of context objects."));
4762
- if (Dt.includes(e) && !n)
4763
- throw new d(h(`The '${e}' event must contain a 'context.versionId'.`));
4755
+ throw new p(h("context must be a context object or array of context objects."));
4756
+ if (Ft.includes(e) && !n)
4757
+ throw new p(h(`The '${e}' event must contain a 'context.versionId'.`));
4764
4758
  let i2 = Array.isArray(t) ? t : [t];
4765
- return zi(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: me(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
4759
+ return Ji(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ye(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
4766
4760
  }
4767
- var ze = class extends Ge {
4761
+ var Ye = class extends Je {
4768
4762
  constructor(t) {
4769
4763
  super();
4770
4764
  if (this.subRequest = t, !t.endpoint)
4771
- throw new d(h("Subscription request should contain an endpoint."));
4772
- if (!Je(t))
4773
- throw new d(h("Subscription request failed validation."));
4765
+ throw new p(h("Subscription request should contain an endpoint."));
4766
+ if (!Xe(t))
4767
+ throw new p(h("Subscription request failed validation."));
4774
4768
  let n = new WebSocket(t.endpoint);
4775
4769
  n.addEventListener("open", () => {
4776
4770
  this.dispatchEvent({ type: "connect" }), n.addEventListener("message", (i2) => {
@@ -4778,7 +4772,7 @@ var ze = class extends Ge {
4778
4772
  if (o["hub.topic"])
4779
4773
  return;
4780
4774
  let s = o;
4781
- this.dispatchEvent({ type: "message", payload: s }), n.send(JSON.stringify({ id: o?.id, timestamp: (/* @__PURE__ */ new Date()).toISOString() }));
4775
+ s.event["hub.event"] !== "heartbeat" && (this.dispatchEvent({ type: "message", payload: s }), n.send(JSON.stringify({ id: o?.id, timestamp: (/* @__PURE__ */ new Date()).toISOString() })));
4782
4776
  }), n.addEventListener("close", () => {
4783
4777
  this.dispatchEvent({ type: "disconnect" });
4784
4778
  });
@@ -4788,31 +4782,31 @@ var ze = class extends Ge {
4788
4782
  this.websocket.close();
4789
4783
  }
4790
4784
  };
4791
- function Ji(r4) {
4792
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = $r(e), n = Array.from(t).reduce((o, s) => {
4785
+ function Yi(r4) {
4786
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Qr(e), n = Array.from(t).reduce((o, s) => {
4793
4787
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
4794
4788
  return `${o}%${a}`;
4795
4789
  }, ""), i2 = decodeURIComponent(n);
4796
4790
  return JSON.parse(i2);
4797
4791
  }
4798
- function Jr(r4) {
4792
+ function Xr(r4) {
4799
4793
  return r4.split(".").length === 3;
4800
4794
  }
4801
- function _t(r4) {
4795
+ function Lt(r4) {
4802
4796
  let [e, t, n] = r4.split(".");
4803
- return Ji(t);
4797
+ return Yi(t);
4804
4798
  }
4805
- function Yr(r4) {
4799
+ function Zr(r4) {
4806
4800
  try {
4807
- return typeof _t(r4).login_id == "string";
4801
+ return typeof Lt(r4).login_id == "string";
4808
4802
  } catch {
4809
4803
  return false;
4810
4804
  }
4811
4805
  }
4812
- var Yi;
4813
- var w = class {
4806
+ var Xi;
4807
+ var I = class {
4814
4808
  constructor(e) {
4815
- this[Yi] = "ReadablePromise";
4809
+ this[Xi] = "ReadablePromise";
4816
4810
  this.status = "pending";
4817
4811
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
4818
4812
  throw this.status = "error", this.error = t, t;
@@ -4844,10 +4838,10 @@ var w = class {
4844
4838
  return this.suspender.finally(e);
4845
4839
  }
4846
4840
  };
4847
- Yi = Symbol.toStringTag;
4848
- var Ye = class {
4841
+ Xi = Symbol.toStringTag;
4842
+ var Ze = class {
4849
4843
  constructor(e) {
4850
- this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Ut());
4844
+ this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Mt());
4851
4845
  }
4852
4846
  clear() {
4853
4847
  this.storage.clear();
@@ -4863,10 +4857,10 @@ var Ye = class {
4863
4857
  return t ? JSON.parse(t) : void 0;
4864
4858
  }
4865
4859
  setObject(e, t) {
4866
- this.setString(e, t ? zt(t) : void 0);
4860
+ this.setString(e, t ? Yt(t) : void 0);
4867
4861
  }
4868
4862
  };
4869
- var Ut = class {
4863
+ var Mt = class {
4870
4864
  constructor() {
4871
4865
  this.data = /* @__PURE__ */ new Map();
4872
4866
  }
@@ -4889,23 +4883,23 @@ var Ut = class {
4889
4883
  return Array.from(this.data.keys())[e];
4890
4884
  }
4891
4885
  };
4892
- var Xi = C.FHIR_JSON + ", */*; q=0.1";
4893
- var Zi = "https://api.medplum.com/";
4894
- var eo = 1e3;
4895
- var to = 6e4;
4896
- var Xr = "Binary/";
4897
- var Zr = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4898
- var ro = ((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))(ro || {});
4899
- var no = ((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))(no || {});
4900
- var io = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(io || {});
4901
- var oo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(oo || {});
4902
- var en = class extends he {
4886
+ var Zi = w.FHIR_JSON + ", */*; q=0.1";
4887
+ var eo = "https://api.medplum.com/";
4888
+ var to = 1e3;
4889
+ var ro = 6e4;
4890
+ var en = "Binary/";
4891
+ var tn = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
4892
+ var no = ((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))(no || {});
4893
+ var io = ((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))(io || {});
4894
+ var oo = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(oo || {});
4895
+ var so = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(so || {});
4896
+ var rn = class extends ge {
4903
4897
  constructor(t) {
4904
4898
  super();
4905
4899
  this.initComplete = true;
4906
4900
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4907
4901
  throw new Error("Base URL must start with http or https");
4908
- if (this.options = t ?? {}, this.fetch = t?.fetch ?? so(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = rn(t?.baseUrl ?? Zi), this.fhirBaseUrl = rn(Xe(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Xe(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Xe(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Xe(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? to, this.cacheTime > 0 ? this.requestCache = new We(t?.resourceCacheSize ?? eo) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4902
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? ao(), this.storage = t?.storage ?? new Ze(), this.createPdfImpl = t?.createPdf, this.baseUrl = on(t?.baseUrl ?? eo), this.fhirBaseUrl = on(et(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = et(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = et(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = et(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? ro, this.cacheTime > 0 ? this.requestCache = new ze(t?.resourceCacheSize ?? to) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4909
4903
  this.setAccessToken(t.accessToken), this.initPromise = Promise.resolve();
4910
4904
  else if (this.storage.getInitPromise !== void 0) {
4911
4905
  let n = this.storage.getInitPromise(), i2 = new Promise((o) => {
@@ -4964,10 +4958,10 @@ var en = class extends he {
4964
4958
  if (i2)
4965
4959
  return i2.value;
4966
4960
  let o;
4967
- t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, c2) => {
4968
- this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a, reject: c2 }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
4961
+ t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, u2) => {
4962
+ this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a, reject: u2 }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
4969
4963
  }) : o = this.request("GET", t, n);
4970
- let s = new w(o);
4964
+ let s = new I(o);
4971
4965
  return this.setCacheEntry(t, s), s;
4972
4966
  }
4973
4967
  post(t, n, i2, o = {}) {
@@ -4977,7 +4971,7 @@ var en = class extends he {
4977
4971
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
4978
4972
  }
4979
4973
  patch(t, n, i2 = {}) {
4980
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, C.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4974
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, w.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
4981
4975
  }
4982
4976
  delete(t, n) {
4983
4977
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -5026,12 +5020,12 @@ var en = class extends he {
5026
5020
  getExternalAuthRedirectUri(t, n, i2, o, s = true) {
5027
5021
  let a = new URL(t);
5028
5022
  if (a.searchParams.set("response_type", "code"), a.searchParams.set("client_id", n), a.searchParams.set("redirect_uri", i2), a.searchParams.set("scope", "openid profile email"), a.searchParams.set("state", JSON.stringify(o)), s) {
5029
- let { codeChallenge: c2, codeChallengeMethod: f } = o;
5030
- if (!f)
5023
+ let { codeChallenge: u2, codeChallengeMethod: l2 } = o;
5024
+ if (!l2)
5031
5025
  throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");
5032
- if (!c2)
5026
+ if (!u2)
5033
5027
  throw new Error("`LoginRequest` for external auth must include a `codeChallenge`.");
5034
- a.searchParams.set("code_challenge_method", f), a.searchParams.set("code_challenge", c2);
5028
+ a.searchParams.set("code_challenge_method", l2), a.searchParams.set("code_challenge", u2);
5035
5029
  }
5036
5030
  return a.toString();
5037
5031
  }
@@ -5046,14 +5040,14 @@ var en = class extends he {
5046
5040
  let o = this.fhirSearchUrl(t, n), s = o.toString() + "-search", a = this.getCacheEntry(s, i2);
5047
5041
  if (a)
5048
5042
  return a.value;
5049
- let c2 = new w((async () => {
5050
- let f = await this.get(o, i2);
5051
- if (f.entry)
5052
- for (let p2 of f.entry)
5053
- this.cacheResource(p2.resource);
5054
- return f;
5043
+ let u2 = new I((async () => {
5044
+ let l2 = await this.get(o, i2);
5045
+ if (l2.entry)
5046
+ for (let f of l2.entry)
5047
+ this.cacheResource(f.resource);
5048
+ return l2;
5055
5049
  })());
5056
- return this.setCacheEntry(s, c2), c2;
5050
+ return this.setCacheEntry(s, u2), u2;
5057
5051
  }
5058
5052
  searchOne(t, n, i2) {
5059
5053
  let o = this.fhirSearchUrl(t, n);
@@ -5061,23 +5055,23 @@ var en = class extends he {
5061
5055
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
5062
5056
  if (a)
5063
5057
  return a.value;
5064
- let c2 = new w(this.search(t, o.searchParams, i2).then((f) => f.entry?.[0]?.resource));
5065
- return this.setCacheEntry(s, c2), c2;
5058
+ let u2 = new I(this.search(t, o.searchParams, i2).then((l2) => l2.entry?.[0]?.resource));
5059
+ return this.setCacheEntry(s, u2), u2;
5066
5060
  }
5067
5061
  searchResources(t, n, i2) {
5068
5062
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
5069
5063
  if (a)
5070
5064
  return a.value;
5071
- let c2 = new w(this.search(t, n, i2).then(on));
5072
- return this.setCacheEntry(s, c2), c2;
5065
+ let u2 = new I(this.search(t, n, i2).then(an));
5066
+ return this.setCacheEntry(s, u2), u2;
5073
5067
  }
5074
5068
  async *searchResourcePages(t, n, i2) {
5075
5069
  let o = this.fhirSearchUrl(t, n);
5076
5070
  for (; o; ) {
5077
- let s = new URL(o).searchParams, a = await this.search(t, s, i2), c2 = a.link?.find((f) => f.relation === "next");
5078
- if (!a.entry?.length && !c2)
5071
+ let s = new URL(o).searchParams, a = await this.search(t, s, i2), u2 = a.link?.find((l2) => l2.relation === "next");
5072
+ if (!a.entry?.length && !u2)
5079
5073
  break;
5080
- yield on(a), o = c2?.url ? new URL(c2.url) : void 0;
5074
+ yield an(a), o = u2?.url ? new URL(u2.url) : void 0;
5081
5075
  }
5082
5076
  }
5083
5077
  searchValueSet(t, n, i2) {
@@ -5093,7 +5087,7 @@ var en = class extends he {
5093
5087
  if (!n)
5094
5088
  return;
5095
5089
  if (n === "system")
5096
- return Zr;
5090
+ return tn;
5097
5091
  let [i2, o] = n.split("/");
5098
5092
  if (!(!i2 || !o))
5099
5093
  return this.getCached(i2, o);
@@ -5104,19 +5098,19 @@ var en = class extends he {
5104
5098
  readReference(t, n) {
5105
5099
  let i2 = t.reference;
5106
5100
  if (!i2)
5107
- return new w(Promise.reject(new Error("Missing reference")));
5101
+ return new I(Promise.reject(new Error("Missing reference")));
5108
5102
  if (i2 === "system")
5109
- return new w(Promise.resolve(Zr));
5103
+ return new I(Promise.resolve(tn));
5110
5104
  let [o, s] = i2.split("/");
5111
- return !o || !s ? new w(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
5105
+ return !o || !s ? new I(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
5112
5106
  }
5113
5107
  requestSchema(t) {
5114
- if (br(t))
5108
+ if (Ar(t))
5115
5109
  return Promise.resolve();
5116
5110
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
5117
5111
  if (i2)
5118
5112
  return i2.value;
5119
- let o = new w((async () => {
5113
+ let o = new I((async () => {
5120
5114
  let s = `{
5121
5115
  StructureDefinitionList(name: "${t}") {
5122
5116
  resourceType,
@@ -5155,9 +5149,9 @@ var en = class extends he {
5155
5149
  target
5156
5150
  }
5157
5151
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
5158
- Er(a.data.StructureDefinitionList);
5159
- for (let c2 of a.data.SearchParameterList)
5160
- Rt(c2);
5152
+ Rr(a.data.StructureDefinitionList);
5153
+ for (let u2 of a.data.SearchParameterList)
5154
+ Pt(u2);
5161
5155
  })());
5162
5156
  return this.setCacheEntry(n, o), o;
5163
5157
  }
@@ -5178,20 +5172,24 @@ var en = class extends he {
5178
5172
  async createResourceIfNoneExist(t, n, i2) {
5179
5173
  return await this.searchOne(t.resourceType, n, i2) ?? this.createResource(t, i2);
5180
5174
  }
5181
- async createAttachment(t, n, i2, o) {
5182
- let s = await this.createBinary(t, n, i2, o);
5183
- return { contentType: i2, url: s.url, title: n };
5175
+ async createAttachment(t, n, i2, o, s) {
5176
+ let a = await this.createBinary(t, n, i2, o, s);
5177
+ return { contentType: i2, url: a.url, title: n };
5184
5178
  }
5185
- createBinary(t, n, i2, o) {
5186
- let s = this.fhirUrl("Binary");
5187
- return n && s.searchParams.set("_filename", n), o ? this.uploadwithProgress(s, t, i2, o) : this.post(s, t, i2);
5179
+ createBinary(t, n, i2, o, s) {
5180
+ let a = this.fhirUrl("Binary");
5181
+ return n && a.searchParams.set("_filename", n), o ? this.uploadwithProgress(a, t, i2, o, s) : this.post(a, t, i2, s);
5188
5182
  }
5189
- uploadwithProgress(t, n, i2, o) {
5190
- return new Promise((s, a) => {
5191
- let c2 = new XMLHttpRequest();
5192
- 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 = () => {
5193
- c2.status >= 200 && c2.status < 300 ? s(c2.response) : a(new d(Oe(c2.response || c2.statusText)));
5194
- }, 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);
5183
+ uploadwithProgress(t, n, i2, o, s) {
5184
+ return new Promise((a, u2) => {
5185
+ let l2 = new XMLHttpRequest(), f = () => l2.abort();
5186
+ s?.signal?.addEventListener("abort", f);
5187
+ let P = (M) => {
5188
+ s?.signal?.removeEventListener("abort", f), M instanceof Error ? u2(M) : a(M);
5189
+ };
5190
+ l2.responseType = "json", l2.onabort = () => P(new Error("Request aborted")), l2.onerror = () => P(new Error("Request error")), o && (l2.upload.onprogress = (M) => o(M), l2.upload.onload = (M) => o(M)), l2.onload = () => {
5191
+ l2.status >= 200 && l2.status < 300 ? P(l2.response) : P(new p(De(l2.response || l2.statusText)));
5192
+ }, l2.open("POST", t), l2.withCredentials = true, l2.setRequestHeader("Authorization", "Bearer " + this.accessToken), l2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), l2.setRequestHeader("Content-Type", i2), l2.setRequestHeader("X-Medplum", "extended"), l2.send(n);
5195
5193
  });
5196
5194
  }
5197
5195
  async createPdf(t, n, i2, o) {
@@ -5202,7 +5200,7 @@ var en = class extends he {
5202
5200
  }
5203
5201
  createComment(t, n, i2) {
5204
5202
  let o = this.getProfile(), s, a;
5205
- return t.resourceType === "Encounter" && (s = G(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = G(t)), this.createResource({ resourceType: "Communication", basedOn: [G(t)], encounter: s, subject: a, sender: o ? G(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5203
+ return t.resourceType === "Encounter" && (s = z(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = z(t)), this.createResource({ resourceType: "Communication", basedOn: [z(t)], encounter: s, subject: a, sender: o ? z(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
5206
5204
  }
5207
5205
  async updateResource(t, n) {
5208
5206
  if (!t.resourceType)
@@ -5236,28 +5234,28 @@ var en = class extends he {
5236
5234
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
5237
5235
  }
5238
5236
  sendEmail(t, n) {
5239
- return this.post("email/v1/send", t, C.JSON, n);
5237
+ return this.post("email/v1/send", t, w.JSON, n);
5240
5238
  }
5241
5239
  graphql(t, n, i2, o) {
5242
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, C.JSON, o);
5240
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, w.JSON, o);
5243
5241
  }
5244
5242
  readResourceGraph(t, n, i2, o) {
5245
5243
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
5246
5244
  }
5247
5245
  pushToAgent(t, n, i2, o, s) {
5248
- return this.post(this.fhirUrl("Agent", Kt(t), "$push"), { destination: se(n), body: i2, contentType: o }, C.FHIR_JSON, s);
5246
+ return this.post(this.fhirUrl("Agent", Gt(t), "$push"), { destination: ce(n), body: i2, contentType: o }, w.FHIR_JSON, s);
5249
5247
  }
5250
5248
  getActiveLogin() {
5251
5249
  return this.storage.getObject("activeLogin");
5252
5250
  }
5253
5251
  async setActiveLogin(t) {
5254
- (!this.sessionDetails?.profile || se(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
5252
+ (!this.sessionDetails?.profile || ce(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
5255
5253
  }
5256
5254
  getAccessToken() {
5257
5255
  return this.accessToken;
5258
5256
  }
5259
5257
  setAccessToken(t, n) {
5260
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Yr(t);
5258
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Zr(t);
5261
5259
  }
5262
5260
  getLogins() {
5263
5261
  return this.storage.getObject("logins") ?? [];
@@ -5305,11 +5303,11 @@ var en = class extends he {
5305
5303
  async download(t, n = {}) {
5306
5304
  this.refreshPromise && await this.refreshPromise;
5307
5305
  let i2 = t.toString();
5308
- return i2.startsWith(Xr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5306
+ return i2.startsWith(en) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
5309
5307
  }
5310
5308
  async uploadMedia(t, n, i2, o, s) {
5311
5309
  let a = await this.createBinary(t, i2, n);
5312
- return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Xr + a.id, title: i2 }, ...o }, s);
5310
+ return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: en + a.id, title: i2 }, ...o }, s);
5313
5311
  }
5314
5312
  async bulkExport(t = "", n, i2, o) {
5315
5313
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -5321,7 +5319,7 @@ var en = class extends he {
5321
5319
  i2.Prefer = "respond-async";
5322
5320
  let o = await this.fetchWithRetry(t, n);
5323
5321
  if (o.status === 202) {
5324
- let s = await nn(o);
5322
+ let s = await sn(o);
5325
5323
  if (s)
5326
5324
  return this.pollStatus(s);
5327
5325
  }
@@ -5338,7 +5336,7 @@ var en = class extends he {
5338
5336
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
5339
5337
  }
5340
5338
  cacheResource(t) {
5341
- t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new w(Promise.resolve(t)));
5339
+ t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new I(Promise.resolve(t)));
5342
5340
  }
5343
5341
  deleteCacheEntry(t) {
5344
5342
  this.requestCache && this.requestCache.delete(t);
@@ -5355,22 +5353,22 @@ var en = class extends he {
5355
5353
  return;
5356
5354
  let a = t.headers.get("content-type")?.includes("json");
5357
5355
  if (t.status === 404 && !a)
5358
- throw new d(mr);
5359
- let c2 = t.headers.get("content-location"), f = o.redirect ?? this.options.redirect;
5360
- if (t.status === 201 && c2 && f === "follow")
5361
- return this.request("GET", c2, { ...o, body: void 0 });
5362
- let p2;
5356
+ throw new p(yr);
5357
+ let u2 = t.headers.get("content-location"), l2 = o.redirect ?? this.options.redirect;
5358
+ if (t.status === 201 && u2 && l2 === "follow")
5359
+ return this.request("GET", u2, { ...o, body: void 0 });
5360
+ let f;
5363
5361
  if (a)
5364
5362
  try {
5365
- p2 = await t.json();
5366
- } catch (q) {
5367
- throw console.error("Error parsing response", t.status, q), q;
5363
+ f = await t.json();
5364
+ } catch (P) {
5365
+ throw console.error("Error parsing response", t.status, P), P;
5368
5366
  }
5369
5367
  else
5370
- p2 = await t.text();
5368
+ f = await t.text();
5371
5369
  if (t.status >= 400)
5372
- throw new d(Oe(p2));
5373
- return p2;
5370
+ throw new p(De(f));
5371
+ return f;
5374
5372
  }
5375
5373
  async fetchWithRetry(t, n) {
5376
5374
  t.startsWith("http") || (t = new URL(t, this.baseUrl).href);
@@ -5379,10 +5377,10 @@ var en = class extends he {
5379
5377
  try {
5380
5378
  if (this.options.verbose && this.logRequest(t, n), s = await this.fetch(t, n), this.options.verbose && this.logResponse(s), s.status < 500)
5381
5379
  return s;
5382
- } catch (c2) {
5383
- this.retryCatch(a, i2, c2);
5380
+ } catch (u2) {
5381
+ this.retryCatch(a, i2, u2);
5384
5382
  }
5385
- await ot(o);
5383
+ await at(o);
5386
5384
  }
5387
5385
  return s;
5388
5386
  }
@@ -5403,10 +5401,10 @@ var en = class extends he {
5403
5401
  this.addFetchOptionsDefaults(s);
5404
5402
  let a = await this.fetchWithRetry(t, s);
5405
5403
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
5406
- let c2 = await nn(a);
5407
- c2 && (i2 = await this.fetchWithRetry(c2, s));
5404
+ let u2 = await sn(a);
5405
+ u2 && (i2 = await this.fetchWithRetry(u2, s));
5408
5406
  }
5409
- await ot(o);
5407
+ await at(o);
5410
5408
  }
5411
5409
  return this.parseResponse(i2, "POST", t);
5412
5410
  }
@@ -5417,19 +5415,19 @@ var en = class extends he {
5417
5415
  try {
5418
5416
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
5419
5417
  } catch (s) {
5420
- o.reject(new d(Oe(s)));
5418
+ o.reject(new p(De(s)));
5421
5419
  }
5422
5420
  return;
5423
5421
  }
5424
5422
  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);
5425
5423
  for (let o = 0; o < t.length; o++) {
5426
5424
  let s = t[o], a = i2.entry?.[o];
5427
- a?.response?.outcome && !yt(a.response.outcome) ? s.reject(new d(a.response.outcome)) : s.resolve(a?.resource);
5425
+ a?.response?.outcome && !xt(a.response.outcome) ? s.reject(new p(a.response.outcome)) : s.resolve(a?.resource);
5428
5426
  }
5429
5427
  }
5430
5428
  addFetchOptionsDefaults(t) {
5431
5429
  let n = t.headers;
5432
- n || (n = {}, t.headers = n), n.Accept || (n.Accept = Xi), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = C.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");
5430
+ n || (n = {}, t.headers = n), n.Accept || (n.Accept = Zi), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = w.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");
5433
5431
  }
5434
5432
  setRequestContentType(t, n) {
5435
5433
  t.headers || (t.headers = {});
@@ -5443,20 +5441,20 @@ var en = class extends he {
5443
5441
  return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
5444
5442
  }
5445
5443
  async startPkce() {
5446
- let t = Ot();
5444
+ let t = Dt();
5447
5445
  sessionStorage.setItem("pkceState", t);
5448
- let n = Ot();
5446
+ let n = Dt();
5449
5447
  sessionStorage.setItem("codeVerifier", n);
5450
- let i2 = await Qr(n), o = Zt(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5448
+ let i2 = await Kr(n), o = tr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
5451
5449
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
5452
5450
  }
5453
5451
  async requestAuthorization(t) {
5454
5452
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
5455
- 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 ?? tn()), 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());
5453
+ 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 ?? nn()), 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());
5456
5454
  }
5457
5455
  processCode(t, n) {
5458
5456
  let i2 = new URLSearchParams();
5459
- 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 ?? tn()), typeof sessionStorage < "u") {
5457
+ 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 ?? nn()), typeof sessionStorage < "u") {
5460
5458
  let o = sessionStorage.getItem("codeVerifier");
5461
5459
  o && i2.set("code_verifier", o);
5462
5460
  }
@@ -5487,30 +5485,30 @@ var en = class extends he {
5487
5485
  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);
5488
5486
  }
5489
5487
  setBasicAuth(t, n) {
5490
- this.clientId = t, this.clientSecret = n, this.basicAuth = jr(t + ":" + n);
5488
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Hr(t + ":" + n);
5491
5489
  }
5492
5490
  async fhircastSubscribe(t, n) {
5493
5491
  if (!(typeof t == "string" && t !== ""))
5494
- throw new d(h("Invalid topic provided. Topic must be a valid string."));
5492
+ throw new p(h("Invalid topic provided. Topic must be a valid string."));
5495
5493
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
5496
- throw new d(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5497
- let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", Nt(i2), C.FORM_URL_ENCODED))["hub.channel.endpoint"];
5494
+ throw new p(h("Invalid events provided. Events must be an array of event names containing at least one event."));
5495
+ let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", _t(i2), w.FORM_URL_ENCODED))["hub.channel.endpoint"];
5498
5496
  if (!s)
5499
5497
  throw new Error("Invalid response!");
5500
5498
  return i2.endpoint = s, i2;
5501
5499
  }
5502
5500
  async fhircastUnsubscribe(t) {
5503
- if (!Je(t))
5504
- throw new d(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5501
+ if (!Xe(t))
5502
+ throw new p(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
5505
5503
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
5506
- throw new d(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5507
- t.mode = "unsubscribe", await this.post("/fhircast/STU3", Nt(t), C.FORM_URL_ENCODED);
5504
+ throw new p(h("Provided subscription request must have an endpoint in order to unsubscribe."));
5505
+ t.mode = "unsubscribe", await this.post("/fhircast/STU3", _t(t), w.FORM_URL_ENCODED);
5508
5506
  }
5509
5507
  fhircastConnect(t) {
5510
- return new ze(t);
5508
+ return new Ye(t);
5511
5509
  }
5512
5510
  async fhircastPublish(t, n, i2, o) {
5513
- return Wr(n) ? this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2, o), C.JSON) : (Gr(n), this.post(`/fhircast/STU3/${t}`, Ft(t, n, i2), C.JSON));
5511
+ return zr(n) ? this.post(`/fhircast/STU3/${t}`, Ut(t, n, i2, o), w.JSON) : (Jr(n), this.post(`/fhircast/STU3/${t}`, Ut(t, n, i2), w.JSON));
5514
5512
  }
5515
5513
  async fhircastGetContext(t) {
5516
5514
  return this.get(`/fhircast/STU3/${t}`);
@@ -5519,16 +5517,16 @@ var en = class extends he {
5519
5517
  return this.post("admin/projects/" + t + "/invite", n);
5520
5518
  }
5521
5519
  async fetchTokens(t) {
5522
- let n = { method: "POST", headers: { "Content-Type": C.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5520
+ let n = { method: "POST", headers: { "Content-Type": w.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
5523
5521
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
5524
5522
  let o = await this.fetchWithRetry(this.tokenUrl, n);
5525
5523
  if (!o.ok) {
5526
5524
  this.clearActiveLogin();
5527
5525
  try {
5528
5526
  let a = await o.json();
5529
- throw new d(F(a.error_description));
5527
+ throw new p(_(a.error_description));
5530
5528
  } catch (a) {
5531
- throw new d(F("Failed to fetch tokens"), a);
5529
+ throw new p(_("Failed to fetch tokens"), a);
5532
5530
  }
5533
5531
  }
5534
5532
  let s = await o.json();
@@ -5536,8 +5534,8 @@ var en = class extends he {
5536
5534
  }
5537
5535
  async verifyTokens(t) {
5538
5536
  let n = t.access_token;
5539
- if (Jr(n)) {
5540
- let i2 = _t(n);
5537
+ if (Xr(n)) {
5538
+ let i2 = Lt(n);
5541
5539
  if (Date.now() >= i2.exp * 1e3)
5542
5540
  throw this.clearActiveLogin(), new Error("Token expired");
5543
5541
  if (i2.cid) {
@@ -5561,21 +5559,21 @@ var en = class extends he {
5561
5559
  throw i2;
5562
5560
  }
5563
5561
  };
5564
- function so() {
5562
+ function ao() {
5565
5563
  if (!globalThis.fetch)
5566
5564
  throw new Error("Fetch not available in this environment");
5567
5565
  return globalThis.fetch.bind(globalThis);
5568
5566
  }
5569
- function tn() {
5567
+ function nn() {
5570
5568
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
5571
5569
  }
5572
- function rn(r4) {
5570
+ function on(r4) {
5573
5571
  return r4.endsWith("/") ? r4 : r4 + "/";
5574
5572
  }
5575
- function Xe(r4, e) {
5573
+ function et(r4, e) {
5576
5574
  return new URL(e, r4).toString();
5577
5575
  }
5578
- async function nn(r4) {
5576
+ async function sn(r4) {
5579
5577
  let e = r4.headers.get("content-location");
5580
5578
  if (e)
5581
5579
  return e;
@@ -5583,18 +5581,18 @@ async function nn(r4) {
5583
5581
  if (t)
5584
5582
  return t;
5585
5583
  let n = await r4.json();
5586
- if (ke(n) && n.issue?.[0]?.diagnostics)
5584
+ if (Ve(n) && n.issue?.[0]?.diagnostics)
5587
5585
  return n.issue[0].diagnostics;
5588
5586
  }
5589
- function on(r4) {
5587
+ function an(r4) {
5590
5588
  let e = r4.entry?.map((t) => t.resource) ?? [];
5591
5589
  return Object.assign(e, { bundle: r4 });
5592
5590
  }
5593
- var ao = [...le, "->", "<<", ">>"];
5594
- var co = de().registerInfix("->", { precedence: m.Arrow }).registerInfix(";", { precedence: m.Semicolon });
5595
- var uo = [...le, "eq", "ne", "co"];
5596
- var fo = de();
5597
- var W = class {
5591
+ var co = [...pe, "->", "<<", ">>"];
5592
+ var uo = fe().registerInfix("->", { precedence: m.Arrow }).registerInfix(";", { precedence: m.Semicolon });
5593
+ var lo = [...pe, "eq", "ne", "co"];
5594
+ var mo = fe();
5595
+ var G = class {
5598
5596
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
5599
5597
  this.segmentSeparator = e;
5600
5598
  this.fieldSeparator = t;
@@ -5610,8 +5608,8 @@ var W = class {
5610
5608
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
5611
5609
  }
5612
5610
  };
5613
- var un = class r {
5614
- constructor(e, t = new W()) {
5611
+ var dn = class r {
5612
+ constructor(e, t = new G()) {
5615
5613
  this.context = t, this.segments = e;
5616
5614
  }
5617
5615
  get header() {
@@ -5633,8 +5631,8 @@ var un = class r {
5633
5631
  return this.segments.map((e) => e.toString()).join(this.context.segmentSeparator);
5634
5632
  }
5635
5633
  buildAck() {
5636
- 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";
5637
- return new r([new ye(["MSH", this.context.getMsh2(), o, s, n, i2, ho(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new ye(["MSA", "AA", a, "OK"], this.context)]);
5634
+ 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() ?? "", u2 = t?.getField(12)?.toString() ?? "2.5.1";
5635
+ return new r([new xe(["MSH", this.context.getMsh2(), o, s, n, i2, yo(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", u2], this.context), new xe(["MSA", "AA", a, "OK"], this.context)]);
5638
5636
  }
5639
5637
  buildAckMessageType(e) {
5640
5638
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -5645,13 +5643,13 @@ var un = class r {
5645
5643
  let n = new Error("Invalid HL7 message");
5646
5644
  throw n.type = "entity.parse.failed", n;
5647
5645
  }
5648
- let t = new W("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5649
- return new r(e.split(/[\r\n]+/).map((n) => ye.parse(n, t)), t);
5646
+ let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
5647
+ return new r(e.split(/[\r\n]+/).map((n) => xe.parse(n, t)), t);
5650
5648
  }
5651
5649
  };
5652
- var ye = class r2 {
5653
- constructor(e, t = new W()) {
5654
- this.context = t, Jt(e) ? this.fields = e.map((n) => oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5650
+ var xe = class r2 {
5651
+ constructor(e, t = new G()) {
5652
+ this.context = t, Xt(e) ? this.fields = e.map((n) => ae.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
5655
5653
  }
5656
5654
  get(e) {
5657
5655
  return this.fields[e];
@@ -5659,9 +5657,9 @@ var ye = class r2 {
5659
5657
  getField(e) {
5660
5658
  if (this.name === "MSH") {
5661
5659
  if (e === 1)
5662
- return new oe([[this.context.getMsh1()]], this.context);
5660
+ return new ae([[this.context.getMsh1()]], this.context);
5663
5661
  if (e === 2)
5664
- return new oe([[this.context.getMsh2()]], this.context);
5662
+ return new ae([[this.context.getMsh2()]], this.context);
5665
5663
  if (e > 2)
5666
5664
  return this.fields[e - 1];
5667
5665
  }
@@ -5673,12 +5671,12 @@ var ye = class r2 {
5673
5671
  toString() {
5674
5672
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
5675
5673
  }
5676
- static parse(e, t = new W()) {
5677
- return new r2(e.split(t.fieldSeparator).map((n) => oe.parse(n, t)), t);
5674
+ static parse(e, t = new G()) {
5675
+ return new r2(e.split(t.fieldSeparator).map((n) => ae.parse(n, t)), t);
5678
5676
  }
5679
5677
  };
5680
- var oe = class r3 {
5681
- constructor(e, t = new W()) {
5678
+ var ae = class r3 {
5679
+ constructor(e, t = new G()) {
5682
5680
  this.context = t, this.components = e;
5683
5681
  }
5684
5682
  get(e, t, n = 0) {
@@ -5691,11 +5689,11 @@ var oe = class r3 {
5691
5689
  toString() {
5692
5690
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
5693
5691
  }
5694
- static parse(e, t = new W()) {
5692
+ static parse(e, t = new G()) {
5695
5693
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
5696
5694
  }
5697
5695
  };
5698
- function ho(r4) {
5696
+ function yo(r4) {
5699
5697
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
5700
5698
  return i2 > 0 && (n += "." + i2.toString()), n;
5701
5699
  }
@@ -5711,9 +5709,9 @@ var i = class extends EventTarget {
5711
5709
  super.removeEventListener(n, e, t);
5712
5710
  }
5713
5711
  };
5714
- var m2 = String.fromCharCode(11);
5715
- var p = String.fromCharCode(28);
5716
- var v2 = String.fromCharCode(13);
5712
+ var m2 = "\v";
5713
+ var p2 = "";
5714
+ var v2 = "\r";
5717
5715
  var d2 = class extends Event {
5718
5716
  constructor(e, t) {
5719
5717
  super("message");
@@ -5721,13 +5719,13 @@ var d2 = class extends Event {
5721
5719
  this.message = t;
5722
5720
  }
5723
5721
  };
5724
- var l2 = class extends Event {
5722
+ var l = class extends Event {
5725
5723
  constructor(e) {
5726
5724
  super("error");
5727
5725
  this.error = e;
5728
5726
  }
5729
5727
  };
5730
- var c = class extends i {
5728
+ var c2 = class extends i {
5731
5729
  constructor(e, t) {
5732
5730
  super();
5733
5731
  this.socket = e;
@@ -5735,19 +5733,19 @@ var c = class extends i {
5735
5733
  let o = "";
5736
5734
  e.on("data", (s) => {
5737
5735
  try {
5738
- if (o += s.toString(), o.endsWith(p + v2)) {
5739
- let r4 = un.parse(o.substring(1, o.length - 2));
5736
+ if (o += s.toString(), o.endsWith(p2 + v2)) {
5737
+ let r4 = dn.parse(o.substring(1, o.length - 2));
5740
5738
  this.dispatchEvent(new d2(this, r4)), o = "";
5741
5739
  }
5742
5740
  } catch (r4) {
5743
- this.dispatchEvent(new l2(r4));
5741
+ this.dispatchEvent(new l(r4));
5744
5742
  }
5745
5743
  }).setEncoding(t ?? "utf-8"), e.on("error", (s) => {
5746
- o = "", this.dispatchEvent(new l2(s));
5744
+ o = "", this.dispatchEvent(new l(s));
5747
5745
  });
5748
5746
  }
5749
5747
  send(e) {
5750
- this.socket.write(m2 + e.toString() + p + v2);
5748
+ this.socket.write(m2 + e.toString() + p2 + v2);
5751
5749
  }
5752
5750
  async sendAndWait(e) {
5753
5751
  let t = new Promise((o) => {
@@ -5770,7 +5768,7 @@ var h2 = class extends i {
5770
5768
  connect() {
5771
5769
  return this.connection ? Promise.resolve(this.connection) : new Promise((e) => {
5772
5770
  let t = (0, import_net.connect)({ host: this.host, port: this.port }, () => {
5773
- this.connection = new c(t), e(this.connection);
5771
+ this.connection = new c2(t), e(this.connection);
5774
5772
  });
5775
5773
  });
5776
5774
  }
@@ -5790,7 +5788,7 @@ var E2 = class {
5790
5788
  }
5791
5789
  start(n, e) {
5792
5790
  let t = import_net2.default.createServer((o) => {
5793
- let s = new c(o, e);
5791
+ let s = new c2(o, e);
5794
5792
  this.handler(s);
5795
5793
  });
5796
5794
  t.listen(n), this.server = t;
@@ -5808,7 +5806,65 @@ var import_websocket = __toESM(require_websocket(), 1);
5808
5806
  var import_websocket_server = __toESM(require_websocket_server(), 1);
5809
5807
  var wrapper_default = import_websocket.default;
5810
5808
 
5811
- // src/main.ts
5809
+ // src/hl7.ts
5810
+ var AgentHl7Channel = class {
5811
+ constructor(app, definition, endpoint) {
5812
+ this.app = app;
5813
+ this.definition = definition;
5814
+ this.endpoint = endpoint;
5815
+ this.connections = /* @__PURE__ */ new Map();
5816
+ this.server = new E2((connection) => this.handleNewConnection(connection));
5817
+ }
5818
+ start() {
5819
+ const address = new URL(this.endpoint.address);
5820
+ this.app.log.info(`Channel starting on ${address}`);
5821
+ this.server.start(parseInt(address.port, 10));
5822
+ this.app.log.info("Channel started successfully");
5823
+ }
5824
+ stop() {
5825
+ this.app.log.info("Channel stopping...");
5826
+ this.connections.forEach((connection) => connection.close());
5827
+ this.server.stop();
5828
+ this.app.log.info("Channel stopped successfully");
5829
+ }
5830
+ sendToRemote(msg) {
5831
+ const connection = this.connections.get(msg.remote);
5832
+ if (connection) {
5833
+ connection.hl7Connection.send(dn.parse(msg.body));
5834
+ }
5835
+ }
5836
+ handleNewConnection(connection) {
5837
+ const c3 = new AgentHl7ChannelConnection(this, connection);
5838
+ this.app.log.info(`HL7 connection established: ${c3.remote}`);
5839
+ this.connections.set(c3.remote, c3);
5840
+ }
5841
+ };
5842
+ var AgentHl7ChannelConnection = class {
5843
+ constructor(channel, hl7Connection) {
5844
+ this.channel = channel;
5845
+ this.hl7Connection = hl7Connection;
5846
+ this.remote = `${hl7Connection.socket.remoteAddress}:${hl7Connection.socket.remotePort}`;
5847
+ this.hl7Connection.addEventListener("message", (event) => this.handler(event));
5848
+ }
5849
+ async handler(event) {
5850
+ try {
5851
+ this.channel.app.log.info("Received:");
5852
+ this.channel.app.log.info(event.message.toString().replaceAll("\r", "\n"));
5853
+ this.channel.app.addToWebSocketQueue({
5854
+ channel: this.channel.definition.name,
5855
+ remote: this.remote,
5856
+ body: event.message.toString()
5857
+ });
5858
+ } catch (err) {
5859
+ this.channel.app.log.error(`HL7 error: ${Wn(err)}`);
5860
+ }
5861
+ }
5862
+ close() {
5863
+ this.hl7Connection.close();
5864
+ }
5865
+ };
5866
+
5867
+ // src/app.ts
5812
5868
  var App = class {
5813
5869
  constructor(medplum, agentId) {
5814
5870
  this.medplum = medplum;
@@ -5857,7 +5913,7 @@ var App = class {
5857
5913
  break;
5858
5914
  }
5859
5915
  } catch (err) {
5860
- this.log.error(`WebSocket error: ${Kn(err)}`);
5916
+ this.log.error(`WebSocket error: ${Wn(err)}`);
5861
5917
  }
5862
5918
  });
5863
5919
  }
@@ -5907,10 +5963,7 @@ var App = class {
5907
5963
  if (msg) {
5908
5964
  const channel = this.channels.get(msg.channel);
5909
5965
  if (channel) {
5910
- const connection = channel.connections.get(msg.remote);
5911
- if (connection) {
5912
- connection.hl7Connection.send(un.parse(msg.body));
5913
- }
5966
+ channel.sendToRemote(msg);
5914
5967
  }
5915
5968
  }
5916
5969
  }
@@ -5921,72 +5974,24 @@ var App = class {
5921
5974
  host: address.hostname,
5922
5975
  port: parseInt(address.port, 10)
5923
5976
  });
5924
- client.sendAndWait(un.parse(message.body)).then((response) => {
5977
+ client.sendAndWait(dn.parse(message.body)).then((response) => {
5925
5978
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
5926
5979
  }).catch((err) => {
5927
- this.log.error(`HL7 error: ${Kn(err)}`);
5980
+ this.log.error(`HL7 error: ${Wn(err)}`);
5928
5981
  }).finally(() => {
5929
5982
  client.close();
5930
5983
  });
5931
5984
  }
5932
5985
  };
5933
- var AgentHl7Channel = class {
5934
- constructor(app, definition, endpoint) {
5935
- this.app = app;
5936
- this.definition = definition;
5937
- this.endpoint = endpoint;
5938
- this.connections = /* @__PURE__ */ new Map();
5939
- this.server = new E2((connection) => this.handleNewConnection(connection));
5940
- }
5941
- start() {
5942
- const address = new URL(this.endpoint.address);
5943
- this.app.log.info(`Channel starting on ${address}`);
5944
- this.server.start(parseInt(address.port, 10));
5945
- this.app.log.info("Channel started successfully");
5946
- }
5947
- stop() {
5948
- this.app.log.info("Channel stopping...");
5949
- this.connections.forEach((connection) => connection.close());
5950
- this.server.stop();
5951
- this.app.log.info("Channel stopped successfully");
5952
- }
5953
- handleNewConnection(connection) {
5954
- const c2 = new AgentHl7ChannelConnection(this, connection);
5955
- this.app.log.info(`HL7 connection established: ${c2.remote}`);
5956
- this.connections.set(c2.remote, c2);
5957
- }
5958
- };
5959
- var AgentHl7ChannelConnection = class {
5960
- constructor(channel, hl7Connection) {
5961
- this.channel = channel;
5962
- this.hl7Connection = hl7Connection;
5963
- this.remote = `${hl7Connection.socket.remoteAddress}:${hl7Connection.socket.remotePort}`;
5964
- this.hl7Connection.addEventListener("message", (event) => this.handler(event));
5965
- }
5966
- async handler(event) {
5967
- try {
5968
- this.channel.app.log.info("Received:");
5969
- this.channel.app.log.info(event.message.toString().replaceAll("\r", "\n"));
5970
- this.channel.app.addToWebSocketQueue({
5971
- channel: this.channel.definition.name,
5972
- remote: this.remote,
5973
- body: event.message.toString()
5974
- });
5975
- } catch (err) {
5976
- this.channel.app.log.error(`HL7 error: ${Kn(err)}`);
5977
- }
5978
- }
5979
- close() {
5980
- this.hl7Connection.close();
5981
- }
5982
- };
5986
+
5987
+ // src/main.ts
5983
5988
  async function main(argv) {
5984
5989
  if (argv.length < 6) {
5985
5990
  console.log("Usage: node medplum-agent.js <baseUrl> <clientId> <clientSecret> <agentId>");
5986
5991
  process.exit(1);
5987
5992
  }
5988
5993
  const [_node, _script, baseUrl, clientId, clientSecret, agentId] = argv;
5989
- const medplum = new en({ baseUrl, clientId });
5994
+ const medplum = new rn({ baseUrl, clientId });
5990
5995
  await medplum.startClientLogin(clientId, clientSecret);
5991
5996
  const app = new App(medplum, agentId);
5992
5997
  await app.start();
@@ -5999,9 +6004,3 @@ async function main(argv) {
5999
6004
  if (typeof require !== "undefined" && require.main === module) {
6000
6005
  main(process.argv).catch(console.error);
6001
6006
  }
6002
- // Annotate the CommonJS export names for ESM import in node:
6003
- 0 && (module.exports = {
6004
- AgentHl7Channel,
6005
- AgentHl7ChannelConnection,
6006
- App
6007
- });