@medplum/agent 3.1.11 → 3.2.1

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 +639 -532
  2. package/package.json +6 -6
@@ -3767,10 +3767,14 @@ var require_stream = __commonJS({
3767
3767
  var require_constants = __commonJS({
3768
3768
  "../../node_modules/ws/lib/constants.js"(exports2, module2) {
3769
3769
  "use strict";
3770
+ var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
3771
+ var hasBlob = typeof Blob !== "undefined";
3772
+ if (hasBlob) BINARY_TYPES.push("blob");
3770
3773
  module2.exports = {
3771
- BINARY_TYPES: ["nodebuffer", "arraybuffer", "fragments"],
3774
+ BINARY_TYPES,
3772
3775
  EMPTY_BUFFER: Buffer.alloc(0),
3773
3776
  GUID: "258EAFA5-E914-47DA-95CA-C5AB0DC85B11",
3777
+ hasBlob,
3774
3778
  kForOnEventAttribute: Symbol("kIsForOnEventAttribute"),
3775
3779
  kListener: Symbol("kListener"),
3776
3780
  kStatusCode: Symbol("status-code"),
@@ -4290,6 +4294,7 @@ var require_validation = __commonJS({
4290
4294
  "../../node_modules/ws/lib/validation.js"(exports2, module2) {
4291
4295
  "use strict";
4292
4296
  var { isUtf8 } = require("buffer");
4297
+ var { hasBlob } = require_constants();
4293
4298
  var tokenChars = [
4294
4299
  0,
4295
4300
  0,
@@ -4460,7 +4465,11 @@ var require_validation = __commonJS({
4460
4465
  }
4461
4466
  return true;
4462
4467
  }
4468
+ function isBlob(value) {
4469
+ return hasBlob && typeof value === "object" && typeof value.arrayBuffer === "function" && typeof value.type === "string" && typeof value.stream === "function" && (value[Symbol.toStringTag] === "Blob" || value[Symbol.toStringTag] === "File");
4470
+ }
4463
4471
  module2.exports = {
4472
+ isBlob,
4464
4473
  isValidStatusCode,
4465
4474
  isValidUTF8: _isValidUTF8,
4466
4475
  tokenChars
@@ -4942,6 +4951,8 @@ var require_receiver = __commonJS({
4942
4951
  data2 = concat(fragments, messageLength);
4943
4952
  } else if (this._binaryType === "arraybuffer") {
4944
4953
  data2 = toArrayBuffer(concat(fragments, messageLength));
4954
+ } else if (this._binaryType === "blob") {
4955
+ data2 = new Blob(fragments);
4945
4956
  } else {
4946
4957
  data2 = fragments;
4947
4958
  }
@@ -5078,14 +5089,17 @@ var require_sender = __commonJS({
5078
5089
  var { Duplex } = require("stream");
5079
5090
  var { randomFillSync } = require("crypto");
5080
5091
  var PerMessageDeflate = require_permessage_deflate();
5081
- var { EMPTY_BUFFER } = require_constants();
5082
- var { isValidStatusCode } = require_validation();
5092
+ var { EMPTY_BUFFER, kWebSocket, NOOP } = require_constants();
5093
+ var { isBlob, isValidStatusCode } = require_validation();
5083
5094
  var { mask: applyMask, toBuffer } = require_buffer_util();
5084
5095
  var kByteLength = Symbol("kByteLength");
5085
5096
  var maskBuffer = Buffer.alloc(4);
5086
5097
  var RANDOM_POOL_SIZE = 8 * 1024;
5087
5098
  var randomPool;
5088
5099
  var randomPoolPointer = RANDOM_POOL_SIZE;
5100
+ var DEFAULT = 0;
5101
+ var DEFLATING = 1;
5102
+ var GET_BLOB_DATA = 2;
5089
5103
  var Sender2 = class _Sender {
5090
5104
  /**
5091
5105
  * Creates a Sender instance.
@@ -5105,8 +5119,10 @@ var require_sender = __commonJS({
5105
5119
  this._firstFragment = true;
5106
5120
  this._compress = false;
5107
5121
  this._bufferedBytes = 0;
5108
- this._deflating = false;
5109
5122
  this._queue = [];
5123
+ this._state = DEFAULT;
5124
+ this.onerror = NOOP;
5125
+ this[kWebSocket] = void 0;
5110
5126
  }
5111
5127
  /**
5112
5128
  * Frames a piece of data according to the HyBi WebSocket protocol.
@@ -5239,7 +5255,7 @@ var require_sender = __commonJS({
5239
5255
  readOnly: false,
5240
5256
  rsv1: false
5241
5257
  };
5242
- if (this._deflating) {
5258
+ if (this._state !== DEFAULT) {
5243
5259
  this.enqueue([this.dispatch, buf, false, options, cb]);
5244
5260
  } else {
5245
5261
  this.sendFrame(_Sender.frame(buf, options), cb);
@@ -5259,6 +5275,9 @@ var require_sender = __commonJS({
5259
5275
  if (typeof data2 === "string") {
5260
5276
  byteLength = Buffer.byteLength(data2);
5261
5277
  readOnly = false;
5278
+ } else if (isBlob(data2)) {
5279
+ byteLength = data2.size;
5280
+ readOnly = false;
5262
5281
  } else {
5263
5282
  data2 = toBuffer(data2);
5264
5283
  byteLength = data2.length;
@@ -5277,7 +5296,13 @@ var require_sender = __commonJS({
5277
5296
  readOnly,
5278
5297
  rsv1: false
5279
5298
  };
5280
- if (this._deflating) {
5299
+ if (isBlob(data2)) {
5300
+ if (this._state !== DEFAULT) {
5301
+ this.enqueue([this.getBlobData, data2, false, options, cb]);
5302
+ } else {
5303
+ this.getBlobData(data2, false, options, cb);
5304
+ }
5305
+ } else if (this._state !== DEFAULT) {
5281
5306
  this.enqueue([this.dispatch, data2, false, options, cb]);
5282
5307
  } else {
5283
5308
  this.sendFrame(_Sender.frame(data2, options), cb);
@@ -5297,6 +5322,9 @@ var require_sender = __commonJS({
5297
5322
  if (typeof data2 === "string") {
5298
5323
  byteLength = Buffer.byteLength(data2);
5299
5324
  readOnly = false;
5325
+ } else if (isBlob(data2)) {
5326
+ byteLength = data2.size;
5327
+ readOnly = false;
5300
5328
  } else {
5301
5329
  data2 = toBuffer(data2);
5302
5330
  byteLength = data2.length;
@@ -5315,7 +5343,13 @@ var require_sender = __commonJS({
5315
5343
  readOnly,
5316
5344
  rsv1: false
5317
5345
  };
5318
- if (this._deflating) {
5346
+ if (isBlob(data2)) {
5347
+ if (this._state !== DEFAULT) {
5348
+ this.enqueue([this.getBlobData, data2, false, options, cb]);
5349
+ } else {
5350
+ this.getBlobData(data2, false, options, cb);
5351
+ }
5352
+ } else if (this._state !== DEFAULT) {
5319
5353
  this.enqueue([this.dispatch, data2, false, options, cb]);
5320
5354
  } else {
5321
5355
  this.sendFrame(_Sender.frame(data2, options), cb);
@@ -5346,6 +5380,9 @@ var require_sender = __commonJS({
5346
5380
  if (typeof data2 === "string") {
5347
5381
  byteLength = Buffer.byteLength(data2);
5348
5382
  readOnly = false;
5383
+ } else if (isBlob(data2)) {
5384
+ byteLength = data2.size;
5385
+ readOnly = false;
5349
5386
  } else {
5350
5387
  data2 = toBuffer(data2);
5351
5388
  byteLength = data2.length;
@@ -5362,38 +5399,75 @@ var require_sender = __commonJS({
5362
5399
  opcode = 0;
5363
5400
  }
5364
5401
  if (options.fin) this._firstFragment = true;
5365
- if (perMessageDeflate) {
5366
- const opts = {
5367
- [kByteLength]: byteLength,
5368
- fin: options.fin,
5369
- generateMask: this._generateMask,
5370
- mask: options.mask,
5371
- maskBuffer: this._maskBuffer,
5372
- opcode,
5373
- readOnly,
5374
- rsv1
5375
- };
5376
- if (this._deflating) {
5377
- this.enqueue([this.dispatch, data2, this._compress, opts, cb]);
5402
+ const opts = {
5403
+ [kByteLength]: byteLength,
5404
+ fin: options.fin,
5405
+ generateMask: this._generateMask,
5406
+ mask: options.mask,
5407
+ maskBuffer: this._maskBuffer,
5408
+ opcode,
5409
+ readOnly,
5410
+ rsv1
5411
+ };
5412
+ if (isBlob(data2)) {
5413
+ if (this._state !== DEFAULT) {
5414
+ this.enqueue([this.getBlobData, data2, this._compress, opts, cb]);
5378
5415
  } else {
5379
- this.dispatch(data2, this._compress, opts, cb);
5416
+ this.getBlobData(data2, this._compress, opts, cb);
5380
5417
  }
5418
+ } else if (this._state !== DEFAULT) {
5419
+ this.enqueue([this.dispatch, data2, this._compress, opts, cb]);
5381
5420
  } else {
5382
- this.sendFrame(
5383
- _Sender.frame(data2, {
5384
- [kByteLength]: byteLength,
5385
- fin: options.fin,
5386
- generateMask: this._generateMask,
5387
- mask: options.mask,
5388
- maskBuffer: this._maskBuffer,
5389
- opcode,
5390
- readOnly,
5391
- rsv1: false
5392
- }),
5393
- cb
5394
- );
5421
+ this.dispatch(data2, this._compress, opts, cb);
5395
5422
  }
5396
5423
  }
5424
+ /**
5425
+ * Gets the contents of a blob as binary data.
5426
+ *
5427
+ * @param {Blob} blob The blob
5428
+ * @param {Boolean} [compress=false] Specifies whether or not to compress
5429
+ * the data
5430
+ * @param {Object} options Options object
5431
+ * @param {Boolean} [options.fin=false] Specifies whether or not to set the
5432
+ * FIN bit
5433
+ * @param {Function} [options.generateMask] The function used to generate the
5434
+ * masking key
5435
+ * @param {Boolean} [options.mask=false] Specifies whether or not to mask
5436
+ * `data`
5437
+ * @param {Buffer} [options.maskBuffer] The buffer used to store the masking
5438
+ * key
5439
+ * @param {Number} options.opcode The opcode
5440
+ * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
5441
+ * modified
5442
+ * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
5443
+ * RSV1 bit
5444
+ * @param {Function} [cb] Callback
5445
+ * @private
5446
+ */
5447
+ getBlobData(blob, compress, options, cb) {
5448
+ this._bufferedBytes += options[kByteLength];
5449
+ this._state = GET_BLOB_DATA;
5450
+ blob.arrayBuffer().then((arrayBuffer) => {
5451
+ if (this._socket.destroyed) {
5452
+ const err = new Error(
5453
+ "The socket was closed while the blob was being read"
5454
+ );
5455
+ process.nextTick(callCallbacks, this, err, cb);
5456
+ return;
5457
+ }
5458
+ this._bufferedBytes -= options[kByteLength];
5459
+ const data2 = toBuffer(arrayBuffer);
5460
+ if (!compress) {
5461
+ this._state = DEFAULT;
5462
+ this.sendFrame(_Sender.frame(data2, options), cb);
5463
+ this.dequeue();
5464
+ } else {
5465
+ this.dispatch(data2, compress, options, cb);
5466
+ }
5467
+ }).catch((err) => {
5468
+ process.nextTick(onError, this, err, cb);
5469
+ });
5470
+ }
5397
5471
  /**
5398
5472
  * Dispatches a message.
5399
5473
  *
@@ -5424,22 +5498,17 @@ var require_sender = __commonJS({
5424
5498
  }
5425
5499
  const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName];
5426
5500
  this._bufferedBytes += options[kByteLength];
5427
- this._deflating = true;
5501
+ this._state = DEFLATING;
5428
5502
  perMessageDeflate.compress(data2, options.fin, (_2, buf) => {
5429
5503
  if (this._socket.destroyed) {
5430
5504
  const err = new Error(
5431
5505
  "The socket was closed while data was being compressed"
5432
5506
  );
5433
- if (typeof cb === "function") cb(err);
5434
- for (let i = 0; i < this._queue.length; i++) {
5435
- const params = this._queue[i];
5436
- const callback = params[params.length - 1];
5437
- if (typeof callback === "function") callback(err);
5438
- }
5507
+ callCallbacks(this, err, cb);
5439
5508
  return;
5440
5509
  }
5441
5510
  this._bufferedBytes -= options[kByteLength];
5442
- this._deflating = false;
5511
+ this._state = DEFAULT;
5443
5512
  options.readOnly = false;
5444
5513
  this.sendFrame(_Sender.frame(buf, options), cb);
5445
5514
  this.dequeue();
@@ -5451,7 +5520,7 @@ var require_sender = __commonJS({
5451
5520
  * @private
5452
5521
  */
5453
5522
  dequeue() {
5454
- while (!this._deflating && this._queue.length) {
5523
+ while (this._state === DEFAULT && this._queue.length) {
5455
5524
  const params = this._queue.shift();
5456
5525
  this._bufferedBytes -= params[3][kByteLength];
5457
5526
  Reflect.apply(params[0], this, params.slice(1));
@@ -5486,6 +5555,18 @@ var require_sender = __commonJS({
5486
5555
  }
5487
5556
  };
5488
5557
  module2.exports = Sender2;
5558
+ function callCallbacks(sender, err, cb) {
5559
+ if (typeof cb === "function") cb(err);
5560
+ for (let i = 0; i < sender._queue.length; i++) {
5561
+ const params = sender._queue[i];
5562
+ const callback = params[params.length - 1];
5563
+ if (typeof callback === "function") callback(err);
5564
+ }
5565
+ }
5566
+ function onError(sender, err, cb) {
5567
+ callCallbacks(sender, err, cb);
5568
+ sender.onerror(err);
5569
+ }
5489
5570
  }
5490
5571
  });
5491
5572
 
@@ -5886,6 +5967,7 @@ var require_websocket = __commonJS({
5886
5967
  var PerMessageDeflate = require_permessage_deflate();
5887
5968
  var Receiver2 = require_receiver();
5888
5969
  var Sender2 = require_sender();
5970
+ var { isBlob } = require_validation();
5889
5971
  var {
5890
5972
  BINARY_TYPES,
5891
5973
  EMPTY_BUFFER,
@@ -5922,6 +6004,7 @@ var require_websocket = __commonJS({
5922
6004
  this._closeFrameSent = false;
5923
6005
  this._closeMessage = EMPTY_BUFFER;
5924
6006
  this._closeTimer = null;
6007
+ this._errorEmitted = false;
5925
6008
  this._extensions = {};
5926
6009
  this._paused = false;
5927
6010
  this._protocol = "";
@@ -5950,9 +6033,8 @@ var require_websocket = __commonJS({
5950
6033
  }
5951
6034
  }
5952
6035
  /**
5953
- * This deviates from the WHATWG interface since ws doesn't support the
5954
- * required default "blob" type (instead we define a custom "nodebuffer"
5955
- * type).
6036
+ * For historical reasons, the custom "nodebuffer" type is used by the default
6037
+ * instead of "blob".
5956
6038
  *
5957
6039
  * @type {String}
5958
6040
  */
@@ -6054,10 +6136,12 @@ var require_websocket = __commonJS({
6054
6136
  maxPayload: options.maxPayload,
6055
6137
  skipUTF8Validation: options.skipUTF8Validation
6056
6138
  });
6057
- this._sender = new Sender2(socket, this._extensions, options.generateMask);
6139
+ const sender = new Sender2(socket, this._extensions, options.generateMask);
6058
6140
  this._receiver = receiver;
6141
+ this._sender = sender;
6059
6142
  this._socket = socket;
6060
6143
  receiver[kWebSocket] = this;
6144
+ sender[kWebSocket] = this;
6061
6145
  socket[kWebSocket] = this;
6062
6146
  receiver.on("conclude", receiverOnConclude);
6063
6147
  receiver.on("drain", receiverOnDrain);
@@ -6065,6 +6149,7 @@ var require_websocket = __commonJS({
6065
6149
  receiver.on("message", receiverOnMessage);
6066
6150
  receiver.on("ping", receiverOnPing);
6067
6151
  receiver.on("pong", receiverOnPong);
6152
+ sender.onerror = senderOnError;
6068
6153
  if (socket.setTimeout) socket.setTimeout(0);
6069
6154
  if (socket.setNoDelay) socket.setNoDelay();
6070
6155
  if (head.length > 0) socket.unshift(head);
@@ -6134,10 +6219,7 @@ var require_websocket = __commonJS({
6134
6219
  this._socket.end();
6135
6220
  }
6136
6221
  });
6137
- this._closeTimer = setTimeout(
6138
- this._socket.destroy.bind(this._socket),
6139
- closeTimeout
6140
- );
6222
+ setCloseTimer(this);
6141
6223
  }
6142
6224
  /**
6143
6225
  * Pause the socket.
@@ -6602,6 +6684,7 @@ var require_websocket = __commonJS({
6602
6684
  }
6603
6685
  function emitErrorAndClose(websocket, err) {
6604
6686
  websocket._readyState = WebSocket3.CLOSING;
6687
+ websocket._errorEmitted = true;
6605
6688
  websocket.emit("error", err);
6606
6689
  websocket.emitClose();
6607
6690
  }
@@ -6635,7 +6718,7 @@ var require_websocket = __commonJS({
6635
6718
  }
6636
6719
  function sendAfterClose(websocket, data2, cb) {
6637
6720
  if (data2) {
6638
- const length = toBuffer(data2).length;
6721
+ const length = isBlob(data2) ? data2.size : toBuffer(data2).length;
6639
6722
  if (websocket._socket) websocket._sender._bufferedBytes += length;
6640
6723
  else websocket._bufferedAmount += length;
6641
6724
  }
@@ -6668,7 +6751,10 @@ var require_websocket = __commonJS({
6668
6751
  process.nextTick(resume, websocket._socket);
6669
6752
  websocket.close(err[kStatusCode]);
6670
6753
  }
6671
- websocket.emit("error", err);
6754
+ if (!websocket._errorEmitted) {
6755
+ websocket._errorEmitted = true;
6756
+ websocket.emit("error", err);
6757
+ }
6672
6758
  }
6673
6759
  function receiverOnFinish() {
6674
6760
  this[kWebSocket].emitClose();
@@ -6687,6 +6773,25 @@ var require_websocket = __commonJS({
6687
6773
  function resume(stream) {
6688
6774
  stream.resume();
6689
6775
  }
6776
+ function senderOnError(err) {
6777
+ const websocket = this[kWebSocket];
6778
+ if (websocket.readyState === WebSocket3.CLOSED) return;
6779
+ if (websocket.readyState === WebSocket3.OPEN) {
6780
+ websocket._readyState = WebSocket3.CLOSING;
6781
+ setCloseTimer(websocket);
6782
+ }
6783
+ this._socket.end();
6784
+ if (!websocket._errorEmitted) {
6785
+ websocket._errorEmitted = true;
6786
+ websocket.emit("error", err);
6787
+ }
6788
+ }
6789
+ function setCloseTimer(websocket) {
6790
+ websocket._closeTimer = setTimeout(
6791
+ websocket._socket.destroy.bind(websocket._socket),
6792
+ closeTimeout
6793
+ );
6794
+ }
6690
6795
  function socketOnClose() {
6691
6796
  const websocket = this[kWebSocket];
6692
6797
  this.removeListener("close", socketOnClose);
@@ -7660,11 +7765,11 @@ var require_dcmjs = __commonJS({
7660
7765
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
7661
7766
  if (_i == null) return;
7662
7767
  var _arr = [];
7663
- var _n = true;
7768
+ var _n2 = true;
7664
7769
  var _d = false;
7665
7770
  var _s2, _e2;
7666
7771
  try {
7667
- for (_i = _i.call(arr); !(_n = (_s2 = _i.next()).done); _n = true) {
7772
+ for (_i = _i.call(arr); !(_n2 = (_s2 = _i.next()).done); _n2 = true) {
7668
7773
  _arr.push(_s2.value);
7669
7774
  if (i && _arr.length === i) break;
7670
7775
  }
@@ -7673,7 +7778,7 @@ var require_dcmjs = __commonJS({
7673
7778
  _e2 = err2;
7674
7779
  } finally {
7675
7780
  try {
7676
- if (!_n && _i["return"] != null) _i["return"]();
7781
+ if (!_n2 && _i["return"] != null) _i["return"]();
7677
7782
  } finally {
7678
7783
  if (_d) throw _e2;
7679
7784
  }
@@ -13402,10 +13507,10 @@ var require_dcmjs = __commonJS({
13402
13507
  while (1) {
13403
13508
  var g = stream.readUint16();
13404
13509
  if (g == 65534) {
13405
- var ge2 = stream.readUint16();
13510
+ var ge = stream.readUint16();
13406
13511
  var itemLength = stream.readUint32();
13407
13512
  stream.increment(-4);
13408
- if (ge2 == 57357) {
13513
+ if (ge == 57357) {
13409
13514
  if (itemLength === 0) {
13410
13515
  stack--;
13411
13516
  if (stack < 0) {
@@ -13418,7 +13523,7 @@ var require_dcmjs = __commonJS({
13418
13523
  } else {
13419
13524
  toRead += 2;
13420
13525
  }
13421
- } else if (ge2 == 57344) {
13526
+ } else if (ge == 57344) {
13422
13527
  toRead += 4;
13423
13528
  if (itemLength == 4294967295) {
13424
13529
  stack++;
@@ -14679,12 +14784,12 @@ var require_dcmjs = __commonJS({
14679
14784
  value: function xyz2LAB(xyz) {
14680
14785
  var whitePoint = Colors2.d65WhitePointXYZ();
14681
14786
  var X2 = xyz[0] / whitePoint[0];
14682
- var Y = xyz[1] / whitePoint[1];
14683
- var Z2 = xyz[2] / whitePoint[2];
14787
+ var Y2 = xyz[1] / whitePoint[1];
14788
+ var Z = xyz[2] / whitePoint[2];
14684
14789
  X2 = Colors2.labf(X2);
14685
- Y = Colors2.labf(Y);
14686
- Z2 = Colors2.labf(Z2);
14687
- return [116 * Y - 16, 500 * (X2 - Y), 200 * (Y - Z2)];
14790
+ Y2 = Colors2.labf(Y2);
14791
+ Z = Colors2.labf(Z);
14792
+ return [116 * Y2 - 16, 500 * (X2 - Y2), 200 * (Y2 - Z)];
14688
14793
  }
14689
14794
  }, {
14690
14795
  key: "lab2RGB",
@@ -31936,9 +32041,9 @@ var require_stream_readable = __commonJS({
31936
32041
  return from(Readable2, iterable, opts);
31937
32042
  };
31938
32043
  }
31939
- function indexOf(xs, x3) {
31940
- for (var i = 0, l3 = xs.length; i < l3; i++) {
31941
- if (xs[i] === x3) return i;
32044
+ function indexOf(xs2, x3) {
32045
+ for (var i = 0, l3 = xs2.length; i < l3; i++) {
32046
+ if (xs2[i] === x3) return i;
31942
32047
  }
31943
32048
  return -1;
31944
32049
  }
@@ -35479,9 +35584,9 @@ var require_stream_readable2 = __commonJS({
35479
35584
  return from(Readable2, iterable, opts);
35480
35585
  };
35481
35586
  }
35482
- function indexOf(xs, x3) {
35483
- for (var i = 0, l3 = xs.length; i < l3; i++) {
35484
- if (xs[i] === x3) return i;
35587
+ function indexOf(xs2, x3) {
35588
+ for (var i = 0, l3 = xs2.length; i < l3; i++) {
35589
+ if (xs2[i] === x3) return i;
35485
35590
  }
35486
35591
  return -1;
35487
35592
  }
@@ -36799,11 +36904,11 @@ var require_conversions = __commonJS({
36799
36904
  var l3 = lab[0];
36800
36905
  var a2 = lab[1];
36801
36906
  var b3 = lab[2];
36802
- var hr2;
36907
+ var hr;
36803
36908
  var h2;
36804
36909
  var c;
36805
- hr2 = Math.atan2(b3, a2);
36806
- h2 = hr2 * 360 / 2 / Math.PI;
36910
+ hr = Math.atan2(b3, a2);
36911
+ h2 = hr * 360 / 2 / Math.PI;
36807
36912
  if (h2 < 0) {
36808
36913
  h2 += 360;
36809
36914
  }
@@ -36816,10 +36921,10 @@ var require_conversions = __commonJS({
36816
36921
  var h2 = lch[2];
36817
36922
  var a2;
36818
36923
  var b3;
36819
- var hr2;
36820
- hr2 = h2 / 360 * 2 * Math.PI;
36821
- a2 = c * Math.cos(hr2);
36822
- b3 = c * Math.sin(hr2);
36924
+ var hr;
36925
+ hr = h2 / 360 * 2 * Math.PI;
36926
+ a2 = c * Math.cos(hr);
36927
+ b3 = c * Math.sin(hr);
36823
36928
  return [l3, a2, b3];
36824
36929
  };
36825
36930
  convert.rgb.ansi16 = function(args) {
@@ -41399,7 +41504,7 @@ var require_dcmjs_dimse_min = __commonJS({
41399
41504
  };
41400
41505
  }, 371: (e2, t2, s2) => {
41401
41506
  const { Association: n2 } = s2(570), { AAbort: i2, AAssociateAC: r7, AAssociateRJ: o2, AAssociateRQ: a2, AReleaseRP: c, AReleaseRQ: d3, PDataTF: u2, Pdv: h2, RawPdu: m2 } = s2(942), { CommandFieldType: g, Status: l3, TranscodableTransferSyntaxes: p2 } = s2(492), { CCancelRequest: R2, CEchoRequest: f2, CEchoResponse: y2, CFindRequest: S2, CFindResponse: I2, CGetRequest: C2, CGetResponse: P2, CMoveRequest: v, CMoveResponse: x3, Command: w3, CStoreRequest: A, CStoreResponse: U2, NActionRequest: q, NActionResponse: D2, NCreateRequest: E, NCreateResponse: T, NDeleteRequest: O2, NDeleteResponse: b3, NEventReportRequest: N2, NEventReportResponse: B2, NGetRequest: M3, NGetResponse: L2, NSetRequest: F2, NSetResponse: k2, Response: $2 } = s2(940), j2 = s2(825), V2 = s2(139), G = s2(906), _2 = s2(547), { SmartBuffer: z2 } = s2(766), { EOL: Q2 } = s2(857), W2 = s2(733);
41402
- class J2 extends W2 {
41507
+ class J extends W2 {
41403
41508
  constructor() {
41404
41509
  super();
41405
41510
  }
@@ -41705,7 +41810,7 @@ var require_dcmjs_dimse_min = __commonJS({
41705
41810
  this.socket.setTimeout(this.connectTimeout), this.socket.on("connect", () => {
41706
41811
  this.connected = true, this.connectedTime = Date.now(), this.emit("connect");
41707
41812
  });
41708
- const e3 = new J2();
41813
+ const e3 = new J();
41709
41814
  e3.on("pdu", (e4) => {
41710
41815
  this.lastPduTime = Date.now(), this._processPdu(e4);
41711
41816
  }), this.socket.on("data", (t3) => {
@@ -42301,8 +42406,8 @@ var require_dcmjs_dimse_min = __commonJS({
42301
42406
  }
42302
42407
  };
42303
42408
  }, 237: (e2, t2, s2) => {
42304
- const { Association: n2, PresentationContext: i2 } = s2(570), { Scp: r7, Server: o2 } = s2(538), { CCancelRequest: a2, CEchoRequest: c, CEchoResponse: d3, CFindRequest: u2, CFindResponse: h2, CGetRequest: m2, CGetResponse: g, CMoveRequest: l3, CMoveResponse: p2, CStoreRequest: R2, CStoreResponse: f2, NActionRequest: y2, NActionResponse: S2, NCreateRequest: I2, NCreateResponse: C2, NDeleteRequest: P2, NDeleteResponse: v, NEventReportRequest: x3, NEventReportResponse: w3, NGetRequest: A, NGetResponse: U2, NSetRequest: q, NSetResponse: D2 } = s2(940), { AbortReason: E, AbortSource: T, CommandFieldType: O2, PresentationContextResult: b3, Priority: N2, RejectReason: B2, RejectResult: M3, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G } = s2(492), _2 = s2(422), z2 = s2(825), Q2 = s2(139), W2 = s2(906), J2 = { association: { Association: n2, PresentationContext: i2 }, Client: _2, constants: { AbortReason: E, AbortSource: T, CommandFieldType: O2, PresentationContextResult: b3, Priority: N2, RejectReason: B2, RejectResult: M3, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G }, Dataset: z2, Implementation: Q2, log: s2(547), requests: { CCancelRequest: a2, CEchoRequest: c, CFindRequest: u2, CGetRequest: m2, CMoveRequest: l3, CStoreRequest: R2, NActionRequest: y2, NCreateRequest: I2, NDeleteRequest: P2, NEventReportRequest: x3, NGetRequest: A, NSetRequest: q }, responses: { CEchoResponse: d3, CFindResponse: h2, CGetResponse: g, CMoveResponse: p2, CStoreResponse: f2, NActionResponse: S2, NCreateResponse: C2, NDeleteResponse: v, NEventReportResponse: w3, NGetResponse: U2, NSetResponse: D2 }, Scp: r7, Server: o2, Statistics: W2, version: s2(837) };
42305
- e2.exports = J2;
42409
+ const { Association: n2, PresentationContext: i2 } = s2(570), { Scp: r7, Server: o2 } = s2(538), { CCancelRequest: a2, CEchoRequest: c, CEchoResponse: d3, CFindRequest: u2, CFindResponse: h2, CGetRequest: m2, CGetResponse: g, CMoveRequest: l3, CMoveResponse: p2, CStoreRequest: R2, CStoreResponse: f2, NActionRequest: y2, NActionResponse: S2, NCreateRequest: I2, NCreateResponse: C2, NDeleteRequest: P2, NDeleteResponse: v, NEventReportRequest: x3, NEventReportResponse: w3, NGetRequest: A, NGetResponse: U2, NSetRequest: q, NSetResponse: D2 } = s2(940), { AbortReason: E, AbortSource: T, CommandFieldType: O2, PresentationContextResult: b3, Priority: N2, RejectReason: B2, RejectResult: M3, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G } = s2(492), _2 = s2(422), z2 = s2(825), Q2 = s2(139), W2 = s2(906), J = { association: { Association: n2, PresentationContext: i2 }, Client: _2, constants: { AbortReason: E, AbortSource: T, CommandFieldType: O2, PresentationContextResult: b3, Priority: N2, RejectReason: B2, RejectResult: M3, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G }, Dataset: z2, Implementation: Q2, log: s2(547), requests: { CCancelRequest: a2, CEchoRequest: c, CFindRequest: u2, CGetRequest: m2, CMoveRequest: l3, CStoreRequest: R2, NActionRequest: y2, NCreateRequest: I2, NDeleteRequest: P2, NEventReportRequest: x3, NGetRequest: A, NSetRequest: q }, responses: { CEchoResponse: d3, CFindResponse: h2, CGetResponse: g, CMoveResponse: p2, CStoreResponse: f2, NActionResponse: S2, NCreateResponse: C2, NDeleteResponse: v, NEventReportResponse: w3, NGetResponse: U2, NSetResponse: D2 }, Scp: r7, Server: o2, Statistics: W2, version: s2(837) };
42410
+ e2.exports = J;
42306
42411
  }, 547: (e2, t2, s2) => {
42307
42412
  const { createLogger: n2, format: i2, transports: r7 } = s2(688), { combine: o2, printf: a2, timestamp: c } = i2, d3 = n2({ format: o2(c(), a2(({ level: e3, message: t3, timestamp: s3 }) => `${s3} -- ${e3.toUpperCase()} -- ${t3}`)), transports: [new r7.Console()] });
42308
42413
  e2.exports = d3;
@@ -42363,7 +42468,7 @@ var Ge = class {
42363
42468
  return `${this.operator}(${this.child.toString()})`;
42364
42469
  }
42365
42470
  };
42366
- var J = class {
42471
+ var Y = class {
42367
42472
  constructor(e, t, n) {
42368
42473
  this.operator = e;
42369
42474
  this.left = t;
@@ -42397,10 +42502,10 @@ var He = class {
42397
42502
  }, precedence: t });
42398
42503
  }
42399
42504
  construct(e) {
42400
- return new Lt(e, this.prefixParselets, this.infixParselets);
42505
+ return new Ut(e, this.prefixParselets, this.infixParselets);
42401
42506
  }
42402
42507
  };
42403
- var Lt = class {
42508
+ var Ut = class {
42404
42509
  constructor(e, t, n) {
42405
42510
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
42406
42511
  }
@@ -42448,91 +42553,91 @@ var Lt = class {
42448
42553
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
42449
42554
  }
42450
42555
  };
42451
- var _t = "ok";
42556
+ var Bt = "ok";
42452
42557
  var Qe = "created";
42453
- var Bt = "not-modified";
42454
- var qt = "not-found";
42558
+ var jt = "not-modified";
42559
+ var $t = "not-found";
42455
42560
  var Ke = "accepted";
42456
- var Hr = { resourceType: "OperationOutcome", id: qt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
42561
+ var Kr = { resourceType: "OperationOutcome", id: $t, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
42457
42562
  function R(r6, e) {
42458
42563
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r6 }, ...e ? { expression: [e] } : void 0 }] };
42459
42564
  }
42460
42565
  function h(r6) {
42461
42566
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r6 } }] };
42462
42567
  }
42463
- function Qr(r6) {
42568
+ function zr(r6) {
42464
42569
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "exception", details: { text: "Internal server error" }, diagnostics: r6.toString() }] };
42465
42570
  }
42466
- function ge(r6) {
42571
+ function xe(r6) {
42467
42572
  return typeof r6 == "object" && r6 !== null && r6.resourceType === "OperationOutcome";
42468
42573
  }
42469
- function jt(r6) {
42470
- return r6.id === _t || r6.id === Qe || r6.id === Bt || r6.id === Ke;
42574
+ function Wt(r6) {
42575
+ return r6.id === Bt || r6.id === Qe || r6.id === jt || r6.id === Ke;
42471
42576
  }
42472
42577
  var f = class extends Error {
42473
42578
  constructor(e, t) {
42474
- super(Kr(e)), this.outcome = e, this.cause = t;
42579
+ super(Jr(e)), this.outcome = e, this.cause = t;
42475
42580
  }
42476
42581
  };
42477
42582
  function ze(r6) {
42478
- return r6 instanceof f ? r6.outcome : ge(r6) ? r6 : R(Ci(r6));
42583
+ return r6 instanceof f ? r6.outcome : xe(r6) ? r6 : R(Oi(r6));
42479
42584
  }
42480
- function Ci(r6) {
42481
- return r6 ? typeof r6 == "string" ? r6 : r6 instanceof Error ? r6.message : ge(r6) ? Kr(r6) : typeof r6 == "object" && "code" in r6 && typeof r6.code == "string" ? r6.code : JSON.stringify(r6) : "Unknown error";
42585
+ function Oi(r6) {
42586
+ return r6 ? typeof r6 == "string" ? r6 : r6 instanceof Error ? r6.message : xe(r6) ? Jr(r6) : typeof r6 == "object" && "code" in r6 && typeof r6.code == "string" ? r6.code : JSON.stringify(r6) : "Unknown error";
42482
42587
  }
42483
- function Kr(r6) {
42484
- let e = r6.issue?.map(wi) ?? [];
42588
+ function Jr(r6) {
42589
+ let e = r6.issue?.map(Ii) ?? [];
42485
42590
  return e.length > 0 ? e.join("; ") : "Unknown error";
42486
42591
  }
42487
- function wi(r6) {
42592
+ function Ii(r6) {
42488
42593
  let e;
42489
42594
  return r6.details?.text ? r6.diagnostics ? e = `${r6.details.text} (${r6.diagnostics})` : e = r6.details.text : r6.diagnostics ? e = r6.diagnostics : e = "Unknown error", r6.expression?.length && (e += ` (${r6.expression.join(", ")})`), e;
42490
42595
  }
42491
- function Oi(r6, e) {
42596
+ function Vi(r6, e) {
42492
42597
  let t = e.max && e.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : e.max;
42493
42598
  return { path: r6, description: "", type: e.type ?? [], min: e.min ?? 0, max: t ?? 1, isArray: !!t && t > 1, constraints: [] };
42494
42599
  }
42495
- function Yr(r6) {
42600
+ function Xr(r6) {
42496
42601
  let e = /* @__PURE__ */ Object.create(null);
42497
- for (let [t, n] of Object.entries(r6)) e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i, o]) => [i, Oi(i, o)])), constraints: [], innerTypes: [] };
42602
+ for (let [t, n] of Object.entries(r6)) e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i, o]) => [i, Vi(i, o)])), constraints: [], innerTypes: [] };
42498
42603
  return e;
42499
42604
  }
42500
- var Zr = { 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "uri" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, 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" }] } } }, 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" }] } } } };
42501
- function Qt(r6) {
42502
- return new Gt(r6).parse();
42605
+ var en = { 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", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "uri" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, onBehalfOf: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, 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" }] } } }, 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" }] } } } };
42606
+ function zt(r6) {
42607
+ return new Qt(r6).parse();
42503
42608
  }
42504
- var ke = Yr(Zr);
42505
- var Kt = /* @__PURE__ */ Object.create(null);
42506
- var Xr = /* @__PURE__ */ Object.create(null);
42507
- function Wt(r6) {
42609
+ var ke = Xr(en);
42610
+ var Jt = /* @__PURE__ */ Object.create(null);
42611
+ var tn = /* @__PURE__ */ Object.create(null);
42612
+ function Ht(r6) {
42508
42613
  let e;
42509
- return r6 ? (e = Xr[r6], e || (e = Xr[r6] = /* @__PURE__ */ Object.create(null))) : e = ke, e;
42614
+ return r6 ? (e = tn[r6], e || (e = tn[r6] = /* @__PURE__ */ Object.create(null))) : e = ke, e;
42510
42615
  }
42511
- function zt(r6, e) {
42616
+ function Yt(r6, e) {
42512
42617
  let t = Array.isArray(r6) ? r6 : r6.entry?.map((n) => n.resource) ?? [];
42513
- for (let n of t) Jt(n, e);
42618
+ for (let n of t) Zt(n, e);
42514
42619
  }
42515
- function Jt(r6, e) {
42620
+ function Zt(r6, e) {
42516
42621
  if (!r6?.name) throw new Error("Failed loading StructureDefinition from bundle");
42517
42622
  if (r6.resourceType !== "StructureDefinition") return;
42518
- let t = Qt(r6), n = Wt(e);
42519
- n[r6.name] = t, e && r6.url === e && (Kt[e] = t);
42623
+ let t = zt(r6), n = Ht(e);
42624
+ n[r6.name] = t, e && r6.url === e && (Jt[e] = t);
42520
42625
  for (let i of t.innerTypes) i.parentType = t, n[i.name] = i;
42521
42626
  }
42522
- function on(r6) {
42627
+ function an(r6) {
42523
42628
  return !!ke[r6];
42524
42629
  }
42525
42630
  function Ve(r6, e) {
42526
- let t = Wt(e)[r6];
42527
- return !t && e && (t = Wt()[r6]), t;
42631
+ let t = Ht(e)[r6];
42632
+ return !t && e && (t = Ht()[r6]), t;
42528
42633
  }
42529
- function an(r6) {
42530
- return !!Kt[r6];
42634
+ function un(r6) {
42635
+ return !!Jt[r6];
42531
42636
  }
42532
- var Gt = class {
42637
+ var Qt = class {
42533
42638
  constructor(e) {
42534
42639
  if (!e.snapshot?.element || e.snapshot.element.length === 0) throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
42535
- 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, title: e.title, type: e.type, url: e.url, kind: e.kind, description: Mi(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
42640
+ 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, title: e.title, type: e.type, url: e.url, kind: e.kind, description: Li(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
42536
42641
  }
42537
42642
  parse() {
42538
42643
  let e = this.next();
@@ -42540,7 +42645,7 @@ var Gt = class {
42540
42645
  if (e.sliceName) this.parseSliceStart(e);
42541
42646
  else if (e.id?.includes(":")) {
42542
42647
  if (this.slicingContext?.current) {
42543
- let t = $t(e, this.slicingContext.path);
42648
+ let t = Gt(e, this.slicingContext.path);
42544
42649
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
42545
42650
  }
42546
42651
  } else {
@@ -42549,13 +42654,13 @@ var Gt = class {
42549
42654
  let n = this.backboneContext;
42550
42655
  for (; n; ) {
42551
42656
  if (e.path?.startsWith(n.path + ".")) {
42552
- n.type.elements[$t(e, n.path)] = t;
42657
+ n.type.elements[Gt(e, n.path)] = t;
42553
42658
  break;
42554
42659
  }
42555
42660
  n = n.parent;
42556
42661
  }
42557
42662
  if (!n) {
42558
- let i = $t(e, this.root.path);
42663
+ let i = Gt(e, this.root.path);
42559
42664
  e.isSummary && this.resourceSchema.summaryProperties?.add(i.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i.replace("[x]", "")), this.resourceSchema.elements[i] = t;
42560
42665
  }
42561
42666
  this.checkFieldExit(e);
@@ -42568,21 +42673,21 @@ var Gt = class {
42568
42673
  this.isInnerType(e) && this.enterInnerType(e), e.slicing && !this.slicingContext && this.enterSlice(e, t);
42569
42674
  }
42570
42675
  enterInnerType(e) {
42571
- for (; this.backboneContext && !xe(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42572
- this.backboneContext = { type: { name: Ht(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: xe(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
42676
+ for (; this.backboneContext && !ve(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42677
+ this.backboneContext = { type: { name: Kt(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: ve(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
42573
42678
  }
42574
42679
  enterSlice(e, t) {
42575
- Di(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
42680
+ Fi(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
42576
42681
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type") throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
42577
42682
  return { path: n.path, type: n.type };
42578
42683
  }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
42579
42684
  }
42580
42685
  checkFieldExit(e = void 0) {
42581
- if (this.backboneContext && !xe(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
42686
+ if (this.backboneContext && !ve(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
42582
42687
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
42583
- while (this.backboneContext && !xe(this.backboneContext.path, e?.path));
42688
+ while (this.backboneContext && !ve(this.backboneContext.path, e?.path));
42584
42689
  else this.innerTypes.push(this.backboneContext.type), this.backboneContext = void 0;
42585
- this.slicingContext && !xe(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext = void 0);
42690
+ this.slicingContext && !ve(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext = void 0);
42586
42691
  }
42587
42692
  next() {
42588
42693
  let e = this.peek();
@@ -42600,7 +42705,7 @@ var Gt = class {
42600
42705
  }
42601
42706
  isInnerType(e) {
42602
42707
  let t = this.peek();
42603
- return !!(xe(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
42708
+ return !!(ve(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
42604
42709
  }
42605
42710
  parseSliceStart(e) {
42606
42711
  if (!this.slicingContext) throw new Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);
@@ -42609,43 +42714,43 @@ var Gt = class {
42609
42714
  parseElementDefinitionType(e) {
42610
42715
  return (e.type ?? []).map((t) => {
42611
42716
  let n;
42612
- return (t.code === "BackboneElement" || t.code === "Element") && (n = Ht(e)), n || (n = Z(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
42717
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = Kt(e)), n || (n = X(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
42613
42718
  });
42614
42719
  }
42615
42720
  parseElementDefinition(e) {
42616
- let t = tn(e.max), n = e.base?.max ? tn(e.base.max) : t, i = { type: "ElementDefinition", value: e };
42617
- 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: this.parseElementDefinitionType(e), fixed: rn(C(i, "fixed[x]")), pattern: rn(C(i, "pattern[x]")), binding: e.binding };
42721
+ let t = nn(e.max), n = e.base?.max ? nn(e.base.max) : t, i = { type: "ElementDefinition", value: e };
42722
+ 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: this.parseElementDefinitionType(e), fixed: on(C(i, "fixed[x]")), pattern: on(C(i, "pattern[x]")), binding: e.binding };
42618
42723
  }
42619
42724
  };
42620
- function tn(r6) {
42725
+ function nn(r6) {
42621
42726
  return r6 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r6, 10);
42622
42727
  }
42623
- function $t(r6, e = "") {
42624
- return Vi(r6.path, e);
42728
+ function Gt(r6, e = "") {
42729
+ return Ni(r6.path, e);
42625
42730
  }
42626
- function Vi(r6, e) {
42731
+ function Ni(r6, e) {
42627
42732
  return r6 ? e && r6.startsWith(e) ? r6.substring(e.length + 1) : r6 : "";
42628
42733
  }
42629
- function xe(r6, e) {
42734
+ function ve(r6, e) {
42630
42735
  return !r6 || !e ? false : e.startsWith(r6 + ".") || e === r6;
42631
42736
  }
42632
- function rn(r6) {
42737
+ function on(r6) {
42633
42738
  return Array.isArray(r6) && r6.length > 0 ? r6[0] : S(r6) ? void 0 : r6;
42634
42739
  }
42635
- function Di(r6) {
42740
+ function Fi(r6) {
42636
42741
  let e = r6.slicing?.discriminator;
42637
42742
  return !!(r6.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
42638
42743
  }
42639
- function Mi(r6) {
42744
+ function Li(r6) {
42640
42745
  let e = r6.description;
42641
42746
  return e?.startsWith(`Base StructureDefinition for ${r6.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r6.name} Type: `.length)), e;
42642
42747
  }
42643
- var Je = { base64Binary: /^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/, canonical: /^\S*$/, code: /^[^\s]+( [^\s]+)*$/, date: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/, dateTime: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/, id: /^[A-Za-z0-9\-.]{1,64}$/, instant: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/, markdown: /^[\s\S]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\s\S]+$/, time: /^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/, uri: /^\S*$/, url: /^\S*$/, uuid: /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, xhtml: /.*/ };
42748
+ var Ye = { base64Binary: /^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/, canonical: /^\S*$/, code: /^[^\s]+( [^\s]+)*$/, date: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/, dateTime: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/, id: /^[A-Za-z0-9\-.]{1,64}$/, instant: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/, markdown: /^[\s\S]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\s\S]+$/, time: /^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/, uri: /^\S*$/, url: /^\S*$/, uuid: /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, xhtml: /.*/ };
42644
42749
  function d(r6) {
42645
42750
  return [{ type: l.boolean, value: r6 }];
42646
42751
  }
42647
42752
  function x(r6) {
42648
- return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: l.integer, value: r6 } : typeof r6 == "number" ? { type: l.decimal, value: r6 } : typeof r6 == "boolean" ? { type: l.boolean, value: r6 } : typeof r6 == "string" ? { type: l.string, value: r6 } : I(r6) ? { type: l.Quantity, value: r6 } : L(r6) ? { type: r6.resourceType, value: r6 } : { type: l.BackboneElement, value: r6 };
42753
+ return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: l.integer, value: r6 } : typeof r6 == "number" ? { type: l.decimal, value: r6 } : typeof r6 == "boolean" ? { type: l.boolean, value: r6 } : typeof r6 == "string" ? { type: l.string, value: r6 } : k(r6) ? { type: l.Quantity, value: r6 } : I(r6) ? { type: r6.resourceType, value: r6 } : { type: l.BackboneElement, value: r6 };
42649
42754
  }
42650
42755
  function _(r6) {
42651
42756
  return r6.length === 0 ? false : !!r6[0].value;
@@ -42658,10 +42763,10 @@ function B(r6, e) {
42658
42763
  }
42659
42764
  function C(r6, e, t) {
42660
42765
  if (!r6.value) return;
42661
- let n = et(r6.type, e, t?.profileUrl);
42662
- return n ? Gi(r6, e, n) : Hi(r6, e);
42766
+ let n = tt(r6.type, e, t?.profileUrl);
42767
+ return n ? Ki(r6, e, n) : zi(r6, e);
42663
42768
  }
42664
- function Gi(r6, e, t) {
42769
+ function Ki(r6, e, t) {
42665
42770
  let n = r6.value, i = t.type;
42666
42771
  if (!i || i.length === 0) return;
42667
42772
  let o, s = "undefined", a2;
@@ -42677,14 +42782,14 @@ function Gi(r6, e, t) {
42677
42782
  } else console.assert(i.length === 1, "Expected single type", t.path), o = n[e], s = i[0].code, a2 = n["_" + e];
42678
42783
  if (a2) if (Array.isArray(o)) {
42679
42784
  o = o.slice();
42680
- for (let c = 0; c < Math.max(o.length, a2.length); c++) o[c] = mn(o[c], a2[c]);
42681
- } else o = mn(o, a2);
42682
- if (!S(o)) return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o) ? o.map((c) => ln(c, s)) : ln(o, s);
42785
+ for (let c = 0; c < Math.max(o.length, a2.length); c++) o[c] = yn(o[c], a2[c]);
42786
+ } else o = yn(o, a2);
42787
+ if (!S(o)) return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o) ? o.map((c) => dn(c, s)) : dn(o, s);
42683
42788
  }
42684
- function ln(r6, e) {
42685
- return e === "Resource" && L(r6) && (e = r6.resourceType), { type: e, value: r6 };
42789
+ function dn(r6, e) {
42790
+ return e === "Resource" && I(r6) && (e = r6.resourceType), { type: e, value: r6 };
42686
42791
  }
42687
- function Hi(r6, e) {
42792
+ function zi(r6, e) {
42688
42793
  let t = r6.value;
42689
42794
  if (!t || typeof t != "object") return;
42690
42795
  let n;
@@ -42698,11 +42803,11 @@ function Hi(r6, e) {
42698
42803
  }
42699
42804
  if (!S(n)) return Array.isArray(n) ? n.map(x) : x(n);
42700
42805
  }
42701
- function Ze(r6) {
42806
+ function Xe(r6) {
42702
42807
  let e = [];
42703
42808
  for (let t of r6) {
42704
42809
  let n = false;
42705
- for (let i of e) if (_(hn(t, i))) {
42810
+ for (let i of e) if (_(gn(t, i))) {
42706
42811
  n = true;
42707
42812
  break;
42708
42813
  }
@@ -42710,28 +42815,28 @@ function Ze(r6) {
42710
42815
  }
42711
42816
  return e;
42712
42817
  }
42713
- function ir(r6) {
42818
+ function or(r6) {
42714
42819
  return d(!_(r6));
42715
42820
  }
42716
- function or(r6, e) {
42717
- return r6.length === 0 || e.length === 0 ? [] : r6.length !== e.length ? d(false) : d(r6.every((t, n) => _(hn(t, e[n]))));
42821
+ function sr(r6, e) {
42822
+ return r6.length === 0 || e.length === 0 ? [] : r6.length !== e.length ? d(false) : d(r6.every((t, n) => _(gn(t, e[n]))));
42718
42823
  }
42719
- function hn(r6, e) {
42824
+ function gn(r6, e) {
42720
42825
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
42721
- return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : I(t) && I(n) ? d(xn(t, n)) : d(typeof t == "object" && typeof n == "object" ? ar(r6, e) : t === n);
42826
+ return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : k(t) && k(n) ? d(Tn(t, n)) : d(typeof t == "object" && typeof n == "object" ? cr(r6, e) : t === n);
42722
42827
  }
42723
- function sr(r6, e) {
42724
- return r6.length === 0 && e.length === 0 ? d(true) : r6.length !== e.length ? d(false) : (r6.sort(pn), e.sort(pn), d(r6.every((t, n) => _(Qi(t, e[n])))));
42828
+ function ar(r6, e) {
42829
+ return r6.length === 0 && e.length === 0 ? d(true) : r6.length !== e.length ? d(false) : (r6.sort(fn), e.sort(fn), d(r6.every((t, n) => _(Ji(t, e[n])))));
42725
42830
  }
42726
- function Qi(r6, e) {
42831
+ function Ji(r6, e) {
42727
42832
  let { type: t, value: n } = r6, { type: i, value: o } = e, s = n?.valueOf(), a2 = o?.valueOf();
42728
- return typeof s == "number" && typeof a2 == "number" ? d(Math.abs(s - a2) < 0.01) : I(s) && I(a2) ? d(xn(s, a2)) : d(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? ar({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
42833
+ return typeof s == "number" && typeof a2 == "number" ? d(Math.abs(s - a2) < 0.01) : k(s) && k(a2) ? d(Tn(s, a2)) : d(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a2 != "object" ? false : s.code === a2.code && s.system === a2.system : typeof s == "object" && typeof a2 == "object" ? cr({ ...s, id: void 0 }, { ...a2, id: void 0 }) : typeof s == "string" && typeof a2 == "string" ? s.toLowerCase() === a2.toLowerCase() : s === a2);
42729
42834
  }
42730
- function pn(r6, e) {
42835
+ function fn(r6, e) {
42731
42836
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
42732
42837
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
42733
42838
  }
42734
- function Xe(r6, e) {
42839
+ function et(r6, e) {
42735
42840
  let { value: t } = r6;
42736
42841
  if (t == null) return false;
42737
42842
  switch (e) {
@@ -42741,102 +42846,102 @@ function Xe(r6, e) {
42741
42846
  case "Integer":
42742
42847
  return typeof t == "number";
42743
42848
  case "Date":
42744
- return yn(t);
42849
+ return xn(t);
42745
42850
  case "DateTime":
42746
- return Ye(t);
42851
+ return Ze(t);
42747
42852
  case "Time":
42748
42853
  return typeof t == "string" && !!/^T\d/.exec(t);
42749
42854
  case "Period":
42750
- return gn(t);
42855
+ return vn(t);
42751
42856
  case "Quantity":
42752
- return I(t);
42857
+ return k(t);
42753
42858
  default:
42754
42859
  return typeof t == "object" && t?.resourceType === e;
42755
42860
  }
42756
42861
  }
42757
- function yn(r6) {
42758
- return typeof r6 == "string" && !!Je.date.exec(r6);
42862
+ function xn(r6) {
42863
+ return typeof r6 == "string" && !!Ye.date.exec(r6);
42759
42864
  }
42760
- function Ye(r6) {
42761
- return typeof r6 == "string" && !!Je.dateTime.exec(r6);
42865
+ function Ze(r6) {
42866
+ return typeof r6 == "string" && !!Ye.dateTime.exec(r6);
42762
42867
  }
42763
- function gn(r6) {
42764
- return !!(r6 && typeof r6 == "object" && ("start" in r6 && Ye(r6.start) || "end" in r6 && Ye(r6.end)));
42868
+ function vn(r6) {
42869
+ return !!(r6 && typeof r6 == "object" && ("start" in r6 && Ze(r6.start) || "end" in r6 && Ze(r6.end)));
42765
42870
  }
42766
- function I(r6) {
42871
+ function k(r6) {
42767
42872
  return !!(r6 && typeof r6 == "object" && "value" in r6 && typeof r6.value == "number");
42768
42873
  }
42769
- function xn(r6, e) {
42874
+ function Tn(r6, e) {
42770
42875
  return Math.abs(r6.value - e.value) < 0.01 && (r6.unit === e.unit || r6.code === e.code || r6.unit === e.code || r6.code === e.unit);
42771
42876
  }
42772
- function ar(r6, e) {
42877
+ function cr(r6, e) {
42773
42878
  let t = Object.keys(r6), n = Object.keys(e);
42774
42879
  if (t.length !== n.length) return false;
42775
42880
  for (let i of t) {
42776
42881
  let o = r6[i], s = e[i];
42777
- if (fn(o) && fn(s)) {
42778
- if (!ar(o, s)) return false;
42882
+ if (hn(o) && hn(s)) {
42883
+ if (!cr(o, s)) return false;
42779
42884
  } else if (o !== s) return false;
42780
42885
  }
42781
42886
  return true;
42782
42887
  }
42783
- function fn(r6) {
42888
+ function hn(r6) {
42784
42889
  return r6 !== null && typeof r6 == "object";
42785
42890
  }
42786
- function mn(r6, e) {
42891
+ function yn(r6, e) {
42787
42892
  if (e) {
42788
42893
  if (typeof e != "object") throw new Error("Primitive extension must be an object");
42789
- return Ki(r6 ?? {}, e);
42894
+ return Yi(r6 ?? {}, e);
42790
42895
  }
42791
42896
  return r6;
42792
42897
  }
42793
- function Ki(r6, e) {
42898
+ function Yi(r6, e) {
42794
42899
  return delete e.__proto__, delete e.constructor, Object.assign(r6, e);
42795
42900
  }
42796
- function ee(r6) {
42797
- let e = ce(r6), t = Ji(r6);
42901
+ function te(r6) {
42902
+ let e = ue(r6), t = Xi(r6);
42798
42903
  return t === e ? { reference: e } : { reference: e, display: t };
42799
42904
  }
42800
- function ce(r6) {
42801
- return ae(r6) ? r6.reference : `${r6.resourceType}/${r6.id}`;
42905
+ function ue(r6) {
42906
+ return ce(r6) ? r6.reference : `${r6.resourceType}/${r6.id}`;
42802
42907
  }
42803
- function Te(r6) {
42804
- if (r6) return ae(r6) ? r6.reference.split("/")[1] : r6.id;
42908
+ function Se(r6) {
42909
+ if (r6) return ce(r6) ? r6.reference.split("/")[1] : r6.id;
42805
42910
  }
42806
- function zi(r6) {
42911
+ function Zi(r6) {
42807
42912
  return r6.resourceType === "Patient" || r6.resourceType === "Practitioner" || r6.resourceType === "RelatedPerson";
42808
42913
  }
42809
- function Ji(r6) {
42810
- if (zi(r6)) {
42811
- let e = Yi(r6);
42914
+ function Xi(r6) {
42915
+ if (Zi(r6)) {
42916
+ let e = eo(r6);
42812
42917
  if (e) return e;
42813
42918
  }
42814
42919
  if (r6.resourceType === "Device") {
42815
- let e = Zi(r6);
42920
+ let e = to(r6);
42816
42921
  if (e) return e;
42817
42922
  }
42818
42923
  if (r6.resourceType === "MedicationRequest") {
42819
42924
  let e = r6.medicationCodeableConcept;
42820
- if (e) return tt(e);
42925
+ if (e) return rt(e);
42821
42926
  }
42822
42927
  if (r6.resourceType === "User" && r6.email) return r6.email;
42823
42928
  if ("name" in r6 && r6.name && typeof r6.name == "string") return r6.name;
42824
42929
  if ("code" in r6 && r6.code) {
42825
42930
  let e = r6.code;
42826
- if (Array.isArray(e) && (e = e[0]), co(e)) return tt(e);
42827
- if (uo(e)) return e.text;
42931
+ if (Array.isArray(e) && (e = e[0]), po(e)) return rt(e);
42932
+ if (fo(e)) return e.text;
42828
42933
  }
42829
- return ce(r6);
42934
+ return ue(r6);
42830
42935
  }
42831
- function Yi(r6) {
42936
+ function eo(r6) {
42832
42937
  let e = r6.name;
42833
- if (e && e.length > 0) return it(e[0]);
42938
+ if (e && e.length > 0) return ot(e[0]);
42834
42939
  }
42835
- function Zi(r6) {
42940
+ function to(r6) {
42836
42941
  let e = r6.deviceName;
42837
42942
  if (e && e.length > 0) return e[0].name;
42838
42943
  }
42839
- function rt(r6, e) {
42944
+ function nt(r6, e) {
42840
42945
  let t = new Date(r6);
42841
42946
  t.setUTCHours(0, 0, 0, 0);
42842
42947
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
@@ -42848,18 +42953,18 @@ function rt(r6, e) {
42848
42953
  let g = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
42849
42954
  return { years: p2, months: m2, days: g };
42850
42955
  }
42851
- function Z(r6, ...e) {
42956
+ function X(r6, ...e) {
42852
42957
  let t = r6;
42853
42958
  for (let n = 0; n < e.length && t; n++) t = t?.extension?.find((i) => i.url === e[n]);
42854
42959
  return t;
42855
42960
  }
42856
- function En(r6, e) {
42857
- return JSON.stringify(r6, eo, e ? 2 : void 0);
42961
+ function Rn(r6, e) {
42962
+ return JSON.stringify(r6, no, e ? 2 : void 0);
42858
42963
  }
42859
- function eo(r6, e) {
42860
- return !to(r6) && S(e) ? void 0 : e;
42964
+ function no(r6, e) {
42965
+ return !io(r6) && S(e) ? void 0 : e;
42861
42966
  }
42862
- function to(r6) {
42967
+ function io(r6) {
42863
42968
  return !!/\d+$/.exec(r6);
42864
42969
  }
42865
42970
  function S(r6) {
@@ -42872,49 +42977,49 @@ function H(r6) {
42872
42977
  let e = typeof r6;
42873
42978
  return e === "string" && r6 !== "" || e === "object" && ("length" in r6 && r6.length > 0 || Object.keys(r6).length > 0);
42874
42979
  }
42875
- function X(r6, e, t) {
42876
- return r6 === e || S(r6) && S(e) ? true : S(r6) || S(e) ? false : Array.isArray(r6) && Array.isArray(e) ? ro(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : b(r6) && b(e) ? no(r6, e, t) : (b(r6) || b(e), false);
42980
+ function ee(r6, e, t) {
42981
+ return r6 === e || S(r6) && S(e) ? true : S(r6) || S(e) ? false : Array.isArray(r6) && Array.isArray(e) ? oo(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : b(r6) && b(e) ? so(r6, e, t) : (b(r6) || b(e), false);
42877
42982
  }
42878
- function ro(r6, e) {
42983
+ function oo(r6, e) {
42879
42984
  if (r6.length !== e.length) return false;
42880
- for (let t = 0; t < r6.length; t++) if (!X(r6[t], e[t])) return false;
42985
+ for (let t = 0; t < r6.length; t++) if (!ee(r6[t], e[t])) return false;
42881
42986
  return true;
42882
42987
  }
42883
- function no(r6, e, t) {
42988
+ function so(r6, e, t) {
42884
42989
  let n = /* @__PURE__ */ new Set();
42885
42990
  Object.keys(r6).forEach((i) => n.add(i)), Object.keys(e).forEach((i) => n.add(i)), t === "meta" && (n.delete("versionId"), n.delete("lastUpdated"), n.delete("author"));
42886
42991
  for (let i of n) {
42887
42992
  let o = r6[i], s = e[i];
42888
- if (!X(o, s, i)) return false;
42993
+ if (!ee(o, s, i)) return false;
42889
42994
  }
42890
42995
  return true;
42891
42996
  }
42892
42997
  function b(r6) {
42893
42998
  return r6 !== null && typeof r6 == "object";
42894
42999
  }
42895
- function bn(r6) {
42896
- return r6.every(so);
43000
+ function Pn(r6) {
43001
+ return r6.every(uo);
42897
43002
  }
42898
- function so(r6) {
43003
+ function uo(r6) {
42899
43004
  return typeof r6 == "string";
42900
43005
  }
42901
- function ao(r6) {
43006
+ function lo(r6) {
42902
43007
  return b(r6) && "code" in r6 && typeof r6.code == "string";
42903
43008
  }
42904
- function co(r6) {
42905
- return b(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(ao);
43009
+ function po(r6) {
43010
+ return b(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(lo);
42906
43011
  }
42907
- function uo(r6) {
43012
+ function fo(r6) {
42908
43013
  return b(r6) && "text" in r6 && typeof r6.text == "string";
42909
43014
  }
42910
- var Rn = [];
42911
- for (let r6 = 0; r6 < 256; r6++) Rn.push(r6.toString(16).padStart(2, "0"));
42912
- function Pn(r6) {
43015
+ var Cn = [];
43016
+ for (let r6 = 0; r6 < 256; r6++) Cn.push(r6.toString(16).padStart(2, "0"));
43017
+ function wn(r6) {
42913
43018
  let e = new Uint8Array(r6), t = new Array(e.length);
42914
- for (let n = 0; n < e.length; n++) t[n] = Rn[e[n]];
43019
+ for (let n = 0; n < e.length; n++) t[n] = Cn[e[n]];
42915
43020
  return t.join("");
42916
43021
  }
42917
- function Cn(r6) {
43022
+ function An(r6) {
42918
43023
  let e = new Uint8Array(r6), t = [];
42919
43024
  for (let n = 0; n < e.length; n++) t[n] = String.fromCharCode(e[n]);
42920
43025
  return window.btoa(t.join(""));
@@ -42922,69 +43027,69 @@ function Cn(r6) {
42922
43027
  function w(r6) {
42923
43028
  return r6 ? r6.charAt(0).toUpperCase() + r6.substring(1) : "";
42924
43029
  }
42925
- var lr = (r6) => new Promise((e) => {
43030
+ var pr = (r6) => new Promise((e) => {
42926
43031
  setTimeout(e, r6);
42927
43032
  });
42928
- function nt(r6) {
43033
+ function it(r6) {
42929
43034
  return r6.sort((e, t) => e.localeCompare(t));
42930
43035
  }
42931
- function dr(r6) {
43036
+ function fr(r6) {
42932
43037
  return r6.endsWith("/") ? r6 : r6 + "/";
42933
43038
  }
42934
- function yo(r6) {
43039
+ function vo(r6) {
42935
43040
  return r6.startsWith("/") ? r6.slice(1) : r6;
42936
43041
  }
42937
43042
  function j(r6, e) {
42938
- return new URL(yo(e), dr(r6.toString())).toString();
43043
+ return new URL(vo(e), fr(r6.toString())).toString();
42939
43044
  }
42940
- function In(r6, e) {
43045
+ function Vn(r6, e) {
42941
43046
  return j(r6, e).toString().replace("http://", "ws://").replace("https://", "wss://");
42942
43047
  }
42943
- function kn(r6) {
43048
+ function Dn(r6) {
42944
43049
  return typeof r6 == "object" && !Array.isArray(r6) && !(r6 instanceof URLSearchParams) && (r6 = Object.fromEntries(Object.entries(r6).filter((e) => e[1] !== void 0))), new URLSearchParams(r6).toString();
42945
43050
  }
42946
- var go = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/;
42947
- function vu(r6) {
42948
- return go.test(r6);
43051
+ var To = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/;
43052
+ function bu(r6) {
43053
+ return To.test(r6);
42949
43054
  }
42950
- function it(r6, e) {
43055
+ function ot(r6, e) {
42951
43056
  let t = [];
42952
43057
  if (r6.prefix && e?.prefix !== false && t.push(...r6.prefix), r6.given && t.push(...r6.given), r6.family && t.push(r6.family), r6.suffix && e?.suffix !== false && t.push(...r6.suffix), r6.use && (e?.all || e?.use) && t.push("[" + r6.use + "]"), t.length === 0) {
42953
- let n = be(r6.text);
43058
+ let n = Re(r6.text);
42954
43059
  if (n) return n;
42955
43060
  }
42956
43061
  return t.join(" ").trim();
42957
43062
  }
42958
- function tt(r6) {
43063
+ function rt(r6) {
42959
43064
  if (!r6) return "";
42960
- let e = be(r6.text);
42961
- return e || (r6.coding ? r6.coding.map((t) => bo(t)).join(", ") : "");
43065
+ let e = Re(r6.text);
43066
+ return e || (r6.coding ? r6.coding.map((t) => Co(t)).join(", ") : "");
42962
43067
  }
42963
- function bo(r6) {
42964
- return be(r6?.display) ?? be(r6?.code) ?? "";
43068
+ function Co(r6) {
43069
+ return Re(r6?.display) ?? Re(r6?.code) ?? "";
42965
43070
  }
42966
- function be(r6) {
43071
+ function Re(r6) {
42967
43072
  return typeof r6 == "string" ? r6 : void 0;
42968
43073
  }
42969
43074
  var l = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
42970
- function hr(r6) {
43075
+ function yr(r6) {
42971
43076
  for (let e of r6.base ?? []) {
42972
- let t = M.types[e];
42973
- t || (t = { searchParamsDetails: {} }, M.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[r6.code] = r6;
43077
+ let t = N.types[e];
43078
+ t || (t = { searchParamsDetails: {} }, N.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[r6.code] = r6;
42974
43079
  }
42975
43080
  }
42976
- function Ht(r6) {
43081
+ function Kt(r6) {
42977
43082
  let e = r6.type?.[0]?.code;
42978
- return e === "BackboneElement" || e === "Element" ? wo((r6.base?.path ?? r6.path)?.split(".")) : e;
43083
+ return e === "BackboneElement" || e === "Element" ? Io((r6.base?.path ?? r6.path)?.split(".")) : e;
42979
43084
  }
42980
- function wo(r6) {
43085
+ function Io(r6) {
42981
43086
  return r6.length === 1 ? r6[0] : r6.map(w).join("");
42982
43087
  }
42983
- function et(r6, e, t) {
43088
+ function tt(r6, e, t) {
42984
43089
  let n = Ve(r6, t);
42985
- if (n) return ko(n.elements, e);
43090
+ if (n) return Mo(n.elements, e);
42986
43091
  }
42987
- function ko(r6, e) {
43092
+ function Mo(r6, e) {
42988
43093
  let t = r6[e] ?? r6[e + "[x]"];
42989
43094
  if (t) return t;
42990
43095
  for (let n = 0; n < e.length; n++) {
@@ -42995,14 +43100,14 @@ function ko(r6, e) {
42995
43100
  }
42996
43101
  }
42997
43102
  }
42998
- function L(r6) {
43103
+ function I(r6) {
42999
43104
  return !!(r6 && typeof r6 == "object" && "resourceType" in r6);
43000
43105
  }
43001
- function ae(r6) {
43106
+ function ce(r6) {
43002
43107
  return !!(r6 && typeof r6 == "object" && "reference" in r6 && typeof r6.reference == "string");
43003
43108
  }
43004
- var M = { types: {} };
43005
- function Re(r6) {
43109
+ var N = { types: {} };
43110
+ function Pe(r6) {
43006
43111
  if (r6.startsWith("T")) return r6 + "T00:00:00.000Z".substring(r6.length);
43007
43112
  if (r6.length <= 10) return r6;
43008
43113
  try {
@@ -43026,10 +43131,10 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43026
43131
  return d(false);
43027
43132
  }, subsetOf: (r6, e, t) => {
43028
43133
  if (e.length === 0) return d(true);
43029
- let n = t.eval(r6, pe(r6));
43134
+ let n = t.eval(r6, de(r6));
43030
43135
  return n.length === 0 ? d(false) : d(e.every((i) => n.some((o) => o.value === i.value)));
43031
43136
  }, supersetOf: (r6, e, t) => {
43032
- let n = t.eval(r6, pe(r6));
43137
+ let n = t.eval(r6, de(r6));
43033
43138
  return n.length === 0 ? d(true) : e.length === 0 ? d(false) : d(n.every((i) => e.some((o) => o.value === i.value)));
43034
43139
  }, count: (r6, e) => [{ type: l.integer, value: e.length }], distinct: (r6, e) => {
43035
43140
  let t = [];
@@ -43048,21 +43153,21 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43048
43153
  return n >= e.length ? e : n <= 0 ? [] : e.slice(0, n);
43049
43154
  }, intersect: (r6, e, t) => {
43050
43155
  if (!t) return e;
43051
- let n = t.eval(r6, pe(r6)), i = [];
43156
+ let n = t.eval(r6, de(r6)), i = [];
43052
43157
  for (let o of e) !i.some((s) => s.value === o.value) && n.some((s) => s.value === o.value) && i.push(o);
43053
43158
  return i;
43054
43159
  }, exclude: (r6, e, t) => {
43055
43160
  if (!t) return e;
43056
- let n = t.eval(r6, pe(r6)), i = [];
43161
+ let n = t.eval(r6, de(r6)), i = [];
43057
43162
  for (let o of e) n.some((s) => s.value === o.value) || i.push(o);
43058
43163
  return i;
43059
43164
  }, union: (r6, e, t) => {
43060
43165
  if (!t) return e;
43061
- let n = t.eval(r6, pe(r6));
43062
- return Ze([...e, ...n]);
43166
+ let n = t.eval(r6, de(r6));
43167
+ return Xe([...e, ...n]);
43063
43168
  }, combine: (r6, e, t) => {
43064
43169
  if (!t) return e;
43065
- let n = t.eval(r6, pe(r6));
43170
+ let n = t.eval(r6, de(r6));
43066
43171
  return [...e, ...n];
43067
43172
  }, htmlChecks: (r6, e, t) => [x(true)], iif: (r6, e, t, n, i) => {
43068
43173
  let o = t.eval(r6, e);
@@ -43086,11 +43191,11 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43086
43191
  }, convertsToInteger: (r6, e) => e.length === 0 ? [] : d(O.toInteger(r6, e).length === 1), toDate: (r6, e) => {
43087
43192
  if (e.length === 0) return [];
43088
43193
  let [{ value: t }] = W(e, 1);
43089
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: l.date, value: Re(t) }] : [];
43194
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: l.date, value: Pe(t) }] : [];
43090
43195
  }, convertsToDate: (r6, e) => e.length === 0 ? [] : d(O.toDate(r6, e).length === 1), toDateTime: (r6, e) => {
43091
43196
  if (e.length === 0) return [];
43092
43197
  let [{ value: t }] = W(e, 1);
43093
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: l.dateTime, value: Re(t) }] : [];
43198
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: l.dateTime, value: Pe(t) }] : [];
43094
43199
  }, convertsToDateTime: (r6, e) => e.length === 0 ? [] : d(O.toDateTime(r6, e).length === 1), toDecimal: (r6, e) => {
43095
43200
  if (e.length === 0) return [];
43096
43201
  let [{ value: t }] = W(e, 1);
@@ -43098,24 +43203,24 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43098
43203
  }, convertsToDecimal: (r6, e) => e.length === 0 ? [] : d(O.toDecimal(r6, e).length === 1), toQuantity: (r6, e) => {
43099
43204
  if (e.length === 0) return [];
43100
43205
  let [{ value: t }] = W(e, 1);
43101
- return I(t) ? [{ type: l.Quantity, value: t }] : typeof t == "number" ? [{ type: l.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: l.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: l.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
43206
+ return k(t) ? [{ type: l.Quantity, value: t }] : typeof t == "number" ? [{ type: l.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: l.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: l.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
43102
43207
  }, convertsToQuantity: (r6, e) => e.length === 0 ? [] : d(O.toQuantity(r6, e).length === 1), toString: (r6, e) => {
43103
43208
  if (e.length === 0) return [];
43104
43209
  let [{ value: t }] = W(e, 1);
43105
- return t == null ? [] : I(t) ? [{ type: l.string, value: `${t.value} '${t.unit}'` }] : [{ type: l.string, value: t.toString() }];
43210
+ return t == null ? [] : k(t) ? [{ type: l.string, value: `${t.value} '${t.unit}'` }] : [{ type: l.string, value: t.toString() }];
43106
43211
  }, convertsToString: (r6, e) => e.length === 0 ? [] : d(O.toString(r6, e).length === 1), toTime: (r6, e) => {
43107
43212
  if (e.length === 0) return [];
43108
43213
  let [{ value: t }] = W(e, 1);
43109
43214
  if (typeof t == "string") {
43110
43215
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
43111
- if (n) return [{ type: l.time, value: Re("T" + n[1]) }];
43216
+ if (n) return [{ type: l.time, value: Pe("T" + n[1]) }];
43112
43217
  }
43113
43218
  return [];
43114
- }, convertsToTime: (r6, e) => e.length === 0 ? [] : d(O.toTime(r6, e).length === 1), indexOf: (r6, e, t) => N((n, i) => n.indexOf(i), r6, e, t), substring: (r6, e, t, n) => N((i, o, s) => {
43219
+ }, convertsToTime: (r6, e) => e.length === 0 ? [] : d(O.toTime(r6, e).length === 1), indexOf: (r6, e, t) => F((n, i) => n.indexOf(i), r6, e, t), substring: (r6, e, t, n) => F((i, o, s) => {
43115
43220
  let a2 = o, c = s ? a2 + s : i.length;
43116
43221
  return a2 < 0 || a2 >= i.length ? void 0 : i.substring(a2, c);
43117
- }, r6, e, t, n), startsWith: (r6, e, t) => N((n, i) => n.startsWith(i), r6, e, t), endsWith: (r6, e, t) => N((n, i) => n.endsWith(i), r6, e, t), contains: (r6, e, t) => N((n, i) => n.includes(i), r6, e, t), upper: (r6, e) => N((t) => t.toUpperCase(), r6, e), lower: (r6, e) => N((t) => t.toLowerCase(), r6, e), replace: (r6, e, t, n) => N((i, o, s) => i.replaceAll(o, s), r6, e, t, n), matches: (r6, e, t) => N((n, i) => !!new RegExp(i).exec(n), r6, e, t), replaceMatches: (r6, e, t, n) => N((i, o, s) => i.replaceAll(o, s), r6, e, t, n), length: (r6, e) => N((t) => t.length, r6, e), toChars: (r6, e) => N((t) => t ? t.split("") : void 0, r6, e), encode: Q, decode: Q, escape: Q, unescape: Q, trim: Q, split: Q, join: (r6, e, t) => {
43118
- let n = t?.eval(r6, pe(r6))[0]?.value ?? "";
43222
+ }, r6, e, t, n), startsWith: (r6, e, t) => F((n, i) => n.startsWith(i), r6, e, t), endsWith: (r6, e, t) => F((n, i) => n.endsWith(i), r6, e, t), contains: (r6, e, t) => F((n, i) => n.includes(i), r6, e, t), upper: (r6, e) => F((t) => t.toUpperCase(), r6, e), lower: (r6, e) => F((t) => t.toLowerCase(), r6, e), replace: (r6, e, t, n) => F((i, o, s) => i.replaceAll(o, s), r6, e, t, n), matches: (r6, e, t) => F((n, i) => !!new RegExp(i).exec(n), r6, e, t), replaceMatches: (r6, e, t, n) => F((i, o, s) => i.replaceAll(o, s), r6, e, t, n), length: (r6, e) => F((t) => t.length, r6, e), toChars: (r6, e) => F((t) => t ? t.split("") : void 0, r6, e), encode: Q, decode: Q, escape: Q, unescape: Q, trim: Q, split: Q, join: (r6, e, t) => {
43223
+ let n = t?.eval(r6, de(r6))[0]?.value ?? "";
43119
43224
  if (typeof n != "string") throw new Error("Separator must be a string.");
43120
43225
  return [{ type: l.string, value: e.map((i) => i.value?.toString() ?? "").join(n) }];
43121
43226
  }, abs: (r6, e) => $(Math.abs, r6, e), ceiling: (r6, e) => $(Math.ceil, r6, e), exp: (r6, e) => $(Math.exp, r6, e), floor: (r6, e) => $(Math.floor, r6, e), ln: (r6, e) => $(Math.log, r6, e), log: (r6, e, t) => $((n, i) => Math.log(n) / Math.log(i), r6, e, t), power: (r6, e, t) => $(Math.pow, r6, e, t), round: (r6, e) => $(Math.round, r6, e), sqrt: (r6, e) => $(Math.sqrt, r6, e), truncate: (r6, e) => $((t) => t | 0, r6, e), children: Q, descendants: Q, trace: (r6, e, t) => e, now: () => [{ type: l.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: l.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: l.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r6, e, t, n, i) => {
@@ -43125,11 +43230,11 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43125
43230
  if (s.length === 0) throw new Error("Invalid end date");
43126
43231
  let a2 = i.eval(r6, e)[0]?.value;
43127
43232
  if (a2 !== "years" && a2 !== "months" && a2 !== "days") throw new Error("Invalid units");
43128
- let c = rt(o[0].value, s[0].value);
43233
+ let c = nt(o[0].value, s[0].value);
43129
43234
  return [{ type: l.Quantity, value: { value: c[a2], unit: a2 } }];
43130
43235
  }, is: (r6, e, t) => {
43131
43236
  let n = "";
43132
- return t instanceof U ? n = t.name : t instanceof te && (n = t.left.name + "." + t.right.name), n ? e.map((i) => ({ type: l.boolean, value: Xe(i, n) })) : [];
43237
+ return t instanceof U ? n = t.name : t instanceof re && (n = t.left.name + "." + t.right.name), n ? e.map((i) => ({ type: l.boolean, value: et(i, n) })) : [];
43133
43238
  }, not: (r6, e) => O.toBoolean(r6, e).map((t) => ({ type: l.boolean, value: !t.value })), resolve: (r6, e) => e.map((t) => {
43134
43239
  let n = t.value, i;
43135
43240
  if (typeof n == "string") i = n;
@@ -43147,7 +43252,7 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43147
43252
  return { type: o, value: { resourceType: o, id: s } };
43148
43253
  }
43149
43254
  return { type: l.BackboneElement, value: void 0 };
43150
- }).filter((t) => !!t.value), as: (r6, e) => e, type: (r6, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: l.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: l.BackboneElement, value: { namespace: "System", name: "Integer" } } : L(t) ? { type: l.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: l.BackboneElement, value: null }), conformsTo: (r6, e, t) => {
43255
+ }).filter((t) => !!t.value), as: (r6, e) => e, type: (r6, e) => e.map(({ value: t }) => typeof t == "boolean" ? { type: l.BackboneElement, value: { namespace: "System", name: "Boolean" } } : typeof t == "number" ? { type: l.BackboneElement, value: { namespace: "System", name: "Integer" } } : I(t) ? { type: l.BackboneElement, value: { namespace: "FHIR", name: t.resourceType } } : { type: l.BackboneElement, value: null }), conformsTo: (r6, e, t) => {
43151
43256
  let n = t.eval(r6, e)[0].value;
43152
43257
  if (!n.startsWith("http://hl7.org/fhir/StructureDefinition/")) throw new Error("Expected a StructureDefinition URL");
43153
43258
  let i = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
@@ -43159,16 +43264,16 @@ var O = { empty: (r6, e) => d(e.length === 0 || e.every((t) => S(t.value))), has
43159
43264
  let n = e[0].value;
43160
43265
  if (!n?.reference) return [];
43161
43266
  let i = "";
43162
- return t instanceof U && (i = t.name), i && !n.reference.startsWith(i + "/") ? [] : [{ type: l.id, value: Te(n) }];
43267
+ return t instanceof U && (i = t.name), i && !n.reference.startsWith(i + "/") ? [] : [{ type: l.id, value: Se(n) }];
43163
43268
  }, extension: (r6, e, t) => {
43164
43269
  let n = t.eval(r6, e)[0].value, i = e?.[0]?.value;
43165
43270
  if (i) {
43166
- let o = Z(i, n);
43271
+ let o = X(i, n);
43167
43272
  if (o) return [{ type: l.Extension, value: o }];
43168
43273
  }
43169
43274
  return [];
43170
43275
  } };
43171
- function N(r6, e, t, ...n) {
43276
+ function F(r6, e, t, ...n) {
43172
43277
  if (t.length === 0) return [];
43173
43278
  let [{ value: i }] = W(t, 1);
43174
43279
  if (typeof i != "string") throw new Error("String function cannot be called with non-string");
@@ -43177,7 +43282,7 @@ function N(r6, e, t, ...n) {
43177
43282
  }
43178
43283
  function $(r6, e, t, ...n) {
43179
43284
  if (t.length === 0) return [];
43180
- let [{ value: i }] = W(t, 1), o = I(i), s = o ? i.value : i;
43285
+ let [{ value: i }] = W(t, 1), o = k(i), s = o ? i.value : i;
43181
43286
  if (typeof s != "number") throw new Error("Math function cannot be called with non-number");
43182
43287
  let a2 = r6(s, ...n.map((p2) => p2.eval(e, t)[0]?.value)), c = o ? l.Quantity : t[0].type, u2 = o ? { ...i, value: a2 } : a2;
43183
43288
  return [{ type: c, value: u2 }];
@@ -43187,12 +43292,12 @@ function W(r6, e) {
43187
43292
  for (let t of r6) if (t == null) throw new Error("Expected non-null argument");
43188
43293
  return r6;
43189
43294
  }
43190
- function pe(r6) {
43295
+ function de(r6) {
43191
43296
  let e = r6;
43192
43297
  for (; e.parent?.variables.$this; ) e = e.parent;
43193
43298
  return [e.variables.$this];
43194
43299
  }
43195
- var F = class {
43300
+ var L = class {
43196
43301
  constructor(e) {
43197
43302
  this.value = e;
43198
43303
  }
@@ -43222,13 +43327,13 @@ var U = class {
43222
43327
  }
43223
43328
  evalValue(e) {
43224
43329
  let t = e.value;
43225
- if (!(!t || typeof t != "object")) return L(t) && t.resourceType === this.name ? e : C(e, this.name);
43330
+ if (!(!t || typeof t != "object")) return I(t) && t.resourceType === this.name ? e : C(e, this.name);
43226
43331
  }
43227
43332
  toString() {
43228
43333
  return this.name;
43229
43334
  }
43230
43335
  };
43231
- var st = class {
43336
+ var at = class {
43232
43337
  eval() {
43233
43338
  return [];
43234
43339
  }
@@ -43236,7 +43341,7 @@ var st = class {
43236
43341
  return "{}";
43237
43342
  }
43238
43343
  };
43239
- var at = class extends Ge {
43344
+ var ct = class extends Ge {
43240
43345
  constructor(t, n, i) {
43241
43346
  super(t, n);
43242
43347
  this.impl = i;
@@ -43248,7 +43353,7 @@ var at = class extends Ge {
43248
43353
  return this.operator + this.child.toString();
43249
43354
  }
43250
43355
  };
43251
- var de = class extends J {
43356
+ var fe = class extends Y {
43252
43357
  constructor(e, t) {
43253
43358
  super("as", e, t);
43254
43359
  }
@@ -43256,9 +43361,9 @@ var de = class extends J {
43256
43361
  return O.ofType(e, this.left.eval(e, t), this.right);
43257
43362
  }
43258
43363
  };
43259
- var P = class extends J {
43364
+ var P = class extends Y {
43260
43365
  };
43261
- var k = class extends P {
43366
+ var V = class extends P {
43262
43367
  constructor(t, n, i, o) {
43263
43368
  super(t, n, i);
43264
43369
  this.impl = o;
@@ -43268,11 +43373,11 @@ var k = class extends P {
43268
43373
  if (i.length !== 1) return [];
43269
43374
  let o = this.right.eval(t, n);
43270
43375
  if (o.length !== 1) return [];
43271
- let s = i[0].value, a2 = o[0].value, c = I(s) ? s.value : s, u2 = I(a2) ? a2.value : a2, p2 = this.impl(c, u2);
43272
- return typeof p2 == "boolean" ? d(p2) : I(s) ? [{ type: l.Quantity, value: { ...s, value: p2 } }] : [x(p2)];
43376
+ let s = i[0].value, a2 = o[0].value, c = k(s) ? s.value : s, u2 = k(a2) ? a2.value : a2, p2 = this.impl(c, u2);
43377
+ return typeof p2 == "boolean" ? d(p2) : k(s) ? [{ type: l.Quantity, value: { ...s, value: p2 } }] : [x(p2)];
43273
43378
  }
43274
43379
  };
43275
- var ct = class extends J {
43380
+ var ut = class extends Y {
43276
43381
  constructor(e, t) {
43277
43382
  super("&", e, t);
43278
43383
  }
@@ -43281,7 +43386,7 @@ var ct = class extends J {
43281
43386
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: l.string, value: o.map((s) => s.value).join("") }] : o;
43282
43387
  }
43283
43388
  };
43284
- var ut = class extends P {
43389
+ var lt = class extends P {
43285
43390
  constructor(e, t) {
43286
43391
  super("contains", e, t);
43287
43392
  }
@@ -43290,7 +43395,7 @@ var ut = class extends P {
43290
43395
  return d(n.some((o) => o.value === i[0].value));
43291
43396
  }
43292
43397
  };
43293
- var lt = class extends P {
43398
+ var pt = class extends P {
43294
43399
  constructor(e, t) {
43295
43400
  super("in", e, t);
43296
43401
  }
@@ -43299,7 +43404,7 @@ var lt = class extends P {
43299
43404
  return n ? d(i.some((o) => o.value === n.value)) : [];
43300
43405
  }
43301
43406
  };
43302
- var te = class extends J {
43407
+ var re = class extends Y {
43303
43408
  constructor(e, t) {
43304
43409
  super(".", e, t);
43305
43410
  }
@@ -43310,52 +43415,52 @@ var te = class extends J {
43310
43415
  return `${this.left.toString()}.${this.right.toString()}`;
43311
43416
  }
43312
43417
  };
43313
- var Pe = class extends J {
43418
+ var Ce = class extends Y {
43314
43419
  constructor(e, t) {
43315
43420
  super("|", e, t);
43316
43421
  }
43317
43422
  eval(e, t) {
43318
43423
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43319
- return Ze([...n, ...i]);
43424
+ return Xe([...n, ...i]);
43320
43425
  }
43321
43426
  };
43322
- var pt = class extends P {
43427
+ var dt = class extends P {
43323
43428
  constructor(e, t) {
43324
43429
  super("=", e, t);
43325
43430
  }
43326
43431
  eval(e, t) {
43327
43432
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43328
- return or(n, i);
43433
+ return sr(n, i);
43329
43434
  }
43330
43435
  };
43331
- var dt = class extends P {
43436
+ var ft = class extends P {
43332
43437
  constructor(e, t) {
43333
43438
  super("!=", e, t);
43334
43439
  }
43335
43440
  eval(e, t) {
43336
43441
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43337
- return ir(or(n, i));
43442
+ return or(sr(n, i));
43338
43443
  }
43339
43444
  };
43340
- var ft = class extends P {
43445
+ var mt = class extends P {
43341
43446
  constructor(e, t) {
43342
43447
  super("~", e, t);
43343
43448
  }
43344
43449
  eval(e, t) {
43345
43450
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43346
- return sr(n, i);
43451
+ return ar(n, i);
43347
43452
  }
43348
43453
  };
43349
- var mt = class extends P {
43454
+ var ht = class extends P {
43350
43455
  constructor(e, t) {
43351
43456
  super("!~", e, t);
43352
43457
  }
43353
43458
  eval(e, t) {
43354
43459
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
43355
- return ir(sr(n, i));
43460
+ return or(ar(n, i));
43356
43461
  }
43357
43462
  };
43358
- var fe = class extends P {
43463
+ var me = class extends P {
43359
43464
  constructor(e, t) {
43360
43465
  super("is", e, t);
43361
43466
  }
@@ -43363,10 +43468,10 @@ var fe = class extends P {
43363
43468
  let n = this.left.eval(e, t);
43364
43469
  if (n.length !== 1) return [];
43365
43470
  let i = this.right.name;
43366
- return d(Xe(n[0], i));
43471
+ return d(et(n[0], i));
43367
43472
  }
43368
43473
  };
43369
- var ht = class extends P {
43474
+ var yt = class extends P {
43370
43475
  constructor(e, t) {
43371
43476
  super("and", e, t);
43372
43477
  }
@@ -43375,7 +43480,7 @@ var ht = class extends P {
43375
43480
  return n?.value === true && i?.value === true ? d(true) : n?.value === false || i?.value === false ? d(false) : [];
43376
43481
  }
43377
43482
  };
43378
- var yt = class extends P {
43483
+ var gt = class extends P {
43379
43484
  constructor(e, t) {
43380
43485
  super("or", e, t);
43381
43486
  }
@@ -43384,7 +43489,7 @@ var yt = class extends P {
43384
43489
  return n?.value === false && i?.value === false ? d(false) : n?.value || i?.value ? d(true) : [];
43385
43490
  }
43386
43491
  };
43387
- var gt = class extends P {
43492
+ var xt = class extends P {
43388
43493
  constructor(e, t) {
43389
43494
  super("xor", e, t);
43390
43495
  }
@@ -43393,7 +43498,7 @@ var gt = class extends P {
43393
43498
  return !n || !i ? [] : d(n.value !== i.value);
43394
43499
  }
43395
43500
  };
43396
- var xt = class extends P {
43501
+ var vt = class extends P {
43397
43502
  constructor(e, t) {
43398
43503
  super("implies", e, t);
43399
43504
  }
@@ -43416,7 +43521,7 @@ var K = class {
43416
43521
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
43417
43522
  }
43418
43523
  };
43419
- var me = class {
43524
+ var he = class {
43420
43525
  constructor(e, t) {
43421
43526
  this.left = e;
43422
43527
  this.expr = t;
@@ -43435,57 +43540,57 @@ var me = class {
43435
43540
  };
43436
43541
  var Le = ["!=", "!~", "<=", ">=", "{}", "->"];
43437
43542
  var y = { 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 };
43438
- var Mo = { parse(r6) {
43543
+ var Lo = { parse(r6) {
43439
43544
  let e = r6.consumeAndParse();
43440
43545
  if (!r6.match(")")) throw new Error("Parse error: expected `)` got `" + r6.peek()?.value + "`");
43441
43546
  return e;
43442
43547
  } };
43443
- var No = { parse(r6, e) {
43548
+ var _o = { parse(r6, e) {
43444
43549
  let t = r6.consumeAndParse();
43445
43550
  if (!r6.match("]")) throw new Error("Parse error: expected `]`");
43446
- return new me(e, t);
43551
+ return new he(e, t);
43447
43552
  }, precedence: y.Indexer };
43448
- var Fo = { parse(r6, e) {
43553
+ var Uo = { parse(r6, e) {
43449
43554
  if (!(e instanceof U)) throw new Error("Unexpected parentheses");
43450
43555
  let t = [];
43451
43556
  for (; !r6.match(")"); ) t.push(r6.consumeAndParse()), r6.match(",");
43452
43557
  return new K(e.name, t);
43453
43558
  }, precedence: y.FunctionCall };
43454
- function Lo(r6) {
43559
+ function Bo(r6) {
43455
43560
  let e = r6.split(" "), t = parseFloat(e[0]), n = e[1];
43456
43561
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
43457
43562
  }
43458
43563
  function _e() {
43459
- return new He().registerPrefix("String", { parse: (r6, e) => new F({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r6, e) => new F({ type: l.dateTime, value: Re(e.value) }) }).registerPrefix("Quantity", { parse: (r6, e) => new F({ type: l.Quantity, value: Lo(e.value) }) }).registerPrefix("Number", { parse: (r6, e) => new F({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new F({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new F({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r6, e) => new U(e.value) }).registerPrefix("{}", { parse: () => new st() }).registerPrefix("(", Mo).registerInfix("[", No).registerInfix("(", Fo).prefix("+", y.UnaryAdd, (r6, e) => new at("+", e, (t) => t)).prefix("-", y.UnarySubtract, (r6, e) => new k("-", e, e, (t, n) => -n)).infixLeft(".", y.Dot, (r6, e, t) => new te(r6, t)).infixLeft("/", y.Divide, (r6, e, t) => new k("/", r6, t, (n, i) => n / i)).infixLeft("*", y.Multiply, (r6, e, t) => new k("*", r6, t, (n, i) => n * i)).infixLeft("+", y.Add, (r6, e, t) => new k("+", r6, t, (n, i) => n + i)).infixLeft("-", y.Subtract, (r6, e, t) => new k("-", r6, t, (n, i) => n - i)).infixLeft("|", y.Union, (r6, e, t) => new Pe(r6, t)).infixLeft("=", y.Equals, (r6, e, t) => new pt(r6, t)).infixLeft("!=", y.NotEquals, (r6, e, t) => new dt(r6, t)).infixLeft("~", y.Equivalent, (r6, e, t) => new ft(r6, t)).infixLeft("!~", y.NotEquivalent, (r6, e, t) => new mt(r6, t)).infixLeft("<", y.LessThan, (r6, e, t) => new k("<", r6, t, (n, i) => n < i)).infixLeft("<=", y.LessThanOrEquals, (r6, e, t) => new k("<=", r6, t, (n, i) => n <= i)).infixLeft(">", y.GreaterThan, (r6, e, t) => new k(">", r6, t, (n, i) => n > i)).infixLeft(">=", y.GreaterThanOrEquals, (r6, e, t) => new k(">=", r6, t, (n, i) => n >= i)).infixLeft("&", y.Ampersand, (r6, e, t) => new ct(r6, t)).infixLeft("and", y.And, (r6, e, t) => new ht(r6, t)).infixLeft("as", y.As, (r6, e, t) => new de(r6, t)).infixLeft("contains", y.Contains, (r6, e, t) => new ut(r6, t)).infixLeft("div", y.Divide, (r6, e, t) => new k("div", r6, t, (n, i) => n / i | 0)).infixLeft("in", y.In, (r6, e, t) => new lt(r6, t)).infixLeft("is", y.Is, (r6, e, t) => new fe(r6, t)).infixLeft("mod", y.Modulo, (r6, e, t) => new k("mod", r6, t, (n, i) => n % i)).infixLeft("or", y.Or, (r6, e, t) => new yt(r6, t)).infixLeft("xor", y.Xor, (r6, e, t) => new gt(r6, t)).infixLeft("implies", y.Implies, (r6, e, t) => new xt(r6, t));
43564
+ return new He().registerPrefix("String", { parse: (r6, e) => new L({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r6, e) => new L({ type: l.dateTime, value: Pe(e.value) }) }).registerPrefix("Quantity", { parse: (r6, e) => new L({ type: l.Quantity, value: Bo(e.value) }) }).registerPrefix("Number", { parse: (r6, e) => new L({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new L({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new L({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r6, e) => new U(e.value) }).registerPrefix("{}", { parse: () => new at() }).registerPrefix("(", Lo).registerInfix("[", _o).registerInfix("(", Uo).prefix("+", y.UnaryAdd, (r6, e) => new ct("+", e, (t) => t)).prefix("-", y.UnarySubtract, (r6, e) => new V("-", e, e, (t, n) => -n)).infixLeft(".", y.Dot, (r6, e, t) => new re(r6, t)).infixLeft("/", y.Divide, (r6, e, t) => new V("/", r6, t, (n, i) => n / i)).infixLeft("*", y.Multiply, (r6, e, t) => new V("*", r6, t, (n, i) => n * i)).infixLeft("+", y.Add, (r6, e, t) => new V("+", r6, t, (n, i) => n + i)).infixLeft("-", y.Subtract, (r6, e, t) => new V("-", r6, t, (n, i) => n - i)).infixLeft("|", y.Union, (r6, e, t) => new Ce(r6, t)).infixLeft("=", y.Equals, (r6, e, t) => new dt(r6, t)).infixLeft("!=", y.NotEquals, (r6, e, t) => new ft(r6, t)).infixLeft("~", y.Equivalent, (r6, e, t) => new mt(r6, t)).infixLeft("!~", y.NotEquivalent, (r6, e, t) => new ht(r6, t)).infixLeft("<", y.LessThan, (r6, e, t) => new V("<", r6, t, (n, i) => n < i)).infixLeft("<=", y.LessThanOrEquals, (r6, e, t) => new V("<=", r6, t, (n, i) => n <= i)).infixLeft(">", y.GreaterThan, (r6, e, t) => new V(">", r6, t, (n, i) => n > i)).infixLeft(">=", y.GreaterThanOrEquals, (r6, e, t) => new V(">=", r6, t, (n, i) => n >= i)).infixLeft("&", y.Ampersand, (r6, e, t) => new ut(r6, t)).infixLeft("and", y.And, (r6, e, t) => new yt(r6, t)).infixLeft("as", y.As, (r6, e, t) => new fe(r6, t)).infixLeft("contains", y.Contains, (r6, e, t) => new lt(r6, t)).infixLeft("div", y.Divide, (r6, e, t) => new V("div", r6, t, (n, i) => n / i | 0)).infixLeft("in", y.In, (r6, e, t) => new pt(r6, t)).infixLeft("is", y.Is, (r6, e, t) => new me(r6, t)).infixLeft("mod", y.Modulo, (r6, e, t) => new V("mod", r6, t, (n, i) => n % i)).infixLeft("or", y.Or, (r6, e, t) => new gt(r6, t)).infixLeft("xor", y.Xor, (r6, e, t) => new xt(r6, t)).infixLeft("implies", y.Implies, (r6, e, t) => new vt(r6, t));
43460
43565
  }
43461
- var _o = _e();
43462
- var Fn = ((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))(Fn || {});
43463
- var qn = ((T) => (T.EQUALS = "eq", T.NOT_EQUALS = "ne", T.GREATER_THAN = "gt", T.LESS_THAN = "lt", T.GREATER_THAN_OR_EQUALS = "ge", T.LESS_THAN_OR_EQUALS = "le", T.STARTS_AFTER = "sa", T.ENDS_BEFORE = "eb", T.APPROXIMATELY = "ap", T.CONTAINS = "contains", T.EXACT = "exact", T.TEXT = "text", T.NOT = "not", T.ABOVE = "above", T.BELOW = "below", T.IN = "in", T.NOT_IN = "not-in", T.OF_TYPE = "of-type", T.MISSING = "missing", T.PRESENT = "present", T.IDENTIFIER = "identifier", T.ITERATE = "iterate", T))(qn || {});
43464
- var hs = ((E) => (E.READ = "read", E.VREAD = "vread", E.UPDATE = "update", E.PATCH = "patch", E.DELETE = "delete", E.HISTORY = "history", E.HISTORY_INSTANCE = "history-instance", E.HISTORY_TYPE = "history-type", E.HISTORY_SYSTEM = "history-system", E.CREATE = "create", E.SEARCH = "search", E.SEARCH_TYPE = "search-type", E.SEARCH_SYSTEM = "search-system", E.SEARCH_COMPARTMENT = "search-compartment", E.CAPABILITIES = "capabilities", E.TRANSACTION = "transaction", E.BATCH = "batch", E.OPERATION = "operation", E))(hs || {});
43465
- function Gn(r6) {
43566
+ var qo = _e();
43567
+ var _n = ((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))(_n || {});
43568
+ var $n = ((T) => (T.EQUALS = "eq", T.NOT_EQUALS = "ne", T.GREATER_THAN = "gt", T.LESS_THAN = "lt", T.GREATER_THAN_OR_EQUALS = "ge", T.LESS_THAN_OR_EQUALS = "le", T.STARTS_AFTER = "sa", T.ENDS_BEFORE = "eb", T.APPROXIMATELY = "ap", T.CONTAINS = "contains", T.EXACT = "exact", T.TEXT = "text", T.NOT = "not", T.ABOVE = "above", T.BELOW = "below", T.IN = "in", T.NOT_IN = "not-in", T.OF_TYPE = "of-type", T.MISSING = "missing", T.PRESENT = "present", T.IDENTIFIER = "identifier", T.ITERATE = "iterate", T))($n || {});
43569
+ var xs = ((E) => (E.READ = "read", E.VREAD = "vread", E.UPDATE = "update", E.PATCH = "patch", E.DELETE = "delete", E.HISTORY = "history", E.HISTORY_INSTANCE = "history-instance", E.HISTORY_TYPE = "history-type", E.HISTORY_SYSTEM = "history-system", E.CREATE = "create", E.SEARCH = "search", E.SEARCH_TYPE = "search-type", E.SEARCH_SYSTEM = "search-system", E.SEARCH_COMPARTMENT = "search-compartment", E.CAPABILITIES = "capabilities", E.TRANSACTION = "transaction", E.BATCH = "batch", E.OPERATION = "operation", E))(xs || {});
43570
+ function Qn(r6) {
43466
43571
  if (typeof window < "u") return window.atob(r6);
43467
43572
  if (typeof Buffer < "u") return Buffer.from(r6, "base64").toString("binary");
43468
43573
  throw new Error("Unable to decode base64");
43469
43574
  }
43470
- function Hn(r6) {
43575
+ function Kn(r6) {
43471
43576
  if (typeof window < "u") return window.btoa(r6);
43472
43577
  if (typeof Buffer < "u") return Buffer.from(r6, "binary").toString("base64");
43473
43578
  throw new Error("Unable to encode base64");
43474
43579
  }
43475
- function Er() {
43580
+ function br() {
43476
43581
  let r6 = new Uint32Array(28);
43477
- return crypto.getRandomValues(r6), Pn(r6.buffer);
43582
+ return crypto.getRandomValues(r6), wn(r6.buffer);
43478
43583
  }
43479
- async function Qn(r6) {
43584
+ async function zn(r6) {
43480
43585
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r6));
43481
43586
  }
43482
- function he() {
43587
+ function ye() {
43483
43588
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r6) => {
43484
43589
  let e = Math.random() * 16 | 0;
43485
43590
  return (r6 === "x" ? e : e & 3 | 8).toString(16);
43486
43591
  });
43487
43592
  }
43488
- var Et = class {
43593
+ var bt = class {
43489
43594
  constructor(e = 10) {
43490
43595
  this.max = e, this.cache = /* @__PURE__ */ new Map();
43491
43596
  }
@@ -43509,8 +43614,8 @@ var Et = class {
43509
43614
  return this.cache.keys().next().value;
43510
43615
  }
43511
43616
  };
43512
- var V = { CSS: "text/css", DICOM: "application/dicom", 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", SCIM_JSON: "application/scim+json", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript", PING: "x-application/ping" };
43513
- var br = class {
43617
+ var D = { CSS: "text/css", DICOM: "application/dicom", 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", SCIM_JSON: "application/scim+json", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript", PING: "x-application/ping" };
43618
+ var Rr = class {
43514
43619
  constructor() {
43515
43620
  this.listeners = {};
43516
43621
  }
@@ -43537,7 +43642,7 @@ var br = class {
43537
43642
  };
43538
43643
  var z = class {
43539
43644
  constructor() {
43540
- this.emitter = new br();
43645
+ this.emitter = new Rr();
43541
43646
  }
43542
43647
  dispatchEvent(e) {
43543
43648
  this.emitter.dispatchEvent(e);
@@ -43552,76 +43657,76 @@ var z = class {
43552
43657
  this.emitter.removeAllListeners();
43553
43658
  }
43554
43659
  };
43555
- var Rr = { "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" };
43556
- var Rs = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
43557
- var Pr = ["DiagnosticReport-update"];
43558
- function Jn(r6) {
43559
- return Pr.includes(r6);
43660
+ var Pr = { "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" };
43661
+ var ws = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
43662
+ var Cr = ["DiagnosticReport-update"];
43663
+ function Zn(r6) {
43664
+ return Cr.includes(r6);
43560
43665
  }
43561
- function Yn(r6) {
43562
- if (Pr.includes(r6)) throw new f(h(`'context.version' is required for '${r6}'.`));
43666
+ function Xn(r6) {
43667
+ if (Cr.includes(r6)) throw new f(h(`'context.version' is required for '${r6}'.`));
43563
43668
  }
43564
- var Ps = { "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" } } };
43565
- function Cs(r6) {
43566
- return Rs.includes(r6);
43669
+ var As = { "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" } } };
43670
+ function Os(r6) {
43671
+ return ws.includes(r6);
43567
43672
  }
43568
- function Zn(r6) {
43673
+ function ei(r6) {
43569
43674
  return !!r6.endpoint;
43570
43675
  }
43571
- function Cr(r6) {
43572
- if (!Rt(r6)) throw new f(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
43676
+ function wr(r6) {
43677
+ if (!Pt(r6)) throw new f(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
43573
43678
  let { channelType: e, mode: t, topic: n, events: i } = r6, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i.join(",") };
43574
- return Zn(r6) && (o.endpoint = r6.endpoint), new URLSearchParams(o).toString();
43679
+ return ei(r6) && (o.endpoint = r6.endpoint), new URLSearchParams(o).toString();
43575
43680
  }
43576
- function Rt(r6) {
43681
+ function Pt(r6) {
43577
43682
  if (typeof r6 != "object") return false;
43578
43683
  let { channelType: e, mode: t, topic: n, events: i } = r6;
43579
43684
  if (!(e && t && n && i) || typeof n != "string" || typeof i != "object" || !Array.isArray(i) || i.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe") return false;
43580
- for (let o of i) if (!Rr[o]) return false;
43581
- return !(Zn(r6) && !(typeof r6.endpoint == "string" && r6.endpoint.startsWith("ws")));
43685
+ for (let o of i) if (!Pr[o]) return false;
43686
+ return !(ei(r6) && !(typeof r6.endpoint == "string" && r6.endpoint.startsWith("ws")));
43582
43687
  }
43583
- function zn(r6, e, t, n) {
43688
+ function Yn(r6, e, t, n) {
43584
43689
  if (typeof e != "object") throw new f(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
43585
43690
  if (!(e.id && typeof e.id == "string")) throw new f(h(`context[${t}] is invalid. Resource must contain a valid string ID.`));
43586
43691
  if (!e.resourceType) throw new f(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
43587
43692
  let i = n.resourceType;
43588
43693
  if (i !== "*") {
43589
- if (!Cs(e.resourceType)) throw new f(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
43694
+ if (!Os(e.resourceType)) throw new f(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
43590
43695
  if (i && e.resourceType !== i) throw new f(h(`context[${t}] is invalid. context[${t}] for the '${r6}' event should contain resource of type ${i}.`));
43591
43696
  }
43592
43697
  }
43593
- function ws(r6, e, t, n, i) {
43594
- if (i.set(e.key, (i.get(e.key) ?? 0) + 1), !n.isArray) zn(r6, e.resource, t, n);
43698
+ function Is(r6, e, t, n, i) {
43699
+ if (i.set(e.key, (i.get(e.key) ?? 0) + 1), !n.isArray) Yn(r6, e.resource, t, n);
43595
43700
  else {
43596
43701
  let { resources: o } = e;
43597
43702
  if (!o) throw new f(h(`context[${t}] is invalid. context[${t}] for the '${r6}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
43598
- for (let s of o) zn(r6, s, t, n);
43703
+ for (let s of o) Yn(r6, s, t, n);
43599
43704
  }
43600
43705
  }
43601
- function As(r6, e) {
43602
- let t = /* @__PURE__ */ new Map(), n = Ps[r6];
43706
+ function ks(r6, e) {
43707
+ let t = /* @__PURE__ */ new Map(), n = As[r6];
43603
43708
  for (let i = 0; i < e.length; i++) {
43604
43709
  let o = e[i].key;
43605
43710
  if (!n[o]) throw new f(h(`Key '${o}' not found for event '${r6}'. Make sure to add only valid keys.`));
43606
- ws(r6, e[i], i, n[o], t);
43711
+ Is(r6, e[i], i, n[o], t);
43607
43712
  }
43608
43713
  for (let [i, o] of Object.entries(n)) {
43609
43714
  if (!(o.optional || t.has(i))) throw new f(h(`Missing required key '${i}' on context for '${r6}' event.`));
43610
43715
  if (!o.manyAllowed && (t.get(i) || 0) > 1) throw new f(h(`${t.get(i)} context entries with key '${i}' found for the '${r6}' event when schema only allows for 1.`));
43611
43716
  }
43612
43717
  }
43613
- function wr(r6, e, t, n) {
43718
+ function Ar(r6, e, t, n) {
43614
43719
  if (!(r6 && typeof r6 == "string")) throw new f(h("Must provide a topic."));
43615
- if (!Rr[e]) throw new f(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Rr).join(", ")}`));
43720
+ if (!Pr[e]) throw new f(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Pr).join(", ")}`));
43616
43721
  if (typeof t != "object") throw new f(h("context must be a context object or array of context objects."));
43617
- if (Pr.includes(e) && !n) throw new f(h(`The '${e}' event must contain a 'context.versionId'.`));
43722
+ if (Cr.includes(e) && !n) throw new f(h(`The '${e}' event must contain a 'context.versionId'.`));
43618
43723
  let i = Array.isArray(t) ? t : [t];
43619
- return As(e, i), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: he(), event: { "hub.topic": r6, "hub.event": e, context: i, ...n ? { "context.versionId": n } : {} } };
43724
+ return ks(e, i), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ye(), event: { "hub.topic": r6, "hub.event": e, context: i, ...n ? { "context.versionId": n } : {} } };
43620
43725
  }
43621
- var bt = class extends z {
43726
+ var Rt = class extends z {
43622
43727
  constructor(e) {
43623
43728
  if (super(), this.subRequest = e, !e.endpoint) throw new f(h("Subscription request should contain an endpoint."));
43624
- if (!Rt(e)) throw new f(h("Subscription request failed validation."));
43729
+ if (!Pt(e)) throw new f(h("Subscription request failed validation."));
43625
43730
  let t = new WebSocket(e.endpoint);
43626
43731
  t.addEventListener("open", () => {
43627
43732
  this.dispatchEvent({ type: "connect" }), t.addEventListener("message", (n) => {
@@ -43638,36 +43743,36 @@ var bt = class extends z {
43638
43743
  this.websocket.close();
43639
43744
  }
43640
43745
  };
43641
- function Os(r6) {
43642
- let e = r6.replace(/-/g, "+").replace(/_/g, "/"), t = Gn(e), n = Array.from(t).reduce((o, s) => {
43746
+ function Vs(r6) {
43747
+ let e = r6.replace(/-/g, "+").replace(/_/g, "/"), t = Qn(e), n = Array.from(t).reduce((o, s) => {
43643
43748
  let a2 = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
43644
43749
  return `${o}%${a2}`;
43645
43750
  }, ""), i = decodeURIComponent(n);
43646
43751
  return JSON.parse(i);
43647
43752
  }
43648
- function Xn(r6) {
43753
+ function ti(r6) {
43649
43754
  return r6.split(".").length === 3;
43650
43755
  }
43651
- function Pt(r6) {
43756
+ function Ct(r6) {
43652
43757
  let [e, t, n] = r6.split(".");
43653
- return Os(t);
43758
+ return Vs(t);
43654
43759
  }
43655
- function ei(r6) {
43760
+ function ri(r6) {
43656
43761
  try {
43657
- return typeof Pt(r6).login_id == "string";
43762
+ return typeof Ct(r6).login_id == "string";
43658
43763
  } catch {
43659
43764
  return false;
43660
43765
  }
43661
43766
  }
43662
- function ti(r6) {
43767
+ function ni(r6) {
43663
43768
  try {
43664
- let t = Pt(r6).exp;
43769
+ let t = Ct(r6).exp;
43665
43770
  return typeof t == "number" ? t * 1e3 : void 0;
43666
43771
  } catch {
43667
43772
  return;
43668
43773
  }
43669
43774
  }
43670
- var Ct = class {
43775
+ var wt = class {
43671
43776
  constructor(e) {
43672
43777
  this.medplum = e;
43673
43778
  }
@@ -43675,17 +43780,17 @@ var Ct = class {
43675
43780
  return this.medplum.get(`keyvalue/v1/${e}`);
43676
43781
  }
43677
43782
  async set(e, t) {
43678
- await this.medplum.put(`keyvalue/v1/${e}`, t, V.TEXT);
43783
+ await this.medplum.put(`keyvalue/v1/${e}`, t, D.TEXT);
43679
43784
  }
43680
43785
  async delete(e) {
43681
43786
  await this.medplum.delete(`keyvalue/v1/${e}`);
43682
43787
  }
43683
43788
  };
43684
- var ri;
43685
- ri = Symbol.toStringTag;
43686
- var D = class {
43789
+ var ii;
43790
+ ii = Symbol.toStringTag;
43791
+ var M = class {
43687
43792
  constructor(e) {
43688
- this[ri] = "ReadablePromise";
43793
+ this[ii] = "ReadablePromise";
43689
43794
  this.status = "pending";
43690
43795
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
43691
43796
  throw this.status = "error", this.error = t, t;
@@ -43719,7 +43824,7 @@ var D = class {
43719
43824
  };
43720
43825
  var Be = class {
43721
43826
  constructor(e) {
43722
- this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Ar());
43827
+ this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Or());
43723
43828
  }
43724
43829
  clear() {
43725
43830
  this.storage.clear();
@@ -43735,10 +43840,10 @@ var Be = class {
43735
43840
  return t ? JSON.parse(t) : void 0;
43736
43841
  }
43737
43842
  setObject(e, t) {
43738
- this.setString(e, t ? En(t) : void 0);
43843
+ this.setString(e, t ? Rn(t) : void 0);
43739
43844
  }
43740
43845
  };
43741
- var Ar = class {
43846
+ var Or = class {
43742
43847
  constructor() {
43743
43848
  this.data = /* @__PURE__ */ new Map();
43744
43849
  }
@@ -43761,7 +43866,7 @@ var Ar = class {
43761
43866
  return Array.from(this.data.keys())[e];
43762
43867
  }
43763
43868
  };
43764
- var Or = class extends z {
43869
+ var Ir = class extends z {
43765
43870
  constructor(t) {
43766
43871
  super();
43767
43872
  this.bufferedAmount = -1 / 0;
@@ -43814,21 +43919,21 @@ var qe = class extends z {
43814
43919
  this.criteria.delete(e);
43815
43920
  }
43816
43921
  };
43817
- var Ir = class {
43922
+ var kr = class {
43818
43923
  constructor(e, t) {
43819
43924
  this.criteria = e, this.emitter = new qe(e), this.refCount = 1, this.subscriptionProps = t ? { ...t } : void 0;
43820
43925
  }
43821
43926
  };
43822
- var wt = class {
43927
+ var At = class {
43823
43928
  constructor(e, t, n) {
43824
- if (!(e instanceof At)) throw new f(h("First arg of constructor should be a `MedplumClient`"));
43929
+ if (!(e instanceof Ot)) throw new f(h("First arg of constructor should be a `MedplumClient`"));
43825
43930
  let i;
43826
43931
  try {
43827
43932
  i = new URL(t).toString();
43828
43933
  } catch {
43829
43934
  throw new f(h("Not a valid URL"));
43830
43935
  }
43831
- let o = n?.RobustWebSocket ? new n.RobustWebSocket(i) : new Or(i);
43936
+ let o = n?.RobustWebSocket ? new n.RobustWebSocket(i) : new Ir(i);
43832
43937
  this.medplum = e, this.ws = o, this.masterSubEmitter = new qe(), this.criteriaEntries = /* @__PURE__ */ new Map(), this.criteriaEntriesBySubscriptionId = /* @__PURE__ */ new Map(), this.wsClosed = false, this.setupWebSocketListeners();
43833
43938
  }
43834
43939
  setupWebSocketListeners() {
@@ -43841,7 +43946,7 @@ var wt = class {
43841
43946
  return;
43842
43947
  }
43843
43948
  this.masterSubEmitter?.dispatchEvent({ type: "message", payload: n });
43844
- let o = this.criteriaEntriesBySubscriptionId.get(Te(i.subscription));
43949
+ let o = this.criteriaEntriesBySubscriptionId.get(Se(i.subscription));
43845
43950
  if (!o) {
43846
43951
  console.warn("Received notification for criteria the SubscriptionManager is not listening for");
43847
43952
  return;
@@ -43854,7 +43959,7 @@ var wt = class {
43854
43959
  for (let o of this.getAllCriteriaEmitters()) o.dispatchEvent(i);
43855
43960
  }
43856
43961
  }), e.addEventListener("error", () => {
43857
- let t = { type: "error", payload: new f(Qr(new Error("WebSocket error"))) };
43962
+ let t = { type: "error", payload: new f(zr(new Error("WebSocket error"))) };
43858
43963
  this.masterSubEmitter?.dispatchEvent(t);
43859
43964
  for (let n of this.getAllCriteriaEmitters()) n.dispatchEvent(t);
43860
43965
  }), e.addEventListener("close", () => {
@@ -43881,7 +43986,7 @@ var wt = class {
43881
43986
  }
43882
43987
  async getTokenForCriteria(e) {
43883
43988
  let t = e?.subscriptionId;
43884
- t || (t = (await this.medplum.createResource({ ...e.subscriptionProps, resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${ce(this.medplum.getProfile())}`, channel: { type: "websocket" }, criteria: e.criteria })).id);
43989
+ t || (t = (await this.medplum.createResource({ ...e.subscriptionProps, resourceType: "Subscription", status: "active", reason: `WebSocket subscription for ${ue(this.medplum.getProfile())}`, channel: { type: "websocket" }, criteria: e.criteria })).id);
43885
43990
  let { parameter: n } = await this.medplum.get(`fhir/R4/Subscription/${t}/$get-ws-binding-token`), i = n?.find((s) => s.name === "token")?.valueString, o = n?.find((s) => s.name === "websocket-url")?.valueUrl;
43886
43991
  if (!i) throw new f(h("Failed to get token"));
43887
43992
  if (!o) throw new f(h("Failed to get URL from $get-ws-binding-token"));
@@ -43891,7 +43996,7 @@ var wt = class {
43891
43996
  let n = this.criteriaEntries.get(e);
43892
43997
  if (n) {
43893
43998
  if (!t) return n.bareCriteria;
43894
- for (let i of n.criteriaWithProps) if (X(t, i.subscriptionProps)) return i;
43999
+ for (let i of n.criteriaWithProps) if (ee(t, i.subscriptionProps)) return i;
43895
44000
  }
43896
44001
  }
43897
44002
  getAllCriteriaEmitters() {
@@ -43912,14 +44017,14 @@ var wt = class {
43912
44017
  let s = this.criteriaEntries.get(t);
43913
44018
  n ? s.criteriaWithProps = s.criteriaWithProps.filter((a2) => {
43914
44019
  let c = a2.subscriptionProps;
43915
- return !X(n, c);
44020
+ return !ee(n, c);
43916
44021
  }) : s.bareCriteria = void 0, !s.bareCriteria && s.criteriaWithProps.length === 0 && (this.criteriaEntries.delete(t), this.masterSubEmitter?._removeCriteria(t)), i && this.criteriaEntriesBySubscriptionId.delete(i), o && this.ws.send(JSON.stringify({ type: "unbind-from-token", payload: { token: o } }));
43917
44022
  }
43918
44023
  addCriteria(e, t) {
43919
44024
  this.masterSubEmitter && this.masterSubEmitter._addCriteria(e);
43920
44025
  let n = this.maybeGetCriteriaEntry(e, t);
43921
44026
  if (n) return n.refCount += 1, n.emitter;
43922
- let i = new Ir(e, t);
44027
+ let i = new kr(e, t);
43923
44028
  return this.addCriteriaEntry(i), this.getTokenForCriteria(i).then(([o, s]) => {
43924
44029
  i.subscriptionId = o, i.token = s, this.criteriaEntriesBySubscriptionId.set(o, i), this.emitConnect(i), this.ws.send(JSON.stringify({ type: "bind-with-token", payload: { token: s } }));
43925
44030
  }).catch((o) => {
@@ -43944,26 +44049,28 @@ var wt = class {
43944
44049
  return this.masterSubEmitter || (this.masterSubEmitter = new qe(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
43945
44050
  }
43946
44051
  };
43947
- var sd = "3.1.11-4bc60483a";
43948
- var Vs = V.FHIR_JSON + ", */*; q=0.1";
43949
- var Ds = "https://api.medplum.com/";
43950
- var Ms = 1e3;
43951
- var Ns = 6e4;
43952
- var Fs = 0;
43953
- var Ls = "Binary/";
43954
- var ii = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
43955
- var _s = ((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))(_s || {});
43956
- var Us = ((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))(Us || {});
43957
- var Bs = ((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))(Bs || {});
43958
- var qs = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(qs || {});
43959
- var At = class extends z {
44052
+ var ld = "3.2.1-e374fc0fb";
44053
+ var Ns = D.FHIR_JSON + ", */*; q=0.1";
44054
+ var Fs = "https://api.medplum.com/";
44055
+ var Ls = 1e3;
44056
+ var _s = 6e4;
44057
+ var Us = 0;
44058
+ var Bs = "Binary/";
44059
+ var si = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
44060
+ var qs = ((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))(qs || {});
44061
+ var js = ((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))(js || {});
44062
+ var $s = ((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))($s || {});
44063
+ var Ws = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(Ws || {});
44064
+ var Ot = class extends z {
43960
44065
  constructor(t) {
43961
44066
  super();
43962
44067
  this.initComplete = true;
43963
44068
  if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
43964
- this.options = t ?? {}, this.fetch = t?.fetch ?? js(), this.storage = t?.storage ?? new Be(), this.createPdfImpl = t?.createPdf, this.baseUrl = dr(t?.baseUrl ?? Ds), this.fhirBaseUrl = j(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = j(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = j(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = j(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? Fs : Ns), this.cacheTime > 0 ? this.requestCache = new Et(t?.resourceCacheSize ?? Ms) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve(), this.dispatchEvent({ type: "storageInitialized" })) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
44069
+ this.options = t ?? {}, this.fetch = t?.fetch ?? Gs(), this.storage = t?.storage ?? new Be(), this.createPdfImpl = t?.createPdf, this.baseUrl = fr(t?.baseUrl ?? Fs), this.fhirBaseUrl = j(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = j(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = j(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = j(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? Us : _s), this.cacheTime > 0 ? this.requestCache = new bt(t?.resourceCacheSize ?? Ls) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve(), this.dispatchEvent({ type: "storageInitialized" })) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
43965
44070
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
43966
- }).catch(console.error)), this.setupStorageListener();
44071
+ }).catch((n) => {
44072
+ console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
44073
+ })), this.setupStorageListener();
43967
44074
  }
43968
44075
  get isInitialized() {
43969
44076
  return this.initComplete;
@@ -44011,7 +44118,7 @@ var At = class extends z {
44011
44118
  t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a2, c) => {
44012
44119
  this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a2, reject: c }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
44013
44120
  }) : o = this.request("GET", t, n);
44014
- let s = new D(o);
44121
+ let s = new M(o);
44015
44122
  return this.setCacheEntry(t, s), s;
44016
44123
  }
44017
44124
  post(t, n, i, o = {}) {
@@ -44021,7 +44128,7 @@ var At = class extends z {
44021
44128
  return t = t.toString(), this.setRequestBody(o, n), i && this.setRequestContentType(o, i), this.invalidateUrl(t), this.request("PUT", t, o);
44022
44129
  }
44023
44130
  patch(t, n, i = {}) {
44024
- return t = t.toString(), this.setRequestBody(i, n), this.setRequestContentType(i, V.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i);
44131
+ return t = t.toString(), this.setRequestBody(i, n), this.setRequestContentType(i, D.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i);
44025
44132
  }
44026
44133
  delete(t, n) {
44027
44134
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -44083,12 +44190,12 @@ var At = class extends z {
44083
44190
  }
44084
44191
  fhirSearchUrl(t, n) {
44085
44192
  let i = this.fhirUrl(t);
44086
- return n && (i.search = kn(n)), i;
44193
+ return n && (i.search = Dn(n)), i;
44087
44194
  }
44088
44195
  search(t, n, i) {
44089
44196
  let o = this.fhirSearchUrl(t, n), s = "search-" + o.toString(), a2 = this.getCacheEntry(s, i);
44090
44197
  if (a2) return a2.value;
44091
- let c = new D((async () => {
44198
+ let c = new M((async () => {
44092
44199
  let u2 = await this.get(o, i);
44093
44200
  if (u2.entry) for (let p2 of u2.entry) this.cacheResource(p2.resource);
44094
44201
  return u2;
@@ -44100,13 +44207,13 @@ var At = class extends z {
44100
44207
  o.searchParams.set("_count", "1"), o.searchParams.sort();
44101
44208
  let s = "searchOne-" + o.toString(), a2 = this.getCacheEntry(s, i);
44102
44209
  if (a2) return a2.value;
44103
- let c = new D(this.search(t, o.searchParams, i).then((u2) => u2.entry?.[0]?.resource));
44210
+ let c = new M(this.search(t, o.searchParams, i).then((u2) => u2.entry?.[0]?.resource));
44104
44211
  return this.setCacheEntry(s, c), c;
44105
44212
  }
44106
44213
  searchResources(t, n, i) {
44107
44214
  let s = "searchResources-" + this.fhirSearchUrl(t, n).toString(), a2 = this.getCacheEntry(s, i);
44108
44215
  if (a2) return a2.value;
44109
- let c = new D(this.search(t, n, i).then(kr));
44216
+ let c = new M(this.search(t, n, i).then(Vr));
44110
44217
  return this.setCacheEntry(s, c), c;
44111
44218
  }
44112
44219
  async *searchResourcePages(t, n, i) {
@@ -44114,7 +44221,7 @@ var At = class extends z {
44114
44221
  for (; o; ) {
44115
44222
  let s = new URL(o).searchParams, a2 = await this.search(t, s, i), c = a2.link?.find((u2) => u2.relation === "next");
44116
44223
  if (!a2.entry?.length && !c) break;
44117
- yield kr(a2), o = c?.url ? new URL(c.url) : void 0;
44224
+ yield Vr(a2), o = c?.url ? new URL(c.url) : void 0;
44118
44225
  }
44119
44226
  }
44120
44227
  searchValueSet(t, n, i) {
@@ -44131,7 +44238,7 @@ var At = class extends z {
44131
44238
  getCachedReference(t) {
44132
44239
  let n = t.reference;
44133
44240
  if (!n) return;
44134
- if (n === "system") return ii;
44241
+ if (n === "system") return si;
44135
44242
  let [i, o] = n.split("/");
44136
44243
  if (!(!i || !o)) return this.getCached(i, o);
44137
44244
  }
@@ -44140,16 +44247,16 @@ var At = class extends z {
44140
44247
  }
44141
44248
  readReference(t, n) {
44142
44249
  let i = t.reference;
44143
- if (!i) return new D(Promise.reject(new Error("Missing reference")));
44144
- if (i === "system") return new D(Promise.resolve(ii));
44250
+ if (!i) return new M(Promise.reject(new Error("Missing reference")));
44251
+ if (i === "system") return new M(Promise.resolve(si));
44145
44252
  let [o, s] = i.split("/");
44146
- return !o || !s ? new D(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
44253
+ return !o || !s ? new M(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
44147
44254
  }
44148
44255
  requestSchema(t) {
44149
- if (on(t)) return Promise.resolve();
44256
+ if (an(t)) return Promise.resolve();
44150
44257
  let n = t + "-requestSchema", i = this.getCacheEntry(n, void 0);
44151
44258
  if (i) return i.value;
44152
- let o = new D((async () => {
44259
+ let o = new M((async () => {
44153
44260
  let s = `{
44154
44261
  StructureDefinitionList(name: "${t}") {
44155
44262
  resourceType,
@@ -44190,24 +44297,24 @@ var At = class extends z {
44190
44297
  target
44191
44298
  }
44192
44299
  }`.replace(/\s+/g, " "), a2 = await this.graphql(s);
44193
- zt(a2.data.StructureDefinitionList);
44194
- for (let c of a2.data.SearchParameterList) hr(c);
44300
+ Yt(a2.data.StructureDefinitionList);
44301
+ for (let c of a2.data.SearchParameterList) yr(c);
44195
44302
  })());
44196
44303
  return this.setCacheEntry(n, o), o;
44197
44304
  }
44198
44305
  requestProfileSchema(t, n) {
44199
- if (!n?.expandProfile && an(t)) return Promise.resolve([t]);
44306
+ if (!n?.expandProfile && un(t)) return Promise.resolve([t]);
44200
44307
  let i = t + "-requestSchema" + (n?.expandProfile ? "-nested" : ""), o = this.getCacheEntry(i, void 0);
44201
44308
  if (o) return o.value;
44202
- let s = new D((async () => {
44309
+ let s = new M((async () => {
44203
44310
  if (n?.expandProfile) {
44204
44311
  let a2 = this.fhirUrl("StructureDefinition", "$expand-profile");
44205
44312
  a2.search = new URLSearchParams({ url: t }).toString();
44206
44313
  let c = await this.post(a2.toString(), {});
44207
- return kr(c).map((u2) => (Jt(u2, u2.url), u2.url));
44314
+ return Vr(c).map((u2) => (Zt(u2, u2.url), u2.url));
44208
44315
  } else {
44209
44316
  let a2 = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
44210
- return a2 ? (zt([a2], t), [t]) : (console.warn(`No StructureDefinition found for ${t}!`), []);
44317
+ return a2 ? (Yt([a2], t), [t]) : (console.warn(`No StructureDefinition found for ${t}!`), []);
44211
44318
  }
44212
44319
  })());
44213
44320
  return this.setCacheEntry(i, s), s;
@@ -44233,11 +44340,11 @@ var At = class extends z {
44233
44340
  return s || (s = t), this.cacheResource(s), this.invalidateUrl(this.fhirUrl(t.resourceType, t.id, "_history")), this.invalidateSearches(t.resourceType), s;
44234
44341
  }
44235
44342
  async createAttachment(t, n, i, o, s) {
44236
- let a2 = ai(t, n, i, o), c = s ?? (typeof n == "object" ? n : {}), u2 = await this.createBinary(a2, c);
44343
+ let a2 = ui(t, n, i, o), c = s ?? (typeof n == "object" ? n : {}), u2 = await this.createBinary(a2, c);
44237
44344
  return { contentType: a2.contentType, url: u2.url, title: a2.filename };
44238
44345
  }
44239
44346
  createBinary(t, n, i, o, s) {
44240
- let a2 = ai(t, n, i, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: m2, securityContext: g, onProgress: G } = a2, Ie = this.fhirUrl("Binary");
44347
+ let a2 = ui(t, n, i, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p2, filename: m2, securityContext: g, onProgress: G } = a2, Ie = this.fhirUrl("Binary");
44241
44348
  return m2 && Ie.searchParams.set("_filename", m2), g?.reference && this.setRequestHeader(c, "X-Security-Context", g.reference), G ? this.uploadwithProgress(Ie, u2, p2, G, c) : this.post(Ie, u2, p2, c);
44242
44349
  }
44243
44350
  uploadwithProgress(t, n, i, o, s) {
@@ -44258,12 +44365,12 @@ var At = class extends z {
44258
44365
  }
44259
44366
  async createPdf(t, n, i, o) {
44260
44367
  if (!this.createPdfImpl) throw new Error("PDF creation not enabled");
44261
- let s = Gs(t, n, i, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: p2, ...m2 } = s, g = await this.createPdfImpl(c, u2, p2), G = { ...m2, data: g, contentType: "application/pdf" };
44368
+ let s = Ks(t, n, i, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: p2, ...m2 } = s, g = await this.createPdfImpl(c, u2, p2), G = { ...m2, data: g, contentType: "application/pdf" };
44262
44369
  return this.createBinary(G, a2);
44263
44370
  }
44264
44371
  createComment(t, n, i) {
44265
44372
  let o = this.getProfile(), s, a2;
44266
- return t.resourceType === "Encounter" && (s = ee(t), a2 = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a2 = t.subject), t.resourceType === "Patient" && (a2 = ee(t)), this.createResource({ resourceType: "Communication", status: "completed", basedOn: [ee(t)], encounter: s, subject: a2, sender: o ? ee(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i);
44373
+ return t.resourceType === "Encounter" && (s = te(t), a2 = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a2 = t.subject), t.resourceType === "Patient" && (a2 = te(t)), this.createResource({ resourceType: "Communication", status: "completed", basedOn: [te(t)], encounter: s, subject: a2, sender: o ? te(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i);
44267
44374
  }
44268
44375
  async updateResource(t, n) {
44269
44376
  if (!t.resourceType) throw new Error("Missing resourceType");
@@ -44295,28 +44402,28 @@ var At = class extends z {
44295
44402
  return this.post(this.fhirBaseUrl, t, void 0, n);
44296
44403
  }
44297
44404
  sendEmail(t, n) {
44298
- return this.post("email/v1/send", t, V.JSON, n);
44405
+ return this.post("email/v1/send", t, D.JSON, n);
44299
44406
  }
44300
44407
  graphql(t, n, i, o) {
44301
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i }, V.JSON, o);
44408
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i }, D.JSON, o);
44302
44409
  }
44303
44410
  readResourceGraph(t, n, i, o) {
44304
44411
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i}`, o);
44305
44412
  }
44306
44413
  pushToAgent(t, n, i, o, s, a2) {
44307
- return this.post(this.fhirUrl("Agent", Te(t), "$push"), { destination: typeof n == "string" ? n : ce(n), body: i, contentType: o, waitForResponse: s }, V.FHIR_JSON, a2);
44414
+ return this.post(this.fhirUrl("Agent", Se(t), "$push"), { destination: typeof n == "string" ? n : ue(n), body: i, contentType: o, waitForResponse: s }, D.FHIR_JSON, a2);
44308
44415
  }
44309
44416
  getActiveLogin() {
44310
44417
  return this.storage.getObject("activeLogin");
44311
44418
  }
44312
44419
  async setActiveLogin(t) {
44313
- (!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();
44420
+ (!this.sessionDetails?.profile || ue(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();
44314
44421
  }
44315
44422
  getAccessToken() {
44316
44423
  return this.accessToken;
44317
44424
  }
44318
44425
  setAccessToken(t, n) {
44319
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = ti(t), this.medplumServer = ei(t);
44426
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = ni(t), this.medplumServer = ri(t);
44320
44427
  }
44321
44428
  getLogins() {
44322
44429
  return this.storage.getObject("logins") ?? [];
@@ -44364,13 +44471,13 @@ var At = class extends z {
44364
44471
  async download(t, n = {}) {
44365
44472
  this.refreshPromise && await this.refreshPromise;
44366
44473
  let i = t.toString();
44367
- i.startsWith(Ls) && (t = this.fhirUrl(i));
44474
+ i.startsWith(Bs) && (t = this.fhirUrl(i));
44368
44475
  let o = n.headers;
44369
44476
  return o || (o = {}, n.headers = o), o.Accept || (o.Accept = "*/*"), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
44370
44477
  }
44371
44478
  async createMedia(t, n) {
44372
44479
  let { additionalFields: i, ...o } = t, s = await this.createResource({ resourceType: "Media", status: "preparation", content: { contentType: t.contentType }, ...i });
44373
- o.securityContext || (o.securityContext = ee(s));
44480
+ o.securityContext || (o.securityContext = te(s));
44374
44481
  let a2 = await this.createAttachment(o, n);
44375
44482
  return this.updateResource({ ...s, status: "completed", content: a2 });
44376
44483
  }
@@ -44387,7 +44494,7 @@ var At = class extends z {
44387
44494
  return i.Prefer = "respond-async", this.request("POST", t, n);
44388
44495
  }
44389
44496
  get keyValue() {
44390
- return this.keyValueClient || (this.keyValueClient = new Ct(this)), this.keyValueClient;
44497
+ return this.keyValueClient || (this.keyValueClient = new wt(this)), this.keyValueClient;
44391
44498
  }
44392
44499
  getCacheEntry(t, n) {
44393
44500
  if (!this.requestCache || n?.cache === "no-cache" || n?.cache === "reload") return;
@@ -44398,7 +44505,7 @@ var At = class extends z {
44398
44505
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
44399
44506
  }
44400
44507
  cacheResource(t) {
44401
- t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new D(Promise.resolve(t)));
44508
+ t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new M(Promise.resolve(t)));
44402
44509
  }
44403
44510
  deleteCacheEntry(t) {
44404
44511
  this.requestCache && this.requestCache.delete(t);
@@ -44409,14 +44516,14 @@ var At = class extends z {
44409
44516
  if (s.status === 401) return this.handleUnauthenticated(t, n, i);
44410
44517
  if (s.status === 204 || s.status === 304) return;
44411
44518
  let c = s.headers.get("content-type")?.includes("json");
44412
- if (s.status === 404 && !c) throw new f(Hr);
44519
+ if (s.status === 404 && !c) throw new f(Kr);
44413
44520
  let u2 = await this.parseBody(s, c);
44414
44521
  if (s.status === 200 && i.followRedirectOnOk || s.status === 201 && i.followRedirectOnCreated) {
44415
- let p2 = await si(s, u2);
44522
+ let p2 = await ci(s, u2);
44416
44523
  if (p2) return this.request("GET", p2, { ...i, body: void 0 });
44417
44524
  }
44418
44525
  if (s.status === 202 && i.pollStatusOnAccepted) {
44419
- let m2 = await si(s, u2) ?? o.statusUrl;
44526
+ let m2 = await ci(s, u2) ?? o.statusUrl;
44420
44527
  if (m2) return this.pollStatus(m2, i, o);
44421
44528
  }
44422
44529
  if (s.status >= 400) throw new f(ze(u2));
@@ -44443,14 +44550,14 @@ var At = class extends z {
44443
44550
  } catch (a2) {
44444
44551
  if (a2.message === "Failed to fetch" && s === 0 && this.dispatchEvent({ type: "offline" }), a2.name === "AbortError" || s === i) throw a2;
44445
44552
  }
44446
- await lr(o);
44553
+ await pr(o);
44447
44554
  }
44448
44555
  throw new Error("Unreachable");
44449
44556
  }
44450
44557
  logRequest(t, n) {
44451
44558
  if (console.log(`> ${n.method} ${t}`), n.headers) {
44452
44559
  let i = n.headers;
44453
- for (let o of nt(Object.keys(i))) console.log(`> ${o}: ${i[o]}`);
44560
+ for (let o of it(Object.keys(i))) console.log(`> ${o}: ${i[o]}`);
44454
44561
  }
44455
44562
  }
44456
44563
  logResponse(t) {
@@ -44461,7 +44568,7 @@ var At = class extends z {
44461
44568
  if (i.pollCount === void 0) n.headers && typeof n.headers == "object" && "Prefer" in n.headers && (o.headers = { ...n.headers }, delete o.headers.Prefer), i.statusUrl = t, i.pollCount = 1;
44462
44569
  else {
44463
44570
  let s = n.pollStatusPeriod ?? 1e3;
44464
- await lr(s), i.pollCount++;
44571
+ await pr(s), i.pollCount++;
44465
44572
  }
44466
44573
  return this.request("GET", t, o, i);
44467
44574
  }
@@ -44479,11 +44586,11 @@ var At = class extends z {
44479
44586
  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 })) }, i = await this.post(this.fhirBaseUrl, n);
44480
44587
  for (let o = 0; o < t.length; o++) {
44481
44588
  let s = t[o], a2 = i.entry?.[o];
44482
- a2?.response?.outcome && !jt(a2.response.outcome) ? s.reject(new f(a2.response.outcome)) : s.resolve(a2?.resource);
44589
+ a2?.response?.outcome && !Wt(a2.response.outcome) ? s.reject(new f(a2.response.outcome)) : s.resolve(a2?.resource);
44483
44590
  }
44484
44591
  }
44485
44592
  addFetchOptionsDefaults(t) {
44486
- this.setRequestHeader(t, "X-Medplum", "extended"), this.setRequestHeader(t, "Accept", Vs, true), t.body && this.setRequestHeader(t, "Content-Type", V.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
44593
+ this.setRequestHeader(t, "X-Medplum", "extended"), this.setRequestHeader(t, "Accept", Ns, true), t.body && this.setRequestHeader(t, "Content-Type", D.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
44487
44594
  }
44488
44595
  setRequestContentType(t, n) {
44489
44596
  this.setRequestHeader(t, "Content-Type", n);
@@ -44500,20 +44607,20 @@ var At = class extends z {
44500
44607
  return this.refresh() ? this.request(t, n, i) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
44501
44608
  }
44502
44609
  async startPkce() {
44503
- let t = Er();
44610
+ let t = br();
44504
44611
  sessionStorage.setItem("pkceState", t);
44505
- let n = Er();
44612
+ let n = br();
44506
44613
  sessionStorage.setItem("codeVerifier", n);
44507
- let i = await Qn(n), o = Cn(i).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
44614
+ let i = await zn(n), o = An(i).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
44508
44615
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
44509
44616
  }
44510
44617
  async requestAuthorization(t) {
44511
44618
  let n = await this.ensureCodeChallenge(t ?? {}), i = new URL(this.authorizeUrl);
44512
- i.searchParams.set("response_type", "code"), i.searchParams.set("state", sessionStorage.getItem("pkceState")), i.searchParams.set("client_id", n.clientId ?? this.clientId), i.searchParams.set("redirect_uri", n.redirectUri ?? oi()), i.searchParams.set("code_challenge_method", n.codeChallengeMethod), i.searchParams.set("code_challenge", n.codeChallenge), i.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i.toString());
44619
+ i.searchParams.set("response_type", "code"), i.searchParams.set("state", sessionStorage.getItem("pkceState")), i.searchParams.set("client_id", n.clientId ?? this.clientId), i.searchParams.set("redirect_uri", n.redirectUri ?? ai()), i.searchParams.set("code_challenge_method", n.codeChallengeMethod), i.searchParams.set("code_challenge", n.codeChallenge), i.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i.toString());
44513
44620
  }
44514
44621
  processCode(t, n) {
44515
44622
  let i = new URLSearchParams();
44516
- if (i.set("grant_type", "authorization_code"), i.set("code", t), i.set("client_id", n?.clientId ?? this.clientId), i.set("redirect_uri", n?.redirectUri ?? oi()), typeof sessionStorage < "u") {
44623
+ if (i.set("grant_type", "authorization_code"), i.set("code", t), i.set("client_id", n?.clientId ?? this.clientId), i.set("redirect_uri", n?.redirectUri ?? ai()), typeof sessionStorage < "u") {
44517
44624
  let o = sessionStorage.getItem("codeVerifier");
44518
44625
  o && i.set("code_verifier", o);
44519
44626
  }
@@ -44545,25 +44652,25 @@ var At = class extends z {
44545
44652
  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);
44546
44653
  }
44547
44654
  setBasicAuth(t, n) {
44548
- this.clientId = t, this.clientSecret = n, this.basicAuth = Hn(t + ":" + n);
44655
+ this.clientId = t, this.clientSecret = n, this.basicAuth = Kn(t + ":" + n);
44549
44656
  }
44550
44657
  async fhircastSubscribe(t, n) {
44551
44658
  if (!(typeof t == "string" && t !== "")) throw new f(h("Invalid topic provided. Topic must be a valid string."));
44552
44659
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0)) throw new f(h("Invalid events provided. Events must be an array of event names containing at least one event."));
44553
- let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", Cr(i), V.FORM_URL_ENCODED))["hub.channel.endpoint"];
44660
+ let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", wr(i), D.FORM_URL_ENCODED))["hub.channel.endpoint"];
44554
44661
  if (!s) throw new Error("Invalid response!");
44555
44662
  return i.endpoint = s, i;
44556
44663
  }
44557
44664
  async fhircastUnsubscribe(t) {
44558
- if (!Rt(t)) throw new f(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
44665
+ if (!Pt(t)) throw new f(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
44559
44666
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws"))) throw new f(h("Provided subscription request must have an endpoint in order to unsubscribe."));
44560
- t.mode = "unsubscribe", await this.post("/fhircast/STU3", Cr(t), V.FORM_URL_ENCODED);
44667
+ t.mode = "unsubscribe", await this.post("/fhircast/STU3", wr(t), D.FORM_URL_ENCODED);
44561
44668
  }
44562
44669
  fhircastConnect(t) {
44563
- return new bt(t);
44670
+ return new Rt(t);
44564
44671
  }
44565
44672
  async fhircastPublish(t, n, i, o) {
44566
- return Jn(n) ? this.post(`/fhircast/STU3/${t}`, wr(t, n, i, o), V.JSON) : (Yn(n), this.post(`/fhircast/STU3/${t}`, wr(t, n, i), V.JSON));
44673
+ return Zn(n) ? this.post(`/fhircast/STU3/${t}`, Ar(t, n, i, o), D.JSON) : (Xn(n), this.post(`/fhircast/STU3/${t}`, Ar(t, n, i), D.JSON));
44567
44674
  }
44568
44675
  async fhircastGetContext(t) {
44569
44676
  return this.get(`/fhircast/STU3/${t}`);
@@ -44572,7 +44679,7 @@ var At = class extends z {
44572
44679
  return this.post("admin/projects/" + t + "/invite", n);
44573
44680
  }
44574
44681
  async fetchTokens(t) {
44575
- let n = { method: "POST", headers: { "Content-Type": V.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i = n.headers;
44682
+ let n = { method: "POST", headers: { "Content-Type": D.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i = n.headers;
44576
44683
  this.basicAuth && (i.Authorization = `Basic ${this.basicAuth}`);
44577
44684
  let o;
44578
44685
  try {
@@ -44594,8 +44701,8 @@ var At = class extends z {
44594
44701
  }
44595
44702
  async verifyTokens(t) {
44596
44703
  let n = t.access_token;
44597
- if (Xn(n)) {
44598
- let i = Pt(n);
44704
+ if (ti(n)) {
44705
+ let i = Ct(n);
44599
44706
  if (Date.now() >= i.exp * 1e3) throw this.clearActiveLogin(), new Error("Token expired");
44600
44707
  if (i.cid) {
44601
44708
  if (i.cid !== this.clientId) throw this.clearActiveLogin(), new Error("Token was not issued for this audience");
@@ -44612,7 +44719,7 @@ var At = class extends z {
44612
44719
  }
44613
44720
  }
44614
44721
  getSubscriptionManager() {
44615
- return this.subscriptionManager || (this.subscriptionManager = new wt(this, In(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
44722
+ return this.subscriptionManager || (this.subscriptionManager = new At(this, Vn(this.baseUrl, "/ws/subscriptions-r4"))), this.subscriptionManager;
44616
44723
  }
44617
44724
  subscribeToCriteria(t, n) {
44618
44725
  return this.getSubscriptionManager().addCriteria(t, n);
@@ -44624,41 +44731,41 @@ var At = class extends z {
44624
44731
  return this.getSubscriptionManager().getMasterEmitter();
44625
44732
  }
44626
44733
  };
44627
- function js() {
44734
+ function Gs() {
44628
44735
  if (!globalThis.fetch) throw new Error("Fetch not available in this environment");
44629
44736
  return globalThis.fetch.bind(globalThis);
44630
44737
  }
44631
- function oi() {
44738
+ function ai() {
44632
44739
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
44633
44740
  }
44634
- async function si(r6, e) {
44741
+ async function ci(r6, e) {
44635
44742
  let t = r6.headers.get("content-location");
44636
44743
  if (t) return t;
44637
44744
  let n = r6.headers.get("location");
44638
44745
  if (n) return n;
44639
- if (ge(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
44746
+ if (xe(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
44640
44747
  }
44641
- function kr(r6) {
44748
+ function Vr(r6) {
44642
44749
  let e = r6.entry?.map((t) => t.resource) ?? [];
44643
44750
  return Object.assign(e, { bundle: r6 });
44644
44751
  }
44645
- function $s(r6) {
44752
+ function Hs(r6) {
44646
44753
  return b(r6) && "data" in r6 && "contentType" in r6;
44647
44754
  }
44648
- function ai(r6, e, t, n) {
44649
- return $s(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
44755
+ function ui(r6, e, t, n) {
44756
+ return Hs(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
44650
44757
  }
44651
- function Ws(r6) {
44758
+ function Qs(r6) {
44652
44759
  return b(r6) && "docDefinition" in r6;
44653
44760
  }
44654
- function Gs(r6, e, t, n) {
44655
- return Ws(r6) ? r6 : { docDefinition: r6, filename: e, tableLayouts: t, fonts: n };
44761
+ function Ks(r6, e, t, n) {
44762
+ return Qs(r6) ? r6 : { docDefinition: r6, filename: e, tableLayouts: t, fonts: n };
44656
44763
  }
44657
- var na = [...Le, "->", "<<", ">>", "=="];
44658
- var sa = _e().registerInfix("->", { precedence: y.Arrow }).registerInfix(";", { precedence: y.Semicolon });
44659
- var Ea = [...Le, "eq", "ne", "co"];
44660
- var Pa = _e();
44661
- var oe = class {
44764
+ var sa = [...Le, "->", "<<", ">>", "=="];
44765
+ var ua = _e().registerInfix("->", { precedence: y.Arrow }).registerInfix(";", { precedence: y.Semicolon });
44766
+ var Pa = [...Le, "eq", "ne", "co"];
44767
+ var Aa = _e();
44768
+ var se = class {
44662
44769
  constructor(e = "\r", t = "|", n = "^", i = "~", o = "\\", s = "&") {
44663
44770
  this.segmentSeparator = e;
44664
44771
  this.fieldSeparator = t;
@@ -44674,8 +44781,8 @@ var oe = class {
44674
44781
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
44675
44782
  }
44676
44783
  };
44677
- var bi = class r {
44678
- constructor(e, t = new oe()) {
44784
+ var Ci = class r {
44785
+ constructor(e, t = new se()) {
44679
44786
  this.context = t, this.segments = e;
44680
44787
  }
44681
44788
  get header() {
@@ -44698,7 +44805,7 @@ var bi = class r {
44698
44805
  }
44699
44806
  buildAck() {
44700
44807
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a2 = t?.getField(10)?.toString() ?? "", c = t?.getField(12)?.toString() ?? "2.5.1";
44701
- return new r([new We(["MSH", this.context.getMsh2(), o, s, n, i, wa(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c], this.context), new We(["MSA", "AA", a2, "OK"], this.context)]);
44808
+ return new r([new We(["MSH", this.context.getMsh2(), o, s, n, i, Ia(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c], this.context), new We(["MSA", "AA", a2, "OK"], this.context)]);
44702
44809
  }
44703
44810
  buildAckMessageType(e) {
44704
44811
  let t = e?.getField(9), n = t?.getComponent(2), i = t?.getComponent(3), o = "ACK";
@@ -44709,13 +44816,13 @@ var bi = class r {
44709
44816
  let n = new Error("Invalid HL7 message");
44710
44817
  throw n.type = "entity.parse.failed", n;
44711
44818
  }
44712
- let t = new oe("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
44819
+ let t = new se("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
44713
44820
  return new r(e.split(/[\r\n]+/).map((n) => We.parse(n, t)), t);
44714
44821
  }
44715
44822
  };
44716
44823
  var We = class r2 {
44717
- constructor(e, t = new oe()) {
44718
- this.context = t, bn(e) ? this.fields = e.map((n) => Oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
44824
+ constructor(e, t = new se()) {
44825
+ this.context = t, Pn(e) ? this.fields = e.map((n) => Oe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
44719
44826
  }
44720
44827
  get(e) {
44721
44828
  return this.fields[e];
@@ -44734,12 +44841,12 @@ var We = class r2 {
44734
44841
  toString() {
44735
44842
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
44736
44843
  }
44737
- static parse(e, t = new oe()) {
44844
+ static parse(e, t = new se()) {
44738
44845
  return new r2(e.split(t.fieldSeparator).map((n) => Oe.parse(n, t)), t);
44739
44846
  }
44740
44847
  };
44741
44848
  var Oe = class r3 {
44742
- constructor(e, t = new oe()) {
44849
+ constructor(e, t = new se()) {
44743
44850
  this.context = t, this.components = e;
44744
44851
  }
44745
44852
  get(e, t, n = 0) {
@@ -44752,16 +44859,16 @@ var Oe = class r3 {
44752
44859
  toString() {
44753
44860
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
44754
44861
  }
44755
- static parse(e, t = new oe()) {
44862
+ static parse(e, t = new se()) {
44756
44863
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
44757
44864
  }
44758
44865
  };
44759
- function wa(r6) {
44866
+ function Ia(r6) {
44760
44867
  let e = r6 instanceof Date ? r6 : new Date(r6), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i = e.getUTCMilliseconds();
44761
44868
  return i > 0 && (n += "." + i.toString()), n;
44762
44869
  }
44763
- var Fr = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(Fr || {});
44764
- var Ri = class r4 {
44870
+ var _r = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(_r || {});
44871
+ var wi = class r4 {
44765
44872
  constructor(e, t = {}, n = 3, i) {
44766
44873
  this.write = e;
44767
44874
  this.metadata = t;
@@ -44791,11 +44898,11 @@ var Ri = class r4 {
44791
44898
  }
44792
44899
  log(e, t, n) {
44793
44900
  e > this.level || (n instanceof Error && (n = { error: n.toString(), stack: n.stack?.split(`
44794
- `) }), this.write(JSON.stringify({ level: Fr[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
44901
+ `) }), this.write(JSON.stringify({ level: _r[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...n, ...this.metadata })));
44795
44902
  }
44796
44903
  };
44797
- function vf(r6) {
44798
- let e = Fr[r6.toUpperCase()];
44904
+ function bf(r6) {
44905
+ let e = _r[r6.toUpperCase()];
44799
44906
  if (e === void 0) throw new Error(`Invalid log level: ${r6}`);
44800
44907
  return e;
44801
44908
  }
@@ -44843,7 +44950,7 @@ var p = class extends a {
44843
44950
  e.on("data", (s) => {
44844
44951
  try {
44845
44952
  if (this.appendData(s), s.at(-2) === 28 && s.at(-1) === 13) {
44846
- let o = Buffer.concat(this.chunks), i = o.subarray(1, o.length - 2), f2 = (0, import_iconv_lite.decode)(i, this.encoding), g = bi.parse(f2);
44953
+ let o = Buffer.concat(this.chunks), i = o.subarray(1, o.length - 2), f2 = (0, import_iconv_lite.decode)(i, this.encoding), g = Ci.parse(f2);
44847
44954
  this.dispatchEvent(new d2(this, g)), this.resetBuffer();
44848
44955
  }
44849
44956
  } catch (o) {
@@ -45083,19 +45190,19 @@ var AgentDicomChannel = class extends BaseChannel {
45083
45190
  calledAeTitle: this.association?.getCalledAeTitle()
45084
45191
  },
45085
45192
  dataset: dicomJson,
45086
- binary: binary ? ee(binary) : void 0
45193
+ binary: binary ? te(binary) : void 0
45087
45194
  };
45088
45195
  App.instance.addToWebSocketQueue({
45089
45196
  type: "agent:transmit:request",
45090
45197
  accessToken: "placeholder",
45091
45198
  channel: DcmjsDimseScp.channel.getDefinition().name,
45092
45199
  remote: this.association?.getCallingAeTitle(),
45093
- contentType: V.JSON,
45200
+ contentType: D.JSON,
45094
45201
  body: JSON.stringify(payload)
45095
45202
  });
45096
45203
  response.setStatus(dimse.constants.Status.Success);
45097
45204
  } catch (err) {
45098
- DcmjsDimseScp.channel.log.error(`DICOM error: ${Ci(err)}`);
45205
+ DcmjsDimseScp.channel.log.error(`DICOM error: ${Oi(err)}`);
45099
45206
  response.setStatus(dimse.constants.Status.ProcessingFailure);
45100
45207
  }
45101
45208
  return response;
@@ -45170,7 +45277,7 @@ var AgentHl7Channel = class extends BaseChannel {
45170
45277
  sendToRemote(msg) {
45171
45278
  const connection = this.connections.get(msg.remote);
45172
45279
  if (connection) {
45173
- connection.hl7Connection.send(bi.parse(msg.body));
45280
+ connection.hl7Connection.send(Ci.parse(msg.body));
45174
45281
  }
45175
45282
  }
45176
45283
  handleNewConnection(connection) {
@@ -45194,11 +45301,11 @@ var AgentHl7ChannelConnection = class {
45194
45301
  accessToken: "placeholder",
45195
45302
  channel: this.channel.getDefinition().name,
45196
45303
  remote: this.remote,
45197
- contentType: V.HL7_V2,
45304
+ contentType: D.HL7_V2,
45198
45305
  body: event.message.toString()
45199
45306
  });
45200
45307
  } catch (err) {
45201
- this.channel.log.error(`HL7 error: ${Ci(err)}`);
45308
+ this.channel.log.error(`HL7 error: ${Oi(err)}`);
45202
45309
  }
45203
45310
  }
45204
45311
  close() {
@@ -45281,7 +45388,7 @@ async function fetchVersionManifest(version) {
45281
45388
  try {
45282
45389
  message = (await res.json()).message;
45283
45390
  } catch (err) {
45284
- console.error(`Failed to parse message from body: ${Ci(err)}`);
45391
+ console.error(`Failed to parse message from body: ${Oi(err)}`);
45285
45392
  }
45286
45393
  throw new Error(
45287
45394
  `Received status code ${res.status} while fetching manifest for version '${version ?? "latest"}'. Message: ${message}`
@@ -45359,7 +45466,7 @@ var App = class _App {
45359
45466
  this.shutdown = false;
45360
45467
  this.keepAlive = false;
45361
45468
  _App.instance = this;
45362
- this.log = new Ri((msg) => console.log(msg), void 0, logLevel);
45469
+ this.log = new wi((msg) => console.log(msg), void 0, logLevel);
45363
45470
  }
45364
45471
  async start() {
45365
45472
  this.log.info("Medplum service starting...");
@@ -45379,7 +45486,7 @@ var App = class _App {
45379
45486
  if ((0, import_node_fs3.existsSync)(UPGRADE_MANIFEST_PATH)) {
45380
45487
  const upgradeFile = (0, import_node_fs3.readFileSync)(UPGRADE_MANIFEST_PATH, { encoding: "utf-8" });
45381
45488
  const upgradeDetails = JSON.parse(upgradeFile);
45382
- if (upgradeDetails.targetVersion === sd.split("-")[0]) {
45489
+ if (upgradeDetails.targetVersion === ld.split("-")[0]) {
45383
45490
  await this.sendToWebSocket({
45384
45491
  type: "agent:upgrade:response",
45385
45492
  statusCode: 200,
@@ -45387,7 +45494,7 @@ var App = class _App {
45387
45494
  });
45388
45495
  this.log.info(`Successfully upgraded to version ${upgradeDetails.targetVersion}`);
45389
45496
  } else {
45390
- const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${sd}`;
45497
+ const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${ld}`;
45391
45498
  await this.sendToWebSocket({
45392
45499
  type: "agent:error",
45393
45500
  body: errMsg,
@@ -45425,7 +45532,7 @@ var App = class _App {
45425
45532
  this.webSocket.binaryType = "nodebuffer";
45426
45533
  this.webSocket.addEventListener("error", (err) => {
45427
45534
  if (!this.shutdown) {
45428
- this.log.error(`WebSocket closed due to an error: ${Ci(err)}`);
45535
+ this.log.error(`WebSocket closed due to an error: ${Oi(err)}`);
45429
45536
  }
45430
45537
  });
45431
45538
  this.webSocket.addEventListener("open", async () => {
@@ -45456,7 +45563,7 @@ var App = class _App {
45456
45563
  this.startWebSocketWorker();
45457
45564
  break;
45458
45565
  case "agent:heartbeat:request":
45459
- await this.sendToWebSocket({ type: "agent:heartbeat:response", version: sd });
45566
+ await this.sendToWebSocket({ type: "agent:heartbeat:response", version: ld });
45460
45567
  break;
45461
45568
  case "agent:heartbeat:response":
45462
45569
  break;
@@ -45472,7 +45579,7 @@ var App = class _App {
45472
45579
  case "agent:transmit:request":
45473
45580
  if (this.config?.status !== "active") {
45474
45581
  this.sendAgentDisabledError(command);
45475
- } else if (command.contentType === V.PING) {
45582
+ } else if (command.contentType === D.PING) {
45476
45583
  await this.tryPingHost(command);
45477
45584
  } else {
45478
45585
  this.pushMessage(command);
@@ -45490,7 +45597,7 @@ var App = class _App {
45490
45597
  } catch (err) {
45491
45598
  await this.sendToWebSocket({
45492
45599
  type: "agent:error",
45493
- body: Ci(err),
45600
+ body: Oi(err),
45494
45601
  callback: command.callback
45495
45602
  });
45496
45603
  }
@@ -45505,7 +45612,7 @@ var App = class _App {
45505
45612
  this.log.error(`Unknown message type: ${command.type}`);
45506
45613
  }
45507
45614
  } catch (err) {
45508
- this.log.error(`WebSocket error on incoming message: ${Ci(err)}`);
45615
+ this.log.error(`WebSocket error on incoming message: ${Oi(err)}`);
45509
45616
  }
45510
45617
  });
45511
45618
  return new Promise((resolve2, reject) => {
@@ -45580,7 +45687,7 @@ var App = class _App {
45580
45687
  try {
45581
45688
  await this.startOrReloadChannel(definition, endpoint);
45582
45689
  } catch (err) {
45583
- this.log.error(Ci(err));
45690
+ this.log.error(Oi(err));
45584
45691
  }
45585
45692
  }
45586
45693
  }
@@ -45606,7 +45713,7 @@ var App = class _App {
45606
45713
  parsedEndpoint = new URL(endpoint.address);
45607
45714
  } catch (err) {
45608
45715
  throw new Error(
45609
- `Error while validating endpoint address for channel '${channel.name}': ${Ci(err)}`
45716
+ `Error while validating endpoint address for channel '${channel.name}': ${Oi(err)}`
45610
45717
  );
45611
45718
  }
45612
45719
  if (seenPorts.has(parsedEndpoint.port)) {
@@ -45689,7 +45796,7 @@ var App = class _App {
45689
45796
  try {
45690
45797
  await this.sendToWebSocket(msg);
45691
45798
  } catch (err) {
45692
- this.log.error(`WebSocket error while attempting to send message: ${Ci(err)}`);
45799
+ this.log.error(`WebSocket error while attempting to send message: ${Oi(err)}`);
45693
45800
  this.webSocketQueue.unshift(msg);
45694
45801
  throw err;
45695
45802
  }
@@ -45726,7 +45833,7 @@ IPv6 is currently unsupported.`;
45726
45833
  this.log.error(errMsg);
45727
45834
  throw new Error(errMsg);
45728
45835
  }
45729
- if (!((0, import_node_net.isIPv4)(message.remote) || vu(message.remote))) {
45836
+ if (!((0, import_node_net.isIPv4)(message.remote) || bu(message.remote))) {
45730
45837
  const errMsg = `Attempted to ping an invalid host.
45731
45838
 
45732
45839
  "${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
@@ -45758,22 +45865,22 @@ ${result}`);
45758
45865
  this.addToWebSocketQueue({
45759
45866
  type: "agent:transmit:response",
45760
45867
  channel: message.channel,
45761
- contentType: V.PING,
45868
+ contentType: D.PING,
45762
45869
  remote: message.remote,
45763
45870
  callback: message.callback,
45764
45871
  statusCode: 200,
45765
45872
  body: result
45766
45873
  });
45767
45874
  } catch (err) {
45768
- this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${Ci(err)}`);
45875
+ this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${Oi(err)}`);
45769
45876
  this.addToWebSocketQueue({
45770
45877
  type: "agent:transmit:response",
45771
45878
  channel: message.channel,
45772
- contentType: V.TEXT,
45879
+ contentType: D.TEXT,
45773
45880
  remote: message.remote,
45774
45881
  callback: message.callback,
45775
45882
  statusCode: 400,
45776
- body: Ci(err)
45883
+ body: Oi(err)
45777
45884
  });
45778
45885
  }
45779
45886
  }
@@ -45820,11 +45927,11 @@ ${result}`);
45820
45927
  });
45821
45928
  });
45822
45929
  child.on("error", (err) => {
45823
- this.log.error(Ci(err));
45930
+ this.log.error(Oi(err));
45824
45931
  });
45825
45932
  } catch (err) {
45826
45933
  const versionTag = message.version ? `v${message.version}` : "latest";
45827
- const errMsg = `Error during upgrading to version '${versionTag}': ${Ci(err)}`;
45934
+ const errMsg = `Error during upgrading to version '${versionTag}': ${Oi(err)}`;
45828
45935
  this.log.error(errMsg);
45829
45936
  await this.sendToWebSocket({
45830
45937
  type: "agent:error",
@@ -45837,11 +45944,11 @@ ${result}`);
45837
45944
  await this.stop();
45838
45945
  this.log.info("Successfully stopped agent network services");
45839
45946
  const targetVersion = message.version ?? await fetchLatestVersionString();
45840
- this.log.info("Writing upgrade manifest...", { previousVersion: sd, targetVersion });
45947
+ this.log.info("Writing upgrade manifest...", { previousVersion: ld, targetVersion });
45841
45948
  (0, import_node_fs3.writeFileSync)(
45842
45949
  UPGRADE_MANIFEST_PATH,
45843
45950
  JSON.stringify({
45844
- previousVersion: sd,
45951
+ previousVersion: ld,
45845
45952
  targetVersion,
45846
45953
  callback: message.callback ?? null
45847
45954
  }),
@@ -45851,7 +45958,7 @@ ${result}`);
45851
45958
  child.disconnect();
45852
45959
  } catch (err) {
45853
45960
  this.log.error(
45854
- `Error while stopping agent or messaging child process as part of upgrade: ${Ci(err)}`
45961
+ `Error while stopping agent or messaging child process as part of upgrade: ${Oi(err)}`
45855
45962
  );
45856
45963
  import_node_process.default.exit(1);
45857
45964
  }
@@ -45909,27 +46016,27 @@ ${result}`);
45909
46016
  });
45910
46017
  }
45911
46018
  }
45912
- client.sendAndWait(bi.parse(message.body)).then((response) => {
46019
+ client.sendAndWait(Ci.parse(message.body)).then((response) => {
45913
46020
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
45914
46021
  this.addToWebSocketQueue({
45915
46022
  type: "agent:transmit:response",
45916
46023
  channel: message.channel,
45917
46024
  remote: message.remote,
45918
46025
  callback: message.callback,
45919
- contentType: V.HL7_V2,
46026
+ contentType: D.HL7_V2,
45920
46027
  statusCode: 200,
45921
46028
  body: response.toString()
45922
46029
  });
45923
46030
  }).catch((err) => {
45924
- this.log.error(`HL7 error: ${Ci(err)}`);
46031
+ this.log.error(`HL7 error: ${Oi(err)}`);
45925
46032
  this.addToWebSocketQueue({
45926
46033
  type: "agent:transmit:response",
45927
46034
  channel: message.channel,
45928
46035
  remote: message.remote,
45929
46036
  callback: message.callback,
45930
- contentType: V.TEXT,
46037
+ contentType: D.TEXT,
45931
46038
  statusCode: 400,
45932
- body: Ci(err)
46039
+ body: Oi(err)
45933
46040
  });
45934
46041
  if (client.keepAlive) {
45935
46042
  this.hl7Clients.delete(message.remote);
@@ -45976,9 +46083,9 @@ async function agentMain(argv) {
45976
46083
  process.exit(1);
45977
46084
  }
45978
46085
  const { baseUrl, clientId, clientSecret, agentId } = args;
45979
- const medplum = new At({ baseUrl, clientId });
46086
+ const medplum = new Ot({ baseUrl, clientId });
45980
46087
  await medplum.startClientLogin(clientId, clientSecret);
45981
- const app = new App(medplum, agentId, vf(args.logLevel ?? "INFO"));
46088
+ const app = new App(medplum, agentId, bf(args.logLevel ?? "INFO"));
45982
46089
  await app.start();
45983
46090
  process.on("SIGINT", async () => {
45984
46091
  console.log("Gracefully shutting down from SIGINT (Ctrl-C)");
@@ -46006,7 +46113,7 @@ async function upgraderMain(argv) {
46006
46113
  if ((0, import_node_os4.platform)() !== "win32") {
46007
46114
  throw new Error(`Unsupported platform: ${(0, import_node_os4.platform)()}. Agent upgrader currently only supports Windows`);
46008
46115
  }
46009
- const globalLogger = new Ri((msg) => console.log(msg));
46116
+ const globalLogger = new wi((msg) => console.log(msg));
46010
46117
  if (!import_node_process2.default.send) {
46011
46118
  globalLogger.error("Upgrader not started as a child process with Node IPC enabled. Aborting...");
46012
46119
  import_node_process2.default.exit(1);
@@ -46045,7 +46152,7 @@ async function upgraderMain(argv) {
46045
46152
  (0, import_node_child_process2.spawnSync)(binPath, ["/S"]);
46046
46153
  globalLogger.info(`Agent version ${version} successfully installed`);
46047
46154
  } catch (err) {
46048
- globalLogger.error(`Error while attempting to run installer: ${Ci(err)}`);
46155
+ globalLogger.error(`Error while attempting to run installer: ${Oi(err)}`);
46049
46156
  globalLogger.error("Failed to run installer, attempting to restart agent service...");
46050
46157
  try {
46051
46158
  (0, import_node_child_process2.execSync)('net start "Medplum Agent"');