@medplum/agent 5.1.14 → 5.1.16

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 +824 -689
  2. package/package.json +7 -7
@@ -3997,6 +3997,18 @@ var require_semver = __commonJS({
3997
3997
  var { safeRe: re2, t } = require_re();
3998
3998
  var parseOptions = require_parse_options();
3999
3999
  var { compareIdentifiers } = require_identifiers();
4000
+ var isPrereleaseIdentifier = (prerelease, identifier) => {
4001
+ const identifiers = identifier.split(".");
4002
+ if (identifiers.length > prerelease.length) {
4003
+ return false;
4004
+ }
4005
+ for (let i = 0; i < identifiers.length; i++) {
4006
+ if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
4007
+ return false;
4008
+ }
4009
+ }
4010
+ return true;
4011
+ };
4000
4012
  var SemVer = class _SemVer {
4001
4013
  constructor(version, options) {
4002
4014
  options = parseOptions(options);
@@ -4243,8 +4255,9 @@ var require_semver = __commonJS({
4243
4255
  if (identifierBase === false) {
4244
4256
  prerelease = [identifier];
4245
4257
  }
4246
- if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
4247
- if (isNaN(this.prerelease[1])) {
4258
+ if (isPrereleaseIdentifier(this.prerelease, identifier)) {
4259
+ const prereleaseBase = this.prerelease[identifier.split(".").length];
4260
+ if (isNaN(prereleaseBase)) {
4248
4261
  this.prerelease = prerelease;
4249
4262
  }
4250
4263
  } else {
@@ -4803,8 +4816,8 @@ var require_range = __commonJS({
4803
4816
  return cached;
4804
4817
  }
4805
4818
  const loose = this.options.loose;
4806
- const hr = loose ? re2[t.HYPHENRANGELOOSE] : re2[t.HYPHENRANGE];
4807
- range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
4819
+ const hr2 = loose ? re2[t.HYPHENRANGELOOSE] : re2[t.HYPHENRANGE];
4820
+ range = range.replace(hr2, hyphenReplace(this.options.includePrerelease));
4808
4821
  debug("hyphen replace", range);
4809
4822
  range = range.replace(re2[t.COMPARATORTRIM], comparatorTrimReplace);
4810
4823
  debug("comparator trim", range);
@@ -8946,7 +8959,7 @@ var require_stream = __commonJS({
8946
8959
  this.emit("error", err2);
8947
8960
  }
8948
8961
  }
8949
- function createWebSocketStream2(ws, options) {
8962
+ function createWebSocketStream2(ws2, options) {
8950
8963
  let terminateOnDestroy = true;
8951
8964
  const duplex = new Duplex({
8952
8965
  ...options,
@@ -8955,65 +8968,65 @@ var require_stream = __commonJS({
8955
8968
  objectMode: false,
8956
8969
  writableObjectMode: false
8957
8970
  });
8958
- ws.on("message", function message(msg, isBinary) {
8971
+ ws2.on("message", function message(msg, isBinary) {
8959
8972
  const data2 = !isBinary && duplex._readableState.objectMode ? msg.toString() : msg;
8960
- if (!duplex.push(data2)) ws.pause();
8973
+ if (!duplex.push(data2)) ws2.pause();
8961
8974
  });
8962
- ws.once("error", function error(err2) {
8975
+ ws2.once("error", function error(err2) {
8963
8976
  if (duplex.destroyed) return;
8964
8977
  terminateOnDestroy = false;
8965
8978
  duplex.destroy(err2);
8966
8979
  });
8967
- ws.once("close", function close() {
8980
+ ws2.once("close", function close() {
8968
8981
  if (duplex.destroyed) return;
8969
8982
  duplex.push(null);
8970
8983
  });
8971
8984
  duplex._destroy = function(err2, callback) {
8972
- if (ws.readyState === ws.CLOSED) {
8985
+ if (ws2.readyState === ws2.CLOSED) {
8973
8986
  callback(err2);
8974
8987
  process.nextTick(emitClose, duplex);
8975
8988
  return;
8976
8989
  }
8977
8990
  let called = false;
8978
- ws.once("error", function error(err3) {
8991
+ ws2.once("error", function error(err3) {
8979
8992
  called = true;
8980
8993
  callback(err3);
8981
8994
  });
8982
- ws.once("close", function close() {
8995
+ ws2.once("close", function close() {
8983
8996
  if (!called) callback(err2);
8984
8997
  process.nextTick(emitClose, duplex);
8985
8998
  });
8986
- if (terminateOnDestroy) ws.terminate();
8999
+ if (terminateOnDestroy) ws2.terminate();
8987
9000
  };
8988
9001
  duplex._final = function(callback) {
8989
- if (ws.readyState === ws.CONNECTING) {
8990
- ws.once("open", function open() {
9002
+ if (ws2.readyState === ws2.CONNECTING) {
9003
+ ws2.once("open", function open() {
8991
9004
  duplex._final(callback);
8992
9005
  });
8993
9006
  return;
8994
9007
  }
8995
- if (ws._socket === null) return;
8996
- if (ws._socket._writableState.finished) {
9008
+ if (ws2._socket === null) return;
9009
+ if (ws2._socket._writableState.finished) {
8997
9010
  callback();
8998
9011
  if (duplex._readableState.endEmitted) duplex.destroy();
8999
9012
  } else {
9000
- ws._socket.once("finish", function finish() {
9013
+ ws2._socket.once("finish", function finish() {
9001
9014
  callback();
9002
9015
  });
9003
- ws.close();
9016
+ ws2.close();
9004
9017
  }
9005
9018
  };
9006
9019
  duplex._read = function() {
9007
- if (ws.isPaused) ws.resume();
9020
+ if (ws2.isPaused) ws2.resume();
9008
9021
  };
9009
9022
  duplex._write = function(chunk, encoding, callback) {
9010
- if (ws.readyState === ws.CONNECTING) {
9011
- ws.once("open", function open() {
9023
+ if (ws2.readyState === ws2.CONNECTING) {
9024
+ ws2.once("open", function open() {
9012
9025
  duplex._write(chunk, encoding, callback);
9013
9026
  });
9014
9027
  return;
9015
9028
  }
9016
- ws.send(chunk, callback);
9029
+ ws2.send(chunk, callback);
9017
9030
  };
9018
9031
  duplex.on("end", duplexOnEnd);
9019
9032
  duplex.on("error", duplexOnError);
@@ -9389,12 +9402,12 @@ var require_websocket_server = __commonJS({
9389
9402
  "Connection: Upgrade",
9390
9403
  `Sec-WebSocket-Accept: ${digest}`
9391
9404
  ];
9392
- const ws = new this.options.WebSocket(null, void 0, this.options);
9405
+ const ws2 = new this.options.WebSocket(null, void 0, this.options);
9393
9406
  if (protocols.size) {
9394
9407
  const protocol = this.options.handleProtocols ? this.options.handleProtocols(protocols, req) : protocols.values().next().value;
9395
9408
  if (protocol) {
9396
9409
  headers.push(`Sec-WebSocket-Protocol: ${protocol}`);
9397
- ws._protocol = protocol;
9410
+ ws2._protocol = protocol;
9398
9411
  }
9399
9412
  }
9400
9413
  if (extensions[PerMessageDeflate2.extensionName]) {
@@ -9403,12 +9416,12 @@ var require_websocket_server = __commonJS({
9403
9416
  [PerMessageDeflate2.extensionName]: [params]
9404
9417
  });
9405
9418
  headers.push(`Sec-WebSocket-Extensions: ${value}`);
9406
- ws._extensions = extensions;
9419
+ ws2._extensions = extensions;
9407
9420
  }
9408
9421
  this.emit("headers", headers, req);
9409
9422
  socket.write(headers.concat("\r\n").join("\r\n"));
9410
9423
  socket.removeListener("error", socketOnError);
9411
- ws.setSocket(socket, head, {
9424
+ ws2.setSocket(socket, head, {
9412
9425
  allowSynchronousEvents: this.options.allowSynchronousEvents,
9413
9426
  maxBufferedChunks: this.options.maxBufferedChunks,
9414
9427
  maxFragments: this.options.maxFragments,
@@ -9416,15 +9429,15 @@ var require_websocket_server = __commonJS({
9416
9429
  skipUTF8Validation: this.options.skipUTF8Validation
9417
9430
  });
9418
9431
  if (this.clients) {
9419
- this.clients.add(ws);
9420
- ws.on("close", () => {
9421
- this.clients.delete(ws);
9432
+ this.clients.add(ws2);
9433
+ ws2.on("close", () => {
9434
+ this.clients.delete(ws2);
9422
9435
  if (this._shouldEmitClose && !this.clients.size) {
9423
9436
  process.nextTick(emitClose, this);
9424
9437
  }
9425
9438
  });
9426
9439
  }
9427
- cb(ws, req);
9440
+ cb(ws2, req);
9428
9441
  }
9429
9442
  };
9430
9443
  module2.exports = WebSocketServer2;
@@ -10653,11 +10666,11 @@ var require_dcmjs = __commonJS({
10653
10666
  Promise.resolve(value).then(_next, _throw);
10654
10667
  }
10655
10668
  }
10656
- function _asyncToGenerator2(fn2) {
10669
+ function _asyncToGenerator2(fn) {
10657
10670
  return function() {
10658
10671
  var self2 = this, args = arguments;
10659
10672
  return new Promise(function(resolve2, reject) {
10660
- var gen = fn2.apply(self2, args);
10673
+ var gen = fn.apply(self2, args);
10661
10674
  function _next(value) {
10662
10675
  asyncGeneratorStep2(gen, resolve2, reject, _next, _throw, "next", value);
10663
10676
  }
@@ -10733,11 +10746,11 @@ var require_dcmjs = __commonJS({
10733
10746
  };
10734
10747
  return _setPrototypeOf2(o2, p2);
10735
10748
  }
10736
- function _isNativeFunction(fn2) {
10749
+ function _isNativeFunction(fn) {
10737
10750
  try {
10738
- return Function.toString.call(fn2).indexOf("[native code]") !== -1;
10751
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
10739
10752
  } catch (e) {
10740
- return typeof fn2 === "function";
10753
+ return typeof fn === "function";
10741
10754
  }
10742
10755
  }
10743
10756
  function _wrapNativeSuper(Class) {
@@ -15772,9 +15785,9 @@ var require_dcmjs = __commonJS({
15772
15785
  }, {
15773
15786
  key: "readVR",
15774
15787
  value: function readVR() {
15775
- var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
15788
+ var vr2 = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
15776
15789
  this.increment(2);
15777
- return vr;
15790
+ return vr2;
15778
15791
  }
15779
15792
  }, {
15780
15793
  key: "readEncodedString",
@@ -16785,20 +16798,20 @@ var require_dcmjs = __commonJS({
16785
16798
  }, {
16786
16799
  key: "createByTypeString",
16787
16800
  value: function createByTypeString(type) {
16788
- var vr = VRinstances2[type];
16789
- if (vr === void 0) {
16801
+ var vr2 = VRinstances2[type];
16802
+ if (vr2 === void 0) {
16790
16803
  if (type == "ox") {
16791
16804
  validationLog2.error("Invalid vr type", type, "- using OW");
16792
- vr = VRinstances2["OW"];
16805
+ vr2 = VRinstances2["OW"];
16793
16806
  } else if (type == "xs") {
16794
16807
  validationLog2.error("Invalid vr type", type, "- using US");
16795
- vr = VRinstances2["US"];
16808
+ vr2 = VRinstances2["US"];
16796
16809
  } else {
16797
16810
  validationLog2.error("Invalid vr type", type, "- using UN");
16798
- vr = VRinstances2["UN"];
16811
+ vr2 = VRinstances2["UN"];
16799
16812
  }
16800
16813
  }
16801
- return vr;
16814
+ return vr2;
16802
16815
  }
16803
16816
  }, {
16804
16817
  key: "parseUnknownVr",
@@ -17324,8 +17337,8 @@ var require_dcmjs = __commonJS({
17324
17337
  key: "writeBytes",
17325
17338
  value: function writeBytes(stream, value, writeOptions) {
17326
17339
  var _this11 = this;
17327
- var val = Array.isArray(value) ? value.map(function(is2) {
17328
- return _this11.convertToString(is2);
17340
+ var val = Array.isArray(value) ? value.map(function(is) {
17341
+ return _this11.convertToString(is);
17329
17342
  }) : [this.convertToString(value)];
17330
17343
  return _get2(_getPrototypeOf2(IntegerString3.prototype), "writeBytes", this).call(this, stream, val, writeOptions);
17331
17344
  }
@@ -17884,10 +17897,10 @@ var require_dcmjs = __commonJS({
17884
17897
  })(BinaryRepresentation2);
17885
17898
  var ParsedUnknownValue2 = /* @__PURE__ */ (function(_BinaryRepresentation2) {
17886
17899
  _inherits2(ParsedUnknownValue3, _BinaryRepresentation2);
17887
- function ParsedUnknownValue3(vr) {
17900
+ function ParsedUnknownValue3(vr2) {
17888
17901
  var _this28;
17889
17902
  _classCallCheck2(this, ParsedUnknownValue3);
17890
- _this28 = _callSuper2(this, ParsedUnknownValue3, [vr]);
17903
+ _this28 = _callSuper2(this, ParsedUnknownValue3, [vr2]);
17891
17904
  _this28.maxLength = null;
17892
17905
  _this28.padByte = 0;
17893
17906
  _this28.noMultiple = true;
@@ -17902,13 +17915,13 @@ var require_dcmjs = __commonJS({
17902
17915
  value: function read(stream, length3, syntax, readOptions) {
17903
17916
  var arrayBuffer = this.readBytes(stream, length3, syntax)[0];
17904
17917
  var streamFromBuffer = new ReadBufferStream2(arrayBuffer, true);
17905
- var vr = ValueRepresentation2.createByTypeString(this.type);
17906
- if (vr.isBinary() && length3 > vr.maxLength && !vr.noMultiple) {
17918
+ var vr2 = ValueRepresentation2.createByTypeString(this.type);
17919
+ if (vr2.isBinary() && length3 > vr2.maxLength && !vr2.noMultiple) {
17907
17920
  var values = [];
17908
17921
  var rawValues = [];
17909
- var times = length3 / vr.maxLength, i = 0;
17922
+ var times = length3 / vr2.maxLength, i = 0;
17910
17923
  while (i++ < times) {
17911
- var _vr$read = vr.read(streamFromBuffer, vr.maxLength, syntax, readOptions), rawValue = _vr$read.rawValue, value = _vr$read.value;
17924
+ var _vr$read = vr2.read(streamFromBuffer, vr2.maxLength, syntax, readOptions), rawValue = _vr$read.rawValue, value = _vr$read.value;
17912
17925
  rawValues.push(rawValue);
17913
17926
  values.push(value);
17914
17927
  }
@@ -17917,7 +17930,7 @@ var require_dcmjs = __commonJS({
17917
17930
  value: values
17918
17931
  };
17919
17932
  } else {
17920
- return vr.read(streamFromBuffer, length3, syntax, readOptions);
17933
+ return vr2.read(streamFromBuffer, length3, syntax, readOptions);
17921
17934
  }
17922
17935
  }
17923
17936
  }]);
@@ -18017,12 +18030,12 @@ var require_dcmjs = __commonJS({
18017
18030
  }
18018
18031
  _createClass2(DicomDict3, [{
18019
18032
  key: "upsertTag",
18020
- value: function upsertTag(tag, vr, values) {
18033
+ value: function upsertTag(tag, vr2, values) {
18021
18034
  if (this.dict[tag]) {
18022
18035
  this.dict[tag].Value = values;
18023
18036
  } else {
18024
18037
  this.dict[tag] = ValueRepresentation2.addTagAccessors({
18025
- vr
18038
+ vr: vr2
18026
18039
  });
18027
18040
  this.dict[tag].Value = values;
18028
18041
  }
@@ -18637,13 +18650,13 @@ var require_dcmjs = __commonJS({
18637
18650
  var end = gi2 + 1 < groupStart.length ? groupStart[gi2 + 1] : elems.length;
18638
18651
  var ei2 = _binSearchU162(elems, start, end, elem);
18639
18652
  if (ei2 < 0) return void 0;
18640
- var vr = vrTable$12[vrCode[ei2]];
18653
+ var vr2 = vrTable$12[vrCode[ei2]];
18641
18654
  var vm = vmTable$12[vmCode[ei2]];
18642
18655
  var off = nameOff[ei2];
18643
18656
  var len3 = nameLen[ei2];
18644
18657
  var name = nameBlob$12.slice(off, off + len3);
18645
18658
  return {
18646
- vr,
18659
+ vr: vr2,
18647
18660
  vm,
18648
18661
  name
18649
18662
  };
@@ -18680,14 +18693,14 @@ var require_dcmjs = __commonJS({
18680
18693
  var elem = elems[ei2];
18681
18694
  var eHex = _pad42(elem.toString(16).toUpperCase());
18682
18695
  var tag = "(" + gHex + "," + eHex + ")";
18683
- var vr = vrTable$12[vrCode[ei2]];
18696
+ var vr2 = vrTable$12[vrCode[ei2]];
18684
18697
  var vm = vmTable$12[vmCode[ei2]];
18685
18698
  var off = nameOff[ei2];
18686
18699
  var len3 = nameLen[ei2];
18687
18700
  var name = nameBlob$12.slice(off, off + len3);
18688
18701
  out.push({
18689
18702
  tag,
18690
- vr,
18703
+ vr: vr2,
18691
18704
  vm,
18692
18705
  name
18693
18706
  });
@@ -19011,9 +19024,9 @@ var require_dcmjs = __commonJS({
19011
19024
  if (dataValue === void 0) {
19012
19025
  return;
19013
19026
  }
19014
- var vr = dataset._vrMap && dataset._vrMap[naturalName] ? dataset._vrMap[naturalName] : entry.vr;
19027
+ var vr2 = dataset._vrMap && dataset._vrMap[naturalName] ? dataset._vrMap[naturalName] : entry.vr;
19015
19028
  var dataItem = ValueRepresentation2.addTagAccessors({
19016
- vr
19029
+ vr: vr2
19017
19030
  });
19018
19031
  dataItem.Value = dataset[naturalName];
19019
19032
  if (dataValue !== null) {
@@ -19219,7 +19232,7 @@ var require_dcmjs = __commonJS({
19219
19232
  }
19220
19233
  }, {
19221
19234
  key: "is",
19222
- value: function is2(t) {
19235
+ value: function is(t) {
19223
19236
  return this.value == t;
19224
19237
  }
19225
19238
  /**
@@ -19267,7 +19280,7 @@ var require_dcmjs = __commonJS({
19267
19280
  }, {
19268
19281
  key: "write",
19269
19282
  value: function write(stream, vrType, values, syntax, writeOptions) {
19270
- var vr = ValueRepresentation2.createByTypeString(vrType);
19283
+ var vr2 = ValueRepresentation2.createByTypeString(vrType);
19271
19284
  var useSyntax = DicomMessage$12._normalizeSyntax(syntax);
19272
19285
  var implicit = useSyntax === IMPLICIT_LITTLE_ENDIAN2;
19273
19286
  var isLittleEndian = useSyntax === IMPLICIT_LITTLE_ENDIAN2 || useSyntax === EXPLICIT_LITTLE_ENDIAN$12;
@@ -19279,11 +19292,11 @@ var require_dcmjs = __commonJS({
19279
19292
  var tagStream = new WriteBufferStream2(256), valueLength;
19280
19293
  tagStream.setEndian(isLittleEndian);
19281
19294
  if (vrType == "OW" || vrType == "OB" || vrType == "UN") {
19282
- valueLength = vr.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
19295
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
19283
19296
  } else if (vrType == "SQ") {
19284
- valueLength = vr.writeBytes(tagStream, values, useSyntax, writeOptions);
19297
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, writeOptions);
19285
19298
  } else {
19286
- valueLength = vr.writeBytes(tagStream, values, writeOptions);
19299
+ valueLength = vr2.writeBytes(tagStream, values, writeOptions);
19287
19300
  }
19288
19301
  if (vrType == "SQ") {
19289
19302
  valueLength = UNDEFINED_LENGTH2;
@@ -19293,14 +19306,14 @@ var require_dcmjs = __commonJS({
19293
19306
  stream.writeUint32(valueLength);
19294
19307
  written += 4;
19295
19308
  } else {
19296
- var isBig16Length = !vr.isLength32() && valueLength >= 65536 && valueLength !== UNDEFINED_LENGTH2;
19297
- if (vr.isLength32() || isBig16Length) {
19298
- stream.writeAsciiString(isBig16Length ? "UN" : vr.type);
19309
+ var isBig16Length = !vr2.isLength32() && valueLength >= 65536 && valueLength !== UNDEFINED_LENGTH2;
19310
+ if (vr2.isLength32() || isBig16Length) {
19311
+ stream.writeAsciiString(isBig16Length ? "UN" : vr2.type);
19299
19312
  stream.writeUint16(0);
19300
19313
  stream.writeUint32(valueLength);
19301
19314
  written += 8;
19302
19315
  } else {
19303
- stream.writeAsciiString(vr.type);
19316
+ stream.writeAsciiString(vr2.type);
19304
19317
  stream.writeUint16(valueLength);
19305
19318
  written += 4;
19306
19319
  }
@@ -19535,9 +19548,9 @@ var require_dcmjs = __commonJS({
19535
19548
  }
19536
19549
  }, {
19537
19550
  key: "writeTagObject",
19538
- value: function writeTagObject(stream, tagString, vr, values, syntax, writeOptions) {
19551
+ value: function writeTagObject(stream, tagString, vr2, values, syntax, writeOptions) {
19539
19552
  var tag = Tag2.fromString(tagString);
19540
- tag.write(stream, vr, values, syntax, writeOptions);
19553
+ tag.write(stream, vr2, values, syntax, writeOptions);
19541
19554
  }
19542
19555
  }, {
19543
19556
  key: "write",
@@ -19557,14 +19570,14 @@ var require_dcmjs = __commonJS({
19557
19570
  if (!tagObject._rawValue) {
19558
19571
  return tagObject.Value;
19559
19572
  }
19560
- var vr = ValueRepresentation2.createByTypeString(vrType);
19573
+ var vr2 = ValueRepresentation2.createByTypeString(vrType);
19561
19574
  var originalValue;
19562
19575
  if (Array.isArray(tagObject._rawValue)) {
19563
19576
  originalValue = tagObject._rawValue.map(function(val) {
19564
- return vr.applyFormatting(val);
19577
+ return vr2.applyFormatting(val);
19565
19578
  });
19566
19579
  } else {
19567
- originalValue = vr.applyFormatting(tagObject._rawValue);
19580
+ originalValue = vr2.applyFormatting(tagObject._rawValue);
19568
19581
  }
19569
19582
  if (deepEqual2(tagObject.Value, originalValue)) {
19570
19583
  return tagObject._rawValue;
@@ -19593,7 +19606,7 @@ var require_dcmjs = __commonJS({
19593
19606
  };
19594
19607
  }
19595
19608
  }
19596
- var length3 = null, vr = null, vrType;
19609
+ var length3 = null, vr2 = null, vrType;
19597
19610
  if (implicit) {
19598
19611
  length3 = stream.readUint32();
19599
19612
  var elementData = DicomMessage3.lookupTag(tag);
@@ -19612,16 +19625,16 @@ var require_dcmjs = __commonJS({
19612
19625
  vrType = "UN";
19613
19626
  }
19614
19627
  }
19615
- vr = ValueRepresentation2.createByTypeString(vrType);
19628
+ vr2 = ValueRepresentation2.createByTypeString(vrType);
19616
19629
  } else {
19617
19630
  vrType = stream.readVR();
19618
19631
  if (vrType === "UN" && DicomMessage3.lookupTag(tag) && DicomMessage3.lookupTag(tag).vr) {
19619
19632
  vrType = DicomMessage3.lookupTag(tag).vr;
19620
- vr = ValueRepresentation2.parseUnknownVr(vrType);
19633
+ vr2 = ValueRepresentation2.parseUnknownVr(vrType);
19621
19634
  } else {
19622
- vr = ValueRepresentation2.createByTypeString(vrType);
19635
+ vr2 = ValueRepresentation2.createByTypeString(vrType);
19623
19636
  }
19624
- if (vr.isLength32()) {
19637
+ if (vr2.isLength32()) {
19625
19638
  stream.increment(2);
19626
19639
  length3 = stream.readUint32();
19627
19640
  } else {
@@ -19630,27 +19643,27 @@ var require_dcmjs = __commonJS({
19630
19643
  }
19631
19644
  var values = [];
19632
19645
  var rawValues = [];
19633
- if (vr.isBinary() && length3 > vr.maxLength && !vr.noMultiple) {
19634
- var times = length3 / vr.maxLength, i = 0;
19646
+ if (vr2.isBinary() && length3 > vr2.maxLength && !vr2.noMultiple) {
19647
+ var times = length3 / vr2.maxLength, i = 0;
19635
19648
  while (i++ < times) {
19636
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options), rawValue = _vr$read.rawValue, value = _vr$read.value;
19649
+ var _vr$read = vr2.read(stream, vr2.maxLength, syntax, options), rawValue = _vr$read.rawValue, value = _vr$read.value;
19637
19650
  rawValues.push(rawValue);
19638
19651
  values.push(value);
19639
19652
  }
19640
19653
  } else {
19641
- var _ref = vr.read(stream, length3, syntax, options) || {}, _rawValue = _ref.rawValue, _value2 = _ref.value;
19642
- if (!vr.isBinary() && singleVRs2.indexOf(vr.type) == -1) {
19654
+ var _ref = vr2.read(stream, length3, syntax, options) || {}, _rawValue = _ref.rawValue, _value2 = _ref.value;
19655
+ if (!vr2.isBinary() && singleVRs2.indexOf(vr2.type) == -1) {
19643
19656
  rawValues = _rawValue;
19644
19657
  values = _value2;
19645
19658
  if (typeof _value2 === "string") {
19646
19659
  var delimiterChar = String.fromCharCode(VM_DELIMITER2);
19647
- rawValues = vr.dropPadByte(_rawValue.split(delimiterChar));
19648
- values = vr.dropPadByte(_value2.split(delimiterChar));
19660
+ rawValues = vr2.dropPadByte(_rawValue.split(delimiterChar));
19661
+ values = vr2.dropPadByte(_value2.split(delimiterChar));
19649
19662
  }
19650
- } else if (vr.type == "SQ") {
19663
+ } else if (vr2.type == "SQ") {
19651
19664
  rawValues = _rawValue;
19652
19665
  values = _value2;
19653
- } else if (vr.type == "OW" || vr.type == "OB") {
19666
+ } else if (vr2.type == "OW" || vr2.type == "OB") {
19654
19667
  rawValues = _rawValue;
19655
19668
  values = _value2;
19656
19669
  } else {
@@ -19661,7 +19674,7 @@ var require_dcmjs = __commonJS({
19661
19674
  stream.setEndian(oldEndian);
19662
19675
  var retObj = ValueRepresentation2.addTagAccessors({
19663
19676
  tag,
19664
- vr
19677
+ vr: vr2
19665
19678
  });
19666
19679
  retObj.values = values;
19667
19680
  retObj.rawValues = rawValues;
@@ -19732,13 +19745,13 @@ var require_dcmjs = __commonJS({
19732
19745
  if (keyStr < candidate) hi2 = mid - 1;
19733
19746
  else if (keyStr > candidate) lo = mid + 1;
19734
19747
  else {
19735
- var vr = vrTable2[vrCode[mid]];
19748
+ var vr2 = vrTable2[vrCode[mid]];
19736
19749
  var vm = vmTable2[vmCode[mid]];
19737
19750
  var off = nameOff[mid];
19738
19751
  var nlen = nameLen[mid];
19739
19752
  var name = nameBlob2.slice(off, off + nlen);
19740
19753
  return {
19741
- vr,
19754
+ vr: vr2,
19742
19755
  vm,
19743
19756
  name
19744
19757
  };
@@ -20084,8 +20097,8 @@ var require_dcmjs = __commonJS({
20084
20097
  *
20085
20098
  * @param {(() => Promise<void>) | null} fn - Function that returns a Promise, or null to clear
20086
20099
  */
20087
- function setDrain(fn2) {
20088
- this._drain = typeof fn2 === "function" ? fn2 : null;
20100
+ function setDrain(fn) {
20101
+ this._drain = typeof fn === "function" ? fn : null;
20089
20102
  }
20090
20103
  )
20091
20104
  /**
@@ -21078,8 +21091,8 @@ var require_dcmjs = __commonJS({
21078
21091
  }, {
21079
21092
  key: "isSequence",
21080
21093
  value: function isSequence(tagInfo) {
21081
- var vr = tagInfo.vr, length3 = tagInfo.length;
21082
- return vr === "SQ" || vr === "UN" && length3 === UNDEFINED_LENGTH_FIX2;
21094
+ var vr2 = tagInfo.vr, length3 = tagInfo.length;
21095
+ return vr2 === "SQ" || vr2 === "UN" && length3 === UNDEFINED_LENGTH_FIX2;
21083
21096
  }
21084
21097
  /**
21085
21098
  * Reads a tag header.
@@ -21110,12 +21123,12 @@ var require_dcmjs = __commonJS({
21110
21123
  }
21111
21124
  }
21112
21125
  var length3 = null;
21113
- var vr = null;
21126
+ var vr2 = null;
21114
21127
  var vrType;
21115
21128
  var isCommand = tagObj.group() === 0;
21116
21129
  if (tagObj.isInstruction()) {
21117
21130
  length3 = stream.readUint32();
21118
- vr = ValueRepresentation2.createByTypeString("UN");
21131
+ vr2 = ValueRepresentation2.createByTypeString("UN");
21119
21132
  } else if (implicit && !isCommand) {
21120
21133
  length3 = stream.readUint32();
21121
21134
  var elementData = DicomMessage2.lookupTag(tagObj);
@@ -21136,17 +21149,17 @@ var require_dcmjs = __commonJS({
21136
21149
  vrType = "UN";
21137
21150
  }
21138
21151
  }
21139
- vr = ValueRepresentation2.createByTypeString(vrType);
21152
+ vr2 = ValueRepresentation2.createByTypeString(vrType);
21140
21153
  } else {
21141
21154
  var _DicomMessage$lookupT;
21142
21155
  vrType = stream.readVR();
21143
21156
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage2.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
21144
21157
  vrType = DicomMessage2.lookupTag(tagObj).vr;
21145
- vr = ValueRepresentation2.parseUnknownVr(vrType);
21158
+ vr2 = ValueRepresentation2.parseUnknownVr(vrType);
21146
21159
  } else {
21147
- vr = ValueRepresentation2.createByTypeString(vrType);
21160
+ vr2 = ValueRepresentation2.createByTypeString(vrType);
21148
21161
  }
21149
- if (vr.isLength32()) {
21162
+ if (vr2.isLength32()) {
21150
21163
  stream.increment(2);
21151
21164
  length3 = stream.readUint32();
21152
21165
  } else {
@@ -21156,8 +21169,8 @@ var require_dcmjs = __commonJS({
21156
21169
  var punctuatedTag = DicomMetaDictionary2.punctuateTag(tag);
21157
21170
  var entry = DicomMetaDictionary2.dictionary[punctuatedTag];
21158
21171
  var header = {
21159
- vrObj: vr,
21160
- vr: vr.type,
21172
+ vrObj: vr2,
21173
+ vr: vr2.type,
21161
21174
  tag,
21162
21175
  tagObj,
21163
21176
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
@@ -21176,7 +21189,7 @@ var require_dcmjs = __commonJS({
21176
21189
  key: "readSingle",
21177
21190
  value: (function() {
21178
21191
  var _readSingle = _asyncToGenerator2(/* @__PURE__ */ _regeneratorRuntime2().mark(function _callee11(tagInfo, listener, options) {
21179
- var length3, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value2, delimiterChar, _values, _values2, coding2;
21192
+ var length3, stream, syntax, vr2, values, times, i, _vr$read, value, _vr$read2, _value2, delimiterChar, _values, _values2, coding2;
21180
21193
  return _regeneratorRuntime2().wrap(function _callee11$(_context11) {
21181
21194
  while (1) switch (_context11.prev = _context11.next) {
21182
21195
  case 0:
@@ -21185,25 +21198,25 @@ var require_dcmjs = __commonJS({
21185
21198
  _context11.next = 4;
21186
21199
  return this.stream.ensureAvailable(length3);
21187
21200
  case 4:
21188
- vr = ValueRepresentation2.createByTypeString(tagInfo.vr);
21201
+ vr2 = ValueRepresentation2.createByTypeString(tagInfo.vr);
21189
21202
  values = [];
21190
- if (vr.isBinary() && length3 > vr.maxLength && !vr.noMultiple) {
21191
- times = length3 / vr.maxLength;
21203
+ if (vr2.isBinary() && length3 > vr2.maxLength && !vr2.noMultiple) {
21204
+ times = length3 / vr2.maxLength;
21192
21205
  i = 0;
21193
21206
  while (i++ < times) {
21194
21207
  readLog2.trace("readSingle multi-value loop", i, times);
21195
- _vr$read = vr.read(stream, vr.maxLength, syntax), value = _vr$read.value;
21208
+ _vr$read = vr2.read(stream, vr2.maxLength, syntax), value = _vr$read.value;
21196
21209
  values.push(value);
21197
21210
  }
21198
21211
  } else {
21199
- _value2 = (_vr$read2 = vr.read(stream, length3, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
21200
- if (!vr.isBinary() && singleVRs2.indexOf(vr.type) == -1) {
21212
+ _value2 = (_vr$read2 = vr2.read(stream, length3, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
21213
+ if (!vr2.isBinary() && singleVRs2.indexOf(vr2.type) == -1) {
21201
21214
  values = _value2;
21202
21215
  if (typeof _value2 === "string") {
21203
21216
  delimiterChar = String.fromCharCode(VM_DELIMITER2);
21204
- values = vr.dropPadByte(_value2.split(delimiterChar));
21217
+ values = vr2.dropPadByte(_value2.split(delimiterChar));
21205
21218
  }
21206
- } else if (vr.type == "OW" || vr.type == "OB") {
21219
+ } else if (vr2.type == "OW" || vr2.type == "OB") {
21207
21220
  values = _value2;
21208
21221
  } else {
21209
21222
  Array.isArray(_value2) ? values = _value2 : values.push(_value2);
@@ -27232,7 +27245,7 @@ var require_dcmjs = __commonJS({
27232
27245
  var sqrLen2 = squaredLength2;
27233
27246
  var forEach2 = (function() {
27234
27247
  var vec = create2();
27235
- return function(a, stride, offset, count, fn2, arg) {
27248
+ return function(a, stride, offset, count, fn, arg) {
27236
27249
  var i, l;
27237
27250
  if (!stride) {
27238
27251
  stride = 3;
@@ -27249,7 +27262,7 @@ var require_dcmjs = __commonJS({
27249
27262
  vec[0] = a[i];
27250
27263
  vec[1] = a[i + 1];
27251
27264
  vec[2] = a[i + 2];
27252
- fn2(vec, vec, arg);
27265
+ fn(vec, vec, arg);
27253
27266
  a[i] = vec[0];
27254
27267
  a[i + 1] = vec[1];
27255
27268
  a[i + 2] = vec[2];
@@ -34541,11 +34554,11 @@ var require_decorator = __commonJS({
34541
34554
  };
34542
34555
  };
34543
34556
  var mergeDecorators = (d1, d2) => {
34544
- var _a, _b, _c, _d, _e2, _f;
34557
+ var _a, _b, _c, _d, _e, _f;
34545
34558
  return {
34546
34559
  class: (0, util_1.unique)([...(_a = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a !== void 0 ? _a : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
34547
34560
  static: mergePropertyAndMethodDecorators((_c = d1 === null || d1 === void 0 ? void 0 : d1.static) !== null && _c !== void 0 ? _c : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.static) !== null && _d !== void 0 ? _d : {}),
34548
- instance: mergePropertyAndMethodDecorators((_e2 = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e2 !== void 0 ? _e2 : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {})
34561
+ instance: mergePropertyAndMethodDecorators((_e = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e !== void 0 ? _e : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {})
34549
34562
  };
34550
34563
  };
34551
34564
  var decorators = /* @__PURE__ */ new Map();
@@ -40693,11 +40706,11 @@ var require_from = __commonJS({
40693
40706
  Promise.resolve(value).then(_next, _throw);
40694
40707
  }
40695
40708
  }
40696
- function _asyncToGenerator2(fn2) {
40709
+ function _asyncToGenerator2(fn) {
40697
40710
  return function() {
40698
40711
  var self2 = this, args = arguments;
40699
40712
  return new Promise(function(resolve2, reject) {
40700
- var gen = fn2.apply(self2, args);
40713
+ var gen = fn.apply(self2, args);
40701
40714
  function _next(value) {
40702
40715
  asyncGeneratorStep2(gen, resolve2, reject, _next, _throw, "next", value);
40703
40716
  }
@@ -40840,11 +40853,11 @@ var require_stream_readable = __commonJS({
40840
40853
  require_inherits()(Readable2, Stream);
40841
40854
  var errorOrDestroy = destroyImpl.errorOrDestroy;
40842
40855
  var kProxyEvents = ["error", "close", "destroy", "pause", "resume"];
40843
- function prependListener(emitter, event, fn2) {
40844
- if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn2);
40845
- if (!emitter._events || !emitter._events[event]) emitter.on(event, fn2);
40846
- else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn2);
40847
- else emitter._events[event] = [fn2, emitter._events[event]];
40856
+ function prependListener(emitter, event, fn) {
40857
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
40858
+ if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
40859
+ else if (Array.isArray(emitter._events[event])) emitter._events[event].unshift(fn);
40860
+ else emitter._events[event] = [fn, emitter._events[event]];
40848
40861
  }
40849
40862
  function ReadableState(options, stream, isDuplex) {
40850
40863
  Duplex = Duplex || require_stream_duplex();
@@ -41292,8 +41305,8 @@ var require_stream_readable = __commonJS({
41292
41305
  dest.emit("unpipe", this, unpipeInfo);
41293
41306
  return this;
41294
41307
  };
41295
- Readable2.prototype.on = function(ev, fn2) {
41296
- var res = Stream.prototype.on.call(this, ev, fn2);
41308
+ Readable2.prototype.on = function(ev, fn) {
41309
+ var res = Stream.prototype.on.call(this, ev, fn);
41297
41310
  var state = this._readableState;
41298
41311
  if (ev === "data") {
41299
41312
  state.readableListening = this.listenerCount("readable") > 0;
@@ -41314,8 +41327,8 @@ var require_stream_readable = __commonJS({
41314
41327
  return res;
41315
41328
  };
41316
41329
  Readable2.prototype.addListener = Readable2.prototype.on;
41317
- Readable2.prototype.removeListener = function(ev, fn2) {
41318
- var res = Stream.prototype.removeListener.call(this, ev, fn2);
41330
+ Readable2.prototype.removeListener = function(ev, fn) {
41331
+ var res = Stream.prototype.removeListener.call(this, ev, fn);
41319
41332
  if (ev === "readable") {
41320
41333
  process.nextTick(updateReadableListening, this);
41321
41334
  }
@@ -42391,10 +42404,10 @@ var require_initialParams = __commonJS({
42391
42404
  Object.defineProperty(exports2, "__esModule", {
42392
42405
  value: true
42393
42406
  });
42394
- exports2.default = function(fn2) {
42407
+ exports2.default = function(fn) {
42395
42408
  return function(...args) {
42396
42409
  var callback = args.pop();
42397
- return fn2.call(this, args, callback);
42410
+ return fn.call(this, args, callback);
42398
42411
  };
42399
42412
  };
42400
42413
  module2.exports = exports2.default;
@@ -42413,11 +42426,11 @@ var require_setImmediate = __commonJS({
42413
42426
  var hasQueueMicrotask = exports2.hasQueueMicrotask = typeof queueMicrotask === "function" && queueMicrotask;
42414
42427
  var hasSetImmediate = exports2.hasSetImmediate = typeof setImmediate === "function" && setImmediate;
42415
42428
  var hasNextTick = exports2.hasNextTick = typeof process === "object" && typeof process.nextTick === "function";
42416
- function fallback(fn2) {
42417
- setTimeout(fn2, 0);
42429
+ function fallback(fn) {
42430
+ setTimeout(fn, 0);
42418
42431
  }
42419
42432
  function wrap(defer) {
42420
- return (fn2, ...args) => defer(() => fn2(...args));
42433
+ return (fn, ...args) => defer(() => fn(...args));
42421
42434
  }
42422
42435
  var _defer;
42423
42436
  if (hasQueueMicrotask) {
@@ -42504,11 +42517,11 @@ var require_wrapAsync = __commonJS({
42504
42517
  function _interopRequireDefault(obj) {
42505
42518
  return obj && obj.__esModule ? obj : { default: obj };
42506
42519
  }
42507
- function isAsync(fn2) {
42508
- return fn2[Symbol.toStringTag] === "AsyncFunction";
42520
+ function isAsync(fn) {
42521
+ return fn[Symbol.toStringTag] === "AsyncFunction";
42509
42522
  }
42510
- function isAsyncGenerator(fn2) {
42511
- return fn2[Symbol.toStringTag] === "AsyncGenerator";
42523
+ function isAsyncGenerator(fn) {
42524
+ return fn[Symbol.toStringTag] === "AsyncGenerator";
42512
42525
  }
42513
42526
  function isAsyncIterable(obj) {
42514
42527
  return typeof obj[Symbol.asyncIterator] === "function";
@@ -42593,14 +42606,14 @@ var require_once = __commonJS({
42593
42606
  value: true
42594
42607
  });
42595
42608
  exports2.default = once;
42596
- function once(fn2) {
42609
+ function once(fn) {
42597
42610
  function wrapper(...args) {
42598
- if (fn2 === null) return;
42599
- var callFn = fn2;
42600
- fn2 = null;
42611
+ if (fn === null) return;
42612
+ var callFn = fn;
42613
+ fn = null;
42601
42614
  callFn.apply(this, args);
42602
42615
  }
42603
- Object.assign(wrapper, fn2);
42616
+ Object.assign(wrapper, fn);
42604
42617
  return wrapper;
42605
42618
  }
42606
42619
  module2.exports = exports2.default;
@@ -42683,11 +42696,11 @@ var require_onlyOnce = __commonJS({
42683
42696
  value: true
42684
42697
  });
42685
42698
  exports2.default = onlyOnce;
42686
- function onlyOnce(fn2) {
42699
+ function onlyOnce(fn) {
42687
42700
  return function(...args) {
42688
- if (fn2 === null) throw new Error("Callback was already called.");
42689
- var callFn = fn2;
42690
- fn2 = null;
42701
+ if (fn === null) throw new Error("Callback was already called.");
42702
+ var callFn = fn;
42703
+ fn = null;
42691
42704
  callFn.apply(this, args);
42692
42705
  };
42693
42706
  }
@@ -43086,8 +43099,8 @@ var require_pipeline = __commonJS({
43086
43099
  callback(err2 || new ERR_STREAM_DESTROYED("pipe"));
43087
43100
  };
43088
43101
  }
43089
- function call(fn2) {
43090
- fn2();
43102
+ function call(fn) {
43103
+ fn();
43091
43104
  }
43092
43105
  function pipe(from, to2) {
43093
43106
  return from.pipe(to2);
@@ -43175,17 +43188,17 @@ var require_diagnostics = __commonJS({
43175
43188
  if (!async.length) return false;
43176
43189
  return new Promise(function pinky(resolve2) {
43177
43190
  Promise.all(
43178
- async.map(function prebind(fn2) {
43179
- return fn2(namespace);
43191
+ async.map(function prebind(fn) {
43192
+ return fn(namespace);
43180
43193
  })
43181
43194
  ).then(function resolved(values) {
43182
43195
  resolve2(values.some(Boolean));
43183
43196
  });
43184
43197
  });
43185
43198
  }
43186
- function modify(fn2) {
43187
- if (~modifiers.indexOf(fn2)) return false;
43188
- modifiers.push(fn2);
43199
+ function modify(fn) {
43200
+ if (~modifiers.indexOf(fn)) return false;
43201
+ modifiers.push(fn);
43189
43202
  return true;
43190
43203
  }
43191
43204
  function write() {
@@ -43197,14 +43210,14 @@ var require_diagnostics = __commonJS({
43197
43210
  }
43198
43211
  return message;
43199
43212
  }
43200
- function introduce(fn2, options) {
43213
+ function introduce(fn, options) {
43201
43214
  var has2 = Object.prototype.hasOwnProperty;
43202
43215
  for (var key in options) {
43203
43216
  if (has2.call(options, key)) {
43204
- fn2[key] = options[key];
43217
+ fn[key] = options[key];
43205
43218
  }
43206
43219
  }
43207
- return fn2;
43220
+ return fn;
43208
43221
  }
43209
43222
  function nope(options) {
43210
43223
  options.enabled = false;
@@ -44056,8 +44069,8 @@ var require_index_cjs = __commonJS({
44056
44069
  const a = lab[1];
44057
44070
  const b3 = lab[2];
44058
44071
  let h2;
44059
- const hr = Math.atan2(b3, a);
44060
- h2 = hr * 360 / 2 / Math.PI;
44072
+ const hr2 = Math.atan2(b3, a);
44073
+ h2 = hr2 * 360 / 2 / Math.PI;
44061
44074
  if (h2 < 0) {
44062
44075
  h2 += 360;
44063
44076
  }
@@ -44068,9 +44081,9 @@ var require_index_cjs = __commonJS({
44068
44081
  const l = lch[0];
44069
44082
  const c2 = lch[1];
44070
44083
  const h2 = lch[2];
44071
- const hr = h2 / 360 * 2 * Math.PI;
44072
- const a = c2 * Math.cos(hr);
44073
- const b3 = c2 * Math.sin(hr);
44084
+ const hr2 = h2 / 360 * 2 * Math.PI;
44085
+ const a = c2 * Math.cos(hr2);
44086
+ const b3 = c2 * Math.sin(hr2);
44074
44087
  return [l, a, b3];
44075
44088
  };
44076
44089
  convert$1.rgb.ansi16 = function(args, saturation = null) {
@@ -44362,15 +44375,15 @@ var require_index_cjs = __commonJS({
44362
44375
  }
44363
44376
  function wrapConversion(toModel, graph) {
44364
44377
  const path4 = [graph[toModel].parent, toModel];
44365
- let fn2 = convert$1[graph[toModel].parent][toModel];
44378
+ let fn = convert$1[graph[toModel].parent][toModel];
44366
44379
  let cur = graph[toModel].parent;
44367
44380
  while (graph[cur].parent) {
44368
44381
  path4.unshift(graph[cur].parent);
44369
- fn2 = link(convert$1[graph[cur].parent][cur], fn2);
44382
+ fn = link(convert$1[graph[cur].parent][cur], fn);
44370
44383
  cur = graph[cur].parent;
44371
44384
  }
44372
- fn2.conversion = path4;
44373
- return fn2;
44385
+ fn.conversion = path4;
44386
+ return fn;
44374
44387
  }
44375
44388
  function route(fromModel) {
44376
44389
  const graph = deriveBFS(fromModel);
@@ -44388,7 +44401,7 @@ var require_index_cjs = __commonJS({
44388
44401
  }
44389
44402
  var convert = {};
44390
44403
  var models = Object.keys(convert$1);
44391
- function wrapRaw(fn2) {
44404
+ function wrapRaw(fn) {
44392
44405
  const wrappedFn = function(...args) {
44393
44406
  const arg0 = args[0];
44394
44407
  if (arg0 === void 0 || arg0 === null) {
@@ -44397,14 +44410,14 @@ var require_index_cjs = __commonJS({
44397
44410
  if (arg0.length > 1) {
44398
44411
  args = arg0;
44399
44412
  }
44400
- return fn2(args);
44413
+ return fn(args);
44401
44414
  };
44402
- if ("conversion" in fn2) {
44403
- wrappedFn.conversion = fn2.conversion;
44415
+ if ("conversion" in fn) {
44416
+ wrappedFn.conversion = fn.conversion;
44404
44417
  }
44405
44418
  return wrappedFn;
44406
44419
  }
44407
- function wrapRounded(fn2) {
44420
+ function wrapRounded(fn) {
44408
44421
  const wrappedFn = function(...args) {
44409
44422
  const arg0 = args[0];
44410
44423
  if (arg0 === void 0 || arg0 === null) {
@@ -44413,7 +44426,7 @@ var require_index_cjs = __commonJS({
44413
44426
  if (arg0.length > 1) {
44414
44427
  args = arg0;
44415
44428
  }
44416
- const result = fn2(args);
44429
+ const result = fn(args);
44417
44430
  if (typeof result === "object") {
44418
44431
  for (let { length: length2 } = result, i = 0; i < length2; i++) {
44419
44432
  result[i] = Math.round(result[i]);
@@ -44421,8 +44434,8 @@ var require_index_cjs = __commonJS({
44421
44434
  }
44422
44435
  return result;
44423
44436
  };
44424
- if ("conversion" in fn2) {
44425
- wrappedFn.conversion = fn2.conversion;
44437
+ if ("conversion" in fn) {
44438
+ wrappedFn.conversion = fn.conversion;
44426
44439
  }
44427
44440
  return wrappedFn;
44428
44441
  }
@@ -44433,9 +44446,9 @@ var require_index_cjs = __commonJS({
44433
44446
  const routes = route(fromModel);
44434
44447
  const routeModels = Object.keys(routes);
44435
44448
  for (const toModel of routeModels) {
44436
- const fn2 = routes[toModel];
44437
- convert[fromModel][toModel] = wrapRounded(fn2);
44438
- convert[fromModel][toModel].raw = wrapRaw(fn2);
44449
+ const fn = routes[toModel];
44450
+ convert[fromModel][toModel] = wrapRounded(fn);
44451
+ convert[fromModel][toModel].raw = wrapRaw(fn);
44439
44452
  }
44440
44453
  }
44441
44454
  var skippedModels = [
@@ -44929,10 +44942,10 @@ var require_adapters = __commonJS({
44929
44942
  "../../node_modules/@dabh/diagnostics/adapters/index.js"(exports2, module2) {
44930
44943
  "use strict";
44931
44944
  var enabled = require_enabled();
44932
- module2.exports = function create2(fn2) {
44945
+ module2.exports = function create2(fn) {
44933
44946
  return function adapter(namespace) {
44934
44947
  try {
44935
- return enabled(namespace, fn2());
44948
+ return enabled(namespace, fn());
44936
44949
  } catch (e) {
44937
44950
  }
44938
44951
  return false;
@@ -46143,14 +46156,14 @@ var require_fn = __commonJS({
46143
46156
  "../../node_modules/fn.name/index.js"(exports2, module2) {
46144
46157
  "use strict";
46145
46158
  var toString2 = Object.prototype.toString;
46146
- module2.exports = function name(fn2) {
46147
- if ("string" === typeof fn2.displayName && fn2.constructor.name) {
46148
- return fn2.displayName;
46149
- } else if ("string" === typeof fn2.name && fn2.name) {
46150
- return fn2.name;
46151
- }
46152
- if ("object" === typeof fn2 && fn2.constructor && "string" === typeof fn2.constructor.name) return fn2.constructor.name;
46153
- var named = fn2.toString(), type = toString2.call(fn2).slice(8, -1);
46159
+ module2.exports = function name(fn) {
46160
+ if ("string" === typeof fn.displayName && fn.constructor.name) {
46161
+ return fn.displayName;
46162
+ } else if ("string" === typeof fn.name && fn.name) {
46163
+ return fn.name;
46164
+ }
46165
+ if ("object" === typeof fn && fn.constructor && "string" === typeof fn.constructor.name) return fn.constructor.name;
46166
+ var named = fn.toString(), type = toString2.call(fn).slice(8, -1);
46154
46167
  if ("Function" === type) {
46155
46168
  named = named.substring(named.indexOf("(") + 1, named.indexOf(")"));
46156
46169
  } else {
@@ -46166,16 +46179,16 @@ var require_one_time = __commonJS({
46166
46179
  "../../node_modules/one-time/index.js"(exports2, module2) {
46167
46180
  "use strict";
46168
46181
  var name = require_fn();
46169
- module2.exports = function one(fn2) {
46182
+ module2.exports = function one(fn) {
46170
46183
  var called = 0, value;
46171
46184
  function onetime() {
46172
46185
  if (called) return value;
46173
46186
  called = 1;
46174
- value = fn2.apply(this, arguments);
46175
- fn2 = null;
46187
+ value = fn.apply(this, arguments);
46188
+ fn = null;
46176
46189
  return value;
46177
46190
  }
46178
- onetime.displayName = name(fn2);
46191
+ onetime.displayName = name(fn);
46179
46192
  return onetime;
46180
46193
  };
46181
46194
  }
@@ -47815,18 +47828,18 @@ var require_object_hash = __commonJS({
47815
47828
  write("string:" + string.length + ":");
47816
47829
  write(string.toString());
47817
47830
  },
47818
- _function: function(fn2) {
47831
+ _function: function(fn) {
47819
47832
  write("fn:");
47820
- if (isNativeFunction(fn2)) {
47833
+ if (isNativeFunction(fn)) {
47821
47834
  this.dispatch("[native]");
47822
47835
  } else {
47823
- this.dispatch(fn2.toString());
47836
+ this.dispatch(fn.toString());
47824
47837
  }
47825
47838
  if (options.respectFunctionNames !== false) {
47826
- this.dispatch("function-name:" + String(fn2.name));
47839
+ this.dispatch("function-name:" + String(fn.name));
47827
47840
  }
47828
47841
  if (options.respectFunctionProperties) {
47829
- this._object(fn2);
47842
+ this._object(fn);
47830
47843
  }
47831
47844
  },
47832
47845
  _number: function(number) {
@@ -48030,10 +48043,10 @@ var require_moment = __commonJS({
48030
48043
  function isDate(input) {
48031
48044
  return input instanceof Date || Object.prototype.toString.call(input) === "[object Date]";
48032
48045
  }
48033
- function map(arr, fn2) {
48046
+ function map(arr, fn) {
48034
48047
  var res = [], i, arrLen = arr.length;
48035
48048
  for (i = 0; i < arrLen; ++i) {
48036
- res.push(fn2(arr[i], i));
48049
+ res.push(fn(arr[i], i));
48037
48050
  }
48038
48051
  return res;
48039
48052
  }
@@ -48186,7 +48199,7 @@ var require_moment = __commonJS({
48186
48199
  console.warn("Deprecation warning: " + msg);
48187
48200
  }
48188
48201
  }
48189
- function deprecate(msg, fn2) {
48202
+ function deprecate(msg, fn) {
48190
48203
  var firstTime = true;
48191
48204
  return extend(function() {
48192
48205
  if (hooks.deprecationHandler != null) {
@@ -48214,8 +48227,8 @@ var require_moment = __commonJS({
48214
48227
  );
48215
48228
  firstTime = false;
48216
48229
  }
48217
- return fn2.apply(this, arguments);
48218
- }, fn2);
48230
+ return fn.apply(this, arguments);
48231
+ }, fn);
48219
48232
  }
48220
48233
  var deprecations = {};
48221
48234
  function deprecateSimple(name, msg) {
@@ -49121,8 +49134,8 @@ var require_moment = __commonJS({
49121
49134
  }
49122
49135
  return isNaN(input) ? null : input;
49123
49136
  }
49124
- function shiftWeekdays(ws, n) {
49125
- return ws.slice(n, 7).concat(ws.slice(0, n));
49137
+ function shiftWeekdays(ws2, n) {
49138
+ return ws2.slice(n, 7).concat(ws2.slice(0, n));
49126
49139
  }
49127
49140
  var defaultLocaleWeekdays = "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), defaultLocaleWeekdaysShort = "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), defaultLocaleWeekdaysMin = "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), defaultWeekdaysRegex = matchWord, defaultWeekdaysShortRegex = matchWord, defaultWeekdaysMinRegex = matchWord;
49128
49141
  function localeWeekdays(m3, format2) {
@@ -50182,7 +50195,7 @@ var require_moment = __commonJS({
50182
50195
  }
50183
50196
  }
50184
50197
  );
50185
- function pickBy(fn2, moments) {
50198
+ function pickBy(fn, moments) {
50186
50199
  var res, i;
50187
50200
  if (moments.length === 1 && isArray(moments[0])) {
50188
50201
  moments = moments[0];
@@ -50192,7 +50205,7 @@ var require_moment = __commonJS({
50192
50205
  }
50193
50206
  res = moments[0];
50194
50207
  for (i = 1; i < moments.length; ++i) {
50195
- if (!moments[i].isValid() || moments[i][fn2](res)) {
50208
+ if (!moments[i].isValid() || moments[i][fn](res)) {
50196
50209
  res = moments[i];
50197
50210
  }
50198
50211
  }
@@ -52757,9 +52770,9 @@ __export(main_exports, {
52757
52770
  module.exports = __toCommonJS(main_exports);
52758
52771
 
52759
52772
  // ../core/dist/esm/index.mjs
52760
- var _o = Object.defineProperty;
52761
- var Lo = (r6, e, t) => e in r6 ? _o(r6, e, { enumerable: true, configurable: true, writable: true, value: t }) : r6[e] = t;
52762
- var c = (r6, e, t) => Lo(r6, typeof e != "symbol" ? e + "" : e, t);
52773
+ var Lo = Object.defineProperty;
52774
+ var No = (r6, e, t) => e in r6 ? Lo(r6, e, { enumerable: true, configurable: true, writable: true, value: t }) : r6[e] = t;
52775
+ var c = (r6, e, t) => No(r6, typeof e != "symbol" ? e + "" : e, t);
52763
52776
  var K = class {
52764
52777
  constructor(e = 10) {
52765
52778
  c(this, "max");
@@ -52831,10 +52844,10 @@ var pt = class {
52831
52844
  }, precedence: t });
52832
52845
  }
52833
52846
  construct(e) {
52834
- return new mr(e, this.prefixParselets, this.infixParselets);
52847
+ return new fr(e, this.prefixParselets, this.infixParselets);
52835
52848
  }
52836
52849
  };
52837
- var mr = class {
52850
+ var fr = class {
52838
52851
  constructor(e, t, n) {
52839
52852
  c(this, "tokens");
52840
52853
  c(this, "prefixParselets");
@@ -52891,28 +52904,28 @@ function oe(r6) {
52891
52904
  var ft = "http://hl7.org";
52892
52905
  var mt = "ok";
52893
52906
  var ht = "created";
52894
- var gr = "not-modified";
52895
- var xr = "not-found";
52896
- var Tr = "unauthorized";
52907
+ var hr = "not-modified";
52908
+ var yr = "not-found";
52909
+ var vr = "unauthorized";
52897
52910
  var gt = "accepted";
52898
- var Fn = { resourceType: "OperationOutcome", id: xr, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
52899
- var _e = { resourceType: "OperationOutcome", id: Tr, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
52900
- var Un = { ..._e, issue: [..._e.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
52901
- var Sr = { ..._e, issue: [..._e.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
52911
+ var Fn = { resourceType: "OperationOutcome", id: yr, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
52912
+ var Le = { resourceType: "OperationOutcome", id: vr, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
52913
+ var Un = { ...Le, issue: [...Le.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
52914
+ var Tr = { ...Le, issue: [...Le.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
52902
52915
  function P(r6, e) {
52903
52916
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r6 }, ...e ? { expression: oe(e) } : void 0 }] };
52904
52917
  }
52905
52918
  function T(r6, e, t, n) {
52906
52919
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: t ?? "structure", details: { text: r6 }, ...e ? { expression: e } : void 0, ...n ? { diagnostics: n } : void 0 }] };
52907
52920
  }
52908
- function br(r6) {
52921
+ function Sr(r6) {
52909
52922
  return !r6 || typeof r6 != "object" ? false : r6 instanceof Error || typeof DOMException < "u" && r6 instanceof DOMException ? true : Object.prototype.toString.call(r6) === "[object Error]";
52910
52923
  }
52911
- function Qe(r6) {
52924
+ function ze(r6) {
52912
52925
  return typeof r6 == "object" && r6 !== null && r6.resourceType === "OperationOutcome";
52913
52926
  }
52914
- function Er(r6) {
52915
- return r6.id === mt || r6.id === ht || r6.id === gr || r6.id === gt;
52927
+ function br(r6) {
52928
+ return r6.id === mt || r6.id === ht || r6.id === hr || r6.id === gt;
52916
52929
  }
52917
52930
  var f = class extends Error {
52918
52931
  constructor(t, n) {
@@ -52922,57 +52935,57 @@ var f = class extends Error {
52922
52935
  }
52923
52936
  };
52924
52937
  function yt(r6) {
52925
- return r6 instanceof f ? r6.outcome : Qe(r6) ? r6 : P(Le(r6));
52938
+ return r6 instanceof f ? r6.outcome : ze(r6) ? r6 : P(Ne(r6));
52926
52939
  }
52927
- function Le(r6) {
52928
- return r6 ? typeof r6 == "string" ? r6 : br(r6) ? r6.message : Qe(r6) ? Bn(r6) : typeof r6 == "object" && "code" in r6 && typeof r6.code == "string" ? r6.code : JSON.stringify(r6) : "Unknown error";
52940
+ function Ne(r6) {
52941
+ return r6 ? typeof r6 == "string" ? r6 : Sr(r6) ? r6.message : ze(r6) ? Bn(r6) : typeof r6 == "object" && "code" in r6 && typeof r6.code == "string" ? r6.code : JSON.stringify(r6) : "Unknown error";
52929
52942
  }
52930
52943
  function Bn(r6) {
52931
- let e = r6.issue?.map(Fo) ?? [];
52944
+ let e = r6.issue?.map(Uo) ?? [];
52932
52945
  return e.length > 0 ? e.join("; ") : "Unknown error";
52933
52946
  }
52934
- function Fo(r6) {
52947
+ function Uo(r6) {
52935
52948
  let e;
52936
52949
  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;
52937
52950
  }
52938
- function Bo(r6, e) {
52951
+ function Wo(r6, e) {
52939
52952
  let t = e.max && e.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : e.max;
52940
52953
  return { path: r6, description: "", type: e.type ?? [], min: e.min ?? 0, max: t ?? 1, isArray: !!t && t > 1, constraints: [] };
52941
52954
  }
52942
52955
  function jn(r6) {
52943
52956
  let e = /* @__PURE__ */ Object.create(null);
52944
- for (let [t, n] of Object.entries(r6)) e[t] = { name: t, type: t, path: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i, o2]) => [i, Bo(i, o2)])), constraints: [], innerTypes: [] };
52957
+ for (let [t, n] of Object.entries(r6)) e[t] = { name: t, type: t, path: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i, o2]) => [i, Wo(i, o2)])), constraints: [], innerTypes: [] };
52945
52958
  return e;
52946
52959
  }
52947
52960
  var $n = { 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" }] } } }, DataRequirementCodeFilter: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] } } }, DataRequirementDateFilter: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { type: [{ code: "string" }] }, searchParam: { type: [{ code: "string" }] }, "value[x]": { type: [{ code: "dateTime" }, { code: "Period" }, { code: "Duration" }] } } }, DataRequirementSort: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, direction: { min: 1, type: [{ code: "code" }] } } }, 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"] }] } } }, DosageDoseAndRate: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { type: [{ code: "CodeableConcept" }] }, "dose[x]": { type: [{ code: "Range" }, { code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, "rate[x]": { type: [{ code: "Ratio" }, { code: "Range" }, { code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { 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" }] } } }, ElementDefinitionSlicingDiscriminator: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, path: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionSlicing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, discriminator: { max: 9007199254740991, type: [{ code: "ElementDefinitionSlicingDiscriminator" }] }, description: { type: [{ code: "string" }] }, ordered: { type: [{ code: "boolean" }] }, rules: { min: 1, type: [{ code: "code" }] } } }, ElementDefinitionBase: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, min: { min: 1, type: [{ code: "unsignedInt" }] }, max: { min: 1, type: [{ code: "string" }] } } }, ElementDefinitionType: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, targetProfile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition", "http://hl7.org/fhir/StructureDefinition/ImplementationGuide"] }] }, aggregation: { max: 9007199254740991, type: [{ code: "code" }] }, versioning: { type: [{ code: "code" }] } } }, ElementDefinitionExample: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, label: { min: 1, type: [{ code: "string" }] }, "value[x]": { min: 1, type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, ElementDefinitionConstraint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, key: { min: 1, type: [{ code: "id" }] }, requirements: { type: [{ code: "string" }] }, severity: { min: 1, type: [{ code: "code" }] }, human: { min: 1, type: [{ code: "string" }] }, expression: { type: [{ code: "string" }] }, xpath: { type: [{ code: "string" }] }, source: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, ElementDefinitionBinding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, strength: { min: 1, type: [{ code: "code" }] }, description: { type: [{ code: "string" }] }, valueSet: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/ValueSet"] }] } } }, ElementDefinitionMapping: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identity: { min: 1, type: [{ code: "id" }] }, language: { type: [{ code: "code" }] }, map: { min: 1, type: [{ code: "string" }] }, comment: { type: [{ code: "string" }] } } }, 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" }] }, accounts: { max: 9007199254740991, 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" }] } } }, SubstanceAmountReferenceRange: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, lowLimit: { type: [{ code: "Quantity" }] }, highLimit: { type: [{ code: "Quantity" }] } } }, 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" }] } } }, TimingRepeat: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "bounds[x]": { type: [{ code: "Duration" }, { code: "Range" }, { code: "Period" }] }, count: { type: [{ code: "positiveInt" }] }, countMax: { type: [{ code: "positiveInt" }] }, duration: { type: [{ code: "decimal" }] }, durationMax: { type: [{ code: "decimal" }] }, durationUnit: { type: [{ code: "code" }] }, frequency: { type: [{ code: "positiveInt" }] }, frequencyMax: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "decimal" }] }, periodMax: { type: [{ code: "decimal" }] }, periodUnit: { type: [{ code: "code" }] }, dayOfWeek: { max: 9007199254740991, type: [{ code: "code" }] }, timeOfDay: { max: 9007199254740991, type: [{ code: "time" }] }, when: { max: 9007199254740991, type: [{ code: "code" }] }, offset: { type: [{ code: "unsignedInt" }] } } }, 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" }] }, identitySource: { type: [{ code: "code" }] }, identityMappingMode: { type: [{ code: "code" }] } } } };
52948
- function Ar(r6) {
52949
- return new Cr(r6).parse();
52961
+ function Pr(r6) {
52962
+ return new Rr(r6).parse();
52950
52963
  }
52951
52964
  var be = jn($n);
52952
- var wr = /* @__PURE__ */ Object.create(null);
52965
+ var Ar = /* @__PURE__ */ Object.create(null);
52953
52966
  var Hn = /* @__PURE__ */ Object.create(null);
52954
- var qo = { "http://hl7.org/fhir/StructureDefinition/MoneyQuantity": "MoneyQuantity", "http://hl7.org/fhir/StructureDefinition/SimpleQuantity": "SimpleQuantity", "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition": "ViewDefinition" };
52967
+ var jo = { "http://hl7.org/fhir/StructureDefinition/MoneyQuantity": "MoneyQuantity", "http://hl7.org/fhir/StructureDefinition/SimpleQuantity": "SimpleQuantity", "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition": "ViewDefinition" };
52955
52968
  function Jn(r6) {
52956
52969
  let e;
52957
52970
  return e = Hn[r6], e || (e = Hn[r6] = /* @__PURE__ */ Object.create(null)), e;
52958
52971
  }
52959
- function Or(r6) {
52972
+ function wr(r6) {
52960
52973
  let t = (Array.isArray(r6) ? r6 : r6.entry?.map((n) => n.resource) ?? []).filter((n) => n?.resourceType === "StructureDefinition");
52961
52974
  ei(t);
52962
- for (let n of t) Ir(n);
52975
+ for (let n of t) Or(n);
52963
52976
  }
52964
- function Ir(r6) {
52977
+ function Or(r6) {
52965
52978
  if (!r6?.name) throw new Error("Failed loading StructureDefinition from bundle");
52966
52979
  if (r6.resourceType !== "StructureDefinition") return;
52967
- let e = Ar(r6), t = qo[r6.url], n, i;
52980
+ let e = Pr(r6), t = jo[r6.url], n, i;
52968
52981
  t ? (n = be, i = t) : r6.url === `http://hl7.org/fhir/StructureDefinition/${r6.type}` || r6.url === `https://medplum.com/fhir/StructureDefinition/${r6.type}` || r6.type?.startsWith("http://") || r6.type?.startsWith("https://") ? (n = be, i = r6.type) : (n = Jn(r6.url), i = r6.type), n[i] = e;
52969
52982
  for (let o2 of e.innerTypes) o2.parentType = e, n[o2.name] = o2;
52970
- wr[r6.url] = e;
52983
+ Ar[r6.url] = e;
52971
52984
  }
52972
52985
  function Yn(r6) {
52973
52986
  return !!be[r6];
52974
52987
  }
52975
- function ze(r6, e) {
52988
+ function Ee(r6, e) {
52976
52989
  if (e) {
52977
52990
  let t = Jn(e)[r6];
52978
52991
  if (t) return t;
@@ -52980,9 +52993,9 @@ function ze(r6, e) {
52980
52993
  return be[r6];
52981
52994
  }
52982
52995
  function Xn(r6) {
52983
- return !!wr[r6];
52996
+ return !!Ar[r6];
52984
52997
  }
52985
- var Cr = class {
52998
+ var Rr = class {
52986
52999
  constructor(e) {
52987
53000
  c(this, "root");
52988
53001
  c(this, "elements");
@@ -52993,7 +53006,7 @@ var Cr = class {
52993
53006
  c(this, "innerTypes");
52994
53007
  c(this, "backboneContext");
52995
53008
  if (!e.snapshot?.element || e.snapshot.element.length === 0) throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
52996
- 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, path: this.root.path, title: e.title, type: e.type, url: e.url, version: e.version, kind: e.kind, description: Go(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
53009
+ 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, path: this.root.path, title: e.title, type: e.type, url: e.url, version: e.version, kind: e.kind, description: Qo(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
52997
53010
  }
52998
53011
  parse() {
52999
53012
  let e = this.next();
@@ -53001,7 +53014,7 @@ var Cr = class {
53001
53014
  if (e.sliceName) this.parseSliceStart(e);
53002
53015
  else if (e.id?.includes(":")) {
53003
53016
  if (this.slicingContext?.current) {
53004
- let t = Rr(e, this.slicingContext.path);
53017
+ let t = Er(e, this.slicingContext.path);
53005
53018
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
53006
53019
  }
53007
53020
  } else {
@@ -53010,13 +53023,13 @@ var Cr = class {
53010
53023
  let n = this.backboneContext;
53011
53024
  for (; n; ) {
53012
53025
  if (e.path?.startsWith(n.path + ".")) {
53013
- n.type.elements[Rr(e, n.path)] = t;
53026
+ n.type.elements[Er(e, n.path)] = t;
53014
53027
  break;
53015
53028
  }
53016
53029
  n = n.parent;
53017
53030
  }
53018
53031
  if (!n) {
53019
- let i = Rr(e, this.root.path);
53032
+ let i = Er(e, this.root.path);
53020
53033
  e.isSummary && this.resourceSchema.summaryProperties?.add(i.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i.replace("[x]", "")), this.resourceSchema.elements[i] = t;
53021
53034
  }
53022
53035
  this.checkFieldExit(e);
@@ -53026,23 +53039,23 @@ var Cr = class {
53026
53039
  return this.checkFieldExit(), this.innerTypes.length > 0 && (this.resourceSchema.innerTypes = this.innerTypes), this.resourceSchema;
53027
53040
  }
53028
53041
  checkFieldEnter(e, t) {
53029
- this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !Ne(this.slicingContext.path, e?.path) && (this.slicingContext = void 0), e.slicing && !this.slicingContext && this.enterSlice(e, t);
53042
+ this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !Fe(this.slicingContext.path, e?.path) && (this.slicingContext = void 0), e.slicing && !this.slicingContext && this.enterSlice(e, t);
53030
53043
  }
53031
53044
  enterInnerType(e) {
53032
- for (; this.backboneContext && !Ne(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
53033
- let t = Pr(e);
53034
- this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent: Ne(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
53045
+ for (; this.backboneContext && !Fe(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
53046
+ let t = Cr(e);
53047
+ this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent: Fe(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
53035
53048
  }
53036
53049
  enterSlice(e, t) {
53037
- Ho(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
53050
+ Go(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
53038
53051
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type") throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
53039
53052
  return { path: n.path, type: n.type };
53040
53053
  }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
53041
53054
  }
53042
53055
  checkFieldExit(e = void 0) {
53043
- if (this.backboneContext && !Ne(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
53056
+ if (this.backboneContext && !Fe(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
53044
53057
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
53045
- while (this.backboneContext && !Ne(this.backboneContext.path, e?.path));
53058
+ while (this.backboneContext && !Fe(this.backboneContext.path, e?.path));
53046
53059
  else this.innerTypes.push(this.backboneContext.type), this.backboneContext = void 0;
53047
53060
  }
53048
53061
  next() {
@@ -53061,7 +53074,7 @@ var Cr = class {
53061
53074
  }
53062
53075
  isInnerType(e) {
53063
53076
  let t = this.peek();
53064
- return !!(Ne(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
53077
+ return !!(Fe(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
53065
53078
  }
53066
53079
  parseSliceStart(e) {
53067
53080
  if (!this.slicingContext) throw new Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);
@@ -53070,7 +53083,7 @@ var Cr = class {
53070
53083
  parseElementDefinitionType(e) {
53071
53084
  return (e.type ?? []).map((t) => {
53072
53085
  let n;
53073
- return (t.code === "BackboneElement" || t.code === "Element") && (n = Pr(e)), n || (n = pe(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
53086
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = Cr(e)), n || (n = pe(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
53074
53087
  });
53075
53088
  }
53076
53089
  parseElementDefinition(e) {
@@ -53081,41 +53094,41 @@ var Cr = class {
53081
53094
  function Qn(r6) {
53082
53095
  return r6 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r6, 10);
53083
53096
  }
53084
- function Rr(r6, e = "") {
53085
- return $o(r6.path, e);
53097
+ function Er(r6, e = "") {
53098
+ return Ho(r6.path, e);
53086
53099
  }
53087
- function $o(r6, e) {
53100
+ function Ho(r6, e) {
53088
53101
  return r6 ? e && r6.startsWith(e) ? r6.substring(e.length + 1) : r6 : "";
53089
53102
  }
53090
- function Ne(r6, e) {
53103
+ function Fe(r6, e) {
53091
53104
  return !r6 || !e ? false : e.startsWith(r6 + ".") || e === r6;
53092
53105
  }
53093
53106
  function zn(r6) {
53094
53107
  return Array.isArray(r6) && r6.length > 0 ? r6[0] : A(r6) ? void 0 : r6;
53095
53108
  }
53096
- function Ho(r6) {
53109
+ function Go(r6) {
53097
53110
  let e = r6.slicing?.discriminator;
53098
53111
  return !!(r6.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
53099
53112
  }
53100
- function Go(r6) {
53113
+ function Qo(r6) {
53101
53114
  let e = r6.description;
53102
53115
  return e?.startsWith(`Base StructureDefinition for ${r6.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r6.name} Type: `.length)), e;
53103
53116
  }
53104
- function _r(r6, e, t) {
53117
+ function Mr(r6, e, t) {
53105
53118
  let n = r6.path;
53106
- return Qo(L(r6, e, t), n, e);
53119
+ return zo(L(r6, e, t), n, e);
53107
53120
  }
53108
- function Qo(r6, e, t) {
53121
+ function zo(r6, e, t) {
53109
53122
  let n = e ? e + "." : "";
53110
53123
  return r6 === void 0 ? { type: "undefined", value: void 0, path: `${n}${t}` } : Array.isArray(r6) ? r6.map((i, o2) => ({ ...i, path: `${n}${t}[${o2}]` })) : { ...r6, path: `${n}${t}` };
53111
53124
  }
53112
- var zo = new K(1e3);
53125
+ var Jo = new K(1e3);
53113
53126
  var Tt = { 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: /^[\r\n\t\u0020-\uFFFF]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\r\n\t\u0020-\uFFFF]+$/, 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: /.*/ };
53114
53127
  function h(r6) {
53115
53128
  return [{ type: d.boolean, value: r6 }];
53116
53129
  }
53117
53130
  function b(r6) {
53118
- return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: d.integer, value: r6 } : typeof r6 == "number" ? { type: d.decimal, value: r6 } : typeof r6 == "boolean" ? { type: d.boolean, value: r6 } : typeof r6 == "string" ? { type: d.string, value: r6 } : V(r6) ? { type: d.Quantity, value: r6 } : I(r6) ? { type: r6.resourceType, value: r6 } : $r(r6) ? { type: d.CodeableConcept, value: r6 } : jr(r6) ? { type: d.Coding, value: r6 } : { type: d.BackboneElement, value: r6 };
53131
+ return r6 == null ? { type: "undefined", value: void 0 } : Number.isSafeInteger(r6) ? { type: d.integer, value: r6 } : typeof r6 == "number" ? { type: d.decimal, value: r6 } : typeof r6 == "boolean" ? { type: d.boolean, value: r6 } : typeof r6 == "string" ? { type: d.string, value: r6 } : V(r6) ? { type: d.Quantity, value: r6 } : I(r6) ? { type: r6.resourceType, value: r6 } : jr(r6) ? { type: d.CodeableConcept, value: r6 } : qr(r6) ? { type: d.Coding, value: r6 } : { type: d.BackboneElement, value: r6 };
53119
53132
  }
53120
53133
  function j(r6) {
53121
53134
  return r6.length === 0 ? false : !!r6[0].value;
@@ -53129,9 +53142,9 @@ function D(r6, e) {
53129
53142
  function L(r6, e, t) {
53130
53143
  if (!r6.value) return;
53131
53144
  let n = Ct(r6.type, e, t?.profileUrl);
53132
- return n ? is(r6, e, n) : os(r6, e);
53145
+ return n ? os(r6, e, n) : ss(r6, e);
53133
53146
  }
53134
- function is(r6, e, t) {
53147
+ function os(r6, e, t) {
53135
53148
  let n = r6.value, i = t.type;
53136
53149
  if (!i || i.length === 0) return;
53137
53150
  let o2, s = "undefined", a, u2 = t.path.lastIndexOf("."), l = t.path.substring(u2 + 1), p2 = l, g2 = false;
@@ -53145,17 +53158,17 @@ function is(r6, e, t) {
53145
53158
  }
53146
53159
  if (a) if (Array.isArray(o2)) {
53147
53160
  o2 = o2.slice();
53148
- for (let v2 = 0; v2 < Math.max(o2.length, a.length); v2++) o2[v2] = Br(o2[v2], a[v2]);
53161
+ for (let v2 = 0; v2 < Math.max(o2.length, a.length); v2++) o2[v2] = Ur(o2[v2], a[v2]);
53149
53162
  } else if (!o2 && Array.isArray(a)) {
53150
53163
  o2 = a.slice();
53151
- for (let v2 = 0; v2 < a.length; v2++) o2[v2] = Br(void 0, a[v2]);
53152
- } else o2 = Br(o2, a);
53164
+ for (let v2 = 0; v2 < a.length; v2++) o2[v2] = Ur(void 0, a[v2]);
53165
+ } else o2 = Ur(o2, a);
53153
53166
  if (!A(o2)) return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o2) ? o2.map((v2) => ti(v2, s)) : ti(o2, s);
53154
53167
  }
53155
53168
  function ti(r6, e) {
53156
53169
  return e === "Resource" && I(r6) && (e = r6.resourceType), { type: e, value: r6 };
53157
53170
  }
53158
- function os(r6, e) {
53171
+ function ss(r6, e) {
53159
53172
  let t = r6.value;
53160
53173
  if (!t || typeof t != "object") return;
53161
53174
  let n;
@@ -53201,14 +53214,14 @@ function si(r6, e) {
53201
53214
  }
53202
53215
  function Ke(r6, e) {
53203
53216
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
53204
- return typeof t == "number" && typeof n == "number" ? h(Math.abs(t - n) < 1e-8) : V(t) && V(n) ? h(ui(t, n)) : h(typeof t == "object" && typeof n == "object" ? qr(r6, e) : t === n);
53217
+ return typeof t == "number" && typeof n == "number" ? h(Math.abs(t - n) < 1e-8) : V(t) && V(n) ? h(ui(t, n)) : h(typeof t == "object" && typeof n == "object" ? Wr(r6, e) : t === n);
53205
53218
  }
53206
- function Wr(r6, e) {
53207
- return r6.length === 0 && e.length === 0 ? h(true) : r6.length !== e.length ? h(false) : (r6.sort(ri), e.sort(ri), h(r6.every((t, n) => j(ss(t, e[n])))));
53219
+ function Br(r6, e) {
53220
+ return r6.length === 0 && e.length === 0 ? h(true) : r6.length !== e.length ? h(false) : (r6.sort(ri), e.sort(ri), h(r6.every((t, n) => j(as(t, e[n])))));
53208
53221
  }
53209
- function ss(r6, e) {
53222
+ function as(r6, e) {
53210
53223
  let { type: t, value: n } = r6, { type: i, value: o2 } = e, s = n?.valueOf(), a = o2?.valueOf();
53211
- return typeof s == "number" && typeof a == "number" ? h(Math.abs(s - a) < 0.01) : V(s) && V(a) ? h(ui(s, a)) : h(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? qr({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
53224
+ return typeof s == "number" && typeof a == "number" ? h(Math.abs(s - a) < 0.01) : V(s) && V(a) ? h(ui(s, a)) : h(t === "Coding" && i === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? Wr({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
53212
53225
  }
53213
53226
  function ri(r6, e) {
53214
53227
  let t = r6.value?.valueOf(), n = e.value?.valueOf();
@@ -53227,7 +53240,7 @@ function Et(r6, e) {
53227
53240
  case "Date":
53228
53241
  return ai(t);
53229
53242
  case "DateTime":
53230
- return Ue(t);
53243
+ return Be(t);
53231
53244
  case "Time":
53232
53245
  return typeof t == "string" && !!/^T\d/.exec(t);
53233
53246
  case "Period":
@@ -53241,11 +53254,11 @@ function Et(r6, e) {
53241
53254
  function ai(r6) {
53242
53255
  return typeof r6 == "string" && !!Tt.date.exec(r6);
53243
53256
  }
53244
- function Ue(r6) {
53257
+ function Be(r6) {
53245
53258
  return typeof r6 == "string" && !!Tt.dateTime.exec(r6);
53246
53259
  }
53247
53260
  function ci(r6) {
53248
- return !!(r6 && typeof r6 == "object" && ("start" in r6 && Ue(r6.start) || "end" in r6 && Ue(r6.end)));
53261
+ return !!(r6 && typeof r6 == "object" && ("start" in r6 && Be(r6.start) || "end" in r6 && Be(r6.end)));
53249
53262
  }
53250
53263
  function V(r6) {
53251
53264
  return !!(r6 && typeof r6 == "object" && "value" in r6 && typeof r6.value == "number");
@@ -53253,13 +53266,13 @@ function V(r6) {
53253
53266
  function ui(r6, e) {
53254
53267
  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);
53255
53268
  }
53256
- function qr(r6, e) {
53269
+ function Wr(r6, e) {
53257
53270
  let t = Object.keys(r6), n = Object.keys(e);
53258
53271
  if (t.length !== n.length) return false;
53259
53272
  for (let i of t) {
53260
53273
  let o2 = r6[i], s = e[i];
53261
53274
  if (ni(o2) && ni(s)) {
53262
- if (!qr(o2, s)) return false;
53275
+ if (!Wr(o2, s)) return false;
53263
53276
  } else if (o2 !== s) return false;
53264
53277
  }
53265
53278
  return true;
@@ -53267,40 +53280,40 @@ function qr(r6, e) {
53267
53280
  function ni(r6) {
53268
53281
  return r6 !== null && typeof r6 == "object";
53269
53282
  }
53270
- function Br(r6, e) {
53283
+ function Ur(r6, e) {
53271
53284
  if (e) {
53272
53285
  if (typeof e != "object") throw new Error("Primitive extension must be an object");
53273
- return as(r6 ?? {}, e);
53286
+ return cs(r6 ?? {}, e);
53274
53287
  }
53275
53288
  return r6;
53276
53289
  }
53277
- function as(r6, e) {
53290
+ function cs(r6, e) {
53278
53291
  return delete e.__proto__, delete e.constructor, Object.assign(r6, e);
53279
53292
  }
53280
53293
  function Xe(r6, e) {
53281
53294
  return I(r6, e) && "id" in r6 && typeof r6.id == "string";
53282
53295
  }
53283
- function Ee(r6) {
53284
- let e = O(r6) ?? "undefined/undefined", t = us(r6);
53296
+ function Re(r6) {
53297
+ let e = O(r6) ?? "undefined/undefined", t = ls(r6);
53285
53298
  return t === e ? { reference: e } : { reference: e, display: t };
53286
53299
  }
53287
53300
  function O(r6) {
53288
53301
  if (Q(r6)) return r6.reference;
53289
53302
  if (Xe(r6)) return `${r6.resourceType}/${r6.id}`;
53290
53303
  }
53291
- function Re(r6) {
53304
+ function Ce(r6) {
53292
53305
  if (r6) return Q(r6) ? r6.reference.split("/")[1] : r6.id;
53293
53306
  }
53294
- function cs(r6) {
53307
+ function us(r6) {
53295
53308
  return r6.resourceType === "Patient" || r6.resourceType === "Practitioner" || r6.resourceType === "RelatedPerson";
53296
53309
  }
53297
- function us(r6) {
53298
- if (cs(r6)) {
53299
- let e = ls(r6);
53310
+ function ls(r6) {
53311
+ if (us(r6)) {
53312
+ let e = ds(r6);
53300
53313
  if (e) return e;
53301
53314
  }
53302
53315
  if (r6.resourceType === "Device") {
53303
- let e = ds(r6);
53316
+ let e = ps(r6);
53304
53317
  if (e) return e;
53305
53318
  }
53306
53319
  if (r6.resourceType === "MedicationRequest" && r6.medicationCodeableConcept) return Ye(r6.medicationCodeableConcept);
@@ -53309,16 +53322,16 @@ function us(r6) {
53309
53322
  if ("name" in r6 && r6.name && typeof r6.name == "string") return r6.name;
53310
53323
  if ("code" in r6 && r6.code) {
53311
53324
  let e = r6.code;
53312
- if (Array.isArray(e) && (e = e[0]), $r(e)) return Ye(e);
53313
- if (vs(e)) return e.text;
53325
+ if (Array.isArray(e) && (e = e[0]), jr(e)) return Ye(e);
53326
+ if (Ts(e)) return e.text;
53314
53327
  }
53315
53328
  return O(r6) ?? "";
53316
53329
  }
53317
- function ls(r6) {
53330
+ function ds(r6) {
53318
53331
  let e = r6.name;
53319
53332
  if (e && e.length > 0) return Ze(e[0]);
53320
53333
  }
53321
- function ds(r6) {
53334
+ function ps(r6) {
53322
53335
  let e = r6.deviceName;
53323
53336
  if (e && e.length > 0) return e[0].name;
53324
53337
  }
@@ -53340,26 +53353,26 @@ function pe(r6, ...e) {
53340
53353
  return t;
53341
53354
  }
53342
53355
  function At(r6, e) {
53343
- let t = Jr(r6);
53356
+ let t = zr(r6);
53344
53357
  return JSON.stringify(t, null, e ? 2 : void 0) ?? "";
53345
53358
  }
53346
- function Jr(r6) {
53347
- if (!(r6 == null || r6 === "")) return typeof r6 == "object" ? Array.isArray(r6) ? ps(r6) : fs2(r6) : r6;
53359
+ function zr(r6) {
53360
+ if (!(r6 == null || r6 === "")) return typeof r6 == "object" ? Array.isArray(r6) ? fs2(r6) : ms(r6) : r6;
53348
53361
  }
53349
- function ps(r6) {
53362
+ function fs2(r6) {
53350
53363
  let e = r6.length;
53351
53364
  if (e === 0) return;
53352
53365
  let t, n = 0;
53353
53366
  for (let i = 0; i < e; i++) {
53354
- let o2 = r6[i], s = Jr(o2);
53367
+ let o2 = r6[i], s = zr(o2);
53355
53368
  s !== o2 && !t && (t = Array.from(r6)), s === void 0 ? t && (t[i] = null) : (t && (t[i] = s), n++);
53356
53369
  }
53357
53370
  if (n !== 0) return t ?? r6;
53358
53371
  }
53359
- function fs2(r6) {
53372
+ function ms(r6) {
53360
53373
  let e, t = 0;
53361
53374
  for (let n in r6) {
53362
- let i = r6[n], o2 = Jr(i);
53375
+ let i = r6[n], o2 = zr(i);
53363
53376
  o2 !== i && !e && (e = { ...r6 }), o2 === void 0 ? e && delete e[n] : (e && (e[n] = o2), t++);
53364
53377
  }
53365
53378
  if (t !== 0) return e ?? r6;
@@ -53375,14 +53388,14 @@ function se(r6) {
53375
53388
  return e === "string" && r6 !== "" || e === "object" && ("length" in r6 && r6.length > 0 || Object.keys(r6).length > 0);
53376
53389
  }
53377
53390
  function fe(r6, e, t) {
53378
- return r6 === e || A(r6) && A(e) ? true : A(r6) || A(e) ? false : Array.isArray(r6) && Array.isArray(e) ? ms(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : C(r6) && C(e) ? hs(r6, e, t) : (C(r6) || C(e), false);
53391
+ return r6 === e || A(r6) && A(e) ? true : A(r6) || A(e) ? false : Array.isArray(r6) && Array.isArray(e) ? hs(r6, e) : Array.isArray(r6) || Array.isArray(e) ? false : C(r6) && C(e) ? gs(r6, e, t) : (C(r6) || C(e), false);
53379
53392
  }
53380
- function ms(r6, e) {
53393
+ function hs(r6, e) {
53381
53394
  if (r6.length !== e.length) return false;
53382
53395
  for (let t = 0; t < r6.length; t++) if (!fe(r6[t], e[t])) return false;
53383
53396
  return true;
53384
53397
  }
53385
- function hs(r6, e, t) {
53398
+ function gs(r6, e, t) {
53386
53399
  let n = /* @__PURE__ */ new Set();
53387
53400
  for (let i of Object.keys(r6)) n.add(i);
53388
53401
  for (let i of Object.keys(e)) n.add(i);
@@ -53396,13 +53409,13 @@ function hs(r6, e, t) {
53396
53409
  function C(r6) {
53397
53410
  return r6 !== null && typeof r6 == "object";
53398
53411
  }
53399
- function jr(r6) {
53412
+ function qr(r6) {
53400
53413
  return C(r6) && "code" in r6 && typeof r6.code == "string";
53401
53414
  }
53402
- function $r(r6) {
53403
- return C(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(jr);
53415
+ function jr(r6) {
53416
+ return C(r6) && "coding" in r6 && Array.isArray(r6.coding) && r6.coding.every(qr);
53404
53417
  }
53405
- function vs(r6) {
53418
+ function Ts(r6) {
53406
53419
  return C(r6) && "text" in r6 && typeof r6.text == "string";
53407
53420
  }
53408
53421
  var fi = [];
@@ -53423,14 +53436,14 @@ function gi(r6) {
53423
53436
  function N(r6) {
53424
53437
  return r6 ? r6.charAt(0).toUpperCase() + r6.substring(1) : "";
53425
53438
  }
53426
- var Yr = (r6, e) => new Promise((t, n) => {
53439
+ var Kr = (r6, e) => new Promise((t, n) => {
53427
53440
  e?.signal?.throwIfAborted();
53428
53441
  let i = setTimeout(t, r6);
53429
53442
  e?.signal?.addEventListener("abort", () => {
53430
53443
  clearTimeout(i), n(e.signal?.reason);
53431
53444
  }, { once: true });
53432
53445
  });
53433
- function We(r6, e, t) {
53446
+ function qe(r6, e, t) {
53434
53447
  let n = [];
53435
53448
  for (let i = 0; i < t - 1; i++) {
53436
53449
  let o2 = r6.indexOf(e);
@@ -53442,14 +53455,14 @@ function We(r6, e, t) {
53442
53455
  function wt(r6) {
53443
53456
  return r6.sort((e, t) => e.localeCompare(t));
53444
53457
  }
53445
- function Xr(r6) {
53458
+ function Yr(r6) {
53446
53459
  return r6.endsWith("/") ? r6 : r6 + "/";
53447
53460
  }
53448
- function Ps(r6) {
53461
+ function As(r6) {
53449
53462
  return r6.startsWith("/") ? r6.slice(1) : r6;
53450
53463
  }
53451
53464
  function U(r6, e) {
53452
- return new URL(Ps(e), Xr(r6.toString())).toString();
53465
+ return new URL(As(e), Yr(r6.toString())).toString();
53453
53466
  }
53454
53467
  function Ti(r6, e) {
53455
53468
  return U(r6, e).toString().replace("http://", "ws://").replace("https://", "wss://");
@@ -53457,34 +53470,34 @@ function Ti(r6, e) {
53457
53470
  function Si(r6) {
53458
53471
  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();
53459
53472
  }
53460
- var As = /^(([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])$/;
53473
+ var ws = /^(([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])$/;
53461
53474
  function Cd(r6) {
53462
- return As.test(r6);
53475
+ return ws.test(r6);
53463
53476
  }
53464
53477
  var y = Object.freeze([]);
53465
53478
  function Ze(r6, e) {
53466
53479
  if (!r6) return "";
53467
53480
  let t = [];
53468
53481
  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) {
53469
- let n = Pe(r6.text);
53482
+ let n = Ae(r6.text);
53470
53483
  if (n) return n;
53471
53484
  }
53472
53485
  return t.join(" ").trim();
53473
53486
  }
53474
53487
  function Ye(r6) {
53475
53488
  if (!r6) return "";
53476
- let e = Pe(r6.text);
53489
+ let e = Ae(r6.text);
53477
53490
  return e || (r6.coding ? r6.coding.map((t) => Ei(t)).join(", ") : "");
53478
53491
  }
53479
53492
  function Ei(r6, e) {
53480
- let t = Pe(r6?.display);
53493
+ let t = Ae(r6?.display);
53481
53494
  if (t) {
53482
- let n = e ? Pe(r6?.code) : void 0;
53495
+ let n = e ? Ae(r6?.code) : void 0;
53483
53496
  return `${t}${n ? " (" + n + ")" : ""}`;
53484
53497
  }
53485
- return Pe(r6?.code) ?? "";
53498
+ return Ae(r6?.code) ?? "";
53486
53499
  }
53487
- function Pe(r6) {
53500
+ function Ae(r6) {
53488
53501
  return typeof r6 == "string" ? r6 : void 0;
53489
53502
  }
53490
53503
  var d = { 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", Element: "Element", ElementDefinition: "ElementDefinition", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", MoneyQuantity: "MoneyQuantity", 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", SimpleQuantity: "SimpleQuantity", 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", xhtml: "xhtml" };
@@ -53496,24 +53509,24 @@ function Pi(r6) {
53496
53509
  let e = $.types[r6];
53497
53510
  return e || (e = { searchParamsDetails: {} }, $.types[r6] = e), !e.searchParams && r6 !== "Binary" && (e.searchParams = { _id: { base: [r6], code: "_id", type: "token", expression: r6 + ".id" }, _lastUpdated: { base: [r6], code: "_lastUpdated", type: "date", expression: r6 + ".meta.lastUpdated" }, _compartment: { base: [r6], code: "_compartment", type: "reference", expression: r6 + ".meta.compartment" }, _profile: { base: [r6], code: "_profile", type: "uri", expression: r6 + ".meta.profile" }, _security: { base: [r6], code: "_security", type: "token", expression: r6 + ".meta.security" }, _source: { base: [r6], code: "_source", type: "uri", expression: r6 + ".meta.source" }, _tag: { base: [r6], code: "_tag", type: "token", expression: r6 + ".meta.tag" }, _project: { base: [r6], code: "_project", type: "token", expression: r6 + ".meta.project" } }), e;
53498
53511
  }
53499
- function en(r6) {
53512
+ function Zr(r6) {
53500
53513
  for (let e of r6.base ?? y) {
53501
53514
  let t = Pi(e);
53502
53515
  t.searchParams || (t.searchParams = {}), t.searchParams[r6.code] = r6;
53503
53516
  }
53504
53517
  }
53505
- function Pr(r6) {
53518
+ function Cr(r6) {
53506
53519
  let e = r6.type?.[0]?.code;
53507
- return e === "BackboneElement" || e === "Element" ? Fs((r6.base?.path ?? r6.path)?.split(".")) : e;
53520
+ return e === "BackboneElement" || e === "Element" ? Us((r6.base?.path ?? r6.path)?.split(".")) : e;
53508
53521
  }
53509
- function Fs(r6) {
53522
+ function Us(r6) {
53510
53523
  return r6.length === 1 ? r6[0] : r6.map(N).join("");
53511
53524
  }
53512
53525
  function Ct(r6, e, t) {
53513
- let n = ze(r6, t);
53514
- if (n) return qs(n.elements, e);
53526
+ let n = Ee(r6, t);
53527
+ if (n) return Ai(n.elements, e);
53515
53528
  }
53516
- function qs(r6, e) {
53529
+ function Ai(r6, e) {
53517
53530
  let t = r6[e] ?? r6[e + "[x]"];
53518
53531
  if (t) return t;
53519
53532
  for (let n = 0; n < e.length; n++) {
@@ -53531,7 +53544,7 @@ function Q(r6, e) {
53531
53544
  return r6 && typeof r6 == "object" && "reference" in r6 && typeof r6.reference == "string" ? e ? r6.reference.match(new RegExp(`^${e}(/|\\?)`)) !== null : true : false;
53532
53545
  }
53533
53546
  var $ = { types: {} };
53534
- function qe(r6) {
53547
+ function je(r6) {
53535
53548
  if (r6.startsWith("T")) return r6 + "T00:00:00.000Z".substring(r6.length);
53536
53549
  if (r6.length <= 10) return r6;
53537
53550
  try {
@@ -53555,10 +53568,10 @@ var _ = { empty: (r6, e) => h(e.every((t) => A(t.value))), hasValue: (r6, e) =>
53555
53568
  return h(false);
53556
53569
  }, subsetOf: (r6, e, t) => {
53557
53570
  if (e.length === 0) return h(true);
53558
- let n = t.eval(r6, Ae(r6));
53571
+ let n = t.eval(r6, we(r6));
53559
53572
  return n.length === 0 ? h(false) : h(e.every((i) => n.some((o2) => o2.value === i.value)));
53560
53573
  }, supersetOf: (r6, e, t) => {
53561
- let n = t.eval(r6, Ae(r6));
53574
+ let n = t.eval(r6, we(r6));
53562
53575
  return n.length === 0 ? h(true) : e.length === 0 ? h(false) : h(n.every((i) => e.some((o2) => o2.value === i.value)));
53563
53576
  }, count: (r6, e) => [{ type: d.integer, value: e.length }], distinct: (r6, e) => {
53564
53577
  let t = [];
@@ -53577,21 +53590,21 @@ var _ = { empty: (r6, e) => h(e.every((t) => A(t.value))), hasValue: (r6, e) =>
53577
53590
  return n <= 0 ? [] : e.slice(0, n);
53578
53591
  }, intersect: (r6, e, t) => {
53579
53592
  if (!t) return e;
53580
- let n = t.eval(r6, Ae(r6)), i = [];
53593
+ let n = t.eval(r6, we(r6)), i = [];
53581
53594
  for (let o2 of e) !i.some((s) => s.value === o2.value) && n.some((s) => s.value === o2.value) && i.push(o2);
53582
53595
  return i;
53583
53596
  }, exclude: (r6, e, t) => {
53584
53597
  if (!t) return e;
53585
- let n = t.eval(r6, Ae(r6)), i = [];
53598
+ let n = t.eval(r6, we(r6)), i = [];
53586
53599
  for (let o2 of e) n.some((s) => s.value === o2.value) || i.push(o2);
53587
53600
  return i;
53588
53601
  }, union: (r6, e, t) => {
53589
53602
  if (!t) return e;
53590
- let n = t.eval(r6, Ae(r6));
53603
+ let n = t.eval(r6, we(r6));
53591
53604
  return bt([...e, ...n]);
53592
53605
  }, combine: (r6, e, t) => {
53593
53606
  if (!t) return e;
53594
- let n = t.eval(r6, Ae(r6));
53607
+ let n = t.eval(r6, we(r6));
53595
53608
  return [...e, ...n];
53596
53609
  }, htmlChecks: (r6, e, t) => [b(true)], iif: (r6, e, t, n, i) => {
53597
53610
  let o2 = t.eval(r6, e);
@@ -53615,11 +53628,11 @@ var _ = { empty: (r6, e) => h(e.every((t) => A(t.value))), hasValue: (r6, e) =>
53615
53628
  }, convertsToInteger: (r6, e) => e.length === 0 ? [] : h(_.toInteger(r6, e).length === 1), toDate: (r6, e) => {
53616
53629
  if (e.length === 0) return [];
53617
53630
  let [{ value: t }] = ee(e, 1);
53618
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: d.date, value: qe(t) }] : [];
53631
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: d.date, value: je(t) }] : [];
53619
53632
  }, convertsToDate: (r6, e) => e.length === 0 ? [] : h(_.toDate(r6, e).length === 1), toDateTime: (r6, e) => {
53620
53633
  if (e.length === 0) return [];
53621
53634
  let [{ value: t }] = ee(e, 1);
53622
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: d.dateTime, value: qe(t) }] : [];
53635
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: d.dateTime, value: je(t) }] : [];
53623
53636
  }, convertsToDateTime: (r6, e) => e.length === 0 ? [] : h(_.toDateTime(r6, e).length === 1), toDecimal: (r6, e) => {
53624
53637
  if (e.length === 0) return [];
53625
53638
  let [{ value: t }] = ee(e, 1);
@@ -53637,14 +53650,14 @@ var _ = { empty: (r6, e) => h(e.every((t) => A(t.value))), hasValue: (r6, e) =>
53637
53650
  let [{ value: t }] = ee(e, 1);
53638
53651
  if (typeof t == "string") {
53639
53652
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
53640
- if (n) return [{ type: d.time, value: qe("T" + n[1]) }];
53653
+ if (n) return [{ type: d.time, value: je("T" + n[1]) }];
53641
53654
  }
53642
53655
  return [];
53643
53656
  }, convertsToTime: (r6, e) => e.length === 0 ? [] : h(_.toTime(r6, e).length === 1), indexOf: (r6, e, t) => H((n, i) => n.indexOf(i), r6, e, t), substring: (r6, e, t, n) => H((i, o2, s) => {
53644
53657
  let a = o2, u2 = s ? a + s : i.length;
53645
53658
  return a < 0 || a >= i.length ? void 0 : i.substring(a, u2);
53646
53659
  }, r6, e, t, n), startsWith: (r6, e, t) => H((n, i) => n.startsWith(i), r6, e, t), endsWith: (r6, e, t) => H((n, i) => n.endsWith(i), r6, e, t), contains: (r6, e, t) => H((n, i) => n.includes(i), r6, e, t), upper: (r6, e) => H((t) => t.toUpperCase(), r6, e), lower: (r6, e) => H((t) => t.toLowerCase(), r6, e), replace: (r6, e, t, n) => H((i, o2, s) => i.replaceAll(o2, s), r6, e, t, n), matches: (r6, e, t) => H((n, i) => !!new RegExp(i).exec(n), r6, e, t), replaceMatches: (r6, e, t, n) => H((i, o2, s) => i.replaceAll(new RegExp(o2, "g"), s.replaceAll(/\$\{(\w+)\}/g, "$<$1>")), r6, e, t, n), length: (r6, e) => H((t) => t.length, r6, e), toChars: (r6, e) => H((t) => t ? t.split("") : void 0, r6, e), encode: ae, decode: ae, escape: ae, unescape: ae, trim: ae, split: ae, join: (r6, e, t) => {
53647
- let n = t?.eval(r6, Ae(r6))[0]?.value ?? "";
53660
+ let n = t?.eval(r6, we(r6))[0]?.value ?? "";
53648
53661
  if (typeof n != "string") throw new TypeError("Separator must be a string.");
53649
53662
  return [{ type: d.string, value: e.map((i) => i.value?.toString() ?? "").join(n) }];
53650
53663
  }, abs: (r6, e) => Z(Math.abs, r6, e), ceiling: (r6, e) => Z(Math.ceil, r6, e), exp: (r6, e) => Z(Math.exp, r6, e), floor: (r6, e) => Z(Math.floor, r6, e), ln: (r6, e) => Z(Math.log, r6, e), log: (r6, e, t) => Z((n, i) => Math.log(n) / Math.log(i), r6, e, t), power: (r6, e, t) => Z(Math.pow, r6, e, t), round: (r6, e, ...t) => Z((n, i = 0) => {
@@ -53695,7 +53708,7 @@ var _ = { empty: (r6, e) => h(e.every((t) => A(t.value))), hasValue: (r6, e) =>
53695
53708
  let n = e[0].value;
53696
53709
  if (!n?.reference) return [];
53697
53710
  let i = "";
53698
- return t instanceof B && (i = t.name), i && !n.reference.startsWith(i + "/") ? [] : [{ type: d.id, value: Re(n) }];
53711
+ return t instanceof B && (i = t.name), i && !n.reference.startsWith(i + "/") ? [] : [{ type: d.id, value: Ce(n) }];
53699
53712
  }, extension: (r6, e, t) => {
53700
53713
  let n = t.eval(r6, e)[0].value, i = e?.[0]?.value;
53701
53714
  if (i) {
@@ -53723,7 +53736,7 @@ function ee(r6, e) {
53723
53736
  for (let t of r6) if (t == null) throw new Error("Expected non-null argument");
53724
53737
  return r6;
53725
53738
  }
53726
- function Ae(r6) {
53739
+ function we(r6) {
53727
53740
  let e = r6;
53728
53741
  for (; e.parent?.variables.$this; ) e = e.parent;
53729
53742
  return [e.variables.$this];
@@ -53760,7 +53773,7 @@ var B = class {
53760
53773
  }
53761
53774
  evalValue(e) {
53762
53775
  let t = e.value;
53763
- if (!(!t || typeof t != "object")) return I(t, this.name) ? e : _r(e, this.name);
53776
+ if (!(!t || typeof t != "object")) return I(t, this.name) ? ("path" in e || (e.path = t.resourceType), e) : Mr(e, this.name);
53764
53777
  }
53765
53778
  toString() {
53766
53779
  return this.name;
@@ -53808,13 +53821,13 @@ var F = class extends R {
53808
53821
  return typeof p2 == "boolean" ? h(p2) : V(s) ? [{ type: d.Quantity, value: { ...s, value: p2 } }] : [b(p2)];
53809
53822
  }
53810
53823
  };
53811
- var wi = Object.freeze({ type: "string", value: "" });
53824
+ var Oi = Object.freeze({ type: "string", value: "" });
53812
53825
  var Vt = class extends R {
53813
53826
  constructor(e, t) {
53814
53827
  super("&", e, t);
53815
53828
  }
53816
53829
  eval(e, t) {
53817
- let n = D(this.left.eval(e, t)) ?? wi, i = D(this.right.eval(e, t)) ?? wi;
53830
+ let n = D(this.left.eval(e, t)) ?? Oi, i = D(this.right.eval(e, t)) ?? Oi;
53818
53831
  if (typeof n.value != "string") throw new Error(`Expected string operand for &, but got ${n.type}`);
53819
53832
  if (typeof i.value != "string") throw new Error(`Expected string operand for &, but got ${i.type}`);
53820
53833
  return [{ type: d.string, value: n.value + i.value }];
@@ -53849,7 +53862,7 @@ var te = class extends R {
53849
53862
  return `${this.left.toString()}.${this.right.toString()}`;
53850
53863
  }
53851
53864
  };
53852
- var we = class extends R {
53865
+ var Oe = class extends R {
53853
53866
  constructor(e, t) {
53854
53867
  super("|", e, t);
53855
53868
  }
@@ -53882,7 +53895,7 @@ var Nt = class extends R {
53882
53895
  }
53883
53896
  eval(e, t) {
53884
53897
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
53885
- return Wr(n, i);
53898
+ return Br(n, i);
53886
53899
  }
53887
53900
  };
53888
53901
  var Ft = class extends R {
@@ -53891,10 +53904,10 @@ var Ft = class extends R {
53891
53904
  }
53892
53905
  eval(e, t) {
53893
53906
  let n = this.left.eval(e, t), i = this.right.eval(e, t);
53894
- return ii(Wr(n, i));
53907
+ return ii(Br(n, i));
53895
53908
  }
53896
53909
  };
53897
- var Oe = class extends R {
53910
+ var Ie = class extends R {
53898
53911
  constructor(e, t) {
53899
53912
  super("is", e, t);
53900
53913
  }
@@ -53956,7 +53969,7 @@ var re = class {
53956
53969
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
53957
53970
  }
53958
53971
  };
53959
- var Ie = class {
53972
+ var ke = class {
53960
53973
  constructor(e, t) {
53961
53974
  c(this, "left");
53962
53975
  c(this, "expr");
@@ -53984,7 +53997,7 @@ var Gs = { parse(r6) {
53984
53997
  var Qs = { parse(r6, e) {
53985
53998
  let t = r6.consumeAndParse();
53986
53999
  if (!r6.match("]")) throw new Error("Parse error: expected `]`");
53987
- return new Ie(e, t);
54000
+ return new ke(e, t);
53988
54001
  }, precedence: S.Indexer };
53989
54002
  var zs = { parse(r6, e) {
53990
54003
  if (!(e instanceof B)) throw new Error("Unexpected parentheses");
@@ -53997,21 +54010,21 @@ function Js(r6) {
53997
54010
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
53998
54011
  }
53999
54012
  function rt() {
54000
- return new pt().registerPrefix("String", { parse: (r6, e) => new G({ type: d.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r6, e) => new G({ type: d.dateTime, value: qe(e.value) }) }).registerPrefix("Quantity", { parse: (r6, e) => new G({ type: d.Quantity, value: Js(e.value) }) }).registerPrefix("Number", { parse: (r6, e) => new G({ type: e.value.includes(".") ? d.decimal : d.integer, value: Number.parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new G({ type: d.boolean, value: true }) }).registerPrefix("false", { parse: () => new G({ type: d.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r6, e) => new B(e.value) }).registerPrefix("{}", { parse: () => new It() }).registerPrefix("(", Gs).registerInfix("[", Qs).registerInfix("(", zs).prefix("+", S.UnaryAdd, (r6, e) => new kt("+", e, (t) => t)).prefix("-", S.UnarySubtract, (r6, e) => new F("-", e, e, (t, n) => -n)).infixLeft(".", S.Dot, (r6, e, t) => new te(r6, t)).infixLeft("/", S.Divide, (r6, e, t) => new F("/", r6, t, (n, i) => n / i)).infixLeft("*", S.Multiply, (r6, e, t) => new F("*", r6, t, (n, i) => n * i)).infixLeft("+", S.Add, (r6, e, t) => new F("+", r6, t, (n, i) => n + i)).infixLeft("-", S.Subtract, (r6, e, t) => new F("-", r6, t, (n, i) => n - i)).infixLeft("|", S.Union, (r6, e, t) => new we(r6, t)).infixLeft("=", S.Equals, (r6, e, t) => new _t(r6, t)).infixLeft("!=", S.NotEquals, (r6, e, t) => new Lt(r6, t)).infixLeft("~", S.Equivalent, (r6, e, t) => new Nt(r6, t)).infixLeft("!~", S.NotEquivalent, (r6, e, t) => new Ft(r6, t)).infixLeft("<", S.LessThan, (r6, e, t) => new F("<", r6, t, (n, i) => n < i)).infixLeft("<=", S.LessThanOrEquals, (r6, e, t) => new F("<=", r6, t, (n, i) => n <= i)).infixLeft(">", S.GreaterThan, (r6, e, t) => new F(">", r6, t, (n, i) => n > i)).infixLeft(">=", S.GreaterThanOrEquals, (r6, e, t) => new F(">=", r6, t, (n, i) => n >= i)).infixLeft("&", S.Ampersand, (r6, e, t) => new Vt(r6, t)).infixLeft("and", S.And, (r6, e, t) => new Ut(r6, t)).infixLeft("as", S.As, (r6, e, t) => new ye(r6, t)).infixLeft("contains", S.Contains, (r6, e, t) => new Dt(r6, t)).infixLeft("div", S.Divide, (r6, e, t) => new F("div", r6, t, (n, i) => Math.trunc(n / i))).infixLeft("in", S.In, (r6, e, t) => new Mt(r6, t)).infixLeft("is", S.Is, (r6, e, t) => new Oe(r6, t)).infixLeft("mod", S.Modulo, (r6, e, t) => new F("mod", r6, t, (n, i) => n % i)).infixLeft("or", S.Or, (r6, e, t) => new Bt(r6, t)).infixLeft("xor", S.Xor, (r6, e, t) => new Wt(r6, t)).infixLeft("implies", S.Implies, (r6, e, t) => new qt(r6, t));
54013
+ return new pt().registerPrefix("String", { parse: (r6, e) => new G({ type: d.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r6, e) => new G({ type: d.dateTime, value: je(e.value) }) }).registerPrefix("Quantity", { parse: (r6, e) => new G({ type: d.Quantity, value: Js(e.value) }) }).registerPrefix("Number", { parse: (r6, e) => new G({ type: e.value.includes(".") ? d.decimal : d.integer, value: Number.parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new G({ type: d.boolean, value: true }) }).registerPrefix("false", { parse: () => new G({ type: d.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r6, e) => new B(e.value) }).registerPrefix("{}", { parse: () => new It() }).registerPrefix("(", Gs).registerInfix("[", Qs).registerInfix("(", zs).prefix("+", S.UnaryAdd, (r6, e) => new kt("+", e, (t) => t)).prefix("-", S.UnarySubtract, (r6, e) => new F("-", e, e, (t, n) => -n)).infixLeft(".", S.Dot, (r6, e, t) => new te(r6, t)).infixLeft("/", S.Divide, (r6, e, t) => new F("/", r6, t, (n, i) => n / i)).infixLeft("*", S.Multiply, (r6, e, t) => new F("*", r6, t, (n, i) => n * i)).infixLeft("+", S.Add, (r6, e, t) => new F("+", r6, t, (n, i) => n + i)).infixLeft("-", S.Subtract, (r6, e, t) => new F("-", r6, t, (n, i) => n - i)).infixLeft("|", S.Union, (r6, e, t) => new Oe(r6, t)).infixLeft("=", S.Equals, (r6, e, t) => new _t(r6, t)).infixLeft("!=", S.NotEquals, (r6, e, t) => new Lt(r6, t)).infixLeft("~", S.Equivalent, (r6, e, t) => new Nt(r6, t)).infixLeft("!~", S.NotEquivalent, (r6, e, t) => new Ft(r6, t)).infixLeft("<", S.LessThan, (r6, e, t) => new F("<", r6, t, (n, i) => n < i)).infixLeft("<=", S.LessThanOrEquals, (r6, e, t) => new F("<=", r6, t, (n, i) => n <= i)).infixLeft(">", S.GreaterThan, (r6, e, t) => new F(">", r6, t, (n, i) => n > i)).infixLeft(">=", S.GreaterThanOrEquals, (r6, e, t) => new F(">=", r6, t, (n, i) => n >= i)).infixLeft("&", S.Ampersand, (r6, e, t) => new Vt(r6, t)).infixLeft("and", S.And, (r6, e, t) => new Ut(r6, t)).infixLeft("as", S.As, (r6, e, t) => new ye(r6, t)).infixLeft("contains", S.Contains, (r6, e, t) => new Dt(r6, t)).infixLeft("div", S.Divide, (r6, e, t) => new F("div", r6, t, (n, i) => Math.trunc(n / i))).infixLeft("in", S.In, (r6, e, t) => new Mt(r6, t)).infixLeft("is", S.Is, (r6, e, t) => new Ie(r6, t)).infixLeft("mod", S.Modulo, (r6, e, t) => new F("mod", r6, t, (n, i) => n % i)).infixLeft("or", S.Or, (r6, e, t) => new Bt(r6, t)).infixLeft("xor", S.Xor, (r6, e, t) => new Wt(r6, t)).infixLeft("implies", S.Implies, (r6, e, t) => new qt(r6, t));
54001
54014
  }
54002
54015
  var Ks = rt();
54003
54016
  var m = { EQUALS: "eq", NOT_EQUALS: "ne", GREATER_THAN: "gt", LESS_THAN: "lt", GREATER_THAN_OR_EQUALS: "ge", LESS_THAN_OR_EQUALS: "le", STARTS_AFTER: "sa", ENDS_BEFORE: "eb", APPROXIMATELY: "ap", CONTAINS: "contains", STARTS_WITH: "sw", EXACT: "exact", TEXT: "text", NOT: "not", ABOVE: "above", BELOW: "below", IN: "in", NOT_IN: "not-in", OF_TYPE: "of-type", MISSING: "missing", PRESENT: "present", IDENTIFIER: "identifier", ITERATE: "iterate" };
54004
- var tn = { contains: m.CONTAINS, exact: m.EXACT, above: m.ABOVE, below: m.BELOW, text: m.TEXT, not: m.NOT, in: m.IN, "not-in": m.NOT_IN, "of-type": m.OF_TYPE, missing: m.MISSING, identifier: m.IDENTIFIER, iterate: m.ITERATE };
54005
- var rn = { eq: m.EQUALS, ne: m.NOT_EQUALS, lt: m.LESS_THAN, le: m.LESS_THAN_OR_EQUALS, gt: m.GREATER_THAN, ge: m.GREATER_THAN_OR_EQUALS, sa: m.STARTS_AFTER, eb: m.ENDS_BEFORE, ap: m.APPROXIMATELY, sw: m.STARTS_WITH };
54017
+ var en = { contains: m.CONTAINS, exact: m.EXACT, above: m.ABOVE, below: m.BELOW, text: m.TEXT, not: m.NOT, in: m.IN, "not-in": m.NOT_IN, "of-type": m.OF_TYPE, missing: m.MISSING, identifier: m.IDENTIFIER, iterate: m.ITERATE };
54018
+ var tn = { eq: m.EQUALS, ne: m.NOT_EQUALS, lt: m.LESS_THAN, le: m.LESS_THAN_OR_EQUALS, gt: m.GREATER_THAN, ge: m.GREATER_THAN_OR_EQUALS, sa: m.STARTS_AFTER, eb: m.ENDS_BEFORE, ap: m.APPROXIMATELY, sw: m.STARTS_WITH };
54006
54019
  var ia = [m.MISSING, m.PRESENT];
54007
54020
  var fa = new K(1e3);
54008
- var Ve = { READ: "read", VREAD: "vread", UPDATE: "update", DELETE: "delete", HISTORY: "history", CREATE: "create", SEARCH: "search" };
54009
- var Pa = [Ve.READ, Ve.VREAD, Ve.HISTORY, Ve.SEARCH];
54010
- var sf = { FIRST: "first", APPLICATION: "application" };
54021
+ var De = { READ: "read", VREAD: "vread", UPDATE: "update", DELETE: "delete", HISTORY: "history", CREATE: "create", SEARCH: "search" };
54022
+ var Pa = [De.READ, De.VREAD, De.HISTORY, De.SEARCH];
54023
+ var af = { FIRST: "first", APPLICATION: "application" };
54011
54024
  function z() {
54012
54025
  return typeof window < "u";
54013
54026
  }
54014
- function nn() {
54027
+ function rn() {
54015
54028
  return typeof Buffer < "u" ? Buffer : void 0;
54016
54029
  }
54017
54030
  var ce = { assign(r6) {
@@ -54032,7 +54045,7 @@ function Oa(r6) {
54032
54045
  let t = window.atob(r6), n = Uint8Array.from(t, (i) => i.codePointAt(0));
54033
54046
  return new window.TextDecoder().decode(n);
54034
54047
  }
54035
- let e = nn();
54048
+ let e = rn();
54036
54049
  if (e) return e.from(r6, "base64").toString("utf-8");
54037
54050
  throw new Error("Unable to decode base64");
54038
54051
  }
@@ -54041,20 +54054,20 @@ function Gt(r6) {
54041
54054
  let t = new window.TextEncoder().encode(r6), n = String.fromCodePoint.apply(null, t);
54042
54055
  return window.btoa(n);
54043
54056
  }
54044
- let e = nn();
54057
+ let e = rn();
54045
54058
  if (e) return e.from(r6, "utf8").toString("base64");
54046
54059
  throw new Error("Unable to encode base64");
54047
54060
  }
54048
- function Bi(r6) {
54061
+ function Wi(r6) {
54049
54062
  r6 = r6.padEnd(r6.length + (4 - r6.length % 4) % 4, "=");
54050
54063
  let e = r6.replaceAll("-", "+").replaceAll("_", "/");
54051
54064
  return Oa(e);
54052
54065
  }
54053
- function on() {
54066
+ function nn() {
54054
54067
  let r6 = new Uint32Array(28);
54055
54068
  return crypto.getRandomValues(r6), mi(r6.buffer);
54056
54069
  }
54057
- async function Wi(r6) {
54070
+ async function qi(r6) {
54058
54071
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r6));
54059
54072
  }
54060
54073
  function ne() {
@@ -54064,7 +54077,7 @@ function ne() {
54064
54077
  });
54065
54078
  }
54066
54079
  var k = { 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", JWT: "application/jwt", MULTIPART_FORM_DATA: "multipart/form-data", PNG: "image/png", SCIM_JSON: "application/scim+json", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript", PING: "x-application/ping", XML: "text/xml", CDA_XML: "application/cda+xml", OCTET_STREAM: "application/octet-stream" };
54067
- var sn = class {
54080
+ var on = class {
54068
54081
  constructor() {
54069
54082
  c(this, "listeners");
54070
54083
  this.listeners = {};
@@ -54095,7 +54108,7 @@ var sn = class {
54095
54108
  };
54096
54109
  var ie = class {
54097
54110
  constructor() {
54098
- c(this, "emitter", new sn());
54111
+ c(this, "emitter", new on());
54099
54112
  }
54100
54113
  dispatchEvent(e) {
54101
54114
  this.emitter.dispatchEvent(e);
@@ -54113,33 +54126,33 @@ var ie = class {
54113
54126
  return this.emitter.listenerCount(e);
54114
54127
  }
54115
54128
  };
54116
- var an = { "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" };
54129
+ var sn = { "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" };
54117
54130
  var Ba = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
54118
- var cn = ["DiagnosticReport-update"];
54119
- function ji(r6) {
54120
- return cn.includes(r6);
54121
- }
54131
+ var an = ["DiagnosticReport-update"];
54122
54132
  function $i(r6) {
54123
- if (cn.includes(r6)) throw new f(T(`'context.version' is required for '${r6}'.`));
54133
+ return an.includes(r6);
54134
+ }
54135
+ function Hi(r6) {
54136
+ if (an.includes(r6)) throw new f(T(`'context.version' is required for '${r6}'.`));
54124
54137
  }
54125
54138
  var Wa = { "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", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, select: { resourceType: "*", reference: true, manyAllowed: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport", reference: true }, patient: { resourceType: "Patient", optional: true, reference: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
54126
54139
  function qa(r6) {
54127
54140
  return Ba.includes(r6);
54128
54141
  }
54129
- function Hi(r6) {
54142
+ function Gi(r6) {
54130
54143
  return !!r6.endpoint;
54131
54144
  }
54132
- function un(r6) {
54145
+ function cn(r6) {
54133
54146
  if (!zt(r6)) throw new f(T("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
54134
54147
  let { channelType: e, mode: t, topic: n, events: i } = r6, o2 = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i.join(",") };
54135
- return Hi(r6) && (o2.endpoint = r6.endpoint), new URLSearchParams(o2).toString();
54148
+ return Gi(r6) && (o2.endpoint = r6.endpoint), new URLSearchParams(o2).toString();
54136
54149
  }
54137
54150
  function zt(r6) {
54138
54151
  if (typeof r6 != "object") return false;
54139
54152
  let { channelType: e, mode: t, topic: n, events: i } = r6;
54140
54153
  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;
54141
- for (let o2 of i) if (!an[o2]) return false;
54142
- return !(Hi(r6) && !(typeof r6.endpoint == "string" && r6.endpoint.startsWith("ws")));
54154
+ for (let o2 of i) if (!sn[o2]) return false;
54155
+ return !(Gi(r6) && !(typeof r6.endpoint == "string" && r6.endpoint.startsWith("ws")));
54143
54156
  }
54144
54157
  function ja(r6, e, t, n) {
54145
54158
  if (typeof e != "object") throw new f(T(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
@@ -54168,11 +54181,11 @@ function Ha(r6, e) {
54168
54181
  if (!o2.manyAllowed && (t.get(i) ?? 0) > 1) throw new f(T(`${t.get(i)} context entries with key '${i}' found for the '${r6}' event when schema only allows for 1.`));
54169
54182
  }
54170
54183
  }
54171
- function ln(r6, e, t, n) {
54184
+ function un(r6, e, t, n) {
54172
54185
  if (!(r6 && typeof r6 == "string")) throw new f(T("Must provide a topic."));
54173
- if (!an[e]) throw new f(T(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(an).join(", ")}`));
54186
+ if (!sn[e]) throw new f(T(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(sn).join(", ")}`));
54174
54187
  if (typeof t != "object") throw new f(T("context must be a context object or array of context objects."));
54175
- if (cn.includes(e) && !n) throw new f(T(`The '${e}' event must contain a 'context.versionId'.`));
54188
+ if (an.includes(e) && !n) throw new f(T(`The '${e}' event must contain a 'context.versionId'.`));
54176
54189
  let i = Array.isArray(t) ? t : [t];
54177
54190
  return Ha(e, i), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ne(), event: { "hub.topic": r6, "hub.event": e, context: i, ...n ? { "context.versionId": n } : {} } };
54178
54191
  }
@@ -54200,23 +54213,23 @@ var Qt = class extends ie {
54200
54213
  }
54201
54214
  };
54202
54215
  function Ga(r6) {
54203
- return JSON.parse(Bi(r6));
54216
+ return JSON.parse(Wi(r6));
54204
54217
  }
54205
- function Gi(r6) {
54218
+ function Qi(r6) {
54206
54219
  return r6.split(".").length === 3;
54207
54220
  }
54208
54221
  function Jt(r6) {
54209
54222
  let [e, t, n] = r6.split(".");
54210
54223
  return Ga(t);
54211
54224
  }
54212
- function Qi(r6) {
54225
+ function zi(r6) {
54213
54226
  try {
54214
54227
  return typeof Jt(r6).login_id == "string";
54215
54228
  } catch {
54216
54229
  return false;
54217
54230
  }
54218
54231
  }
54219
- function zi(r6) {
54232
+ function Ji(r6) {
54220
54233
  try {
54221
54234
  let t = Jt(r6).exp;
54222
54235
  return typeof t == "number" ? t * 1e3 : void 0;
@@ -54239,11 +54252,11 @@ var Kt = class {
54239
54252
  await this.medplum.delete(`keyvalue/v1/${e}`);
54240
54253
  }
54241
54254
  };
54242
- var Ji;
54243
- Ji = Symbol.toStringTag;
54255
+ var Ki;
54256
+ Ki = Symbol.toStringTag;
54244
54257
  var W = class {
54245
54258
  constructor(e) {
54246
- c(this, Ji, "ReadablePromise");
54259
+ c(this, Ki, "ReadablePromise");
54247
54260
  c(this, "suspender");
54248
54261
  c(this, "status", "pending");
54249
54262
  c(this, "response");
@@ -54282,7 +54295,7 @@ var ot = class {
54282
54295
  constructor(e, t = "") {
54283
54296
  c(this, "storage");
54284
54297
  c(this, "prefix", "");
54285
- this.storage = e ?? globalThis.localStorage ?? new dn(), this.prefix = t;
54298
+ this.storage = e ?? globalThis.localStorage ?? new ln(), this.prefix = t;
54286
54299
  }
54287
54300
  makeKey(e) {
54288
54301
  return this.prefix + e;
@@ -54306,7 +54319,7 @@ var ot = class {
54306
54319
  this.setString(e, t ? At(t) : void 0);
54307
54320
  }
54308
54321
  };
54309
- var dn = class {
54322
+ var ln = class {
54310
54323
  constructor() {
54311
54324
  c(this, "data");
54312
54325
  this.data = /* @__PURE__ */ new Map();
@@ -54330,18 +54343,18 @@ var dn = class {
54330
54343
  return Array.from(this.data.keys())[e];
54331
54344
  }
54332
54345
  };
54333
- var $e = { Event: typeof globalThis.Event < "u" ? globalThis.Event : void 0, ErrorEvent: void 0, CloseEvent: void 0 };
54334
- var Yi = false;
54346
+ var He = { Event: typeof globalThis.Event < "u" ? globalThis.Event : void 0, ErrorEvent: void 0, CloseEvent: void 0 };
54347
+ var Xi = false;
54335
54348
  function Qa() {
54336
54349
  if (typeof globalThis.Event > "u") throw new Error("Unable to lazy init events for ReconnectingWebSocket. globalThis.Event is not defined yet");
54337
- $e.Event = globalThis.Event, $e.ErrorEvent = class extends Event {
54350
+ He.Event = globalThis.Event, He.ErrorEvent = class extends Event {
54338
54351
  constructor(t, n) {
54339
54352
  super("error", n);
54340
54353
  c(this, "message");
54341
54354
  c(this, "error");
54342
54355
  this.message = t.message, this.error = t;
54343
54356
  }
54344
- }, $e.CloseEvent = class extends Event {
54357
+ }, He.CloseEvent = class extends Event {
54345
54358
  constructor(t = 1e3, n = "", i) {
54346
54359
  super("close", i);
54347
54360
  c(this, "code");
@@ -54357,11 +54370,11 @@ function za(r6, e) {
54357
54370
  function Yt(r6) {
54358
54371
  return new r6.constructor(r6.type, r6);
54359
54372
  }
54360
- var De = { maxReconnectionDelay: 1e4, minReconnectionDelay: 1e3 + Math.random() * 4e3, minUptime: 5e3, reconnectionDelayGrowFactor: 1.3, connectionTimeout: 4e3, maxRetries: 1 / 0, maxEnqueuedMessages: 1 / 0, startClosed: false, debug: false };
54361
- var Xi = false;
54373
+ var Me = { maxReconnectionDelay: 1e4, minReconnectionDelay: 1e3 + Math.random() * 4e3, minUptime: 5e3, reconnectionDelayGrowFactor: 1.3, connectionTimeout: 4e3, maxRetries: 1 / 0, maxEnqueuedMessages: 1 / 0, startClosed: false, debug: false };
54374
+ var Zi = false;
54362
54375
  var Xt = class r extends ie {
54363
54376
  constructor(t, n, i = {}) {
54364
- Yi || (Qa(), Yi = true);
54377
+ Xi || (Qa(), Xi = true);
54365
54378
  super();
54366
54379
  c(this, "_ws");
54367
54380
  c(this, "_retryCount", -1);
@@ -54382,7 +54395,7 @@ var Xt = class r extends ie {
54382
54395
  c(this, "onopen", null);
54383
54396
  c(this, "_handleOpen", (t2) => {
54384
54397
  this._debug("open event");
54385
- let { minUptime: n2 = De.minUptime } = this._options;
54398
+ let { minUptime: n2 = Me.minUptime } = this._options;
54386
54399
  clearTimeout(this._connectTimeout), this._uptimeTimeout = setTimeout(() => this._acceptOpen(), n2), za(this._ws, "WebSocket is not defined"), this._ws.binaryType = this._binaryType, this._messageQueue.forEach((i2) => this._ws?.send(i2)), this._messageQueue = [], this.onopen && this.onopen(t2), this.dispatchEvent(Yt(t2));
54387
54400
  });
54388
54401
  c(this, "_handleMessage", (t2) => {
@@ -54464,7 +54477,7 @@ var Xt = class r extends ie {
54464
54477
  send(t) {
54465
54478
  if (this._ws?.readyState === this.OPEN) this._debug("send", t), this._ws.send(t);
54466
54479
  else {
54467
- let { maxEnqueuedMessages: n = De.maxEnqueuedMessages } = this._options;
54480
+ let { maxEnqueuedMessages: n = Me.maxEnqueuedMessages } = this._options;
54468
54481
  this._messageQueue.length < n && (this._debug("enqueue", t), this._messageQueue.push(t));
54469
54482
  }
54470
54483
  }
@@ -54472,7 +54485,7 @@ var Xt = class r extends ie {
54472
54485
  this._options.debug && this._debugLogger("RWS>", ...t);
54473
54486
  }
54474
54487
  _getNextDelay() {
54475
- let { reconnectionDelayGrowFactor: t = De.reconnectionDelayGrowFactor, minReconnectionDelay: n = De.minReconnectionDelay, maxReconnectionDelay: i = De.maxReconnectionDelay } = this._options, o2 = 0;
54488
+ let { reconnectionDelayGrowFactor: t = Me.reconnectionDelayGrowFactor, minReconnectionDelay: n = Me.minReconnectionDelay, maxReconnectionDelay: i = Me.maxReconnectionDelay } = this._options, o2 = 0;
54476
54489
  return this._retryCount > 0 && (o2 = n * Math.pow(t, this._retryCount - 1), o2 > i && (o2 = i)), this._debug("next delay", o2), o2;
54477
54490
  }
54478
54491
  _wait() {
@@ -54483,7 +54496,7 @@ var Xt = class r extends ie {
54483
54496
  _connect() {
54484
54497
  if (this._connectLock || !this._shouldReconnect) return;
54485
54498
  this._connectLock = true;
54486
- let { maxRetries: t = De.maxRetries, connectionTimeout: n = De.connectionTimeout } = this._options;
54499
+ let { maxRetries: t = Me.maxRetries, connectionTimeout: n = Me.connectionTimeout } = this._options;
54487
54500
  if (this._retryCount >= t) {
54488
54501
  this._debug("max retries reached", this._retryCount, ">=", t);
54489
54502
  return;
@@ -54493,21 +54506,21 @@ var Xt = class r extends ie {
54493
54506
  this._connectLock = false;
54494
54507
  return;
54495
54508
  }
54496
- !this._options.WebSocket && typeof WebSocket > "u" && !Xi && (console.error("\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket."), Xi = true);
54509
+ !this._options.WebSocket && typeof WebSocket > "u" && !Zi && (console.error("\u203C\uFE0F No WebSocket implementation available. You should define options.WebSocket."), Zi = true);
54497
54510
  let i = this._options.WebSocket || WebSocket;
54498
54511
  this._debug("connect", { url: this._url, protocols: this._protocols }), this._ws = this._protocols ? new i(this._url, this._protocols) : new i(this._url), this._ws.binaryType = this._binaryType, this._connectLock = false, this._addListeners(), this._connectTimeout = setTimeout(() => this._handleTimeout(), n);
54499
54512
  }).catch((i) => {
54500
- this._connectLock = false, this._handleError(new $e.ErrorEvent(Error(i.message), this));
54513
+ this._connectLock = false, this._handleError(new He.ErrorEvent(Error(i.message), this));
54501
54514
  });
54502
54515
  }
54503
54516
  _handleTimeout() {
54504
- this._debug("timeout event"), this._handleError(new $e.ErrorEvent(Error("TIMEOUT"), this));
54517
+ this._debug("timeout event"), this._handleError(new He.ErrorEvent(Error("TIMEOUT"), this));
54505
54518
  }
54506
54519
  _disconnect(t = 1e3, n) {
54507
54520
  if (this._clearTimeouts(), !!this._ws) {
54508
54521
  this._removeListeners();
54509
54522
  try {
54510
- this._ws.close(t, n), this._handleClose(new $e.CloseEvent(t, n, this));
54523
+ this._ws.close(t, n), this._handleClose(new He.CloseEvent(t, n, this));
54511
54524
  } catch {
54512
54525
  }
54513
54526
  }
@@ -54542,7 +54555,7 @@ var at = class extends ie {
54542
54555
  this.criteria.delete(t);
54543
54556
  }
54544
54557
  };
54545
- var pn = class {
54558
+ var dn = class {
54546
54559
  constructor(e, t) {
54547
54560
  c(this, "criteria");
54548
54561
  c(this, "emitter");
@@ -54598,7 +54611,7 @@ var Zt = class {
54598
54611
  return;
54599
54612
  }
54600
54613
  if (o2.type === "handshake") {
54601
- let a = Re(o2.subscription), u2 = { type: "connect", payload: { subscriptionId: a } };
54614
+ let a = Ce(o2.subscription), u2 = { type: "connect", payload: { subscriptionId: a } };
54602
54615
  this.masterSubEmitter?.dispatchEvent(u2);
54603
54616
  let l = this.criteriaEntriesBySubscriptionId.get(a);
54604
54617
  if (!l) {
@@ -54609,7 +54622,7 @@ var Zt = class {
54609
54622
  return;
54610
54623
  }
54611
54624
  this.masterSubEmitter?.dispatchEvent({ type: "message", payload: i });
54612
- let s = this.criteriaEntriesBySubscriptionId.get(Re(o2.subscription));
54625
+ let s = this.criteriaEntriesBySubscriptionId.get(Ce(o2.subscription));
54613
54626
  if (!s) {
54614
54627
  console.warn("Received notification for criteria the SubscriptionManager is not listening for");
54615
54628
  return;
@@ -54714,7 +54727,7 @@ var Zt = class {
54714
54727
  if (this.isStale(e, t)) return;
54715
54728
  e.token = i, e.tokenExpiry = new Date(s).getTime(), this.criteriaEntriesBySubscriptionId.set(e.subscriptionId, e), this.sendBind(i);
54716
54729
  } catch (n) {
54717
- console.error(Le(n)), e.generation === t && !this.isEntryGettingRemoved(e) && (e.state = e.state === "refreshing" ? "active" : "idle"), this.emitError(e, n);
54730
+ console.error(Ne(n)), e.generation === t && !this.isEntryGettingRemoved(e) && (e.state = e.state === "refreshing" ? "active" : "idle"), this.emitError(e, n);
54718
54731
  }
54719
54732
  }
54720
54733
  checkTokenExpirations() {
@@ -54728,7 +54741,7 @@ var Zt = class {
54728
54741
  this.masterSubEmitter && this.masterSubEmitter._addCriteria(e);
54729
54742
  let n = this.maybeGetCriteriaEntry(e, t);
54730
54743
  if (n) return n.refCount === 0 && (n.lastUnrefTime = void 0, n.generation++, n.state !== "active" && (n.state = n.token ? "active" : "idle")), n.refCount += 1, n.state === "idle" && this.subscribeToCriteria(n).catch(console.error), n.emitter;
54731
- let i = new pn(e, t);
54744
+ let i = new dn(e, t);
54732
54745
  return this.addCriteriaEntry(i), this.subscribeToCriteria(i).catch(console.error), i.emitter;
54733
54746
  }
54734
54747
  removeCriteria(e, t) {
@@ -54779,7 +54792,7 @@ function st(r6) {
54779
54792
  return r6.bareCriteria ? [r6.bareCriteria, ...r6.criteriaWithProps] : r6.criteriaWithProps;
54780
54793
  }
54781
54794
  var Ka = new K(1e3);
54782
- var fn = "5.1.14-a19ab66";
54795
+ var pn = "5.1.16-2197100";
54783
54796
  var Za = k.FHIR_JSON + ", */*; q=0.1";
54784
54797
  var ec = "https://api.medplum.com/";
54785
54798
  var tc = 1e3;
@@ -54787,8 +54800,8 @@ var rc = 6e4;
54787
54800
  var nc = 0;
54788
54801
  var ic = 3e5;
54789
54802
  var oc = "Binary/";
54790
- var Zi = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
54791
- var He = { ClientCredentials: "client_credentials", AuthorizationCode: "authorization_code", RefreshToken: "refresh_token", JwtBearer: "urn:ietf:params:oauth:grant-type:jwt-bearer", TokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange", PreAuthorizedCode: "urn:ietf:params:oauth:grant-type:pre-authorized_code" };
54803
+ var eo = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
54804
+ var Ge = { ClientCredentials: "client_credentials", AuthorizationCode: "authorization_code", RefreshToken: "refresh_token", JwtBearer: "urn:ietf:params:oauth:grant-type:jwt-bearer", TokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange", PreAuthorizedCode: "urn:ietf:params:oauth:grant-type:pre-authorized_code" };
54792
54805
  var sc = { AccessToken: "urn:ietf:params:oauth:token-type:access_token", RefreshToken: "urn:ietf:params:oauth:token-type:refresh_token", IdToken: "urn:ietf:params:oauth:token-type:id_token", Saml1Token: "urn:ietf:params:oauth:token-type:saml1", Saml2Token: "urn:ietf:params:oauth:token-type:saml2" };
54793
54806
  var ac = { JwtBearer: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" };
54794
54807
  var er = class extends ie {
@@ -54833,7 +54846,7 @@ var er = class extends ie {
54833
54846
  c(this, "keyValueClient");
54834
54847
  c(this, "logLevel");
54835
54848
  if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
54836
- this.options = t ?? {}, this.fetch = t?.fetch ?? cc(), this.storage = t?.storage ?? new ot(void 0, t?.storagePrefix), this.createPdfImpl = t?.createPdf, this.baseUrl = Xr(t?.baseUrl ?? ec), this.fhirBaseUrl = U(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = U(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = U(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = U(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = U(this.baseUrl, t?.fhircastHubUrl ?? "fhircast/STU3"), this.cdsServicesUrl = U(this.baseUrl, t?.cdsServicesUrl ?? "cds-services"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.credentialsInHeader = t?.authCredentialsMethod === "header", this.defaultHeaders = t?.defaultHeaders ?? {}, this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? ic, this.logLevel = this.initializeLogLevel(t), this.maxRetries = t?.maxRetries ?? 2, this.maxRetryTime = t?.maxRetryTime ?? 2e3, this.cacheTime = t?.cacheTime ?? (z() ? rc : nc), this.cacheTime > 0 ? this.requestCache = new K(t?.resourceCacheSize ?? tc) : 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(() => {
54849
+ this.options = t ?? {}, this.fetch = t?.fetch ?? cc(), this.storage = t?.storage ?? new ot(void 0, t?.storagePrefix), this.createPdfImpl = t?.createPdf, this.baseUrl = Yr(t?.baseUrl ?? ec), this.fhirBaseUrl = U(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = U(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = U(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = U(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = U(this.baseUrl, t?.fhircastHubUrl ?? "fhircast/STU3"), this.cdsServicesUrl = U(this.baseUrl, t?.cdsServicesUrl ?? "cds-services"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.credentialsInHeader = t?.authCredentialsMethod === "header", this.defaultHeaders = t?.defaultHeaders ?? {}, this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? ic, this.logLevel = this.initializeLogLevel(t), this.maxRetries = t?.maxRetries ?? 2, this.maxRetryTime = t?.maxRetryTime ?? 2e3, this.cacheTime = t?.cacheTime ?? (z() ? rc : nc), this.cacheTime > 0 ? this.requestCache = new K(t?.resourceCacheSize ?? tc) : 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(() => {
54837
54850
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
54838
54851
  }).catch((n) => {
54839
54852
  console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
@@ -54951,7 +54964,7 @@ var er = class extends ie {
54951
54964
  }
54952
54965
  async exchangeExternalAccessToken(t, n, i) {
54953
54966
  if (n = n ?? this.clientId, !n) throw new Error("MedplumClient is missing clientId");
54954
- let o2 = { grant_type: He.TokenExchange, subject_token_type: sc.AccessToken, client_id: n, subject_token: t };
54967
+ let o2 = { grant_type: Ge.TokenExchange, subject_token_type: sc.AccessToken, client_id: n, subject_token: t };
54955
54968
  return i && (o2.membership_id = i), this.fetchTokens(o2);
54956
54969
  }
54957
54970
  getExternalAuthRedirectUri(t, n, i, o2, s = true) {
@@ -54988,7 +55001,7 @@ var er = class extends ie {
54988
55001
  searchResources(t, n, i) {
54989
55002
  let s = "searchResources-" + this.fhirSearchUrl(t, n).toString(), a = this.getCacheEntry(s, i);
54990
55003
  if (a) return a.value;
54991
- let u2 = new W(this.search(t, n, i).then(to));
55004
+ let u2 = new W(this.search(t, n, i).then(ro));
54992
55005
  return this.setCacheEntry(s, u2, i), u2;
54993
55006
  }
54994
55007
  async *searchResourcePages(t, n, i) {
@@ -54998,7 +55011,7 @@ var er = class extends ie {
54998
55011
  s.has("_count") || s.set("_count", "1000");
54999
55012
  let a = await this.search(t, s, i), u2 = a.link?.find((l) => l.relation === "next");
55000
55013
  if (!a.entry?.length && !u2) break;
55001
- yield to(a), o2 = u2?.url ? new URL(u2.url) : void 0;
55014
+ yield ro(a), o2 = u2?.url ? new URL(u2.url) : void 0;
55002
55015
  }
55003
55016
  }
55004
55017
  valueSetExpand(t, n) {
@@ -55012,7 +55025,7 @@ var er = class extends ie {
55012
55025
  getCachedReference(t) {
55013
55026
  let n = t.reference;
55014
55027
  if (!n) return;
55015
- if (n === "system") return Zi;
55028
+ if (n === "system") return eo;
55016
55029
  let [i, o2] = n.split("/");
55017
55030
  if (!(!i || !o2)) return this.getCached(i, o2);
55018
55031
  }
@@ -55023,7 +55036,7 @@ var er = class extends ie {
55023
55036
  readReference(t, n) {
55024
55037
  let i = t.reference;
55025
55038
  if (!i) return new W(Promise.reject(new Error("Missing reference")));
55026
- if (i === "system") return new W(Promise.resolve(Zi));
55039
+ if (i === "system") return new W(Promise.resolve(eo));
55027
55040
  let [o2, s] = i.split("/");
55028
55041
  return !o2 || !s ? new W(Promise.reject(new Error("Invalid reference"))) : this.readResource(o2, s, n);
55029
55042
  }
@@ -55076,8 +55089,8 @@ var er = class extends ie {
55076
55089
  target
55077
55090
  }
55078
55091
  }`.replaceAll(/\s+/g, " "), u2 = await this.graphql(a);
55079
- Or(u2.data.StructureDefinitionList);
55080
- for (let l of u2.data.SearchParameterList) en(l);
55092
+ wr(u2.data.StructureDefinitionList);
55093
+ for (let l of u2.data.SearchParameterList) Zr(l);
55081
55094
  })());
55082
55095
  return this.setCacheEntry(i, s, n), s;
55083
55096
  }
@@ -55090,14 +55103,14 @@ var er = class extends ie {
55090
55103
  let a = this.fhirUrl("StructureDefinition", "$expand-profile");
55091
55104
  a.search = new URLSearchParams({ url: t }).toString();
55092
55105
  let u2 = await this.post(a.toString(), {});
55093
- Or(u2);
55106
+ wr(u2);
55094
55107
  } else {
55095
55108
  let a = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
55096
55109
  if (!a) {
55097
55110
  console.warn(`No StructureDefinition found for ${t}!`);
55098
55111
  return;
55099
55112
  }
55100
- Ir(a);
55113
+ Or(a);
55101
55114
  }
55102
55115
  })());
55103
55116
  return this.setCacheEntry(i, s, n), s;
@@ -55130,7 +55143,7 @@ var er = class extends ie {
55130
55143
  return s || (s = t), this.cacheResource(s, i), this.invalidateUrl(this.fhirUrl(t.resourceType, t.id, "_history")), this.invalidateSearches(t.resourceType), s;
55131
55144
  }
55132
55145
  async createAttachment(t, n, i, o2, s) {
55133
- let a = ro(t, n, i, o2);
55146
+ let a = no(t, n, i, o2);
55134
55147
  if (a.contentType === k.XML) {
55135
55148
  let p2 = a.data, g2;
55136
55149
  p2 instanceof Blob ? g2 = await new Promise((v2, M2) => {
@@ -55148,7 +55161,7 @@ var er = class extends ie {
55148
55161
  return { contentType: a.contentType, url: l.url, title: a.filename };
55149
55162
  }
55150
55163
  createBinary(t, n, i, o2, s) {
55151
- let a = ro(t, n, i, o2), u2 = s ?? (typeof n == "object" ? n : {}), { data: l, contentType: p2, filename: g2, securityContext: v2, onProgress: M2 } = a, J = this.fhirUrl("Binary");
55164
+ let a = no(t, n, i, o2), u2 = s ?? (typeof n == "object" ? n : {}), { data: l, contentType: p2, filename: g2, securityContext: v2, onProgress: M2 } = a, J = this.fhirUrl("Binary");
55152
55165
  return g2 && J.searchParams.set("_filename", g2), v2?.reference && this.setRequestHeader(u2, "X-Security-Context", v2.reference), M2 ? this.uploadwithProgress(J, l, p2, M2, u2) : this.post(J, l, p2, u2);
55153
55166
  }
55154
55167
  uploadwithProgress(t, n, i, o2, s) {
@@ -55174,7 +55187,7 @@ var er = class extends ie {
55174
55187
  }
55175
55188
  createComment(t, n, i) {
55176
55189
  let o2 = this.getProfile(), s, a;
55177
- return t.resourceType === "Encounter" && (s = Ee(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = Ee(t)), this.createResource({ resourceType: "Communication", status: "completed", basedOn: [Ee(t)], encounter: s, subject: a, sender: o2 ? Ee(o2) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i);
55190
+ return t.resourceType === "Encounter" && (s = Re(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = Re(t)), this.createResource({ resourceType: "Communication", status: "completed", basedOn: [Re(t)], encounter: s, subject: a, sender: o2 ? Re(o2) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i);
55178
55191
  }
55179
55192
  async updateResource(t, n) {
55180
55193
  if (!t.resourceType) throw new Error("Missing resourceType");
@@ -55217,7 +55230,7 @@ var er = class extends ie {
55217
55230
  }
55218
55231
  pushToAgent(t, n, i, o2, s, a) {
55219
55232
  let { waitTimeout: u2, returnAck: l, ...p2 } = a ?? {};
55220
- return this.post(this.fhirUrl("Agent", Re(t), "$push"), { destination: typeof n == "string" ? n : O(n), body: i, contentType: o2, waitForResponse: s, ...u2 !== void 0 ? { waitTimeout: u2 } : void 0, ...l !== void 0 ? { returnAck: l } : void 0 }, k.FHIR_JSON, p2);
55233
+ return this.post(this.fhirUrl("Agent", Ce(t), "$push"), { destination: typeof n == "string" ? n : O(n), body: i, contentType: o2, waitForResponse: s, ...u2 !== void 0 ? { waitTimeout: u2 } : void 0, ...l !== void 0 ? { returnAck: l } : void 0 }, k.FHIR_JSON, p2);
55221
55234
  }
55222
55235
  getCdsServices(t) {
55223
55236
  return this.get(this.cdsServicesUrl, t);
@@ -55238,7 +55251,7 @@ var er = class extends ie {
55238
55251
  return this.accessTokenExpires !== void 0 && Date.now() < this.accessTokenExpires - (t ?? this.refreshGracePeriod);
55239
55252
  }
55240
55253
  setAccessToken(t, n) {
55241
- this.accessToken = t, this.refreshToken = n, this.accessTokenExpires = zi(t), this.medplumServer = Qi(t);
55254
+ this.accessToken = t, this.refreshToken = n, this.accessTokenExpires = Ji(t), this.medplumServer = zi(t);
55242
55255
  }
55243
55256
  getLogins() {
55244
55257
  return this.storage.getObject("logins") ?? [];
@@ -55252,10 +55265,16 @@ var er = class extends ie {
55252
55265
  this.get("auth/me", { cache: "no-cache" }).then((i) => {
55253
55266
  this.profilePromise = void 0;
55254
55267
  let o2 = this.sessionDetails?.profile?.id !== i.profile.id;
55255
- this.sessionDetails = i, o2 && this.dispatchEvent({ type: "change" }), t(i.profile), this.dispatchEvent({ type: "profileRefreshed" });
55268
+ this.sessionDetails = i, this.syncStoredLoginProject(), o2 && this.dispatchEvent({ type: "change" }), t(i.profile), this.dispatchEvent({ type: "profileRefreshed" });
55256
55269
  }).catch(n);
55257
55270
  }), this.dispatchEvent({ type: "profileRefreshing" }), this.profilePromise;
55258
55271
  }
55272
+ syncStoredLoginProject() {
55273
+ let t = this.getActiveLogin(), n = this.sessionDetails?.project?.name;
55274
+ if (!t || !n || t.project.display === n) return;
55275
+ let i = { ...t, project: { ...t.project, display: n } };
55276
+ this.storage.setObject("activeLogin", i), this.addLogin(i);
55277
+ }
55259
55278
  isLoading() {
55260
55279
  return !this.isInitialized || !!this.profilePromise && !this.sessionDetails?.profile;
55261
55280
  }
@@ -55295,7 +55314,7 @@ var er = class extends ie {
55295
55314
  }
55296
55315
  async createMedia(t, n) {
55297
55316
  let { additionalFields: i, ...o2 } = t, s = await this.createResource({ resourceType: "Media", status: "preparation", content: { contentType: t.contentType }, ...i });
55298
- o2.securityContext || (o2.securityContext = Ee(s));
55317
+ o2.securityContext || (o2.securityContext = Re(s));
55299
55318
  let a = await this.createAttachment(o2, n);
55300
55319
  return this.updateResource({ ...s, status: "completed", content: a });
55301
55320
  }
@@ -55304,7 +55323,7 @@ var er = class extends ie {
55304
55323
  }
55305
55324
  async createDocumentReference(t, n) {
55306
55325
  let { additionalFields: i, ...o2 } = t, s = await this.createResource({ resourceType: "DocumentReference", status: "current", content: [{ attachment: { contentType: t.contentType } }], ...i });
55307
- o2.securityContext || (o2.securityContext = Ee(s));
55326
+ o2.securityContext || (o2.securityContext = Re(s));
55308
55327
  let a = await this.createAttachment(o2, n);
55309
55328
  return this.updateResource({ ...s, content: [{ attachment: a }] });
55310
55329
  }
@@ -55357,11 +55376,11 @@ var er = class extends ie {
55357
55376
  if (o2.status === 404 && !a) throw new f(Fn);
55358
55377
  let u2 = await this.parseBody(o2, a);
55359
55378
  if (o2.status === 200 && n.followRedirectOnOk || o2.status === 201 && n.followRedirectOnCreated) {
55360
- let l = await eo(o2, u2);
55379
+ let l = await to(o2, u2);
55361
55380
  if (l) return this.request(l, { ...n, method: "GET", body: void 0 });
55362
55381
  }
55363
55382
  if (o2.status === 202 && n.pollStatusOnAccepted) {
55364
- let p2 = await eo(o2, u2) ?? i.statusUrl;
55383
+ let p2 = await to(o2, u2) ?? i.statusUrl;
55365
55384
  if (p2) return this.pollStatus(p2, n, i);
55366
55385
  }
55367
55386
  if (o2.status >= 400) throw new f(yt(u2));
@@ -55388,7 +55407,7 @@ var er = class extends ie {
55388
55407
  if (this.logLevel !== "none" && this.logResponse(s), this.setCurrentRateLimit(s), o2 >= i || !pc(s)) return s;
55389
55408
  let a = this.getRetryDelay(o2), u2 = n.maxRetryTime ?? this.maxRetryTime;
55390
55409
  if (a > u2) return s;
55391
- await Yr(a, { signal: n.signal });
55410
+ await Kr(a, { signal: n.signal });
55392
55411
  } catch (s) {
55393
55412
  if (s.message === "Failed to fetch" && o2 === 0 && this.dispatchEvent({ type: "offline" }), s.name === "AbortError" || o2 === i) throw s;
55394
55413
  }
@@ -55429,7 +55448,7 @@ var er = class extends ie {
55429
55448
  if (i.pollCount === void 0) n.headers && typeof n.headers == "object" && "Prefer" in n.headers && (o2.headers = { ...n.headers }, delete o2.headers.Prefer), i.statusUrl = t, i.pollCount = 1;
55430
55449
  else {
55431
55450
  let s = n.pollStatusPeriod ?? 1e3;
55432
- await Yr(s, { signal: n.signal }), i.pollCount++;
55451
+ await Kr(s, { signal: n.signal }), i.pollCount++;
55433
55452
  }
55434
55453
  return this.request(t, { ...n, method: "GET" }, i);
55435
55454
  }
@@ -55448,7 +55467,7 @@ var er = class extends ie {
55448
55467
  let n = { resourceType: "Bundle", type: "batch", entry: t.map((o2) => ({ request: { method: o2.method, url: o2.url }, resource: o2.options.body ? JSON.parse(o2.options.body) : void 0 })) }, i = await this.post(this.fhirBaseUrl, n);
55449
55468
  for (let o2 = 0; o2 < t.length; o2++) {
55450
55469
  let s = t[o2], a = i.entry?.[o2];
55451
- a?.response?.outcome && !Er(a.response.outcome) ? s.reject(new f(a.response.outcome)) : s.resolve(a?.resource);
55470
+ a?.response?.outcome && !br(a.response.outcome) ? s.reject(new f(a.response.outcome)) : s.resolve(a?.resource);
55452
55471
  }
55453
55472
  }
55454
55473
  addFetchOptionsDefaults(t) {
@@ -55479,15 +55498,15 @@ var er = class extends ie {
55479
55498
  }
55480
55499
  handleUnauthenticated(t, n) {
55481
55500
  if (this.refresh()) return this.request(t, n);
55482
- throw this.clear(), this.onUnauthenticated?.(), new f(_e);
55501
+ throw this.clear(), this.onUnauthenticated?.(), new f(Le);
55483
55502
  }
55484
55503
  async startPkce() {
55485
- let t = on();
55504
+ let t = nn();
55486
55505
  this.storage.setString("pkceState", t);
55487
- let n = on().slice(0, 128);
55506
+ let n = nn().slice(0, 128);
55488
55507
  this.storage.setString("codeVerifier", n);
55489
55508
  try {
55490
- let i = await Wi(n);
55509
+ let i = await qi(n);
55491
55510
  return { codeChallengeMethod: "S256", codeChallenge: hi(i).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "") };
55492
55511
  } catch (i) {
55493
55512
  return console.warn("Failed to hash code verifier. Falling back to 'plain' code challenge method", i), { codeChallengeMethod: "plain", codeChallenge: n };
@@ -55498,7 +55517,7 @@ var er = class extends ie {
55498
55517
  i.searchParams.set("response_type", "code"), i.searchParams.set("state", this.storage.getString("pkceState")), i.searchParams.set("client_id", n.clientId ?? this.clientId), i.searchParams.set("redirect_uri", n.redirectUri ?? ce.getOrigin()), i.searchParams.set("code_challenge_method", n.codeChallengeMethod), i.searchParams.set("code_challenge", n.codeChallenge), i.searchParams.set("scope", n.scope ?? "openid profile"), ce.assign(i.toString());
55499
55518
  }
55500
55519
  processCode(t, n) {
55501
- let i = { grant_type: He.AuthorizationCode, code: t, client_id: n?.clientId ?? this.clientId ?? "", redirect_uri: n?.redirectUri ?? ce.getOrigin() }, o2 = this.storage.getString("codeVerifier");
55520
+ let i = { grant_type: Ge.AuthorizationCode, code: t, client_id: n?.clientId ?? this.clientId ?? "", redirect_uri: n?.redirectUri ?? ce.getOrigin() }, o2 = this.storage.getString("codeVerifier");
55502
55521
  return o2 && (i.code_verifier = o2), this.fetchTokens(i);
55503
55522
  }
55504
55523
  refreshIfExpired(t) {
@@ -55511,20 +55530,20 @@ var er = class extends ie {
55511
55530
  async runRefreshWithLock(t) {
55512
55531
  let n = () => {
55513
55532
  let s = this.getActiveLogin();
55514
- return s?.accessToken && s.accessToken !== this.accessToken && this.setAccessToken(s.accessToken, s.refreshToken), this.isAuthenticated(t) ? Promise.resolve(this.getProfile()) : this.refreshToken ? this.fetchTokens({ grant_type: He.RefreshToken, client_id: this.clientId ?? "", refresh_token: this.refreshToken }) : this.clientId && this.clientSecret ? this.startClientLogin(this.clientId, this.clientSecret) : Promise.resolve(void 0);
55533
+ return s?.accessToken && s.accessToken !== this.accessToken && this.setAccessToken(s.accessToken, s.refreshToken), this.isAuthenticated(t) ? Promise.resolve(this.getProfile()) : this.refreshToken ? this.fetchTokens({ grant_type: Ge.RefreshToken, client_id: this.clientId ?? "", refresh_token: this.refreshToken }) : this.clientId && this.clientSecret ? this.startClientLogin(this.clientId, this.clientSecret) : Promise.resolve(void 0);
55515
55534
  }, i = typeof navigator < "u" ? navigator.locks : void 0;
55516
55535
  if (!i?.request) return n();
55517
55536
  let o2 = `medplum-refresh:${this.storage.makeKey("activeLogin")}`;
55518
55537
  return i.request(o2, n);
55519
55538
  }
55520
55539
  async startClientLogin(t, n) {
55521
- return this.clientId = t, this.clientSecret = n, this.fetchTokens({ grant_type: He.ClientCredentials, client_id: t, client_secret: n });
55540
+ return this.clientId = t, this.clientSecret = n, this.fetchTokens({ grant_type: Ge.ClientCredentials, client_id: t, client_secret: n });
55522
55541
  }
55523
55542
  async startJwtBearerLogin(t, n, i) {
55524
- return this.clientId = t, this.fetchTokens({ grant_type: He.JwtBearer, client_id: t, assertion: n, scope: i });
55543
+ return this.clientId = t, this.fetchTokens({ grant_type: Ge.JwtBearer, client_id: t, assertion: n, scope: i });
55525
55544
  }
55526
55545
  async startJwtAssertionLogin(t) {
55527
- return this.fetchTokens({ grant_type: He.ClientCredentials, client_assertion_type: ac.JwtBearer, client_assertion: t });
55546
+ return this.fetchTokens({ grant_type: Ge.ClientCredentials, client_assertion_type: ac.JwtBearer, client_assertion: t });
55528
55547
  }
55529
55548
  setBasicAuth(t, n) {
55530
55549
  this.clientId = t, this.clientSecret = n, this.basicAuth = Gt(t + ":" + n);
@@ -55541,20 +55560,20 @@ var er = class extends ie {
55541
55560
  async fhircastSubscribe(t, n) {
55542
55561
  if (!(typeof t == "string" && t !== "")) throw new f(T("Invalid topic provided. Topic must be a valid string."));
55543
55562
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0)) throw new f(T("Invalid events provided. Events must be an array of event names containing at least one event."));
55544
- let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post(this.fhircastHubUrl, un(i), k.FORM_URL_ENCODED))["hub.channel.endpoint"];
55563
+ let i = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post(this.fhircastHubUrl, cn(i), k.FORM_URL_ENCODED))["hub.channel.endpoint"];
55545
55564
  if (!s) throw new Error("Invalid response!");
55546
55565
  return i.endpoint = s, i;
55547
55566
  }
55548
55567
  async fhircastUnsubscribe(t) {
55549
55568
  if (!zt(t)) throw new f(T("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
55550
55569
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws"))) throw new f(T("Provided subscription request must have an endpoint in order to unsubscribe."));
55551
- t.mode = "unsubscribe", await this.post(this.fhircastHubUrl, un(t), k.FORM_URL_ENCODED);
55570
+ t.mode = "unsubscribe", await this.post(this.fhircastHubUrl, cn(t), k.FORM_URL_ENCODED);
55552
55571
  }
55553
55572
  fhircastConnect(t) {
55554
55573
  return new Qt(t);
55555
55574
  }
55556
55575
  async fhircastPublish(t, n, i, o2) {
55557
- return ji(n) ? this.post(this.fhircastHubUrl, ln(t, n, i, o2), k.JSON) : ($i(n), this.post(this.fhircastHubUrl, ln(t, n, i), k.JSON));
55576
+ return $i(n) ? this.post(this.fhircastHubUrl, un(t, n, i, o2), k.JSON) : (Hi(n), this.post(this.fhircastHubUrl, un(t, n, i), k.JSON));
55558
55577
  }
55559
55578
  async fhircastGetContext(t) {
55560
55579
  return this.get(`${this.fhircastHubUrl}/${t}`, { cache: "no-cache" });
@@ -55565,7 +55584,7 @@ var er = class extends ie {
55565
55584
  async handleTokenError(t) {
55566
55585
  try {
55567
55586
  let n = await t.json();
55568
- throw Qe(n) ? new f(n) : n.error_description ? new f(P(n.error_description)) : new Error(JSON.stringify(n));
55587
+ throw ze(n) ? new f(n) : n.error_description ? new f(P(n.error_description)) : new Error(JSON.stringify(n));
55569
55588
  } catch (n) {
55570
55589
  throw n instanceof f ? (n.message = `Failed to fetch tokens: ${n.message}`, n) : new f(P("Failed to fetch tokens"), { cause: n });
55571
55590
  }
@@ -55585,12 +55604,12 @@ var er = class extends ie {
55585
55604
  }
55586
55605
  async verifyTokens(t) {
55587
55606
  let n = t.access_token;
55588
- if (Gi(n)) {
55607
+ if (Qi(n)) {
55589
55608
  let i = Jt(n);
55590
55609
  if (Date.now() >= i.exp * 1e3) throw this.clearActiveLogin(), new f(Un);
55591
55610
  if (i.cid) {
55592
- if (i.cid !== this.clientId) throw this.clearActiveLogin(), new f(Sr);
55593
- } else if (this.clientId && i.client_id !== this.clientId) throw this.clearActiveLogin(), new f(Sr);
55611
+ if (i.cid !== this.clientId) throw this.clearActiveLogin(), new f(Tr);
55612
+ } else if (this.clientId && i.client_id !== this.clientId) throw this.clearActiveLogin(), new f(Tr);
55594
55613
  }
55595
55614
  return this.setActiveLogin({ accessToken: n, refreshToken: t.refresh_token, project: t.project, profile: t.profile });
55596
55615
  }
@@ -55626,21 +55645,21 @@ function cc() {
55626
55645
  if (!globalThis.fetch) throw new Error("Fetch not available in this environment");
55627
55646
  return globalThis.fetch.bind(globalThis);
55628
55647
  }
55629
- async function eo(r6, e) {
55648
+ async function to(r6, e) {
55630
55649
  let t = r6.headers.get("content-location");
55631
55650
  if (t) return t;
55632
55651
  let n = r6.headers.get("location");
55633
55652
  if (n) return n;
55634
- if (Qe(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
55653
+ if (ze(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
55635
55654
  }
55636
- function to(r6) {
55655
+ function ro(r6) {
55637
55656
  let e = r6.entry?.map((t) => t.resource) ?? [];
55638
55657
  return Object.assign(e, { bundle: r6 });
55639
55658
  }
55640
55659
  function uc(r6) {
55641
55660
  return C(r6) && "data" in r6 && "contentType" in r6;
55642
55661
  }
55643
- function ro(r6, e, t, n) {
55662
+ function no(r6, e, t, n) {
55644
55663
  return uc(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
55645
55664
  }
55646
55665
  function lc(r6) {
@@ -55676,14 +55695,14 @@ var Te = class {
55676
55695
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
55677
55696
  }
55678
55697
  };
55679
- var Eo = class r2 {
55698
+ var Ro = class r2 {
55680
55699
  constructor(e, t = new Te()) {
55681
55700
  c(this, "context");
55682
55701
  c(this, "_segments");
55683
55702
  c(this, "segmentsByName");
55684
55703
  c(this, "cachedString");
55685
55704
  c(this, "allSegmentsParsed");
55686
- this.context = t, this._segments = e, this.segmentsByName = Ro(e), this.allSegmentsParsed = e.every((n) => typeof n != "string"), this.bindSegments();
55705
+ this.context = t, this._segments = e, this.segmentsByName = Co(e), this.allSegmentsParsed = e.every((n) => typeof n != "string"), this.bindSegments();
55687
55706
  }
55688
55707
  get segments() {
55689
55708
  if (!this.allSegmentsParsed) {
@@ -55754,7 +55773,7 @@ var Eo = class r2 {
55754
55773
  return this.segmentsByName.get(e)?.[0] ?? -1;
55755
55774
  }
55756
55775
  invalidateCache() {
55757
- this.segmentsByName = Ro(this._segments), this.cachedString = void 0, this.bindSegments();
55776
+ this.segmentsByName = Co(this._segments), this.cachedString = void 0, this.bindSegments();
55758
55777
  }
55759
55778
  bindSegments() {
55760
55779
  let e = () => {
@@ -55763,7 +55782,7 @@ var Eo = class r2 {
55763
55782
  for (let t of this._segments) typeof t != "string" && (t.onModified = e);
55764
55783
  }
55765
55784
  };
55766
- function Ro(r6) {
55785
+ function Co(r6) {
55767
55786
  let e = /* @__PURE__ */ new Map();
55768
55787
  for (let t = 0; t < r6.length; t++) {
55769
55788
  let n = r6[t], i = typeof n == "string" ? n.slice(0, 3) : n.name, o2 = e.get(i);
@@ -55890,10 +55909,10 @@ function Zc(r6) {
55890
55909
  let e = r6 instanceof Date ? r6 : new Date(r6), n = e.toISOString().replaceAll(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i = e.getUTCMilliseconds();
55891
55910
  return i > 0 && (n += "." + i.toString()), n;
55892
55911
  }
55893
- var Ge = { NONE: 0, ERROR: 1, WARN: 2, INFO: 3, DEBUG: 4 };
55912
+ var Qe = { NONE: 0, ERROR: 1, WARN: 2, INFO: 3, DEBUG: 4 };
55894
55913
  var eu = ["NONE", "ERROR", "WARN", "INFO", "DEBUG"];
55895
- var Co = class r5 {
55896
- constructor(e, t = {}, n = Ge.INFO, i = {}) {
55914
+ var Po = class r5 {
55915
+ constructor(e, t = {}, n = Qe.INFO, i = {}) {
55897
55916
  c(this, "write");
55898
55917
  c(this, "metadata");
55899
55918
  c(this, "options");
@@ -55910,21 +55929,21 @@ var Co = class r5 {
55910
55929
  return { write: e, metadata: t, level: n, options: i };
55911
55930
  }
55912
55931
  error(e, t) {
55913
- this.log(Ge.ERROR, e, t);
55932
+ this.log(Qe.ERROR, e, t);
55914
55933
  }
55915
55934
  warn(e, t) {
55916
- this.log(Ge.WARN, e, t);
55935
+ this.log(Qe.WARN, e, t);
55917
55936
  }
55918
55937
  info(e, t) {
55919
- this.log(Ge.INFO, e, t);
55938
+ this.log(Qe.INFO, e, t);
55920
55939
  }
55921
55940
  debug(e, t) {
55922
- this.log(Ge.DEBUG, e, t);
55941
+ this.log(Qe.DEBUG, e, t);
55923
55942
  }
55924
55943
  log(e, t, n) {
55925
55944
  if (e > this.level) return;
55926
55945
  let i;
55927
- if (br(n)) i = lr(n);
55946
+ if (Sr(n)) i = lr(n);
55928
55947
  else if (n) {
55929
55948
  i = { ...n };
55930
55949
  for (let [o2, s] of Object.entries(i)) s instanceof Error && (i[o2] = lr(s));
@@ -55932,8 +55951,8 @@ var Co = class r5 {
55932
55951
  this.write(JSON.stringify({ level: eu[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...i, ...this.metadata }));
55933
55952
  }
55934
55953
  };
55935
- function zh(r6) {
55936
- let e = Ge[r6.toUpperCase()];
55954
+ function Jh(r6) {
55955
+ let e = Qe[r6.toUpperCase()];
55937
55956
  if (e === void 0) throw new Error(`Invalid log level: ${r6}`);
55938
55957
  return e;
55939
55958
  }
@@ -55950,12 +55969,12 @@ function lr(r6, e = 0, t = 10) {
55950
55969
  }
55951
55970
  return n;
55952
55971
  }
55953
- var Pn = `${ft}/fhir/StructureDefinition/patient-preferredPharmacy`;
55972
+ var Cn = `${ft}/fhir/StructureDefinition/patient-preferredPharmacy`;
55954
55973
  var bu = "https://meta.medplum.com/releases";
55955
- var fr = /* @__PURE__ */ new Map();
55974
+ var An = /* @__PURE__ */ new Map();
55956
55975
  function Eu(r6) {
55957
55976
  let e = r6;
55958
- if (!e.tag_name) throw new Error("Manifest missing tag_name");
55977
+ if (!e.tag_name?.startsWith("v")) throw new Error("Manifest missing valid tag_name starting with a 'v' (eg. v5.1.15)");
55959
55978
  let t = e.assets;
55960
55979
  if (!t?.length) throw new Error("Manifest missing assets list");
55961
55980
  for (let n of t) {
@@ -55964,29 +55983,29 @@ function Eu(r6) {
55964
55983
  }
55965
55984
  }
55966
55985
  async function wn(r6, e, t) {
55967
- let n = fr.get(e ?? "latest");
55986
+ let n = e ? An.get(e) : void 0;
55968
55987
  if (!n) {
55969
55988
  let i = e ? `v${e}` : "latest", o2 = new URL(`${bu}/${i}.json`);
55970
- if (o2.searchParams.set("a", r6), o2.searchParams.set("c", fn), t) for (let [u2, l] of Object.entries(t)) o2.searchParams.set(u2, l);
55989
+ if (o2.searchParams.set("a", r6), o2.searchParams.set("c", pn), t) for (let [u2, l] of Object.entries(t)) o2.searchParams.set(u2, l);
55971
55990
  let s = await fetch(o2.toString());
55972
55991
  if (s.status !== 200) {
55973
55992
  let u2;
55974
55993
  try {
55975
55994
  u2 = (await s.json()).message;
55976
55995
  } catch (l) {
55977
- console.error(`Failed to parse message from body: ${Le(l)}`);
55996
+ console.error(`Failed to parse message from body: ${Ne(l)}`);
55978
55997
  }
55979
55998
  throw new Error(`Received status code ${s.status} while fetching manifest for version '${e ?? "latest"}'. Message: ${u2}`);
55980
55999
  }
55981
56000
  let a = await s.json();
55982
- Eu(a), n = a, fr.set(e ?? "latest", n), e || fr.set(n.tag_name.slice(1), n);
56001
+ Eu(a), n = a, An.set(n.tag_name.slice(1), n);
55983
56002
  }
55984
56003
  return n;
55985
56004
  }
55986
56005
  function Ru(r6) {
55987
56006
  return /^\d+\.\d+\.\d+(-[0-9a-z]{7})?$/.test(r6);
55988
56007
  }
55989
- async function Hg(r6, e) {
56008
+ async function Gg(r6, e) {
55990
56009
  if (!Ru(e)) return false;
55991
56010
  try {
55992
56011
  await wn(r6, e);
@@ -55995,7 +56014,7 @@ async function Hg(r6, e) {
55995
56014
  }
55996
56015
  return true;
55997
56016
  }
55998
- async function Gg(r6) {
56017
+ async function Qg(r6) {
55999
56018
  let e = await wn(r6);
56000
56019
  if (!e.tag_name.startsWith("v")) throw new Error(`Invalid release name found. Release tag '${e.tag_name}' did not start with 'v'`);
56001
56020
  return e.tag_name.slice(1);
@@ -56107,7 +56126,7 @@ var v = class extends m2 {
56107
56126
  return;
56108
56127
  }
56109
56128
  let l = c2.message.getSegment("MSA")?.getField(1)?.toString()?.toUpperCase();
56110
- l && (h2.returnAck === sf.APPLICATION && l === "CA" || (h2.timer && clearTimeout(h2.timer), h2.resolve(c2.message), this.deletePendingMessage(a)));
56129
+ l && (h2.returnAck === af.APPLICATION && l === "CA" || (h2.timer && clearTimeout(h2.timer), h2.resolve(c2.message), this.deletePendingMessage(a)));
56111
56130
  });
56112
56131
  }
56113
56132
  isClosed() {
@@ -56122,7 +56141,7 @@ var v = class extends m2 {
56122
56141
  for (this.responseQueueProcessing = true; this.responseQueue.length; ) {
56123
56142
  if (this.messagesPerMin) {
56124
56143
  let t = B2 / this.messagesPerMin, s = Date.now() - this.lastMessageDispatchedTime;
56125
- t > s && await Yr(t - s);
56144
+ t > s && await Kr(t - s);
56126
56145
  }
56127
56146
  let e = this.responseQueue.shift();
56128
56147
  e && this.dispatchEvent(e), this.lastMessageDispatchedTime = Date.now();
@@ -56142,7 +56161,7 @@ var v = class extends m2 {
56142
56161
  break;
56143
56162
  }
56144
56163
  if (n === -1) break;
56145
- let r6 = t.subarray(s, n + 1).subarray(1, -2), a = import_iconv_lite.default.decode(r6, this.encoding), h2 = Eo.parse(a);
56164
+ let r6 = t.subarray(s, n + 1).subarray(1, -2), a = import_iconv_lite.default.decode(r6, this.encoding), h2 = Ro.parse(a);
56146
56165
  e.push(h2), s = n + 1;
56147
56166
  }
56148
56167
  return this.chunks = s < t.length ? [t.subarray(s)] : [], e;
@@ -56160,7 +56179,7 @@ var v = class extends m2 {
56160
56179
  let r6;
56161
56180
  t?.timeoutMs && (r6 = setTimeout(() => {
56162
56181
  this.deletePendingMessage(c2), n(new f({ resourceType: "OperationOutcome", issue: [{ severity: "error", code: "timeout", details: { text: "Client timeout" }, diagnostics: `Request timed out after waiting ${t.timeoutMs} milliseconds for response` }] }));
56163
- }, t.timeoutMs)), this.setPendingMessage(c2, { message: e, resolve: s, reject: n, returnAck: t?.returnAck ?? sf.APPLICATION, timer: r6 }), this.sendImpl(e);
56182
+ }, t.timeoutMs)), this.setPendingMessage(c2, { message: e, resolve: s, reject: n, returnAck: t?.returnAck ?? af.APPLICATION, timer: r6 }), this.sendImpl(e);
56164
56183
  });
56165
56184
  }
56166
56185
  async close() {
@@ -56334,7 +56353,7 @@ var x = class {
56334
56353
  c2(T2);
56335
56354
  });
56336
56355
  }, h2 = (l) => {
56337
- l?.code === "EADDRINUSE" ? n.close(() => Yr(50).then(() => a(i))) : r6(l);
56356
+ l?.code === "EADDRINUSE" ? n.close(() => Kr(50).then(() => a(i))) : r6(l);
56338
56357
  };
56339
56358
  n.on("error", h2), n.once("listening", () => {
56340
56359
  n.off("error", h2);
@@ -56608,7 +56627,7 @@ var ByteStreamChannelConnection = class {
56608
56627
  }
56609
56628
  } catch (err2) {
56610
56629
  this.channel.log.error(`Byte stream error occurred - check channel logs`);
56611
- this.channel.channelLog.error(`Byte stream error: ${Le(err2)}`);
56630
+ this.channel.channelLog.error(`Byte stream error: ${Ne(err2)}`);
56612
56631
  }
56613
56632
  }
56614
56633
  write(data2) {
@@ -57337,11 +57356,11 @@ function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) {
57337
57356
  Promise.resolve(value).then(_next, _throw);
57338
57357
  }
57339
57358
  }
57340
- function _asyncToGenerator(fn2) {
57359
+ function _asyncToGenerator(fn) {
57341
57360
  return function() {
57342
57361
  var self2 = this, args = arguments;
57343
57362
  return new Promise(function(resolve2, reject) {
57344
- var gen = fn2.apply(self2, args);
57363
+ var gen = fn.apply(self2, args);
57345
57364
  function _next(value) {
57346
57365
  asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "next", value);
57347
57366
  }
@@ -62424,9 +62443,9 @@ var BufferStream = /* @__PURE__ */ (function() {
62424
62443
  }, {
62425
62444
  key: "readVR",
62426
62445
  value: function readVR() {
62427
- var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
62446
+ var vr2 = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
62428
62447
  this.increment(2);
62429
- return vr;
62448
+ return vr2;
62430
62449
  }
62431
62450
  }, {
62432
62451
  key: "readEncodedString",
@@ -63369,20 +63388,20 @@ var ValueRepresentation = /* @__PURE__ */ (function() {
63369
63388
  }, {
63370
63389
  key: "createByTypeString",
63371
63390
  value: function createByTypeString(type) {
63372
- var vr = VRinstances[type];
63373
- if (vr === void 0) {
63391
+ var vr2 = VRinstances[type];
63392
+ if (vr2 === void 0) {
63374
63393
  if (type == "ox") {
63375
63394
  validationLog.error("Invalid vr type", type, "- using OW");
63376
- vr = VRinstances["OW"];
63395
+ vr2 = VRinstances["OW"];
63377
63396
  } else if (type == "xs") {
63378
63397
  validationLog.error("Invalid vr type", type, "- using US");
63379
- vr = VRinstances["US"];
63398
+ vr2 = VRinstances["US"];
63380
63399
  } else {
63381
63400
  validationLog.error("Invalid vr type", type, "- using UN");
63382
- vr = VRinstances["UN"];
63401
+ vr2 = VRinstances["UN"];
63383
63402
  }
63384
63403
  }
63385
- return vr;
63404
+ return vr2;
63386
63405
  }
63387
63406
  }, {
63388
63407
  key: "parseUnknownVr",
@@ -63908,8 +63927,8 @@ var IntegerString = /* @__PURE__ */ (function(_NumericStringReprese2) {
63908
63927
  key: "writeBytes",
63909
63928
  value: function writeBytes(stream, value, writeOptions) {
63910
63929
  var _this11 = this;
63911
- var val = Array.isArray(value) ? value.map(function(is2) {
63912
- return _this11.convertToString(is2);
63930
+ var val = Array.isArray(value) ? value.map(function(is) {
63931
+ return _this11.convertToString(is);
63913
63932
  }) : [this.convertToString(value)];
63914
63933
  return _get(_getPrototypeOf(IntegerString2.prototype), "writeBytes", this).call(this, stream, val, writeOptions);
63915
63934
  }
@@ -64468,10 +64487,10 @@ var UnknownValue = /* @__PURE__ */ (function(_BinaryRepresentation) {
64468
64487
  })(BinaryRepresentation);
64469
64488
  var ParsedUnknownValue = /* @__PURE__ */ (function(_BinaryRepresentation2) {
64470
64489
  _inherits(ParsedUnknownValue2, _BinaryRepresentation2);
64471
- function ParsedUnknownValue2(vr) {
64490
+ function ParsedUnknownValue2(vr2) {
64472
64491
  var _this28;
64473
64492
  _classCallCheck(this, ParsedUnknownValue2);
64474
- _this28 = _callSuper(this, ParsedUnknownValue2, [vr]);
64493
+ _this28 = _callSuper(this, ParsedUnknownValue2, [vr2]);
64475
64494
  _this28.maxLength = null;
64476
64495
  _this28.padByte = 0;
64477
64496
  _this28.noMultiple = true;
@@ -64486,13 +64505,13 @@ var ParsedUnknownValue = /* @__PURE__ */ (function(_BinaryRepresentation2) {
64486
64505
  value: function read(stream, length2, syntax, readOptions) {
64487
64506
  var arrayBuffer = this.readBytes(stream, length2, syntax)[0];
64488
64507
  var streamFromBuffer = new ReadBufferStream(arrayBuffer, true);
64489
- var vr = ValueRepresentation.createByTypeString(this.type);
64490
- if (vr.isBinary() && length2 > vr.maxLength && !vr.noMultiple) {
64508
+ var vr2 = ValueRepresentation.createByTypeString(this.type);
64509
+ if (vr2.isBinary() && length2 > vr2.maxLength && !vr2.noMultiple) {
64491
64510
  var values = [];
64492
64511
  var rawValues = [];
64493
- var times = length2 / vr.maxLength, i = 0;
64512
+ var times = length2 / vr2.maxLength, i = 0;
64494
64513
  while (i++ < times) {
64495
- var _vr$read = vr.read(streamFromBuffer, vr.maxLength, syntax, readOptions), rawValue = _vr$read.rawValue, value = _vr$read.value;
64514
+ var _vr$read = vr2.read(streamFromBuffer, vr2.maxLength, syntax, readOptions), rawValue = _vr$read.rawValue, value = _vr$read.value;
64496
64515
  rawValues.push(rawValue);
64497
64516
  values.push(value);
64498
64517
  }
@@ -64501,7 +64520,7 @@ var ParsedUnknownValue = /* @__PURE__ */ (function(_BinaryRepresentation2) {
64501
64520
  value: values
64502
64521
  };
64503
64522
  } else {
64504
- return vr.read(streamFromBuffer, length2, syntax, readOptions);
64523
+ return vr2.read(streamFromBuffer, length2, syntax, readOptions);
64505
64524
  }
64506
64525
  }
64507
64526
  }]);
@@ -64601,12 +64620,12 @@ var DicomDict = /* @__PURE__ */ (function() {
64601
64620
  }
64602
64621
  _createClass(DicomDict2, [{
64603
64622
  key: "upsertTag",
64604
- value: function upsertTag(tag, vr, values) {
64623
+ value: function upsertTag(tag, vr2, values) {
64605
64624
  if (this.dict[tag]) {
64606
64625
  this.dict[tag].Value = values;
64607
64626
  } else {
64608
64627
  this.dict[tag] = ValueRepresentation.addTagAccessors({
64609
- vr
64628
+ vr: vr2
64610
64629
  });
64611
64630
  this.dict[tag].Value = values;
64612
64631
  }
@@ -65221,13 +65240,13 @@ function lookupTagHex(hex8) {
65221
65240
  var end = gi2 + 1 < groupStart.length ? groupStart[gi2 + 1] : elems.length;
65222
65241
  var ei2 = _binSearchU16(elems, start, end, elem);
65223
65242
  if (ei2 < 0) return void 0;
65224
- var vr = vrTable$1[vrCode[ei2]];
65243
+ var vr2 = vrTable$1[vrCode[ei2]];
65225
65244
  var vm = vmTable$1[vmCode[ei2]];
65226
65245
  var off = nameOff[ei2];
65227
65246
  var len2 = nameLen[ei2];
65228
65247
  var name = nameBlob$1.slice(off, off + len2);
65229
65248
  return {
65230
- vr,
65249
+ vr: vr2,
65231
65250
  vm,
65232
65251
  name
65233
65252
  };
@@ -65264,14 +65283,14 @@ function getAllStandardTagEntries() {
65264
65283
  var elem = elems[ei2];
65265
65284
  var eHex = _pad4(elem.toString(16).toUpperCase());
65266
65285
  var tag = "(" + gHex + "," + eHex + ")";
65267
- var vr = vrTable$1[vrCode[ei2]];
65286
+ var vr2 = vrTable$1[vrCode[ei2]];
65268
65287
  var vm = vmTable$1[vmCode[ei2]];
65269
65288
  var off = nameOff[ei2];
65270
65289
  var len2 = nameLen[ei2];
65271
65290
  var name = nameBlob$1.slice(off, off + len2);
65272
65291
  out.push({
65273
65292
  tag,
65274
- vr,
65293
+ vr: vr2,
65275
65294
  vm,
65276
65295
  name
65277
65296
  });
@@ -65595,9 +65614,9 @@ var DicomMetaDictionary = /* @__PURE__ */ (function() {
65595
65614
  if (dataValue === void 0) {
65596
65615
  return;
65597
65616
  }
65598
- var vr = dataset._vrMap && dataset._vrMap[naturalName] ? dataset._vrMap[naturalName] : entry.vr;
65617
+ var vr2 = dataset._vrMap && dataset._vrMap[naturalName] ? dataset._vrMap[naturalName] : entry.vr;
65599
65618
  var dataItem = ValueRepresentation.addTagAccessors({
65600
- vr
65619
+ vr: vr2
65601
65620
  });
65602
65621
  dataItem.Value = dataset[naturalName];
65603
65622
  if (dataValue !== null) {
@@ -65803,7 +65822,7 @@ var Tag = /* @__PURE__ */ (function() {
65803
65822
  }
65804
65823
  }, {
65805
65824
  key: "is",
65806
- value: function is2(t) {
65825
+ value: function is(t) {
65807
65826
  return this.value == t;
65808
65827
  }
65809
65828
  /**
@@ -65851,7 +65870,7 @@ var Tag = /* @__PURE__ */ (function() {
65851
65870
  }, {
65852
65871
  key: "write",
65853
65872
  value: function write(stream, vrType, values, syntax, writeOptions) {
65854
- var vr = ValueRepresentation.createByTypeString(vrType);
65873
+ var vr2 = ValueRepresentation.createByTypeString(vrType);
65855
65874
  var useSyntax = DicomMessage$1._normalizeSyntax(syntax);
65856
65875
  var implicit = useSyntax === IMPLICIT_LITTLE_ENDIAN;
65857
65876
  var isLittleEndian = useSyntax === IMPLICIT_LITTLE_ENDIAN || useSyntax === EXPLICIT_LITTLE_ENDIAN$1;
@@ -65863,11 +65882,11 @@ var Tag = /* @__PURE__ */ (function() {
65863
65882
  var tagStream = new WriteBufferStream(256), valueLength;
65864
65883
  tagStream.setEndian(isLittleEndian);
65865
65884
  if (vrType == "OW" || vrType == "OB" || vrType == "UN") {
65866
- valueLength = vr.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
65885
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
65867
65886
  } else if (vrType == "SQ") {
65868
- valueLength = vr.writeBytes(tagStream, values, useSyntax, writeOptions);
65887
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, writeOptions);
65869
65888
  } else {
65870
- valueLength = vr.writeBytes(tagStream, values, writeOptions);
65889
+ valueLength = vr2.writeBytes(tagStream, values, writeOptions);
65871
65890
  }
65872
65891
  if (vrType == "SQ") {
65873
65892
  valueLength = UNDEFINED_LENGTH;
@@ -65877,14 +65896,14 @@ var Tag = /* @__PURE__ */ (function() {
65877
65896
  stream.writeUint32(valueLength);
65878
65897
  written += 4;
65879
65898
  } else {
65880
- var isBig16Length = !vr.isLength32() && valueLength >= 65536 && valueLength !== UNDEFINED_LENGTH;
65881
- if (vr.isLength32() || isBig16Length) {
65882
- stream.writeAsciiString(isBig16Length ? "UN" : vr.type);
65899
+ var isBig16Length = !vr2.isLength32() && valueLength >= 65536 && valueLength !== UNDEFINED_LENGTH;
65900
+ if (vr2.isLength32() || isBig16Length) {
65901
+ stream.writeAsciiString(isBig16Length ? "UN" : vr2.type);
65883
65902
  stream.writeUint16(0);
65884
65903
  stream.writeUint32(valueLength);
65885
65904
  written += 8;
65886
65905
  } else {
65887
- stream.writeAsciiString(vr.type);
65906
+ stream.writeAsciiString(vr2.type);
65888
65907
  stream.writeUint16(valueLength);
65889
65908
  written += 4;
65890
65909
  }
@@ -66119,9 +66138,9 @@ var DicomMessage = /* @__PURE__ */ (function() {
66119
66138
  }
66120
66139
  }, {
66121
66140
  key: "writeTagObject",
66122
- value: function writeTagObject(stream, tagString, vr, values, syntax, writeOptions) {
66141
+ value: function writeTagObject(stream, tagString, vr2, values, syntax, writeOptions) {
66123
66142
  var tag = Tag.fromString(tagString);
66124
- tag.write(stream, vr, values, syntax, writeOptions);
66143
+ tag.write(stream, vr2, values, syntax, writeOptions);
66125
66144
  }
66126
66145
  }, {
66127
66146
  key: "write",
@@ -66141,14 +66160,14 @@ var DicomMessage = /* @__PURE__ */ (function() {
66141
66160
  if (!tagObject._rawValue) {
66142
66161
  return tagObject.Value;
66143
66162
  }
66144
- var vr = ValueRepresentation.createByTypeString(vrType);
66163
+ var vr2 = ValueRepresentation.createByTypeString(vrType);
66145
66164
  var originalValue;
66146
66165
  if (Array.isArray(tagObject._rawValue)) {
66147
66166
  originalValue = tagObject._rawValue.map(function(val) {
66148
- return vr.applyFormatting(val);
66167
+ return vr2.applyFormatting(val);
66149
66168
  });
66150
66169
  } else {
66151
- originalValue = vr.applyFormatting(tagObject._rawValue);
66170
+ originalValue = vr2.applyFormatting(tagObject._rawValue);
66152
66171
  }
66153
66172
  if (deepEqual(tagObject.Value, originalValue)) {
66154
66173
  return tagObject._rawValue;
@@ -66177,7 +66196,7 @@ var DicomMessage = /* @__PURE__ */ (function() {
66177
66196
  };
66178
66197
  }
66179
66198
  }
66180
- var length2 = null, vr = null, vrType;
66199
+ var length2 = null, vr2 = null, vrType;
66181
66200
  if (implicit) {
66182
66201
  length2 = stream.readUint32();
66183
66202
  var elementData = DicomMessage2.lookupTag(tag);
@@ -66196,16 +66215,16 @@ var DicomMessage = /* @__PURE__ */ (function() {
66196
66215
  vrType = "UN";
66197
66216
  }
66198
66217
  }
66199
- vr = ValueRepresentation.createByTypeString(vrType);
66218
+ vr2 = ValueRepresentation.createByTypeString(vrType);
66200
66219
  } else {
66201
66220
  vrType = stream.readVR();
66202
66221
  if (vrType === "UN" && DicomMessage2.lookupTag(tag) && DicomMessage2.lookupTag(tag).vr) {
66203
66222
  vrType = DicomMessage2.lookupTag(tag).vr;
66204
- vr = ValueRepresentation.parseUnknownVr(vrType);
66223
+ vr2 = ValueRepresentation.parseUnknownVr(vrType);
66205
66224
  } else {
66206
- vr = ValueRepresentation.createByTypeString(vrType);
66225
+ vr2 = ValueRepresentation.createByTypeString(vrType);
66207
66226
  }
66208
- if (vr.isLength32()) {
66227
+ if (vr2.isLength32()) {
66209
66228
  stream.increment(2);
66210
66229
  length2 = stream.readUint32();
66211
66230
  } else {
@@ -66214,27 +66233,27 @@ var DicomMessage = /* @__PURE__ */ (function() {
66214
66233
  }
66215
66234
  var values = [];
66216
66235
  var rawValues = [];
66217
- if (vr.isBinary() && length2 > vr.maxLength && !vr.noMultiple) {
66218
- var times = length2 / vr.maxLength, i = 0;
66236
+ if (vr2.isBinary() && length2 > vr2.maxLength && !vr2.noMultiple) {
66237
+ var times = length2 / vr2.maxLength, i = 0;
66219
66238
  while (i++ < times) {
66220
- var _vr$read = vr.read(stream, vr.maxLength, syntax, options), rawValue = _vr$read.rawValue, value = _vr$read.value;
66239
+ var _vr$read = vr2.read(stream, vr2.maxLength, syntax, options), rawValue = _vr$read.rawValue, value = _vr$read.value;
66221
66240
  rawValues.push(rawValue);
66222
66241
  values.push(value);
66223
66242
  }
66224
66243
  } else {
66225
- var _ref = vr.read(stream, length2, syntax, options) || {}, _rawValue = _ref.rawValue, _value = _ref.value;
66226
- if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
66244
+ var _ref = vr2.read(stream, length2, syntax, options) || {}, _rawValue = _ref.rawValue, _value = _ref.value;
66245
+ if (!vr2.isBinary() && singleVRs.indexOf(vr2.type) == -1) {
66227
66246
  rawValues = _rawValue;
66228
66247
  values = _value;
66229
66248
  if (typeof _value === "string") {
66230
66249
  var delimiterChar = String.fromCharCode(VM_DELIMITER);
66231
- rawValues = vr.dropPadByte(_rawValue.split(delimiterChar));
66232
- values = vr.dropPadByte(_value.split(delimiterChar));
66250
+ rawValues = vr2.dropPadByte(_rawValue.split(delimiterChar));
66251
+ values = vr2.dropPadByte(_value.split(delimiterChar));
66233
66252
  }
66234
- } else if (vr.type == "SQ") {
66253
+ } else if (vr2.type == "SQ") {
66235
66254
  rawValues = _rawValue;
66236
66255
  values = _value;
66237
- } else if (vr.type == "OW" || vr.type == "OB") {
66256
+ } else if (vr2.type == "OW" || vr2.type == "OB") {
66238
66257
  rawValues = _rawValue;
66239
66258
  values = _value;
66240
66259
  } else {
@@ -66245,7 +66264,7 @@ var DicomMessage = /* @__PURE__ */ (function() {
66245
66264
  stream.setEndian(oldEndian);
66246
66265
  var retObj = ValueRepresentation.addTagAccessors({
66247
66266
  tag,
66248
- vr
66267
+ vr: vr2
66249
66268
  });
66250
66269
  retObj.values = values;
66251
66270
  retObj.rawValues = rawValues;
@@ -66316,13 +66335,13 @@ function lookupPrivateTag(keyStr) {
66316
66335
  if (keyStr < candidate) hi2 = mid - 1;
66317
66336
  else if (keyStr > candidate) lo = mid + 1;
66318
66337
  else {
66319
- var vr = vrTable[vrCode[mid]];
66338
+ var vr2 = vrTable[vrCode[mid]];
66320
66339
  var vm = vmTable[vmCode[mid]];
66321
66340
  var off = nameOff[mid];
66322
66341
  var nlen = nameLen[mid];
66323
66342
  var name = nameBlob.slice(off, off + nlen);
66324
66343
  return {
66325
- vr,
66344
+ vr: vr2,
66326
66345
  vm,
66327
66346
  name
66328
66347
  };
@@ -66550,8 +66569,8 @@ var DicomMetadataListener = /* @__PURE__ */ (function() {
66550
66569
  *
66551
66570
  * @param {(() => Promise<void>) | null} fn - Function that returns a Promise, or null to clear
66552
66571
  */
66553
- function setDrain(fn2) {
66554
- this._drain = typeof fn2 === "function" ? fn2 : null;
66572
+ function setDrain(fn) {
66573
+ this._drain = typeof fn === "function" ? fn : null;
66555
66574
  }
66556
66575
  )
66557
66576
  /**
@@ -67544,8 +67563,8 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67544
67563
  }, {
67545
67564
  key: "isSequence",
67546
67565
  value: function isSequence(tagInfo) {
67547
- var vr = tagInfo.vr, length2 = tagInfo.length;
67548
- return vr === "SQ" || vr === "UN" && length2 === UNDEFINED_LENGTH_FIX;
67566
+ var vr2 = tagInfo.vr, length2 = tagInfo.length;
67567
+ return vr2 === "SQ" || vr2 === "UN" && length2 === UNDEFINED_LENGTH_FIX;
67549
67568
  }
67550
67569
  /**
67551
67570
  * Reads a tag header.
@@ -67576,12 +67595,12 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67576
67595
  }
67577
67596
  }
67578
67597
  var length2 = null;
67579
- var vr = null;
67598
+ var vr2 = null;
67580
67599
  var vrType;
67581
67600
  var isCommand = tagObj.group() === 0;
67582
67601
  if (tagObj.isInstruction()) {
67583
67602
  length2 = stream.readUint32();
67584
- vr = ValueRepresentation.createByTypeString("UN");
67603
+ vr2 = ValueRepresentation.createByTypeString("UN");
67585
67604
  } else if (implicit && !isCommand) {
67586
67605
  length2 = stream.readUint32();
67587
67606
  var elementData = DicomMessage.lookupTag(tagObj);
@@ -67602,17 +67621,17 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67602
67621
  vrType = "UN";
67603
67622
  }
67604
67623
  }
67605
- vr = ValueRepresentation.createByTypeString(vrType);
67624
+ vr2 = ValueRepresentation.createByTypeString(vrType);
67606
67625
  } else {
67607
67626
  var _DicomMessage$lookupT;
67608
67627
  vrType = stream.readVR();
67609
67628
  if (vrType === "UN" && (_DicomMessage$lookupT = DicomMessage.lookupTag(tagObj)) !== null && _DicomMessage$lookupT !== void 0 && _DicomMessage$lookupT.vr) {
67610
67629
  vrType = DicomMessage.lookupTag(tagObj).vr;
67611
- vr = ValueRepresentation.parseUnknownVr(vrType);
67630
+ vr2 = ValueRepresentation.parseUnknownVr(vrType);
67612
67631
  } else {
67613
- vr = ValueRepresentation.createByTypeString(vrType);
67632
+ vr2 = ValueRepresentation.createByTypeString(vrType);
67614
67633
  }
67615
- if (vr.isLength32()) {
67634
+ if (vr2.isLength32()) {
67616
67635
  stream.increment(2);
67617
67636
  length2 = stream.readUint32();
67618
67637
  } else {
@@ -67622,8 +67641,8 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67622
67641
  var punctuatedTag = DicomMetaDictionary.punctuateTag(tag);
67623
67642
  var entry = DicomMetaDictionary.dictionary[punctuatedTag];
67624
67643
  var header = {
67625
- vrObj: vr,
67626
- vr: vr.type,
67644
+ vrObj: vr2,
67645
+ vr: vr2.type,
67627
67646
  tag,
67628
67647
  tagObj,
67629
67648
  vm: entry === null || entry === void 0 ? void 0 : entry.vm,
@@ -67642,7 +67661,7 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67642
67661
  key: "readSingle",
67643
67662
  value: (function() {
67644
67663
  var _readSingle = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee11(tagInfo, listener, options) {
67645
- var length2, stream, syntax, vr, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, _values, _values2, coding;
67664
+ var length2, stream, syntax, vr2, values, times, i, _vr$read, value, _vr$read2, _value, delimiterChar, _values, _values2, coding;
67646
67665
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
67647
67666
  while (1) switch (_context11.prev = _context11.next) {
67648
67667
  case 0:
@@ -67651,25 +67670,25 @@ var AsyncDicomReader = /* @__PURE__ */ (function() {
67651
67670
  _context11.next = 4;
67652
67671
  return this.stream.ensureAvailable(length2);
67653
67672
  case 4:
67654
- vr = ValueRepresentation.createByTypeString(tagInfo.vr);
67673
+ vr2 = ValueRepresentation.createByTypeString(tagInfo.vr);
67655
67674
  values = [];
67656
- if (vr.isBinary() && length2 > vr.maxLength && !vr.noMultiple) {
67657
- times = length2 / vr.maxLength;
67675
+ if (vr2.isBinary() && length2 > vr2.maxLength && !vr2.noMultiple) {
67676
+ times = length2 / vr2.maxLength;
67658
67677
  i = 0;
67659
67678
  while (i++ < times) {
67660
67679
  readLog.trace("readSingle multi-value loop", i, times);
67661
- _vr$read = vr.read(stream, vr.maxLength, syntax), value = _vr$read.value;
67680
+ _vr$read = vr2.read(stream, vr2.maxLength, syntax), value = _vr$read.value;
67662
67681
  values.push(value);
67663
67682
  }
67664
67683
  } else {
67665
- _value = (_vr$read2 = vr.read(stream, length2, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
67666
- if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
67684
+ _value = (_vr$read2 = vr2.read(stream, length2, syntax)) === null || _vr$read2 === void 0 ? void 0 : _vr$read2.value;
67685
+ if (!vr2.isBinary() && singleVRs.indexOf(vr2.type) == -1) {
67667
67686
  values = _value;
67668
67687
  if (typeof _value === "string") {
67669
67688
  delimiterChar = String.fromCharCode(VM_DELIMITER);
67670
- values = vr.dropPadByte(_value.split(delimiterChar));
67689
+ values = vr2.dropPadByte(_value.split(delimiterChar));
67671
67690
  }
67672
- } else if (vr.type == "OW" || vr.type == "OB") {
67691
+ } else if (vr2.type == "OW" || vr2.type == "OB") {
67673
67692
  values = _value;
67674
67693
  } else {
67675
67694
  Array.isArray(_value) ? values = _value : values.push(_value);
@@ -72225,7 +72244,7 @@ var len = length;
72225
72244
  var sqrLen = squaredLength;
72226
72245
  var forEach = (function() {
72227
72246
  var vec = create();
72228
- return function(a, stride, offset, count, fn2, arg) {
72247
+ return function(a, stride, offset, count, fn, arg) {
72229
72248
  var i, l;
72230
72249
  if (!stride) {
72231
72250
  stride = 3;
@@ -72242,7 +72261,7 @@ var forEach = (function() {
72242
72261
  vec[0] = a[i];
72243
72262
  vec[1] = a[i + 1];
72244
72263
  vec[2] = a[i + 2];
72245
- fn2(vec, vec, arg);
72264
+ fn(vec, vec, arg);
72246
72265
  a[i] = vec[0];
72247
72266
  a[i + 1] = vec[1];
72248
72267
  a[i + 2] = vec[2];
@@ -73306,7 +73325,7 @@ var AgentDicomChannel = class extends BaseChannel {
73306
73325
  calledAeTitle: this.association?.getCalledAeTitle()
73307
73326
  },
73308
73327
  dataset: dicomJson2,
73309
- binary: binary ? Ee(binary) : void 0
73328
+ binary: binary ? Re(binary) : void 0
73310
73329
  };
73311
73330
  App.instance.addToWebSocketQueue({
73312
73331
  type: "agent:transmit:request",
@@ -73320,7 +73339,7 @@ var AgentDicomChannel = class extends BaseChannel {
73320
73339
  response2.setStatus(dimse.constants.Status.Success);
73321
73340
  } catch (err2) {
73322
73341
  _DcmjsDimseScp.channel.log.error(`DICOM error - check channel logs`);
73323
- _DcmjsDimseScp.channel.channelLog.error(`DICOM error: ${Le(err2)}`);
73342
+ _DcmjsDimseScp.channel.channelLog.error(`DICOM error: ${Ne(err2)}`);
73324
73343
  response2.setStatus(dimse.constants.Status.ProcessingFailure);
73325
73344
  }
73326
73345
  return response2;
@@ -73367,7 +73386,7 @@ var AgentDicomChannel = class extends BaseChannel {
73367
73386
  this.server.on("networkError", async (err2) => {
73368
73387
  this.log.error("Network error: ", { err: err2 });
73369
73388
  if (err2?.code === "EADDRINUSE") {
73370
- await Yr(50);
73389
+ await Kr(50);
73371
73390
  this.server.close();
73372
73391
  this.server.listen(port);
73373
73392
  }
@@ -73633,7 +73652,7 @@ var AgentHl7Channel = class extends BaseChannel {
73633
73652
  sendToRemote(msg) {
73634
73653
  const connection = this.connections.get(msg.remote);
73635
73654
  if (connection) {
73636
- const hl7Message = Eo.parse(msg.body);
73655
+ const hl7Message = Ro.parse(msg.body);
73637
73656
  const msgControlId = hl7Message.getSegment("MSA")?.getField(2)?.toString();
73638
73657
  const ackCode = hl7Message.getSegment("MSA")?.getField(1)?.toString()?.toUpperCase();
73639
73658
  if (ackCode && isAppLevelAckCode(ackCode) && !shouldSendAppLevelAck({
@@ -73644,10 +73663,13 @@ var AgentHl7Channel = class extends BaseChannel {
73644
73663
  this.channelLog.debug(
73645
73664
  `[Skipping ACK -- Mode: ${this.appLevelAckMode} -- ID: ${msgControlId ?? "not provided"} -- ACK: ${ackCode ?? "unknown"}]`
73646
73665
  );
73666
+ if (msgControlId) {
73667
+ this.stats.recordAckReceived(msgControlId);
73668
+ }
73647
73669
  return;
73648
73670
  }
73649
73671
  this.channelLog.info(`[Sending ACK -- ID: ${msgControlId}]: ${hl7Message.toString().replaceAll("\r", "\n")}`);
73650
- connection.hl7Connection.send(Eo.parse(msg.body));
73672
+ connection.hl7Connection.send(Ro.parse(msg.body));
73651
73673
  if (msgControlId) {
73652
73674
  this.stats.recordAckReceived(msgControlId);
73653
73675
  }
@@ -73760,12 +73782,12 @@ var AgentHl7ChannelConnection = class {
73760
73782
  }
73761
73783
  } catch (err2) {
73762
73784
  this.channel.log.error(`HL7 error occurred - check channel logs`);
73763
- this.channel.channelLog.error(`HL7 error: ${Le(err2)}`);
73785
+ this.channel.channelLog.error(`HL7 error: ${Ne(err2)}`);
73764
73786
  }
73765
73787
  }
73766
73788
  async handleError(event) {
73767
- this.channel.log.error(`HL7 connection error: ${Le(event.error)}`);
73768
- this.channel.channelLog.error(`HL7 connection error: ${Le(event.error)}`);
73789
+ this.channel.log.error(`HL7 connection error: ${Ne(event.error)}`);
73790
+ this.channel.channelLog.error(`HL7 connection error: ${Ne(event.error)}`);
73769
73791
  }
73770
73792
  handleEnhancedAckSent(event) {
73771
73793
  const hl7Message = event.message;
@@ -74160,13 +74182,13 @@ var Hl7ClientPool = class {
74160
74182
  this.closeAndRemoveClient(client);
74161
74183
  if (this.keepAlive) {
74162
74184
  this.log.error(
74163
- `Persistent connection to remote 'mllp://${this.host}:${this.port}' encountered error: '${Le(event.error)}' - Closing connection...`
74185
+ `Persistent connection to remote 'mllp://${this.host}:${this.port}' encountered error: '${Ne(event.error)}' - Closing connection...`
74164
74186
  );
74165
74187
  }
74166
74188
  });
74167
74189
  client.addEventListener("warning", (event) => {
74168
74190
  this.log.warn(
74169
- `Connection to remote 'mllp://${this.host}:${this.port}' warning: '${Le(event.error)}'`
74191
+ `Connection to remote 'mllp://${this.host}:${this.port}' warning: '${Ne(event.error)}'`
74170
74192
  );
74171
74193
  });
74172
74194
  return client;
@@ -74199,7 +74221,7 @@ var DEFAULT_LOGGER_CONFIG = {
74199
74221
  logDir: __dirname,
74200
74222
  maxFileSizeMb: 10,
74201
74223
  filesToKeep: 10,
74202
- logLevel: Ge.INFO
74224
+ logLevel: Qe.INFO
74203
74225
  };
74204
74226
  var LOGGER_CONFIG_INTEGER_KEYS = ["maxFileSizeMb", "filesToKeep"];
74205
74227
  var LEVELS_TO_UPPERCASE = {
@@ -74266,16 +74288,16 @@ function parseLoggerConfigFromArgs(args) {
74266
74288
  if (!propName.startsWith("logger.") || propVal === void 0) {
74267
74289
  continue;
74268
74290
  }
74269
- const [_2, configType, settingName] = We(propName, ".", 3);
74291
+ const [_2, configType, settingName] = qe(propName, ".", 3);
74270
74292
  if (!LOGGER_CONFIG_KEYS.includes(settingName)) {
74271
74293
  warnings.push(`${propName} is not a valid setting name`);
74272
74294
  }
74273
74295
  let configValue;
74274
74296
  if (settingName === "logLevel") {
74275
74297
  try {
74276
- configValue = zh(propVal);
74298
+ configValue = Jh(propVal);
74277
74299
  } catch (err2) {
74278
- warnings.push(`Error while parsing ${propName}: ${Le(err2)}`);
74300
+ warnings.push(`Error while parsing ${propName}: ${Ne(err2)}`);
74279
74301
  }
74280
74302
  } else if (LOGGER_CONFIG_INTEGER_KEYS.includes(settingName)) {
74281
74303
  try {
@@ -74301,14 +74323,14 @@ function parseLoggerConfigFromArgs(args) {
74301
74323
  function getWinstonLevelFromMedplumLevel(level) {
74302
74324
  switch (level) {
74303
74325
  // Return error for NONE since we are going to turn silent on anyways
74304
- case Ge.NONE:
74305
- case Ge.ERROR:
74326
+ case Qe.NONE:
74327
+ case Qe.ERROR:
74306
74328
  return "error";
74307
- case Ge.WARN:
74329
+ case Qe.WARN:
74308
74330
  return "warn";
74309
- case Ge.INFO:
74331
+ case Qe.INFO:
74310
74332
  return "info";
74311
- case Ge.DEBUG:
74333
+ case Qe.DEBUG:
74312
74334
  return "debug";
74313
74335
  default:
74314
74336
  throw new Error("Invalid log level");
@@ -74318,7 +74340,7 @@ function createWinstonFromLoggerConfig(config, loggerType) {
74318
74340
  const level = getWinstonLevelFromMedplumLevel(config.logLevel);
74319
74341
  const logger = import_winston.default.createLogger({
74320
74342
  level,
74321
- silent: config.logLevel === Ge.NONE,
74343
+ silent: config.logLevel === Qe.NONE,
74322
74344
  format: import_winston.default.format.combine(
74323
74345
  import_winston.default.format.timestamp(),
74324
74346
  // Custom transform to match previous Medplum logger output
@@ -74372,16 +74394,16 @@ var WinstonWrapperLogger = class _WinstonWrapperLogger {
74372
74394
  this.prefix = options?.prefix;
74373
74395
  }
74374
74396
  debug(msg, data2) {
74375
- this.log(Ge.DEBUG, msg, data2);
74397
+ this.log(Qe.DEBUG, msg, data2);
74376
74398
  }
74377
74399
  info(msg, data2) {
74378
- this.log(Ge.INFO, msg, data2);
74400
+ this.log(Qe.INFO, msg, data2);
74379
74401
  }
74380
74402
  warn(msg, data2) {
74381
- this.log(Ge.WARN, msg, data2);
74403
+ this.log(Qe.WARN, msg, data2);
74382
74404
  }
74383
74405
  error(msg, data2) {
74384
- this.log(Ge.ERROR, msg, data2);
74406
+ this.log(Qe.ERROR, msg, data2);
74385
74407
  }
74386
74408
  log(level, msg, data2) {
74387
74409
  if (level > this.level) {
@@ -74396,16 +74418,16 @@ var WinstonWrapperLogger = class _WinstonWrapperLogger {
74396
74418
  const dataToLog = { ...data2, ...this.metadata };
74397
74419
  const msgToLog = this.prefix ? `${this.prefix}${msg}` : msg;
74398
74420
  switch (level) {
74399
- case Ge.DEBUG:
74421
+ case Qe.DEBUG:
74400
74422
  this.winston.debug(msgToLog, dataToLog);
74401
74423
  return;
74402
- case Ge.INFO:
74424
+ case Qe.INFO:
74403
74425
  this.winston.info(msgToLog, dataToLog);
74404
74426
  return;
74405
- case Ge.WARN:
74427
+ case Qe.WARN:
74406
74428
  this.winston.warn(msgToLog, dataToLog);
74407
74429
  return;
74408
- case Ge.ERROR:
74430
+ case Qe.ERROR:
74409
74431
  this.winston.error(msgToLog, dataToLog);
74410
74432
  }
74411
74433
  }
@@ -74447,7 +74469,7 @@ var import_node_os2 = require("node:os");
74447
74469
  var import_node_path3 = __toESM(require("node:path"));
74448
74470
  var import_node_process = __toESM(require("node:process"));
74449
74471
  var EXIT_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
74450
- var pidLogger = new Co((msg) => `[PID]: ${msg}`);
74472
+ var pidLogger = new Po((msg) => `[PID]: ${msg}`);
74451
74473
  var pidFileApps = /* @__PURE__ */ new Set();
74452
74474
  var processExitListener = () => {
74453
74475
  removeAllPidFiles();
@@ -74565,7 +74587,7 @@ async function waitForPidFile(appName, timeoutMs = 3e3) {
74565
74587
  if (Date.now() - startTime > timeoutMs) {
74566
74588
  throw new Error("Timeout while waiting for PID file");
74567
74589
  }
74568
- await Yr(0);
74590
+ await Kr(0);
74569
74591
  }
74570
74592
  }
74571
74593
  function removeAllPidFiles() {
@@ -74610,7 +74632,9 @@ async function downloadRelease(version, path4) {
74610
74632
  try {
74611
74633
  await (0, import_promises.pipeline)(readable, (0, import_node_fs3.createWriteStream)(path4));
74612
74634
  } catch (err2) {
74613
- (0, import_node_fs3.unlinkSync)(path4);
74635
+ if ((0, import_node_fs3.existsSync)(path4)) {
74636
+ (0, import_node_fs3.unlinkSync)(path4);
74637
+ }
74614
74638
  throw new Error(`Error while downloading release version ${version} to ${path4}`, { cause: err2 });
74615
74639
  }
74616
74640
  }
@@ -74686,21 +74710,29 @@ var _App = class _App {
74686
74710
  __publicField(this, "logStatsTimer");
74687
74711
  __publicField(this, "config");
74688
74712
  __publicField(this, "lastHeartbeatSentTime", -1);
74713
+ // Whether this process owns the `medplum-agent` PID, i.e. it is the sole agent that should
74714
+ // touch the data plane. A normally-started agent is primary from the outset (main.ts creates
74715
+ // the PID before start()). An upgrading agent stays non-primary until it wins the PID from the
74716
+ // outgoing agent, so that the two overlapping processes don't both send to the same remote.
74717
+ __publicField(this, "isPrimary", false);
74689
74718
  _App.instance = this;
74690
74719
  this.medplum = medplum;
74691
74720
  this.agentId = agentId;
74692
- this.log = options?.mainLogger ?? new Co((msg) => console.log(msg), void 0, logLevel);
74693
- this.channelLog = options?.channelLogger ?? new Co((msg) => console.log(msg), void 0, logLevel);
74721
+ this.log = options?.mainLogger ?? new Po((msg) => console.log(msg), void 0, logLevel);
74722
+ this.channelLog = options?.channelLogger ?? new Po((msg) => console.log(msg), void 0, logLevel);
74694
74723
  }
74695
74724
  async start() {
74696
74725
  this.log.info("Medplum service starting...");
74726
+ this.isPrimary = !(0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH);
74697
74727
  await this.startWebSocket();
74698
- await this.reloadConfig();
74699
- await this.maybeFinalizeUpgrade();
74728
+ const { listenersStarted } = await this.beginReloadConfig();
74729
+ const upgradeManifest = this.consumeUpgradeManifest();
74730
+ await listenersStarted;
74731
+ await this.maybeFinalizeUpgrade(upgradeManifest);
74700
74732
  this.medplum.addEventListener("change", () => {
74701
74733
  if (!this.webSocket) {
74702
74734
  this.connectWebSocket().catch((err2) => {
74703
- this.log.error(Le(err2));
74735
+ this.log.error(Ne(err2));
74704
74736
  });
74705
74737
  } else {
74706
74738
  this.startWebSocketWorker();
@@ -74708,47 +74740,65 @@ var _App = class _App {
74708
74740
  });
74709
74741
  this.log.info("Medplum service started successfully");
74710
74742
  }
74711
- async maybeFinalizeUpgrade() {
74712
- if ((0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH)) {
74713
- const upgradeFile = (0, import_node_fs4.readFileSync)(UPGRADE_MANIFEST_PATH, { encoding: "utf-8" });
74714
- const upgradeDetails = JSON.parse(upgradeFile);
74715
- if (fn.startsWith(upgradeDetails.targetVersion)) {
74716
- await this.sendToWebSocket({
74717
- type: "agent:upgrade:response",
74718
- statusCode: 200,
74719
- callback: upgradeDetails.callback ?? void 0
74720
- });
74721
- this.log.info(`Successfully upgraded to version ${upgradeDetails.targetVersion}`);
74722
- } else {
74723
- const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${fn}`;
74724
- await this.sendToWebSocket({
74725
- type: "agent:error",
74726
- body: errMsg,
74727
- callback: upgradeDetails.callback ?? void 0
74728
- });
74729
- this.log.error(errMsg);
74730
- }
74731
- (0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
74732
- await this.tryToCreateAgentPidFile();
74733
- await waitForPidFile("medplum-upgrading-agent");
74734
- removePidFile("medplum-upgrading-agent");
74743
+ /**
74744
+ * Reads and deletes the upgrade manifest if one is present.
74745
+ *
74746
+ * Deleting the manifest is intentionally decoupled from {@link App.maybeFinalizeUpgrade}: removing
74747
+ * the file is the signal the installer waits on before stopping the previous agent (which frees the
74748
+ * ports the new agent is binding to), so it must happen BEFORE we await the channel binds. Reporting
74749
+ * upgrade status and taking over the agent PID file happen afterwards in {@link App.maybeFinalizeUpgrade}.
74750
+ *
74751
+ * @returns The parsed manifest, or undefined if no upgrade is in progress.
74752
+ */
74753
+ consumeUpgradeManifest() {
74754
+ if (!(0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH)) {
74755
+ return void 0;
74756
+ }
74757
+ const upgradeFile = (0, import_node_fs4.readFileSync)(UPGRADE_MANIFEST_PATH, { encoding: "utf-8" });
74758
+ const upgradeDetails = JSON.parse(upgradeFile);
74759
+ (0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
74760
+ return upgradeDetails;
74761
+ }
74762
+ async maybeFinalizeUpgrade(upgradeDetails) {
74763
+ if (!upgradeDetails) {
74764
+ return;
74735
74765
  }
74766
+ if (pn.startsWith(upgradeDetails.targetVersion)) {
74767
+ await this.sendToWebSocket({
74768
+ type: "agent:upgrade:response",
74769
+ statusCode: 200,
74770
+ callback: upgradeDetails.callback ?? void 0
74771
+ });
74772
+ this.log.info(`Successfully upgraded to version ${upgradeDetails.targetVersion}`);
74773
+ } else {
74774
+ const errMsg = `Failed to upgrade to version ${upgradeDetails.targetVersion}. Agent still running with version ${pn}`;
74775
+ await this.sendToWebSocket({
74776
+ type: "agent:error",
74777
+ body: errMsg,
74778
+ callback: upgradeDetails.callback ?? void 0
74779
+ });
74780
+ this.log.error(errMsg);
74781
+ }
74782
+ await this.tryToCreateAgentPidFile();
74783
+ await waitForPidFile("medplum-upgrading-agent");
74784
+ removePidFile("medplum-upgrading-agent");
74736
74785
  }
74737
74786
  async tryToCreateAgentPidFile() {
74738
- const maxAttempts = 1e3;
74787
+ const maxAttempts = 1e4;
74739
74788
  let attempt = 0;
74740
74789
  let success = false;
74741
74790
  while (!success) {
74742
74791
  try {
74743
74792
  createPidFile("medplum-agent");
74744
74793
  success = true;
74794
+ this.isPrimary = true;
74745
74795
  } catch (_err) {
74746
74796
  this.log.info("Unable to create agent PID file, trying again...");
74747
74797
  attempt++;
74748
74798
  if (attempt === maxAttempts) {
74749
74799
  throw new Error("Too many unsuccessful attempts to create agent PID file");
74750
74800
  }
74751
- await Yr(500);
74801
+ await Kr(50);
74752
74802
  }
74753
74803
  }
74754
74804
  }
@@ -74761,7 +74811,7 @@ var _App = class _App {
74761
74811
  if (!this.webSocket) {
74762
74812
  this.log.warn("WebSocket not connected");
74763
74813
  this.connectWebSocket().catch((err2) => {
74764
- this.log.error(Le(err2));
74814
+ this.log.error(Ne(err2));
74765
74815
  });
74766
74816
  return;
74767
74817
  }
@@ -74821,7 +74871,7 @@ var _App = class _App {
74821
74871
  break;
74822
74872
  case "agent:heartbeat:request":
74823
74873
  this.outstandingHeartbeats = 0;
74824
- await this.sendToWebSocket({ type: "agent:heartbeat:response", version: fn });
74874
+ await this.sendToWebSocket({ type: "agent:heartbeat:response", version: pn });
74825
74875
  break;
74826
74876
  case "agent:heartbeat:response":
74827
74877
  this.outstandingHeartbeats = 0;
@@ -74830,6 +74880,10 @@ var _App = class _App {
74830
74880
  // @ts-expect-error - Deprecated message type
74831
74881
  case "transmit":
74832
74882
  case "agent:transmit:response": {
74883
+ if (!this.isPrimary) {
74884
+ this.log.debug("Ignoring transmit response while not primary");
74885
+ break;
74886
+ }
74833
74887
  if (!command.callback) {
74834
74888
  this.log.warn("Transmit response missing callback");
74835
74889
  }
@@ -74845,6 +74899,10 @@ var _App = class _App {
74845
74899
  // @ts-expect-error - Deprecated message type
74846
74900
  case "push":
74847
74901
  case "agent:transmit:request":
74902
+ if (!this.isPrimary) {
74903
+ this.log.debug("Ignoring transmit request while not primary");
74904
+ break;
74905
+ }
74848
74906
  if (this.config?.status !== "active") {
74849
74907
  this.sendAgentDisabledError(command);
74850
74908
  } else if (command.contentType === k.PING) {
@@ -74865,7 +74923,7 @@ var _App = class _App {
74865
74923
  } catch (err2) {
74866
74924
  await this.sendToWebSocket({
74867
74925
  type: "agent:error",
74868
- body: Le(err2),
74926
+ body: Ne(err2),
74869
74927
  callback: command.callback
74870
74928
  });
74871
74929
  }
@@ -74893,7 +74951,7 @@ var _App = class _App {
74893
74951
  }
74894
74952
  }
74895
74953
  } catch (err2) {
74896
- const errMsg = `WebSocket error on incoming message: ${Le(err2)}`;
74954
+ const errMsg = `WebSocket error on incoming message: ${Ne(err2)}`;
74897
74955
  this.log.error(errMsg);
74898
74956
  try {
74899
74957
  await this.sendToWebSocket({
@@ -74902,7 +74960,7 @@ var _App = class _App {
74902
74960
  callback: command?.callback
74903
74961
  });
74904
74962
  } catch (sendErr) {
74905
- this.log.error(`Failed to send agent:error response: ${Le(sendErr)}`);
74963
+ this.log.error(`Failed to send agent:error response: ${Ne(sendErr)}`);
74906
74964
  }
74907
74965
  }
74908
74966
  });
@@ -74915,6 +74973,21 @@ var _App = class _App {
74915
74973
  });
74916
74974
  }
74917
74975
  async reloadConfig() {
74976
+ const { listenersStarted } = await this.beginReloadConfig();
74977
+ await listenersStarted;
74978
+ }
74979
+ /**
74980
+ * Reloads the agent config and begins (re)starting channel listeners, resolving as soon as the
74981
+ * listeners have been *kicked off* -- it does NOT wait for them to finish binding to their ports.
74982
+ * The returned `listenersStarted` promise resolves once all listeners have bound, or rejects with
74983
+ * the aggregated bind errors.
74984
+ *
74985
+ * This split exists for the zero-downtime upgrade flow; see {@link App.start} and
74986
+ * {@link App.consumeUpgradeManifest} for why binding must be deferred past manifest deletion.
74987
+ *
74988
+ * @returns An object whose `listenersStarted` promise resolves once all channel listeners have bound.
74989
+ */
74990
+ async beginReloadConfig() {
74918
74991
  const agent = await this.medplum.readResource("Agent", this.agentId, { cache: "no-cache" });
74919
74992
  const keepAlive = agent?.setting?.find((setting) => setting.name === "keepAlive")?.valueBoolean;
74920
74993
  const maxClientsPerRemote = agent?.setting?.find((setting) => setting.name === "maxClientsPerRemote")?.valueInteger;
@@ -74923,7 +74996,7 @@ var _App = class _App {
74923
74996
  const results = await Promise.allSettled(Array.from(this.hl7Clients.values()).map((pool) => pool.closeAll()));
74924
74997
  for (const result of results) {
74925
74998
  if (result.status === "rejected") {
74926
- this.log.error(Le(result.reason));
74999
+ this.log.error(Ne(result.reason));
74927
75000
  }
74928
75001
  }
74929
75002
  this.hl7Clients.clear();
@@ -74949,7 +75022,8 @@ var _App = class _App {
74949
75022
  this.log.info(`Stats logging enabled. Logging stats every ${this.logStatsFreqSecs} seconds...`);
74950
75023
  this.logStatsTimer ??= setInterval(() => this.logStats(), this.logStatsFreqSecs * 1e3);
74951
75024
  }
74952
- await this.hydrateListeners();
75025
+ const startPromises = await this.hydrateListeners();
75026
+ return { listenersStarted: this.waitForChannelsToStart(startPromises) };
74953
75027
  }
74954
75028
  getStats() {
74955
75029
  const stats = getCurrentStats();
@@ -74984,7 +75058,13 @@ var _App = class _App {
74984
75058
  this.log.info("Agent stats", { stats: this.getStats() });
74985
75059
  }
74986
75060
  /**
74987
- * This method should only be called by {@link App.reloadConfig}
75061
+ * This method should only be called by {@link App.beginReloadConfig}.
75062
+ *
75063
+ * Channel listener start promises are returned rather than awaited here, so the caller can delete
75064
+ * the upgrade manifest before waiting for the listeners to bind. See {@link App.start} for the
75065
+ * zero-downtime upgrade rationale.
75066
+ *
75067
+ * @returns The channel listener start promises for the caller to await.
74988
75068
  */
74989
75069
  async hydrateListeners() {
74990
75070
  const config = this.config;
@@ -75024,6 +75104,7 @@ var _App = class _App {
75024
75104
  this.channels.delete(leftover);
75025
75105
  }
75026
75106
  const errors = [];
75107
+ const startPromises = [];
75027
75108
  for (let i = 0; i < filteredChannels.length; i++) {
75028
75109
  const definition = filteredChannels[i];
75029
75110
  const endpoint = filteredEndpoints[i];
@@ -75031,10 +75112,17 @@ var _App = class _App {
75031
75112
  this.log.warn(`Ignoring empty endpoint address: ${definition.name}`);
75032
75113
  }
75033
75114
  try {
75034
- await this.startOrReloadChannel(definition, endpoint);
75115
+ const newChannel = await this.reloadOrCreateChannel(definition, endpoint);
75116
+ if (newChannel) {
75117
+ startPromises.push(
75118
+ newChannel.start().then(() => {
75119
+ this.channels.set(definition.name, newChannel);
75120
+ })
75121
+ );
75122
+ }
75035
75123
  } catch (err2) {
75036
75124
  errors.push(err2);
75037
- this.log.error(Le(err2));
75125
+ this.log.error(Ne(err2));
75038
75126
  }
75039
75127
  }
75040
75128
  if (errors.length) {
@@ -75052,12 +75140,48 @@ var _App = class _App {
75052
75140
  (err2) => ({
75053
75141
  severity: "error",
75054
75142
  code: "invalid",
75055
- details: { text: Le(err2) }
75143
+ details: { text: Ne(err2) }
75056
75144
  })
75057
75145
  )
75058
75146
  ]
75059
75147
  });
75060
75148
  }
75149
+ return startPromises;
75150
+ }
75151
+ /**
75152
+ * Awaits the channel listener start promises returned by {@link App.hydrateListeners},
75153
+ * aggregating any bind failures into a single error (mirroring {@link App.hydrateListeners}).
75154
+ *
75155
+ * @param startPromises - The channel listener start promises to await.
75156
+ */
75157
+ async waitForChannelsToStart(startPromises) {
75158
+ const results = await Promise.allSettled(startPromises);
75159
+ const errors = results.filter((result) => result.status === "rejected").map((result) => result.reason);
75160
+ if (!errors.length) {
75161
+ return;
75162
+ }
75163
+ for (const err2 of errors) {
75164
+ this.log.error(Ne(err2));
75165
+ }
75166
+ throw new f({
75167
+ resourceType: "OperationOutcome",
75168
+ issue: [
75169
+ {
75170
+ severity: "error",
75171
+ code: "invalid",
75172
+ details: {
75173
+ text: `${errors.length} error(s) occurred while starting channel listeners`
75174
+ }
75175
+ },
75176
+ ...errors.map(
75177
+ (err2) => ({
75178
+ severity: "error",
75179
+ code: "invalid",
75180
+ details: { text: Ne(err2) }
75181
+ })
75182
+ )
75183
+ ]
75184
+ });
75061
75185
  }
75062
75186
  /**
75063
75187
  * Validates whether all endpoints are valid. Also ensures that there are no conflicting ports between any endpoints in the group.
@@ -75081,7 +75205,7 @@ var _App = class _App {
75081
75205
  parsedEndpoint = new URL(endpoint.address);
75082
75206
  } catch (err2) {
75083
75207
  throw new Error(
75084
- `Error while validating endpoint address for channel '${channel.name}': ${Le(err2)}`
75208
+ `Error while validating endpoint address for channel '${channel.name}': ${Ne(err2)}`
75085
75209
  );
75086
75210
  }
75087
75211
  if (seenPorts.has(parsedEndpoint.port)) {
@@ -75094,28 +75218,37 @@ var _App = class _App {
75094
75218
  portToChannelMap.set(parsedEndpoint.port, [channel.name, endpoint.address]);
75095
75219
  }
75096
75220
  }
75097
- async startOrReloadChannel(definition, endpoint) {
75221
+ /**
75222
+ * Reloads the config of an existing channel, or creates a new (unstarted) one.
75223
+ *
75224
+ * Starting the new channel is intentionally left to the caller ({@link App.hydrateListeners}),
75225
+ * which collects the unawaited `start()` promises so binding can be deferred past upgrade
75226
+ * manifest deletion. See {@link App.start} for the zero-downtime upgrade rationale.
75227
+ *
75228
+ * @param definition - The channel definition from the agent config.
75229
+ * @param endpoint - The endpoint for the channel.
75230
+ * @returns The newly created channel for the caller to start, or `undefined` if no new channel
75231
+ * was needed (config reload) or creating it failed.
75232
+ */
75233
+ async reloadOrCreateChannel(definition, endpoint) {
75098
75234
  const existingChannel = this.channels.get(definition.name);
75099
75235
  if (existingChannel) {
75100
75236
  const previousType = getChannelType(existingChannel.getEndpoint());
75101
75237
  const nextType = getChannelType(endpoint);
75102
75238
  if (previousType === nextType) {
75103
75239
  await existingChannel.reloadConfig(definition, endpoint);
75104
- return;
75240
+ return void 0;
75105
75241
  }
75106
75242
  await existingChannel.stop();
75107
75243
  this.channels.delete(definition.name);
75108
75244
  }
75109
- let channel;
75110
75245
  try {
75111
75246
  const channelType = getChannelType(endpoint);
75112
- channel = this.createChannel(channelType, definition, endpoint);
75247
+ return this.createChannel(channelType, definition, endpoint);
75113
75248
  } catch (err2) {
75114
- this.log.error(Le(err2));
75115
- return;
75249
+ this.log.error(Ne(err2));
75250
+ return void 0;
75116
75251
  }
75117
- await channel.start();
75118
- this.channels.set(definition.name, channel);
75119
75252
  }
75120
75253
  createChannel(channelType, definition, endpoint) {
75121
75254
  switch (channelType) {
@@ -75186,7 +75319,7 @@ var _App = class _App {
75186
75319
  try {
75187
75320
  await this.sendToWebSocket(msg);
75188
75321
  } catch (err2) {
75189
- this.log.error(`WebSocket error while attempting to send message: ${Le(err2)}`);
75322
+ this.log.error(`WebSocket error while attempting to send message: ${Ne(err2)}`);
75190
75323
  this.webSocketQueue.unshift(msg);
75191
75324
  throw err2;
75192
75325
  }
@@ -75262,7 +75395,7 @@ ${result}`);
75262
75395
  body: result
75263
75396
  });
75264
75397
  } catch (err2) {
75265
- this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${Le(err2)}`);
75398
+ this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${Ne(err2)}`);
75266
75399
  this.addToWebSocketQueue({
75267
75400
  type: "agent:transmit:response",
75268
75401
  channel: message.channel,
@@ -75270,12 +75403,12 @@ ${result}`);
75270
75403
  remote: message.remote,
75271
75404
  callback: message.callback,
75272
75405
  statusCode: 400,
75273
- body: Le(err2)
75406
+ body: Ne(err2)
75274
75407
  });
75275
75408
  }
75276
75409
  }
75277
75410
  async tryUpgradeAgent(message) {
75278
- this.log.info(`Attempting to upgrade from ${fn} to ${message.version ?? "latest"}...`);
75411
+ this.log.info(`Attempting to upgrade from ${pn} to ${message.version ?? "latest"}...`);
75279
75412
  if ((0, import_node_os4.platform)() !== "win32") {
75280
75413
  const errMsg = "Auto-upgrading is currently only supported on Windows";
75281
75414
  this.log.error(errMsg);
@@ -75298,7 +75431,7 @@ ${result}`);
75298
75431
  return;
75299
75432
  }
75300
75433
  let child;
75301
- if (message.version && !await Hg("agent-upgrader", message.version)) {
75434
+ if (message.version && !await Gg("agent-upgrader", message.version)) {
75302
75435
  const versionTag = message.version ? `v${message.version}` : "latest";
75303
75436
  const errMsg = `Error during upgrading to version '${versionTag}'. '${message.version}' is not a valid version`;
75304
75437
  this.log.error(errMsg);
@@ -75309,8 +75442,8 @@ ${result}`);
75309
75442
  });
75310
75443
  return;
75311
75444
  }
75312
- const targetVersion = message.version ?? await Gg("agent-upgrader");
75313
- if (fn.startsWith(targetVersion)) {
75445
+ const targetVersion = message.version ?? await Qg("agent-upgrader");
75446
+ if (pn.startsWith(targetVersion)) {
75314
75447
  if (!message?.force) {
75315
75448
  this.log.info(`Attempted to upgrade to version ${targetVersion}, but agent is already on that version`);
75316
75449
  await this.sendToWebSocket({
@@ -75320,7 +75453,7 @@ ${result}`);
75320
75453
  });
75321
75454
  return;
75322
75455
  }
75323
- this.log.info(`Forcing upgrade from ${fn} to ${targetVersion}`);
75456
+ this.log.info(`Forcing upgrade from ${pn} to ${targetVersion}`);
75324
75457
  }
75325
75458
  if (semver.lt(targetVersion, "4.2.4") && !message.force) {
75326
75459
  const errMsg = `WARNING: ${targetVersion} predates the zero-downtime upgrade feature. Downgrading to this version will 1) incur downtime during the downgrade process, as the current agent must stop itself before installing the older agent, and 2) incur downtime on any subsequent upgrade to a later version. We recommend against downgrading to this version, but if you must, reissue the command with force set to true to downgrade.`;
@@ -75340,14 +75473,16 @@ ${result}`);
75340
75473
  forceKillApp("medplum-agent-upgrader");
75341
75474
  removePidFile("medplum-agent-upgrader");
75342
75475
  }
75343
- (0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
75476
+ if ((0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH)) {
75477
+ (0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
75478
+ }
75344
75479
  }
75345
75480
  try {
75346
75481
  const release = await wn("agent-upgrader", targetVersion);
75347
75482
  parseDownloadUrl(release, (0, import_node_os4.platform)());
75348
75483
  } catch (err2) {
75349
75484
  const versionTag = message.version ? `v${message.version}` : "latest";
75350
- const errMsg = `Error during upgrading to version '${versionTag}': ${Le(err2)}`;
75485
+ const errMsg = `Error during upgrading to version '${versionTag}': ${Ne(err2)}`;
75351
75486
  this.log.error(errMsg);
75352
75487
  await this.sendToWebSocket({
75353
75488
  type: "agent:error",
@@ -75381,13 +75516,13 @@ ${result}`);
75381
75516
  }
75382
75517
  });
75383
75518
  child.on("error", (err2) => {
75384
- this.log.error(Le(err2));
75519
+ this.log.error(Ne(err2));
75385
75520
  reject(err2);
75386
75521
  });
75387
75522
  });
75388
75523
  } catch (err2) {
75389
75524
  const versionTag = message.version ? `v${message.version}` : "latest";
75390
- const errMsg = `Error during upgrading to version '${versionTag}': ${Le(err2)}`;
75525
+ const errMsg = `Error during upgrading to version '${versionTag}': ${Ne(err2)}`;
75391
75526
  this.log.error(errMsg);
75392
75527
  await this.sendToWebSocket({
75393
75528
  type: "agent:error",
@@ -75397,11 +75532,11 @@ ${result}`);
75397
75532
  return;
75398
75533
  }
75399
75534
  try {
75400
- this.log.info("Writing upgrade manifest...", { previousVersion: fn, targetVersion });
75535
+ this.log.info("Writing upgrade manifest...", { previousVersion: pn, targetVersion });
75401
75536
  (0, import_node_fs4.writeFileSync)(
75402
75537
  UPGRADE_MANIFEST_PATH,
75403
75538
  JSON.stringify({
75404
- previousVersion: fn,
75539
+ previousVersion: pn,
75405
75540
  targetVersion,
75406
75541
  callback: message.callback ?? null
75407
75542
  }),
@@ -75411,7 +75546,7 @@ ${result}`);
75411
75546
  child.disconnect();
75412
75547
  } catch (err2) {
75413
75548
  this.log.error(
75414
- `Error while stopping agent or messaging child process as part of upgrade: ${Le(err2)}`
75549
+ `Error while stopping agent or messaging child process as part of upgrade: ${Ne(err2)}`
75415
75550
  );
75416
75551
  import_node_process2.default.exit(1);
75417
75552
  }
@@ -75425,10 +75560,10 @@ ${result}`);
75425
75560
  callback: command.callback
75426
75561
  });
75427
75562
  } catch (err2) {
75428
- this.log.error(Le(err2));
75563
+ this.log.error(Ne(err2));
75429
75564
  await this.sendToWebSocket({
75430
75565
  type: "agent:error",
75431
- body: Le(err2),
75566
+ body: Ne(err2),
75432
75567
  callback: command.callback
75433
75568
  });
75434
75569
  }
@@ -75453,10 +75588,10 @@ ${result}`);
75453
75588
  callback: command.callback
75454
75589
  });
75455
75590
  } catch (err2) {
75456
- this.log.error(Le(err2));
75591
+ this.log.error(Ne(err2));
75457
75592
  await this.sendToWebSocket({
75458
75593
  type: "agent:error",
75459
- body: Le(err2),
75594
+ body: Ne(err2),
75460
75595
  callback: command.callback
75461
75596
  });
75462
75597
  }
@@ -75497,7 +75632,7 @@ ${result}`);
75497
75632
  try {
75498
75633
  msgReturnAck = this.parseReturnAck(message.returnAck);
75499
75634
  } catch (err2) {
75500
- this.log.error(Le(err2));
75635
+ this.log.error(Ne(err2));
75501
75636
  this.addToWebSocketQueue({
75502
75637
  type: "agent:transmit:response",
75503
75638
  channel: message.channel,
@@ -75505,7 +75640,7 @@ ${result}`);
75505
75640
  callback: message.callback,
75506
75641
  contentType: k.TEXT,
75507
75642
  statusCode: 400,
75508
- body: Le(err2)
75643
+ body: Ne(err2)
75509
75644
  });
75510
75645
  return;
75511
75646
  }
@@ -75513,9 +75648,9 @@ ${result}`);
75513
75648
  try {
75514
75649
  defaultReturnAck = this.parseReturnAck(address.searchParams.get("defaultReturnAck"));
75515
75650
  } catch (err2) {
75516
- this.log.warn(`${Le(err2)} - falling back to default return ACK behavior of 'first'.`);
75651
+ this.log.warn(`${Ne(err2)} - falling back to default return ACK behavior of 'first'.`);
75517
75652
  }
75518
- const returnAck = msgReturnAck ?? defaultReturnAck ?? sf.FIRST;
75653
+ const returnAck = msgReturnAck ?? defaultReturnAck ?? af.FIRST;
75519
75654
  let pool;
75520
75655
  if (this.hl7Clients.has(message.remote)) {
75521
75656
  pool = this.hl7Clients.get(message.remote);
@@ -75536,7 +75671,7 @@ ${result}`);
75536
75671
  encoding
75537
75672
  });
75538
75673
  }
75539
- const requestMsg = Eo.parse(message.body);
75674
+ const requestMsg = Ro.parse(message.body);
75540
75675
  const msh10 = requestMsg.getSegment("MSH")?.getField(10);
75541
75676
  if (!msh10) {
75542
75677
  const errMsg = "MSH.10 is missing but required";
@@ -75558,7 +75693,7 @@ ${result}`);
75558
75693
  try {
75559
75694
  client = pool.getClient();
75560
75695
  } catch (err2) {
75561
- this.log.error(`Failed to get client from pool: ${Le(err2)}`);
75696
+ this.log.error(`Failed to get client from pool: ${Ne(err2)}`);
75562
75697
  this.addToWebSocketQueue({
75563
75698
  type: "agent:transmit:response",
75564
75699
  channel: message.channel,
@@ -75566,7 +75701,7 @@ ${result}`);
75566
75701
  callback: message.callback,
75567
75702
  contentType: k.TEXT,
75568
75703
  statusCode: 400,
75569
- body: Le(err2)
75704
+ body: Ne(err2)
75570
75705
  });
75571
75706
  return;
75572
75707
  }
@@ -75582,7 +75717,7 @@ ${result}`);
75582
75717
  body: response2.toString()
75583
75718
  });
75584
75719
  }).catch((err2) => {
75585
- this.log.error(`HL7 error: ${Le(err2)}`);
75720
+ this.log.error(`HL7 error: ${Ne(err2)}`);
75586
75721
  this.addToWebSocketQueue({
75587
75722
  type: "agent:transmit:response",
75588
75723
  channel: message.channel,
@@ -75590,7 +75725,7 @@ ${result}`);
75590
75725
  callback: message.callback,
75591
75726
  contentType: k.TEXT,
75592
75727
  statusCode: 400,
75593
- body: Le(err2)
75728
+ body: Ne(err2)
75594
75729
  });
75595
75730
  forceClose = true;
75596
75731
  }).finally(() => {
@@ -75618,10 +75753,10 @@ ${result}`);
75618
75753
  }
75619
75754
  const normalizedValue = rawValue.toLowerCase();
75620
75755
  if (normalizedValue === "application") {
75621
- return sf.APPLICATION;
75756
+ return af.APPLICATION;
75622
75757
  }
75623
75758
  if (normalizedValue === "first") {
75624
- return sf.FIRST;
75759
+ return af.FIRST;
75625
75760
  }
75626
75761
  throw new Error(`Invalid value for returnAck; expected: 'first' or 'application', received: ${rawValue}`);
75627
75762
  }
@@ -75669,9 +75804,9 @@ async function agentMain(argv) {
75669
75804
  await medplum.startClientLogin(clientId, clientSecret);
75670
75805
  loggedIn = true;
75671
75806
  } catch (err2) {
75672
- console.error("Failed to login", { err: Le(err2) });
75807
+ console.error("Failed to login", { err: Ne(err2) });
75673
75808
  console.log("Retrying login in 10 seconds...");
75674
- await Yr(RETRY_WAIT_DURATION_MS);
75809
+ await Kr(RETRY_WAIT_DURATION_MS);
75675
75810
  }
75676
75811
  }
75677
75812
  if (args.logLevel) {
@@ -75684,7 +75819,7 @@ async function agentMain(argv) {
75684
75819
  for (const warning of warnings) {
75685
75820
  mainLogger.warn(warning);
75686
75821
  }
75687
- const app = new App(medplum, agentId, args.logLevel ? zh(args.logLevel) : void 0, {
75822
+ const app = new App(medplum, agentId, args.logLevel ? Jh(args.logLevel) : void 0, {
75688
75823
  mainLogger,
75689
75824
  channelLogger
75690
75825
  });
@@ -75716,7 +75851,7 @@ async function upgraderMain(argv) {
75716
75851
  if ((0, import_node_os5.platform)() !== "win32") {
75717
75852
  throw new Error(`Unsupported platform: ${(0, import_node_os5.platform)()}. Agent upgrader currently only supports Windows`);
75718
75853
  }
75719
- const globalLogger = new Co((msg) => console.log(msg));
75854
+ const globalLogger = new Po((msg) => console.log(msg));
75720
75855
  if (!import_node_process3.default.send) {
75721
75856
  globalLogger.error("Upgrader not started as a child process with Node IPC enabled. Aborting...");
75722
75857
  import_node_process3.default.exit(1);
@@ -75733,7 +75868,7 @@ async function upgraderMain(argv) {
75733
75868
  if (argv[3] && !Ru(argv[3])) {
75734
75869
  throw new Error("Invalid version specified");
75735
75870
  }
75736
- version = argv[3] ?? await Gg("agent-upgrader");
75871
+ version = argv[3] ?? await Qg("agent-upgrader");
75737
75872
  binPath = getReleaseBinPath(version);
75738
75873
  if (!(0, import_node_fs6.existsSync)(binPath)) {
75739
75874
  globalLogger.info(`Could not find binary at "${binPath}". Downloading release from GitHub...`);
@@ -75741,7 +75876,7 @@ async function upgraderMain(argv) {
75741
75876
  globalLogger.info("Release successfully downloaded");
75742
75877
  }
75743
75878
  } catch (err2) {
75744
- import_node_process3.default.send({ type: "ERROR", err: Le(err2) });
75879
+ import_node_process3.default.send({ type: "ERROR", err: Ne(err2) });
75745
75880
  throw err2;
75746
75881
  }
75747
75882
  import_node_process3.default.send({ type: "STARTED" });
@@ -75762,7 +75897,7 @@ async function upgraderMain(argv) {
75762
75897
  (0, import_node_child_process2.spawnSync)(`"${binPath}" /S`, { windowsHide: true, shell: true });
75763
75898
  globalLogger.info(`Agent version ${version} successfully installed`);
75764
75899
  } catch (err2) {
75765
- globalLogger.error(`Error while attempting to run installer: ${Le(err2)}`);
75900
+ globalLogger.error(`Error while attempting to run installer: ${Ne(err2)}`);
75766
75901
  globalLogger.error("Failed to run installer, attempting to restart agent service...");
75767
75902
  try {
75768
75903
  (0, import_node_child_process2.execSync)('net start "Medplum Agent"');
@@ -75788,7 +75923,7 @@ async function main(argv) {
75788
75923
  } else if (argv[2] === "--remove-old-services") {
75789
75924
  const logFileFd = (0, import_node_fs7.openSync)(TEMP_LOG_FILE, "a");
75790
75925
  let allAgentServices = [];
75791
- const currentServiceName = `MedplumAgent_${fn}`;
75926
+ const currentServiceName = `MedplumAgent_${pn}`;
75792
75927
  while (!allAgentServices.includes(currentServiceName)) {
75793
75928
  const output = (0, import_node_child_process3.execSync)('cmd.exe /c sc query type= service state= all | findstr /i "SERVICE_NAME.*MedplumAgent"');
75794
75929
  (0, import_node_fs7.appendFileSync)(logFileFd, `${output}\r
@@ -75798,8 +75933,8 @@ async function main(argv) {
75798
75933
  ${allAgentServices.join("\r\n")}\r
75799
75934
  `, { encoding: "utf-8" });
75800
75935
  }
75801
- const servicesToRemove = argv[3] === "--all" ? allAgentServices : allAgentServices.filter((serviceName) => serviceName !== `MedplumAgent_${fn}`);
75802
- (0, import_node_fs7.appendFileSync)(logFileFd, `Medplum agent service to filter out: MedplumAgent_${fn}\r
75936
+ const servicesToRemove = argv[3] === "--all" ? allAgentServices : allAgentServices.filter((serviceName) => serviceName !== `MedplumAgent_${pn}`);
75937
+ (0, import_node_fs7.appendFileSync)(logFileFd, `Medplum agent service to filter out: MedplumAgent_${pn}\r
75803
75938
  `, {
75804
75939
  encoding: "utf-8"
75805
75940
  });
@@ -75812,10 +75947,10 @@ ${allAgentServices.join("\r\n")}\r
75812
75947
  } catch (err2) {
75813
75948
  (0, import_node_fs7.appendFileSync)(logFileFd, `Failed to stop service: ${serviceName}\r
75814
75949
  `, { encoding: "utf-8" });
75815
- (0, import_node_fs7.appendFileSync)(logFileFd, `${Le(err2)}\r
75950
+ (0, import_node_fs7.appendFileSync)(logFileFd, `${Ne(err2)}\r
75816
75951
  `, { encoding: "utf-8" });
75817
75952
  console.error(`Failed to stop service: ${serviceName}`);
75818
- console.error(Le(err2));
75953
+ console.error(Ne(err2));
75819
75954
  }
75820
75955
  try {
75821
75956
  (0, import_node_child_process3.execSync)(`sc.exe delete ${serviceName}`);
@@ -75825,10 +75960,10 @@ ${allAgentServices.join("\r\n")}\r
75825
75960
  } catch (err2) {
75826
75961
  (0, import_node_fs7.appendFileSync)(logFileFd, `Failed to delete service: ${serviceName}\r
75827
75962
  `, { encoding: "utf-8" });
75828
- (0, import_node_fs7.appendFileSync)(logFileFd, `${Le(err2)}\r
75963
+ (0, import_node_fs7.appendFileSync)(logFileFd, `${Ne(err2)}\r
75829
75964
  `, { encoding: "utf-8" });
75830
75965
  console.error(`Failed to delete service: ${serviceName}`);
75831
- console.error(Le(err2));
75966
+ console.error(Ne(err2));
75832
75967
  }
75833
75968
  }
75834
75969
  (0, import_node_fs7.closeSync)(logFileFd);