@medplum/agent 2.2.2 → 2.2.4

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 +501 -454
  2. package/package.json +1 -2
@@ -5062,15 +5062,15 @@ var require_dcmjs = __commonJS({
5062
5062
  return Array.from(iter);
5063
5063
  }
5064
5064
  function _iterableToArrayLimit(arr, i2) {
5065
- var _i2 = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
5066
- if (_i2 == null)
5065
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
5066
+ if (_i == null)
5067
5067
  return;
5068
5068
  var _arr = [];
5069
5069
  var _n = true;
5070
5070
  var _d = false;
5071
5071
  var _s, _e2;
5072
5072
  try {
5073
- for (_i2 = _i2.call(arr); !(_n = (_s = _i2.next()).done); _n = true) {
5073
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
5074
5074
  _arr.push(_s.value);
5075
5075
  if (i2 && _arr.length === i2)
5076
5076
  break;
@@ -5080,8 +5080,8 @@ var require_dcmjs = __commonJS({
5080
5080
  _e2 = err2;
5081
5081
  } finally {
5082
5082
  try {
5083
- if (!_n && _i2["return"] != null)
5084
- _i2["return"]();
5083
+ if (!_n && _i["return"] != null)
5084
+ _i["return"]();
5085
5085
  } finally {
5086
5086
  if (_d)
5087
5087
  throw _e2;
@@ -9455,9 +9455,9 @@ var require_dcmjs = __commonJS({
9455
9455
  }, {
9456
9456
  key: "readVR",
9457
9457
  value: function readVR() {
9458
- var vr = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
9458
+ var vr2 = String.fromCharCode(this.view.getUint8(this.offset)) + String.fromCharCode(this.view.getUint8(this.offset + 1));
9459
9459
  this.increment(2);
9460
- return vr;
9460
+ return vr2;
9461
9461
  }
9462
9462
  }, {
9463
9463
  key: "readEncodedString",
@@ -9807,7 +9807,7 @@ var require_dcmjs = __commonJS({
9807
9807
  }, {
9808
9808
  key: "write",
9809
9809
  value: function write(stream, vrType, values, syntax, writeOptions) {
9810
- var vr = ValueRepresentation.createByTypeString(vrType), useSyntax = DicomMessage._normalizeSyntax(syntax);
9810
+ var vr2 = ValueRepresentation.createByTypeString(vrType), useSyntax = DicomMessage._normalizeSyntax(syntax);
9811
9811
  var implicit = useSyntax == IMPLICIT_LITTLE_ENDIAN ? true : false, isLittleEndian = useSyntax == IMPLICIT_LITTLE_ENDIAN || useSyntax == EXPLICIT_LITTLE_ENDIAN$1 ? true : false, isEncapsulated = this.isPixelDataTag() && DicomMessage.isEncapsulated(syntax);
9812
9812
  var oldEndian = stream.isLittleEndian;
9813
9813
  stream.setEndian(isLittleEndian);
@@ -9816,11 +9816,11 @@ var require_dcmjs = __commonJS({
9816
9816
  var tagStream = new WriteBufferStream(256), valueLength;
9817
9817
  tagStream.setEndian(isLittleEndian);
9818
9818
  if (vrType == "OW" || vrType == "OB" || vrType == "UN") {
9819
- valueLength = vr.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
9819
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, isEncapsulated, writeOptions);
9820
9820
  } else if (vrType == "SQ") {
9821
- valueLength = vr.writeBytes(tagStream, values, useSyntax, writeOptions);
9821
+ valueLength = vr2.writeBytes(tagStream, values, useSyntax, writeOptions);
9822
9822
  } else {
9823
- valueLength = vr.writeBytes(tagStream, values, writeOptions);
9823
+ valueLength = vr2.writeBytes(tagStream, values, writeOptions);
9824
9824
  }
9825
9825
  if (vrType == "SQ") {
9826
9826
  valueLength = 4294967295;
@@ -9830,13 +9830,13 @@ var require_dcmjs = __commonJS({
9830
9830
  stream.writeUint32(valueLength);
9831
9831
  written += 4;
9832
9832
  } else {
9833
- if (vr.isExplicit()) {
9834
- stream.writeAsciiString(vr.type);
9833
+ if (vr2.isExplicit()) {
9834
+ stream.writeAsciiString(vr2.type);
9835
9835
  stream.writeUint16(0);
9836
9836
  stream.writeUint32(valueLength);
9837
9837
  written += 8;
9838
9838
  } else {
9839
- stream.writeAsciiString(vr.type);
9839
+ stream.writeAsciiString(vr2.type);
9840
9840
  stream.writeUint16(valueLength);
9841
9841
  written += 4;
9842
9842
  }
@@ -10141,20 +10141,20 @@ var require_dcmjs = __commonJS({
10141
10141
  }, {
10142
10142
  key: "createByTypeString",
10143
10143
  value: function createByTypeString(type) {
10144
- var vr = VRinstances[type];
10145
- if (vr === void 0) {
10144
+ var vr2 = VRinstances[type];
10145
+ if (vr2 === void 0) {
10146
10146
  if (type == "ox") {
10147
10147
  validationLog.error("Invalid vr type", type, "- using OW");
10148
- vr = VRinstances["OW"];
10148
+ vr2 = VRinstances["OW"];
10149
10149
  } else if (type == "xs") {
10150
10150
  validationLog.error("Invalid vr type", type, "- using US");
10151
- vr = VRinstances["US"];
10151
+ vr2 = VRinstances["US"];
10152
10152
  } else {
10153
10153
  validationLog.error("Invalid vr type", type, "- using UN");
10154
- vr = VRinstances["UN"];
10154
+ vr2 = VRinstances["UN"];
10155
10155
  }
10156
10156
  }
10157
- return vr;
10157
+ return vr2;
10158
10158
  }
10159
10159
  }]);
10160
10160
  return ValueRepresentation2;
@@ -11432,7 +11432,7 @@ var require_dcmjs = __commonJS({
11432
11432
  log.error("No value representation given for", naturalName);
11433
11433
  }
11434
11434
  }
11435
- var vr = ValueRepresentation.createByTypeString(dataItem.vr);
11435
+ var vr2 = ValueRepresentation.createByTypeString(dataItem.vr);
11436
11436
  dataItem.Value = DicomMetaDictionary2.denaturalizeValue(dataItem.Value);
11437
11437
  if (entry.vr == "SQ") {
11438
11438
  var unnaturalValues = [];
@@ -11442,11 +11442,11 @@ var require_dcmjs = __commonJS({
11442
11442
  }
11443
11443
  dataItem.Value = unnaturalValues;
11444
11444
  }
11445
- if (!vr.isBinary() && vr.maxLength) {
11445
+ if (!vr2.isBinary() && vr2.maxLength) {
11446
11446
  dataItem.Value = dataItem.Value.map(function(value) {
11447
- if (value.length > vr.maxLength) {
11448
- log.warn("Truncating value ".concat(value, " of ").concat(naturalName, " because it is longer than ").concat(vr.maxLength));
11449
- return value.slice(0, vr.maxLength);
11447
+ if (value.length > vr2.maxLength) {
11448
+ log.warn("Truncating value ".concat(value, " of ").concat(naturalName, " because it is longer than ").concat(vr2.maxLength));
11449
+ return value.slice(0, vr2.maxLength);
11450
11450
  } else {
11451
11451
  return value;
11452
11452
  }
@@ -11727,9 +11727,9 @@ var require_dcmjs = __commonJS({
11727
11727
  }
11728
11728
  }, {
11729
11729
  key: "writeTagObject",
11730
- value: function writeTagObject(stream, tagString, vr, values, syntax, writeOptions) {
11730
+ value: function writeTagObject(stream, tagString, vr2, values, syntax, writeOptions) {
11731
11731
  var tag = Tag.fromString(tagString);
11732
- tag.write(stream, vr, values, syntax, writeOptions);
11732
+ tag.write(stream, vr2, values, syntax, writeOptions);
11733
11733
  }
11734
11734
  }, {
11735
11735
  key: "write",
@@ -11763,7 +11763,7 @@ var require_dcmjs = __commonJS({
11763
11763
  };
11764
11764
  }
11765
11765
  }
11766
- var length2 = null, vr = null, vrType;
11766
+ var length2 = null, vr2 = null, vrType;
11767
11767
  if (implicit) {
11768
11768
  length2 = stream.readUint32();
11769
11769
  var elementData = DicomMessage2.lookupTag(tag);
@@ -11782,11 +11782,11 @@ var require_dcmjs = __commonJS({
11782
11782
  vrType = "UN";
11783
11783
  }
11784
11784
  }
11785
- vr = ValueRepresentation.createByTypeString(vrType);
11785
+ vr2 = ValueRepresentation.createByTypeString(vrType);
11786
11786
  } else {
11787
11787
  vrType = stream.readVR();
11788
- vr = ValueRepresentation.createByTypeString(vrType);
11789
- if (vr.isExplicit()) {
11788
+ vr2 = ValueRepresentation.createByTypeString(vrType);
11789
+ if (vr2.isExplicit()) {
11790
11790
  stream.increment(2);
11791
11791
  length2 = stream.readUint32();
11792
11792
  } else {
@@ -11794,21 +11794,21 @@ var require_dcmjs = __commonJS({
11794
11794
  }
11795
11795
  }
11796
11796
  var values = [];
11797
- if (vr.isBinary() && length2 > vr.maxLength && !vr.noMultiple) {
11798
- var times = length2 / vr.maxLength, i2 = 0;
11797
+ if (vr2.isBinary() && length2 > vr2.maxLength && !vr2.noMultiple) {
11798
+ var times = length2 / vr2.maxLength, i2 = 0;
11799
11799
  while (i2++ < times) {
11800
- values.push(vr.read(stream, vr.maxLength, syntax));
11800
+ values.push(vr2.read(stream, vr2.maxLength, syntax));
11801
11801
  }
11802
11802
  } else {
11803
- var val = vr.read(stream, length2, syntax);
11804
- if (!vr.isBinary() && singleVRs.indexOf(vr.type) == -1) {
11803
+ var val = vr2.read(stream, length2, syntax);
11804
+ if (!vr2.isBinary() && singleVRs.indexOf(vr2.type) == -1) {
11805
11805
  values = val;
11806
11806
  if (typeof val === "string") {
11807
11807
  values = val.split(String.fromCharCode(VM_DELIMITER));
11808
11808
  }
11809
- } else if (vr.type == "SQ") {
11809
+ } else if (vr2.type == "SQ") {
11810
11810
  values = val;
11811
- } else if (vr.type == "OW" || vr.type == "OB") {
11811
+ } else if (vr2.type == "OW" || vr2.type == "OB") {
11812
11812
  values = val;
11813
11813
  } else {
11814
11814
  Array.isArray(val) ? values = val : values.push(val);
@@ -11817,7 +11817,7 @@ var require_dcmjs = __commonJS({
11817
11817
  stream.setEndian(oldEndian);
11818
11818
  var retObj = ValueRepresentation.addTagAccessors({
11819
11819
  tag,
11820
- vr
11820
+ vr: vr2
11821
11821
  });
11822
11822
  retObj.values = values;
11823
11823
  return retObj;
@@ -11839,12 +11839,12 @@ var require_dcmjs = __commonJS({
11839
11839
  }
11840
11840
  _createClass(DicomDict2, [{
11841
11841
  key: "upsertTag",
11842
- value: function upsertTag(tag, vr, values) {
11842
+ value: function upsertTag(tag, vr2, values) {
11843
11843
  if (this.dict[tag]) {
11844
11844
  this.dict[tag].Value = values;
11845
11845
  } else {
11846
11846
  this.dict[tag] = ValueRepresentation.addTagAccessors({
11847
- vr
11847
+ vr: vr2
11848
11848
  });
11849
11849
  this.dict[tag].Value = values;
11850
11850
  }
@@ -12074,11 +12074,11 @@ var require_dcmjs = __commonJS({
12074
12074
  var whitePoint = Colors2.d65WhitePointXYZ();
12075
12075
  var X2 = xyz[0] / whitePoint[0];
12076
12076
  var Y2 = xyz[1] / whitePoint[1];
12077
- var Z2 = xyz[2] / whitePoint[2];
12077
+ var Z = xyz[2] / whitePoint[2];
12078
12078
  X2 = Colors2.labf(X2);
12079
12079
  Y2 = Colors2.labf(Y2);
12080
- Z2 = Colors2.labf(Z2);
12081
- return [116 * Y2 - 16, 500 * (X2 - Y2), 200 * (Y2 - Z2)];
12080
+ Z = Colors2.labf(Z);
12081
+ return [116 * Y2 - 16, 500 * (X2 - Y2), 200 * (Y2 - Z)];
12082
12082
  }
12083
12083
  }, {
12084
12084
  key: "lab2RGB",
@@ -15031,9 +15031,9 @@ var require_dcmjs = __commonJS({
15031
15031
  NumberOfFrames += referencedFramesPerSegment[i2].length;
15032
15032
  }
15033
15033
  seg.setNumberOfFrames(NumberOfFrames);
15034
- for (var _i2 = 0; _i2 < segmentIndicies.length; _i2++) {
15035
- var segmentIndex = segmentIndicies[_i2];
15036
- var referencedFrameIndicies = referencedFramesPerSegment[_i2];
15034
+ for (var _i = 0; _i < segmentIndicies.length; _i++) {
15035
+ var segmentIndex = segmentIndicies[_i];
15036
+ var referencedFrameIndicies = referencedFramesPerSegment[_i];
15037
15037
  var referencedFrameNumbers = referencedFrameIndicies.map(function(element) {
15038
15038
  return element + 1;
15039
15039
  });
@@ -15068,13 +15068,13 @@ var require_dcmjs = __commonJS({
15068
15068
  referencedFramesPerSegment.push([]);
15069
15069
  }
15070
15070
  }
15071
- for (var z2 = 0; z2 < images.length; z2++) {
15072
- var imageId = images[z2].imageId;
15071
+ for (var z = 0; z < images.length; z++) {
15072
+ var imageId = images[z].imageId;
15073
15073
  var imageIdSpecificToolState = toolState[imageId];
15074
15074
  for (var _i2 = 0; _i2 < segmentIndicies.length; _i2++) {
15075
15075
  var segIdx = segmentIndicies[_i2];
15076
15076
  if (imageIdSpecificToolState && imageIdSpecificToolState.brush && imageIdSpecificToolState.brush.data && imageIdSpecificToolState.brush.data[segIdx] && imageIdSpecificToolState.brush.data[segIdx].pixelData) {
15077
- referencedFramesPerSegment[_i2].push(z2);
15077
+ referencedFramesPerSegment[_i2].push(z);
15078
15078
  }
15079
15079
  }
15080
15080
  }
@@ -15312,14 +15312,14 @@ var require_dcmjs = __commonJS({
15312
15312
  function length(a) {
15313
15313
  var x = a[0];
15314
15314
  var y = a[1];
15315
- var z2 = a[2];
15316
- return Math.hypot(x, y, z2);
15315
+ var z = a[2];
15316
+ return Math.hypot(x, y, z);
15317
15317
  }
15318
- function fromValues(x, y, z2) {
15318
+ function fromValues(x, y, z) {
15319
15319
  var out = new ARRAY_TYPE(3);
15320
15320
  out[0] = x;
15321
15321
  out[1] = y;
15322
- out[2] = z2;
15322
+ out[2] = z;
15323
15323
  return out;
15324
15324
  }
15325
15325
  function copy(out, a) {
@@ -15328,10 +15328,10 @@ var require_dcmjs = __commonJS({
15328
15328
  out[2] = a[2];
15329
15329
  return out;
15330
15330
  }
15331
- function set(out, x, y, z2) {
15331
+ function set(out, x, y, z) {
15332
15332
  out[0] = x;
15333
15333
  out[1] = y;
15334
- out[2] = z2;
15334
+ out[2] = z;
15335
15335
  return out;
15336
15336
  }
15337
15337
  function add(out, a, b2) {
@@ -15403,20 +15403,20 @@ var require_dcmjs = __commonJS({
15403
15403
  function distance(a, b2) {
15404
15404
  var x = b2[0] - a[0];
15405
15405
  var y = b2[1] - a[1];
15406
- var z2 = b2[2] - a[2];
15407
- return Math.hypot(x, y, z2);
15406
+ var z = b2[2] - a[2];
15407
+ return Math.hypot(x, y, z);
15408
15408
  }
15409
15409
  function squaredDistance(a, b2) {
15410
15410
  var x = b2[0] - a[0];
15411
15411
  var y = b2[1] - a[1];
15412
- var z2 = b2[2] - a[2];
15413
- return x * x + y * y + z2 * z2;
15412
+ var z = b2[2] - a[2];
15413
+ return x * x + y * y + z * z;
15414
15414
  }
15415
15415
  function squaredLength(a) {
15416
15416
  var x = a[0];
15417
15417
  var y = a[1];
15418
- var z2 = a[2];
15419
- return x * x + y * y + z2 * z2;
15418
+ var z = a[2];
15419
+ return x * x + y * y + z * z;
15420
15420
  }
15421
15421
  function negate(out, a) {
15422
15422
  out[0] = -a[0];
@@ -15433,8 +15433,8 @@ var require_dcmjs = __commonJS({
15433
15433
  function normalize$1(out, a) {
15434
15434
  var x = a[0];
15435
15435
  var y = a[1];
15436
- var z2 = a[2];
15437
- var len2 = x * x + y * y + z2 * z2;
15436
+ var z = a[2];
15437
+ var len2 = x * x + y * y + z * z;
15438
15438
  if (len2 > 0) {
15439
15439
  len2 = 1 / Math.sqrt(len2);
15440
15440
  }
@@ -15490,33 +15490,33 @@ var require_dcmjs = __commonJS({
15490
15490
  function random(out, scale2) {
15491
15491
  scale2 = scale2 || 1;
15492
15492
  var r4 = RANDOM() * 2 * Math.PI;
15493
- var z2 = RANDOM() * 2 - 1;
15494
- var zScale = Math.sqrt(1 - z2 * z2) * scale2;
15493
+ var z = RANDOM() * 2 - 1;
15494
+ var zScale = Math.sqrt(1 - z * z) * scale2;
15495
15495
  out[0] = Math.cos(r4) * zScale;
15496
15496
  out[1] = Math.sin(r4) * zScale;
15497
- out[2] = z2 * scale2;
15497
+ out[2] = z * scale2;
15498
15498
  return out;
15499
15499
  }
15500
15500
  function transformMat4(out, a, m3) {
15501
- var x = a[0], y = a[1], z2 = a[2];
15502
- var w2 = m3[3] * x + m3[7] * y + m3[11] * z2 + m3[15];
15501
+ var x = a[0], y = a[1], z = a[2];
15502
+ var w2 = m3[3] * x + m3[7] * y + m3[11] * z + m3[15];
15503
15503
  w2 = w2 || 1;
15504
- out[0] = (m3[0] * x + m3[4] * y + m3[8] * z2 + m3[12]) / w2;
15505
- out[1] = (m3[1] * x + m3[5] * y + m3[9] * z2 + m3[13]) / w2;
15506
- out[2] = (m3[2] * x + m3[6] * y + m3[10] * z2 + m3[14]) / w2;
15504
+ out[0] = (m3[0] * x + m3[4] * y + m3[8] * z + m3[12]) / w2;
15505
+ out[1] = (m3[1] * x + m3[5] * y + m3[9] * z + m3[13]) / w2;
15506
+ out[2] = (m3[2] * x + m3[6] * y + m3[10] * z + m3[14]) / w2;
15507
15507
  return out;
15508
15508
  }
15509
15509
  function transformMat3(out, a, m3) {
15510
- var x = a[0], y = a[1], z2 = a[2];
15511
- out[0] = x * m3[0] + y * m3[3] + z2 * m3[6];
15512
- out[1] = x * m3[1] + y * m3[4] + z2 * m3[7];
15513
- out[2] = x * m3[2] + y * m3[5] + z2 * m3[8];
15510
+ var x = a[0], y = a[1], z = a[2];
15511
+ out[0] = x * m3[0] + y * m3[3] + z * m3[6];
15512
+ out[1] = x * m3[1] + y * m3[4] + z * m3[7];
15513
+ out[2] = x * m3[2] + y * m3[5] + z * m3[8];
15514
15514
  return out;
15515
15515
  }
15516
15516
  function transformQuat(out, a, q2) {
15517
15517
  var qx = q2[0], qy = q2[1], qz = q2[2], qw = q2[3];
15518
- var x = a[0], y = a[1], z2 = a[2];
15519
- var uvx = qy * z2 - qz * y, uvy = qz * x - qx * z2, uvz = qx * y - qy * x;
15518
+ var x = a[0], y = a[1], z = a[2];
15519
+ var uvx = qy * z - qz * y, uvy = qz * x - qx * z, uvz = qx * y - qy * x;
15520
15520
  var uuvx = qy * uvz - qz * uvy, uuvy = qz * uvx - qx * uvz, uuvz = qx * uvy - qy * uvx;
15521
15521
  var w2 = qw * 2;
15522
15522
  uvx *= w2;
@@ -15527,7 +15527,7 @@ var require_dcmjs = __commonJS({
15527
15527
  uuvz *= 2;
15528
15528
  out[0] = x + uvx + uuvx;
15529
15529
  out[1] = y + uvy + uuvy;
15530
- out[2] = z2 + uvz + uuvz;
15530
+ out[2] = z + uvz + uuvz;
15531
15531
  return out;
15532
15532
  }
15533
15533
  function rotateX(out, a, b2, rad) {
@@ -15714,11 +15714,11 @@ var require_dcmjs = __commonJS({
15714
15714
  var bodyLength = rleArray.length % 2 === 0 ? rleArray.length : rleArray.length + 1;
15715
15715
  var encodedFrameBuffer = new ArrayBuffer(headerLength + bodyLength);
15716
15716
  var headerView = new Uint32Array(encodedFrameBuffer, 0, 16);
15717
- for (var _i2 = 0; _i2 < headerView.length; _i2++) {
15718
- headerView[_i2] = header[_i2];
15717
+ for (var _i = 0; _i < headerView.length; _i++) {
15718
+ headerView[_i] = header[_i];
15719
15719
  }
15720
- for (var _i22 = 0; _i22 < headerView.length; _i22++) {
15721
- rleArray.push(headerView[_i22]);
15720
+ for (var _i2 = 0; _i2 < headerView.length; _i2++) {
15721
+ rleArray.push(headerView[_i2]);
15722
15722
  }
15723
15723
  var bodyView = new Uint8Array(encodedFrameBuffer, 64);
15724
15724
  for (var _i3 = 0; _i3 < rleArray.length; _i3++) {
@@ -16419,20 +16419,20 @@ var require_dcmjs = __commonJS({
16419
16419
  referencedFramesPerSegment2[i2] = [];
16420
16420
  }
16421
16421
  }
16422
- var _loop22 = function _loop23(_i3) {
16423
- var labelmap2D = labelmaps2D[_i3];
16424
- if (labelmaps2D[_i3]) {
16422
+ var _loop22 = function _loop23(_i2) {
16423
+ var labelmap2D = labelmaps2D[_i2];
16424
+ if (labelmaps2D[_i2]) {
16425
16425
  var segmentsOnLabelmap = labelmap2D.segmentsOnLabelmap;
16426
16426
  segmentsOnLabelmap.forEach(function(segmentIndex2) {
16427
16427
  if (segmentIndex2 !== 0) {
16428
- referencedFramesPerSegment2[segmentIndex2].push(_i3);
16428
+ referencedFramesPerSegment2[segmentIndex2].push(_i2);
16429
16429
  numberOfFrames++;
16430
16430
  }
16431
16431
  });
16432
16432
  }
16433
16433
  };
16434
- for (var _i2 = 0; _i2 < labelmaps2D.length; _i2++) {
16435
- _loop22(_i2);
16434
+ for (var _i = 0; _i < labelmaps2D.length; _i++) {
16435
+ _loop22(_i);
16436
16436
  }
16437
16437
  referencedFramesPerLabelmap[labelmapIndex2] = referencedFramesPerSegment2;
16438
16438
  };
@@ -21714,7 +21714,7 @@ var require_dcmjs = __commonJS({
21714
21714
  __proto__: null,
21715
21715
  Comprehensive3DSR
21716
21716
  });
21717
- var sr2 = {
21717
+ var sr = {
21718
21718
  coding,
21719
21719
  contentItems,
21720
21720
  documents,
@@ -22026,7 +22026,7 @@ var require_dcmjs = __commonJS({
22026
22026
  data,
22027
22027
  derivations,
22028
22028
  normalizers,
22029
- sr: sr2,
22029
+ sr,
22030
22030
  utilities,
22031
22031
  log,
22032
22032
  anonymizer
@@ -22039,7 +22039,7 @@ var require_dcmjs = __commonJS({
22039
22039
  exports2.derivations = derivations;
22040
22040
  exports2.log = log;
22041
22041
  exports2.normalizers = normalizers;
22042
- exports2.sr = sr2;
22042
+ exports2.sr = sr;
22043
22043
  exports2.utilities = utilities;
22044
22044
  Object.defineProperty(exports2, "__esModule", { value: true });
22045
22045
  });
@@ -25768,8 +25768,8 @@ var require_fecha_umd = __commonJS({
25768
25768
  };
25769
25769
  function assign(origObj) {
25770
25770
  var args = [];
25771
- for (var _i2 = 1; _i2 < arguments.length; _i2++) {
25772
- args[_i2 - 1] = arguments[_i2];
25771
+ for (var _i = 1; _i < arguments.length; _i++) {
25772
+ args[_i - 1] = arguments[_i];
25773
25773
  }
25774
25774
  for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
25775
25775
  var obj = args_1[_a];
@@ -33104,26 +33104,26 @@ var require_conversions = __commonJS({
33104
33104
  b2 = b2 > 0.04045 ? Math.pow((b2 + 0.055) / 1.055, 2.4) : b2 / 12.92;
33105
33105
  var x = r4 * 0.4124 + g2 * 0.3576 + b2 * 0.1805;
33106
33106
  var y = r4 * 0.2126 + g2 * 0.7152 + b2 * 0.0722;
33107
- var z2 = r4 * 0.0193 + g2 * 0.1192 + b2 * 0.9505;
33108
- return [x * 100, y * 100, z2 * 100];
33107
+ var z = r4 * 0.0193 + g2 * 0.1192 + b2 * 0.9505;
33108
+ return [x * 100, y * 100, z * 100];
33109
33109
  };
33110
33110
  convert.rgb.lab = function(rgb) {
33111
33111
  var xyz = convert.rgb.xyz(rgb);
33112
33112
  var x = xyz[0];
33113
33113
  var y = xyz[1];
33114
- var z2 = xyz[2];
33114
+ var z = xyz[2];
33115
33115
  var l2;
33116
33116
  var a;
33117
33117
  var b2;
33118
33118
  x /= 95.047;
33119
33119
  y /= 100;
33120
- z2 /= 108.883;
33120
+ z /= 108.883;
33121
33121
  x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
33122
33122
  y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
33123
- z2 = z2 > 8856e-6 ? Math.pow(z2, 1 / 3) : 7.787 * z2 + 16 / 116;
33123
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
33124
33124
  l2 = 116 * y - 16;
33125
33125
  a = 500 * (x - y);
33126
- b2 = 200 * (y - z2);
33126
+ b2 = 200 * (y - z);
33127
33127
  return [l2, a, b2];
33128
33128
  };
33129
33129
  convert.hsl.rgb = function(hsl) {
@@ -33298,13 +33298,13 @@ var require_conversions = __commonJS({
33298
33298
  convert.xyz.rgb = function(xyz) {
33299
33299
  var x = xyz[0] / 100;
33300
33300
  var y = xyz[1] / 100;
33301
- var z2 = xyz[2] / 100;
33301
+ var z = xyz[2] / 100;
33302
33302
  var r4;
33303
33303
  var g2;
33304
33304
  var b2;
33305
- r4 = x * 3.2406 + y * -1.5372 + z2 * -0.4986;
33306
- g2 = x * -0.9689 + y * 1.8758 + z2 * 0.0415;
33307
- b2 = x * 0.0557 + y * -0.204 + z2 * 1.057;
33305
+ r4 = x * 3.2406 + y * -1.5372 + z * -0.4986;
33306
+ g2 = x * -0.9689 + y * 1.8758 + z * 0.0415;
33307
+ b2 = x * 0.0557 + y * -0.204 + z * 1.057;
33308
33308
  r4 = r4 > 31308e-7 ? 1.055 * Math.pow(r4, 1 / 2.4) - 0.055 : r4 * 12.92;
33309
33309
  g2 = g2 > 31308e-7 ? 1.055 * Math.pow(g2, 1 / 2.4) - 0.055 : g2 * 12.92;
33310
33310
  b2 = b2 > 31308e-7 ? 1.055 * Math.pow(b2, 1 / 2.4) - 0.055 : b2 * 12.92;
@@ -33316,19 +33316,19 @@ var require_conversions = __commonJS({
33316
33316
  convert.xyz.lab = function(xyz) {
33317
33317
  var x = xyz[0];
33318
33318
  var y = xyz[1];
33319
- var z2 = xyz[2];
33319
+ var z = xyz[2];
33320
33320
  var l2;
33321
33321
  var a;
33322
33322
  var b2;
33323
33323
  x /= 95.047;
33324
33324
  y /= 100;
33325
- z2 /= 108.883;
33325
+ z /= 108.883;
33326
33326
  x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
33327
33327
  y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
33328
- z2 = z2 > 8856e-6 ? Math.pow(z2, 1 / 3) : 7.787 * z2 + 16 / 116;
33328
+ z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
33329
33329
  l2 = 116 * y - 16;
33330
33330
  a = 500 * (x - y);
33331
- b2 = 200 * (y - z2);
33331
+ b2 = 200 * (y - z);
33332
33332
  return [l2, a, b2];
33333
33333
  };
33334
33334
  convert.lab.xyz = function(lab) {
@@ -33337,30 +33337,30 @@ var require_conversions = __commonJS({
33337
33337
  var b2 = lab[2];
33338
33338
  var x;
33339
33339
  var y;
33340
- var z2;
33340
+ var z;
33341
33341
  y = (l2 + 16) / 116;
33342
33342
  x = a / 500 + y;
33343
- z2 = y - b2 / 200;
33343
+ z = y - b2 / 200;
33344
33344
  var y2 = Math.pow(y, 3);
33345
33345
  var x2 = Math.pow(x, 3);
33346
- var z22 = Math.pow(z2, 3);
33346
+ var z2 = Math.pow(z, 3);
33347
33347
  y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
33348
33348
  x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
33349
- z2 = z22 > 8856e-6 ? z22 : (z2 - 16 / 116) / 7.787;
33349
+ z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
33350
33350
  x *= 95.047;
33351
33351
  y *= 100;
33352
- z2 *= 108.883;
33353
- return [x, y, z2];
33352
+ z *= 108.883;
33353
+ return [x, y, z];
33354
33354
  };
33355
33355
  convert.lab.lch = function(lab) {
33356
33356
  var l2 = lab[0];
33357
33357
  var a = lab[1];
33358
33358
  var b2 = lab[2];
33359
- var hr;
33359
+ var hr2;
33360
33360
  var h3;
33361
33361
  var c3;
33362
- hr = Math.atan2(b2, a);
33363
- h3 = hr * 360 / 2 / Math.PI;
33362
+ hr2 = Math.atan2(b2, a);
33363
+ h3 = hr2 * 360 / 2 / Math.PI;
33364
33364
  if (h3 < 0) {
33365
33365
  h3 += 360;
33366
33366
  }
@@ -33373,10 +33373,10 @@ var require_conversions = __commonJS({
33373
33373
  var h3 = lch[2];
33374
33374
  var a;
33375
33375
  var b2;
33376
- var hr;
33377
- hr = h3 / 360 * 2 * Math.PI;
33378
- a = c3 * Math.cos(hr);
33379
- b2 = c3 * Math.sin(hr);
33376
+ var hr2;
33377
+ hr2 = h3 / 360 * 2 * Math.PI;
33378
+ a = c3 * Math.cos(hr2);
33379
+ b2 = c3 * Math.sin(hr2);
33380
33380
  return [l2, a, b2];
33381
33381
  };
33382
33382
  convert.rgb.ansi16 = function(args) {
@@ -37917,8 +37917,8 @@ var require_dcmjs_dimse_min = __commonJS({
37917
37917
  }
37918
37918
  };
37919
37919
  }, 988: (e2, t2, s2) => {
37920
- const { Association: n2 } = s2(201), { AAbort: i3, AAssociateAC: r5, AAssociateRJ: o2, AAssociateRQ: a, AReleaseRP: c3, AReleaseRQ: d3, PDataTF: u2, Pdv: h3, RawPdu: m3 } = s2(634), { CommandFieldType: g2, Status: l2, TranscodableTransferSyntaxes: p3 } = s2(855), { CCancelRequest: R2, CEchoRequest: f, CEchoResponse: y, CFindRequest: S2, CFindResponse: I2, CGetRequest: C2, CGetResponse: P, CMoveRequest: v3, CMoveResponse: x, Command: w2, CStoreRequest: A2, CStoreResponse: U2, NActionRequest: q2, NActionResponse: D2, NCreateRequest: E3, NCreateResponse: T2, NDeleteRequest: O2, NDeleteResponse: b2, NEventReportRequest: N, NEventReportResponse: B2, NGetRequest: M, NGetResponse: L2, NSetRequest: F2, NSetResponse: k2, Response: $2 } = s2(406), j2 = s2(347), V2 = s2(719), G2 = s2(266), _2 = s2(437), { SmartBuffer: z2 } = s2(677), { EOL: Q } = s2(37), W = s2(425);
37921
- class J extends W {
37920
+ const { Association: n2 } = s2(201), { AAbort: i3, AAssociateAC: r5, AAssociateRJ: o2, AAssociateRQ: a, AReleaseRP: c3, AReleaseRQ: d3, PDataTF: u2, Pdv: h3, RawPdu: m3 } = s2(634), { CommandFieldType: g2, Status: l2, TranscodableTransferSyntaxes: p3 } = s2(855), { CCancelRequest: R2, CEchoRequest: f, CEchoResponse: y, CFindRequest: S2, CFindResponse: I2, CGetRequest: C2, CGetResponse: P, CMoveRequest: v3, CMoveResponse: x, Command: w2, CStoreRequest: A2, CStoreResponse: U2, NActionRequest: q2, NActionResponse: D2, NCreateRequest: E3, NCreateResponse: T2, NDeleteRequest: O2, NDeleteResponse: b2, NEventReportRequest: N, NEventReportResponse: B2, NGetRequest: M, NGetResponse: L2, NSetRequest: F2, NSetResponse: k2, Response: $2 } = s2(406), j2 = s2(347), V2 = s2(719), G2 = s2(266), _2 = s2(437), { SmartBuffer: z } = s2(677), { EOL: Q } = s2(37), W2 = s2(425);
37921
+ class J2 extends W2 {
37922
37922
  constructor() {
37923
37923
  super();
37924
37924
  }
@@ -37931,7 +37931,7 @@ var require_dcmjs_dimse_min = __commonJS({
37931
37931
  if (void 0 === this.receiving) {
37932
37932
  if (this.minimumReceived && (e3 = Buffer.concat([this.minimumReceived, e3], this.minimumReceived.length + e3.length), this.minimumReceived = void 0), e3.length < 6)
37933
37933
  return void (this.minimumReceived = e3);
37934
- const t3 = z2.fromBuffer(e3, "ascii");
37934
+ const t3 = z.fromBuffer(e3, "ascii");
37935
37935
  t3.readUInt8(), t3.readUInt8();
37936
37936
  const s3 = t3.readUInt32BE();
37937
37937
  let n3 = e3.length - 6;
@@ -37955,7 +37955,7 @@ var require_dcmjs_dimse_min = __commonJS({
37955
37955
  }
37956
37956
  }
37957
37957
  }
37958
- e2.exports = class extends W {
37958
+ e2.exports = class extends W2 {
37959
37959
  constructor(e3, t3) {
37960
37960
  super(), this.messageId = 0, this.socket = e3, this.requests = [], this.pending = [], this.dimseBuffer = void 0, this.dimse = void 0, t3 = t3 || {}, this.connectTimeout = t3.connectTimeout || 18e4, this.associationTimeout = t3.associationTimeout || 6e4, this.pduTimeout = t3.pduTimeout || 6e4, this.logCommandDatasets = t3.logCommandDatasets || false, this.logDatasets = t3.logDatasets || false, this.datasetReadOptions = t3.datasetReadOptions || {}, this.datasetWriteOptions = t3.datasetWriteOptions || {}, this.datasetNameMap = t3.datasetNameMap || {}, this.logId = "", this.connected = false, this.connectedTime = void 0, this.lastPduTime = void 0, this.timeoutIntervalId = void 0, this.statistics = new G2(), this._wrapSocket();
37961
37961
  }
@@ -38110,7 +38110,7 @@ var require_dcmjs_dimse_min = __commonJS({
38110
38110
  _processPDataTf(e3) {
38111
38111
  try {
38112
38112
  e3.getPdvs().forEach((e4) => {
38113
- this.dimseBuffer || (this.dimseBuffer = z2.fromOptions({ encoding: "ascii" })), this.dimseBuffer.writeBuffer(e4.getValue());
38113
+ this.dimseBuffer || (this.dimseBuffer = z.fromOptions({ encoding: "ascii" })), this.dimseBuffer.writeBuffer(e4.getValue());
38114
38114
  const t3 = this.association.getPresentationContext(e4.getPresentationContextId());
38115
38115
  if (e4.isLastFragment())
38116
38116
  if (e4.isCommand()) {
@@ -38239,7 +38239,7 @@ var require_dcmjs_dimse_min = __commonJS({
38239
38239
  this.socket.setTimeout(this.connectTimeout), this.socket.on("connect", () => {
38240
38240
  this.connected = true, this.connectedTime = Date.now(), this.emit("connect");
38241
38241
  });
38242
- const e3 = new J();
38242
+ const e3 = new J2();
38243
38243
  e3.on("pdu", (e4) => {
38244
38244
  this.lastPduTime = Date.now(), this._processPdu(e4);
38245
38245
  }), this.socket.on("data", (t3) => {
@@ -38858,8 +38858,8 @@ var require_dcmjs_dimse_min = __commonJS({
38858
38858
  }
38859
38859
  };
38860
38860
  }, 10: (e2, t2, s2) => {
38861
- const { Association: n2, PresentationContext: i3 } = s2(201), { Scp: r5, Server: o2 } = s2(975), { CCancelRequest: a, CEchoRequest: c3, CEchoResponse: d3, CFindRequest: u2, CFindResponse: h3, CGetRequest: m3, CGetResponse: g2, CMoveRequest: l2, CMoveResponse: p3, CStoreRequest: R2, CStoreResponse: f, NActionRequest: y, NActionResponse: S2, NCreateRequest: I2, NCreateResponse: C2, NDeleteRequest: P, NDeleteResponse: v3, NEventReportRequest: x, NEventReportResponse: w2, NGetRequest: A2, NGetResponse: U2, NSetRequest: q2, NSetResponse: D2 } = s2(406), { AbortReason: E3, AbortSource: T2, CommandFieldType: O2, PresentationContextResult: b2, Priority: N, RejectReason: B2, RejectResult: M, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G2 } = s2(855), _2 = s2(185), z2 = s2(347), Q = s2(719), W = s2(266), J = { association: { Association: n2, PresentationContext: i3 }, Client: _2, constants: { AbortReason: E3, AbortSource: T2, CommandFieldType: O2, PresentationContextResult: b2, Priority: N, RejectReason: B2, RejectResult: M, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G2 }, Dataset: z2, Implementation: Q, log: s2(437), requests: { CCancelRequest: a, CEchoRequest: c3, CFindRequest: u2, CGetRequest: m3, CMoveRequest: l2, CStoreRequest: R2, NActionRequest: y, NCreateRequest: I2, NDeleteRequest: P, NEventReportRequest: x, NGetRequest: A2, NSetRequest: q2 }, responses: { CEchoResponse: d3, CFindResponse: h3, CGetResponse: g2, CMoveResponse: p3, CStoreResponse: f, NActionResponse: S2, NCreateResponse: C2, NDeleteResponse: v3, NEventReportResponse: w2, NGetResponse: U2, NSetResponse: D2 }, Scp: r5, Server: o2, Statistics: W, version: s2(972) };
38862
- e2.exports = J;
38861
+ const { Association: n2, PresentationContext: i3 } = s2(201), { Scp: r5, Server: o2 } = s2(975), { CCancelRequest: a, CEchoRequest: c3, CEchoResponse: d3, CFindRequest: u2, CFindResponse: h3, CGetRequest: m3, CGetResponse: g2, CMoveRequest: l2, CMoveResponse: p3, CStoreRequest: R2, CStoreResponse: f, NActionRequest: y, NActionResponse: S2, NCreateRequest: I2, NCreateResponse: C2, NDeleteRequest: P, NDeleteResponse: v3, NEventReportRequest: x, NEventReportResponse: w2, NGetRequest: A2, NGetResponse: U2, NSetRequest: q2, NSetResponse: D2 } = s2(406), { AbortReason: E3, AbortSource: T2, CommandFieldType: O2, PresentationContextResult: b2, Priority: N, RejectReason: B2, RejectResult: M, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G2 } = s2(855), _2 = s2(185), z = s2(347), Q = s2(719), W2 = s2(266), J2 = { association: { Association: n2, PresentationContext: i3 }, Client: _2, constants: { AbortReason: E3, AbortSource: T2, CommandFieldType: O2, PresentationContextResult: b2, Priority: N, RejectReason: B2, RejectResult: M, RejectSource: L2, SopClass: F2, Status: k2, StorageClass: $2, TransferSyntax: j2, Uid: V2, UserIdentityType: G2 }, Dataset: z, Implementation: Q, log: s2(437), requests: { CCancelRequest: a, CEchoRequest: c3, CFindRequest: u2, CGetRequest: m3, CMoveRequest: l2, CStoreRequest: R2, NActionRequest: y, NCreateRequest: I2, NDeleteRequest: P, NEventReportRequest: x, NGetRequest: A2, NSetRequest: q2 }, responses: { CEchoResponse: d3, CFindResponse: h3, CGetResponse: g2, CMoveResponse: p3, CStoreResponse: f, NActionResponse: S2, NCreateResponse: C2, NDeleteResponse: v3, NEventReportResponse: w2, NGetResponse: U2, NSetResponse: D2 }, Scp: r5, Server: o2, Statistics: W2, version: s2(972) };
38862
+ e2.exports = J2;
38863
38863
  }, 437: (e2, t2, s2) => {
38864
38864
  const { createLogger: n2, format: i3, transports: r5 } = s2(469), { combine: o2, printf: a, timestamp: c3 } = i3, d3 = n2({ format: o2(c3(), a(({ level: e3, message: t3, timestamp: s3 }) => `${s3} -- ${e3.toUpperCase()} -- ${t3}`)), transports: [new r5.Console()] });
38865
38865
  e2.exports = d3;
@@ -38921,7 +38921,7 @@ var Te = class {
38921
38921
  return `${this.operator}(${this.child.toString()})`;
38922
38922
  }
38923
38923
  };
38924
- var j = class {
38924
+ var $ = class {
38925
38925
  constructor(e, t, n) {
38926
38926
  this.operator = e;
38927
38927
  this.left = t;
@@ -39009,44 +39009,44 @@ var it = class {
39009
39009
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
39010
39010
  }
39011
39011
  };
39012
- function z(r4) {
39013
- let e = ce(r4), t = hn(r4);
39012
+ function G(r4) {
39013
+ let e = ae(r4), t = vn(r4);
39014
39014
  return t === e ? { reference: e } : { reference: e, display: t };
39015
39015
  }
39016
- function ce(r4) {
39017
- return ue(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
39016
+ function ae(r4) {
39017
+ return ce(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
39018
39018
  }
39019
- function Gt(r4) {
39019
+ function Yt(r4) {
39020
39020
  if (r4)
39021
- return ue(r4) ? r4.reference.split("/")[1] : r4.id;
39021
+ return ce(r4) ? r4.reference.split("/")[1] : r4.id;
39022
39022
  }
39023
- function mn(r4) {
39023
+ function Tn(r4) {
39024
39024
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
39025
39025
  }
39026
- function hn(r4) {
39027
- if (mn(r4)) {
39028
- let e = yn(r4);
39026
+ function vn(r4) {
39027
+ if (Tn(r4)) {
39028
+ let e = En(r4);
39029
39029
  if (e)
39030
39030
  return e;
39031
39031
  }
39032
39032
  if (r4.resourceType === "Device") {
39033
- let e = gn(r4);
39033
+ let e = Sn(r4);
39034
39034
  if (e)
39035
39035
  return e;
39036
39036
  }
39037
- return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : ce(r4);
39037
+ return r4.resourceType === "Observation" && "code" in r4 && r4.code?.text ? r4.code.text : r4.resourceType === "User" && r4.email ? r4.email : "name" in r4 && r4.name && typeof r4.name == "string" ? r4.name : ae(r4);
39038
39038
  }
39039
- function yn(r4) {
39039
+ function En(r4) {
39040
39040
  let e = r4.name;
39041
39041
  if (e && e.length > 0)
39042
39042
  return Ae(e[0]);
39043
39043
  }
39044
- function gn(r4) {
39044
+ function Sn(r4) {
39045
39045
  let e = r4.deviceName;
39046
39046
  if (e && e.length > 0)
39047
39047
  return e[0].name;
39048
39048
  }
39049
- function Se(r4, e) {
39049
+ function Ee(r4, e) {
39050
39050
  let t = new Date(r4);
39051
39051
  t.setUTCHours(0, 0, 0, 0);
39052
39052
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
@@ -39058,40 +39058,46 @@ function Se(r4, e) {
39058
39058
  let M = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
39059
39059
  return { years: f, months: P, days: M };
39060
39060
  }
39061
- function Yt(r4, e) {
39062
- return JSON.stringify(r4, xn, e ? 2 : void 0);
39061
+ function er(r4, ...e) {
39062
+ let t = r4;
39063
+ for (let n = 0; n < e.length && t; n++)
39064
+ t = t?.extension?.find((i2) => i2.url === e[n]);
39065
+ return t;
39066
+ }
39067
+ function tr(r4, e) {
39068
+ return JSON.stringify(r4, bn, e ? 2 : void 0);
39063
39069
  }
39064
- function xn(r4, e) {
39065
- return !Tn(r4) && E(e) ? void 0 : e;
39070
+ function bn(r4, e) {
39071
+ return !Rn(r4) && S(e) ? void 0 : e;
39066
39072
  }
39067
- function Tn(r4) {
39073
+ function Rn(r4) {
39068
39074
  return !!/\d+$/.exec(r4);
39069
39075
  }
39070
- function E(r4) {
39076
+ function S(r4) {
39071
39077
  if (r4 == null)
39072
39078
  return true;
39073
39079
  let e = typeof r4;
39074
39080
  return e === "string" && r4 === "" || e === "object" && Object.keys(r4).length === 0;
39075
39081
  }
39076
- function Xt(r4) {
39082
+ function rr(r4) {
39077
39083
  return r4.every((e) => typeof e == "string");
39078
39084
  }
39079
- var Zt = [];
39085
+ var nr = [];
39080
39086
  for (let r4 = 0; r4 < 256; r4++)
39081
- Zt.push(r4.toString(16).padStart(2, "0"));
39082
- function er(r4) {
39087
+ nr.push(r4.toString(16).padStart(2, "0"));
39088
+ function ir(r4) {
39083
39089
  let e = new Uint8Array(r4), t = new Array(e.length);
39084
39090
  for (let n = 0; n < e.length; n++)
39085
- t[n] = Zt[e[n]];
39091
+ t[n] = nr[e[n]];
39086
39092
  return t.join("");
39087
39093
  }
39088
- function tr(r4) {
39094
+ function or(r4) {
39089
39095
  let e = new Uint8Array(r4), t = [];
39090
39096
  for (let n = 0; n < e.length; n++)
39091
39097
  t[n] = String.fromCharCode(e[n]);
39092
39098
  return window.btoa(t.join(""));
39093
39099
  }
39094
- function A(r4) {
39100
+ function C(r4) {
39095
39101
  return r4 ? r4.charAt(0).toUpperCase() + r4.substring(1) : "";
39096
39102
  }
39097
39103
  var at = (r4) => new Promise((e) => {
@@ -39100,26 +39106,26 @@ var at = (r4) => new Promise((e) => {
39100
39106
  function Ae(r4, e) {
39101
39107
  let t = [];
39102
39108
  if (r4.prefix && e?.prefix !== false && t.push(...r4.prefix), r4.given && t.push(...r4.given), r4.family && t.push(r4.family), r4.suffix && e?.suffix !== false && t.push(...r4.suffix), r4.use && (e?.all || e?.use) && t.push("[" + r4.use + "]"), t.length === 0) {
39103
- let n = te(r4.text);
39109
+ let n = ee(r4.text);
39104
39110
  if (n)
39105
39111
  return n;
39106
39112
  }
39107
39113
  return t.join(" ").trim();
39108
39114
  }
39109
- function te(r4) {
39115
+ function ee(r4) {
39110
39116
  return typeof r4 == "string" ? r4 : void 0;
39111
39117
  }
39112
- function Bn(r4) {
39113
- let e = r4.max && r4.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : r4.max;
39114
- return { path: "", description: "", type: r4.type ?? [], min: r4.min ?? 0, max: e ?? 1, isArray: !!e && e > 1, constraints: [] };
39118
+ function Hn(r4, e) {
39119
+ let t = e.max && e.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : e.max;
39120
+ return { path: r4, description: "", type: e.type ?? [], min: e.min ?? 0, max: t ?? 1, isArray: !!t && t > 1, constraints: [] };
39115
39121
  }
39116
- function or(r4) {
39122
+ function ur(r4) {
39117
39123
  let e = /* @__PURE__ */ Object.create(null);
39118
39124
  for (let [t, n] of Object.entries(r4))
39119
- e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Bn(o)])), constraints: [], innerTypes: [] };
39125
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Hn(i2, o)])), constraints: [], innerTypes: [] };
39120
39126
  return e;
39121
39127
  }
39122
- var sr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
39128
+ var lr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity" }] }, maxDosePerLifetime: { type: [{ code: "Quantity" }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "string" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity" }] }, high: { type: [{ code: "Quantity" }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity" }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, MetadataResource: { elements: { id: { type: [{ code: "string" }] }, meta: { type: [{ code: "Meta" }] }, implicitRules: { type: [{ code: "uri" }] }, language: { type: [{ code: "code" }] }, text: { type: [{ code: "Narrative" }] }, contained: { max: 9007199254740991, type: [{ code: "Resource" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, name: { type: [{ code: "string" }] }, title: { type: [{ code: "string" }] }, status: { min: 1, type: [{ code: "code" }] }, experimental: { type: [{ code: "boolean" }] }, date: { type: [{ code: "dateTime" }] }, publisher: { type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] }, description: { type: [{ code: "markdown" }] }, useContext: { max: 9007199254740991, type: [{ code: "UsageContext" }] }, jurisdiction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, IdentityProvider: { elements: { authorizeUrl: { min: 1, type: [{ code: "string" }] }, tokenUrl: { min: 1, type: [{ code: "string" }] }, tokenAuthMethod: { type: [{ code: "code" }] }, userInfoUrl: { min: 1, type: [{ code: "string" }] }, clientId: { min: 1, type: [{ code: "string" }] }, clientSecret: { min: 1, type: [{ code: "string" }] }, usePkce: { type: [{ code: "boolean" }] }, useSubject: { type: [{ code: "boolean" }] } } } };
39123
39129
  function d(r4) {
39124
39130
  return [{ type: c.boolean, value: r4 }];
39125
39131
  }
@@ -39140,31 +39146,30 @@ function O(r4, e) {
39140
39146
  if (!r4.value)
39141
39147
  return;
39142
39148
  let t = Ie(r4.type, e);
39143
- return t ? $n(r4, e, t) : jn(r4, e);
39149
+ return t ? Wn(r4.value, e, t) : Gn(r4, e);
39144
39150
  }
39145
- function $n(r4, e, t) {
39151
+ function Wn(r4, e, t) {
39146
39152
  let n = t.type;
39147
39153
  if (!n || n.length === 0)
39148
39154
  return;
39149
- let i2, o = "undefined";
39150
- if (n.length === 1)
39151
- i2 = r4.value[e], o = n[0].code;
39152
- else
39153
- for (let a of n) {
39154
- let u2 = e.replace("[x]", "") + A(a.code);
39155
- if (u2 in r4.value) {
39156
- i2 = r4.value[u2], o = a.code;
39155
+ let i2 = e, o, s = "undefined";
39156
+ if (t.path.endsWith("[x]")) {
39157
+ let u2 = t.path.split(".").pop().replace("[x]", "");
39158
+ for (let l2 of n)
39159
+ if (i2 = u2 + C(l2.code), o = r4[i2], o !== void 0) {
39160
+ s = l2.code;
39157
39161
  break;
39158
39162
  }
39159
- }
39160
- let s = r4.value["_" + e];
39161
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, u2) => s[u2] ? lr(a ?? {}, s[u2]) : a) : i2 = lr(i2 ?? {}, s)), !E(i2))
39162
- return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => ar(a, o)) : ar(i2, o);
39163
+ } else
39164
+ console.assert(n.length === 1, "Expected single type", t.path), o = r4[e], s = n[0].code;
39165
+ let a = r4["_" + i2];
39166
+ if (a && (Array.isArray(o) ? o = o.map((u2, l2) => a[l2] ? mr(u2 ?? {}, a[l2]) : u2) : o = mr(o ?? {}, a)), !S(o))
39167
+ return (s === "Element" || s === "BackboneElement") && (s = t.type[0].code), Array.isArray(o) ? o.map((u2) => dr(u2, s)) : dr(o, s);
39163
39168
  }
39164
- function ar(r4, e) {
39169
+ function dr(r4, e) {
39165
39170
  return e === "Resource" && _(r4) && (e = r4.resourceType), { type: e, value: r4 };
39166
39171
  }
39167
- function jn(r4, e) {
39172
+ function Gn(r4, e) {
39168
39173
  let t = r4.value;
39169
39174
  if (!t || typeof t != "object")
39170
39175
  return;
@@ -39173,13 +39178,13 @@ function jn(r4, e) {
39173
39178
  n = t[e];
39174
39179
  else
39175
39180
  for (let i2 in c) {
39176
- let o = e + A(i2);
39181
+ let o = e + C(i2);
39177
39182
  if (o in t) {
39178
39183
  n = t[o];
39179
39184
  break;
39180
39185
  }
39181
39186
  }
39182
- if (!E(n))
39187
+ if (!S(n))
39183
39188
  return Array.isArray(n) ? n.map(T) : T(n);
39184
39189
  }
39185
39190
  function Ce(r4) {
@@ -39187,7 +39192,7 @@ function Ce(r4) {
39187
39192
  for (let t of r4) {
39188
39193
  let n = false;
39189
39194
  for (let i2 of e)
39190
- if (B(dr(t, i2))) {
39195
+ if (B(hr(t, i2))) {
39191
39196
  n = true;
39192
39197
  break;
39193
39198
  }
@@ -39199,20 +39204,20 @@ function lt(r4) {
39199
39204
  return d(!B(r4));
39200
39205
  }
39201
39206
  function dt(r4, e) {
39202
- return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => B(dr(t, e[n]))));
39207
+ return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? d(false) : d(r4.every((t, n) => B(hr(t, e[n]))));
39203
39208
  }
39204
- function dr(r4, e) {
39209
+ function hr(r4, e) {
39205
39210
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39206
- return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : b(t) && b(n) ? d(pr(t, n)) : d(typeof t == "object" && typeof n == "object" ? ft(r4, e) : t === n);
39211
+ return typeof t == "number" && typeof n == "number" ? d(Math.abs(t - n) < 1e-8) : b(t) && b(n) ? d(yr(t, n)) : d(typeof t == "object" && typeof n == "object" ? ft(r4, e) : t === n);
39207
39212
  }
39208
39213
  function pt(r4, e) {
39209
- return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(cr), e.sort(cr), d(r4.every((t, n) => B(Qn(t, e[n])))));
39214
+ return r4.length === 0 && e.length === 0 ? d(true) : r4.length !== e.length ? d(false) : (r4.sort(pr), e.sort(pr), d(r4.every((t, n) => B(zn(t, e[n])))));
39210
39215
  }
39211
- function Qn(r4, e) {
39216
+ function zn(r4, e) {
39212
39217
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
39213
- return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : b(s) && b(a) ? d(pr(s, a)) : d(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? ft({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
39218
+ return typeof s == "number" && typeof a == "number" ? d(Math.abs(s - a) < 0.01) : b(s) && b(a) ? d(yr(s, a)) : d(t === "Coding" && i2 === "Coding" ? typeof s != "object" || typeof a != "object" ? false : s.code === a.code && s.system === a.system : typeof s == "object" && typeof a == "object" ? ft({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
39214
39219
  }
39215
- function cr(r4, e) {
39220
+ function pr(r4, e) {
39216
39221
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39217
39222
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
39218
39223
  }
@@ -39233,20 +39238,20 @@ function we(r4, e) {
39233
39238
  case "Time":
39234
39239
  return typeof t == "string" && !!/^T\d/.exec(t);
39235
39240
  case "Period":
39236
- return Hn(t);
39241
+ return Jn(t);
39237
39242
  case "Quantity":
39238
39243
  return b(t);
39239
39244
  default:
39240
39245
  return typeof t == "object" && t?.resourceType === e;
39241
39246
  }
39242
39247
  }
39243
- function Hn(r4) {
39248
+ function Jn(r4) {
39244
39249
  return !!(r4 && typeof r4 == "object" && "start" in r4);
39245
39250
  }
39246
39251
  function b(r4) {
39247
39252
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
39248
39253
  }
39249
- function pr(r4, e) {
39254
+ function yr(r4, e) {
39250
39255
  return Math.abs(r4.value - e.value) < 0.01 && (r4.unit === e.unit || r4.code === e.code || r4.unit === e.code || r4.code === e.unit);
39251
39256
  }
39252
39257
  function ft(r4, e) {
@@ -39255,7 +39260,7 @@ function ft(r4, e) {
39255
39260
  return false;
39256
39261
  for (let i2 of t) {
39257
39262
  let o = r4[i2], s = e[i2];
39258
- if (ur(o) && ur(s)) {
39263
+ if (fr(o) && fr(s)) {
39259
39264
  if (!ft(o, s))
39260
39265
  return false;
39261
39266
  } else if (o !== s)
@@ -39263,10 +39268,10 @@ function ft(r4, e) {
39263
39268
  }
39264
39269
  return true;
39265
39270
  }
39266
- function ur(r4) {
39271
+ function fr(r4) {
39267
39272
  return r4 !== null && typeof r4 == "object";
39268
39273
  }
39269
- function lr(r4, e) {
39274
+ function mr(r4, e) {
39270
39275
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
39271
39276
  }
39272
39277
  var mt = "ok";
@@ -39274,14 +39279,14 @@ var ke = "created";
39274
39279
  var yt = "not-modified";
39275
39280
  var gt = "not-found";
39276
39281
  var Oe = "accepted";
39277
- var yr = { resourceType: "OperationOutcome", id: gt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
39278
- function C(r4, e) {
39282
+ var vr = { resourceType: "OperationOutcome", id: gt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
39283
+ function w(r4, e) {
39279
39284
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
39280
39285
  }
39281
39286
  function h(r4) {
39282
39287
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "structure", details: { text: r4 } }] };
39283
39288
  }
39284
- function Ve(r4) {
39289
+ function De(r4) {
39285
39290
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
39286
39291
  }
39287
39292
  function xt(r4) {
@@ -39289,54 +39294,63 @@ function xt(r4) {
39289
39294
  }
39290
39295
  var p = class extends Error {
39291
39296
  constructor(t, n) {
39292
- super(gr(t));
39297
+ super(Er(t));
39293
39298
  this.outcome = t, this.cause = n;
39294
39299
  }
39295
39300
  };
39296
- function De(r4) {
39297
- return r4 instanceof p ? r4.outcome : Ve(r4) ? r4 : C(Kn(r4));
39301
+ function Ve(r4) {
39302
+ return r4 instanceof p ? r4.outcome : De(r4) ? r4 : w(Yn(r4));
39298
39303
  }
39299
- function Kn(r4) {
39300
- return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : Ve(r4) ? gr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
39304
+ function Yn(r4) {
39305
+ return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : De(r4) ? Er(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
39301
39306
  }
39302
- function gr(r4) {
39303
- let e = r4.issue?.map(Wn) ?? [];
39307
+ function Er(r4) {
39308
+ let e = r4.issue?.map(Xn) ?? [];
39304
39309
  return e.length > 0 ? e.join("; ") : "Unknown error";
39305
39310
  }
39306
- function Wn(r4) {
39311
+ function Xn(r4) {
39307
39312
  let e;
39308
39313
  return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
39309
39314
  }
39310
39315
  function bt(r4) {
39311
- return new St(r4).parse();
39316
+ return new Et(r4).parse();
39312
39317
  }
39313
- var H = or(sr);
39314
- function br(r4) {
39315
- let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
39316
- for (let t of e)
39317
- Gn(t);
39318
+ var ue = ur(lr);
39319
+ var Rt = /* @__PURE__ */ Object.create(null);
39320
+ var Rr = /* @__PURE__ */ Object.create(null);
39321
+ function Pt(r4) {
39322
+ let e;
39323
+ return r4 ? (e = Rr[r4], e || (e = Rr[r4] = /* @__PURE__ */ Object.create(null))) : e = ue, e;
39318
39324
  }
39319
- function Gn(r4) {
39325
+ function At(r4, e) {
39326
+ let t = Array.isArray(r4) ? r4 : r4.entry?.map((n) => n.resource) ?? [];
39327
+ for (let n of t)
39328
+ Zn(n, e);
39329
+ }
39330
+ function Zn(r4, e) {
39320
39331
  if (!r4?.name)
39321
39332
  throw new Error("Failed loading StructureDefinition from bundle");
39322
39333
  if (r4.resourceType !== "StructureDefinition")
39323
39334
  return;
39324
- let e = bt(r4);
39325
- H[r4.name] = e;
39326
- for (let t of e.innerTypes)
39327
- t.parentType = e, H[t.name] = t;
39335
+ let t = bt(r4), n = Pt(e);
39336
+ n[r4.name] = t, e && r4.url === e && (Rt[e] = t);
39337
+ for (let i2 of t.innerTypes)
39338
+ i2.parentType = t, n[i2.name] = i2;
39328
39339
  }
39329
- function Pr(r4) {
39330
- return !!H[r4];
39340
+ function Ir(r4) {
39341
+ return !!ue[r4];
39331
39342
  }
39332
- function Ar(r4) {
39333
- return H[r4];
39343
+ function kr(r4, e) {
39344
+ return Pt(e)[r4];
39334
39345
  }
39335
- var St = class {
39346
+ function Dr(r4) {
39347
+ return !!Rt[r4];
39348
+ }
39349
+ var Et = class {
39336
39350
  constructor(e) {
39337
39351
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
39338
39352
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
39339
- this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, url: e.url, kind: e.kind, description: Xn(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
39353
+ this.root = e.snapshot.element[0], this.elements = e.snapshot.element.slice(1), this.elementIndex = /* @__PURE__ */ Object.create(null), this.index = 0, this.resourceSchema = { name: e.name, title: e.title, type: e.type, url: e.url, kind: e.kind, description: ni(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
39340
39354
  }
39341
39355
  parse() {
39342
39356
  let e = this.next();
@@ -39373,26 +39387,26 @@ var St = class {
39373
39387
  this.isInnerType(e) && this.enterInnerType(e), e.slicing && !this.slicingContext && this.enterSlice(e, t);
39374
39388
  }
39375
39389
  enterInnerType(e) {
39376
- for (; this.backboneContext && !re(this.backboneContext?.path, e.path); )
39390
+ for (; this.backboneContext && !te(this.backboneContext?.path, e.path); )
39377
39391
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
39378
- this.backboneContext = { type: { name: Et(e), description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: re(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
39392
+ this.backboneContext = { type: { name: St(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: te(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
39379
39393
  }
39380
39394
  enterSlice(e, t) {
39381
- Yn(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
39395
+ ri(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
39382
39396
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
39383
39397
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
39384
39398
  return { path: n.path, type: n.type };
39385
39399
  }), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
39386
39400
  }
39387
39401
  checkFieldExit(e = void 0) {
39388
- if (this.backboneContext && !re(this.backboneContext.path, e?.path))
39402
+ if (this.backboneContext && !te(this.backboneContext.path, e?.path))
39389
39403
  if (this.backboneContext.parent)
39390
39404
  do
39391
39405
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
39392
- while (this.backboneContext && !re(this.backboneContext.path, e?.path));
39406
+ while (this.backboneContext && !te(this.backboneContext.path, e?.path));
39393
39407
  else
39394
39408
  this.innerTypes.push(this.backboneContext.type), delete this.backboneContext;
39395
- this.slicingContext && !re(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
39409
+ this.slicingContext && !te(this.slicingContext.path, e?.path) && (this.slicingContext?.current && this.slicingContext.field.slices.push(this.slicingContext.current), delete this.slicingContext);
39396
39410
  }
39397
39411
  next() {
39398
39412
  let e = this.peek();
@@ -39411,68 +39425,87 @@ var St = class {
39411
39425
  }
39412
39426
  isInnerType(e) {
39413
39427
  let t = this.peek();
39414
- return !!(re(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
39428
+ return !!(te(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
39415
39429
  }
39416
39430
  parseSliceStart(e) {
39417
39431
  if (!this.slicingContext)
39418
39432
  throw new Error("Invalid slice start before discriminator: " + e.sliceName);
39419
- this.slicingContext.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext.current = { name: e.sliceName ?? "", type: e.type?.map((t) => ({ code: t.code ?? "", targetProfile: t.targetProfile })), elements: {}, min: e.min ?? 0, max: e.max === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(e.max, 10) };
39433
+ this.slicingContext.current && this.slicingContext.field.slices.push(this.slicingContext.current), this.slicingContext.current = { name: e.sliceName ?? "", path: e.path ?? "", definition: e.definition, type: this.parseElementDefinitionType(e), elements: {}, min: e.min ?? 0, max: e.max === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(e.max, 10) };
39434
+ }
39435
+ parseElementDefinitionType(e) {
39436
+ return (e.type ?? []).map((t) => {
39437
+ let n;
39438
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = St(e)), n || (n = er(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
39439
+ });
39420
39440
  }
39421
39441
  parseElementDefinition(e) {
39422
- let t = Sr(e.max), n = e.base?.max ? Sr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
39423
- return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? Et(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Er(O(i2, "fixed")), pattern: Er(O(i2, "pattern")), binding: e.binding };
39442
+ let t = Ar(e.max), n = e.base?.max ? Ar(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
39443
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: this.parseElementDefinitionType(e), fixed: Cr(O(i2, "fixed[x]")), pattern: Cr(O(i2, "pattern[x]")), binding: e.binding };
39424
39444
  }
39425
39445
  };
39426
- function Sr(r4) {
39446
+ function Ar(r4) {
39427
39447
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
39428
39448
  }
39429
39449
  function vt(r4, e = "") {
39430
- return Jn(r4.path, e);
39450
+ return ti(r4.path, e);
39431
39451
  }
39432
- function Jn(r4, e) {
39452
+ function ti(r4, e) {
39433
39453
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
39434
39454
  }
39435
- function re(r4, e) {
39455
+ function te(r4, e) {
39436
39456
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
39437
39457
  }
39438
- function Er(r4) {
39439
- return Array.isArray(r4) && r4.length > 0 ? r4[0] : E(r4) ? void 0 : r4;
39458
+ function Cr(r4) {
39459
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : S(r4) ? void 0 : r4;
39440
39460
  }
39441
- function Yn(r4) {
39461
+ function ri(r4) {
39442
39462
  let e = r4.slicing?.discriminator;
39443
39463
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
39444
39464
  }
39445
- function Xn(r4) {
39465
+ function ni(r4) {
39446
39466
  let e = r4.description;
39447
39467
  return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
39448
39468
  }
39449
39469
  var c = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
39450
- function Pt(r4) {
39470
+ function wt(r4) {
39451
39471
  for (let e of r4.base ?? []) {
39452
- let t = V.types[e];
39453
- t || (t = { searchParamsDetails: {} }, V.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
39472
+ let t = D.types[e];
39473
+ t || (t = { searchParamsDetails: {} }, D.types[e] = t), t.searchParams || (t.searchParams = { _id: { base: [e], code: "_id", type: "token", expression: e + ".id" }, _lastUpdated: { base: [e], code: "_lastUpdated", type: "date", expression: e + ".meta.lastUpdated" }, _compartment: { base: [e], code: "_compartment", type: "reference", expression: e + ".meta.compartment" }, _profile: { base: [e], code: "_profile", type: "uri", expression: e + ".meta.profile" }, _security: { base: [e], code: "_security", type: "token", expression: e + ".meta.security" }, _source: { base: [e], code: "_source", type: "uri", expression: e + ".meta.source" }, _tag: { base: [e], code: "_tag", type: "token", expression: e + ".meta.tag" } }), t.searchParams[r4.code] = r4;
39454
39474
  }
39455
39475
  }
39456
- function Et(r4) {
39476
+ function St(r4) {
39457
39477
  let e = r4.type?.[0]?.code;
39458
- return e === "BackboneElement" || e === "Element" ? Zn((r4.base?.path ?? r4.path)?.split(".")) : e;
39478
+ return e === "BackboneElement" || e === "Element" ? ii((r4.base?.path ?? r4.path)?.split(".")) : e;
39459
39479
  }
39460
- function Zn(r4) {
39461
- return r4.length === 1 ? r4[0] : r4.map(A).join("");
39480
+ function ii(r4) {
39481
+ return r4.length === 1 ? r4[0] : r4.map(C).join("");
39462
39482
  }
39463
39483
  function Ie(r4, e) {
39464
- let t = Ar(r4);
39484
+ let t = kr(r4);
39465
39485
  if (t)
39466
- return t.elements[e] ?? t.elements[e + "[x]"];
39486
+ return ci(t.elements, e);
39487
+ }
39488
+ function ci(r4, e) {
39489
+ let t = r4[e] ?? r4[e + "[x]"];
39490
+ if (t)
39491
+ return t;
39492
+ for (let n = 0; n < e.length; n++) {
39493
+ let i2 = e[n];
39494
+ if (i2 >= "A" && i2 <= "Z") {
39495
+ let o = e.slice(0, n) + "[x]", s = r4[o];
39496
+ if (s)
39497
+ return s;
39498
+ }
39499
+ }
39467
39500
  }
39468
39501
  function _(r4) {
39469
39502
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
39470
39503
  }
39471
- function ue(r4) {
39504
+ function ce(r4) {
39472
39505
  return !!(r4 && typeof r4 == "object" && "reference" in r4);
39473
39506
  }
39474
- var V = { types: {} };
39475
- function ie(r4) {
39507
+ var D = { types: {} };
39508
+ function ne(r4) {
39476
39509
  if (r4.startsWith("T"))
39477
39510
  return r4 + "T00:00:00.000Z".substring(r4.length);
39478
39511
  if (r4.length <= 10)
@@ -39484,7 +39517,7 @@ function ie(r4) {
39484
39517
  }
39485
39518
  }
39486
39519
  var le = () => [];
39487
- var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => B(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => B(t.eval(r4, [n])))), allTrue: (r4, e) => {
39520
+ var E = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.filter((n) => B(t.eval(r4, [n]))).length > 0) : d(e.length > 0), all: (r4, e, t) => d(e.every((n) => B(t.eval(r4, [n])))), allTrue: (r4, e) => {
39488
39521
  for (let t of e)
39489
39522
  if (!t.value)
39490
39523
  return d(false);
@@ -39509,7 +39542,7 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
39509
39542
  for (let n of e)
39510
39543
  t.some((i2) => i2.value === n.value) || t.push(n);
39511
39544
  return t;
39512
- }, isDistinct: (r4, e) => d(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => B(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: le, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
39545
+ }, isDistinct: (r4, e) => d(e.length === E.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => B(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: le, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
39513
39546
  if (e.length > 1)
39514
39547
  throw new Error("Expected input length one for single()");
39515
39548
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -39555,7 +39588,7 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
39555
39588
  }, toBoolean: (r4, e) => {
39556
39589
  if (e.length === 0)
39557
39590
  return [];
39558
- let [{ value: t }] = L(e, 1);
39591
+ let [{ value: t }] = U(e, 1);
39559
39592
  if (typeof t == "boolean")
39560
39593
  return [{ type: c.boolean, value: t }];
39561
39594
  if (typeof t == "number" && (t === 0 || t === 1))
@@ -39568,65 +39601,65 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
39568
39601
  return d(false);
39569
39602
  }
39570
39603
  return [];
39571
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
39604
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : d(E.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
39572
39605
  if (e.length === 0)
39573
39606
  return [];
39574
- let [{ value: t }] = L(e, 1);
39607
+ let [{ value: t }] = U(e, 1);
39575
39608
  return typeof t == "number" ? [{ type: c.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: c.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: c.integer, value: t ? 1 : 0 }] : [];
39576
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
39609
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : d(E.toInteger(r4, e).length === 1), toDate: (r4, e) => {
39577
39610
  if (e.length === 0)
39578
39611
  return [];
39579
- let [{ value: t }] = L(e, 1);
39580
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.date, value: ie(t) }] : [];
39581
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
39612
+ let [{ value: t }] = U(e, 1);
39613
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.date, value: ne(t) }] : [];
39614
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : d(E.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
39582
39615
  if (e.length === 0)
39583
39616
  return [];
39584
- let [{ value: t }] = L(e, 1);
39585
- return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.dateTime, value: ie(t) }] : [];
39586
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
39617
+ let [{ value: t }] = U(e, 1);
39618
+ return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: c.dateTime, value: ne(t) }] : [];
39619
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : d(E.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
39587
39620
  if (e.length === 0)
39588
39621
  return [];
39589
- let [{ value: t }] = L(e, 1);
39622
+ let [{ value: t }] = U(e, 1);
39590
39623
  return typeof t == "number" ? [{ type: c.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: c.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: c.decimal, value: t ? 1 : 0 }] : [];
39591
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
39624
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : d(E.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
39592
39625
  if (e.length === 0)
39593
39626
  return [];
39594
- let [{ value: t }] = L(e, 1);
39627
+ let [{ value: t }] = U(e, 1);
39595
39628
  return b(t) ? [{ type: c.Quantity, value: t }] : typeof t == "number" ? [{ type: c.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: c.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: c.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
39596
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
39629
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : d(E.toQuantity(r4, e).length === 1), toString: (r4, e) => {
39597
39630
  if (e.length === 0)
39598
39631
  return [];
39599
- let [{ value: t }] = L(e, 1);
39632
+ let [{ value: t }] = U(e, 1);
39600
39633
  return t == null ? [] : b(t) ? [{ type: c.string, value: `${t.value} '${t.unit}'` }] : [{ type: c.string, value: t.toString() }];
39601
- }, convertsToString: (r4, e) => e.length === 0 ? [] : d(S.toString(r4, e).length === 1), toTime: (r4, e) => {
39634
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : d(E.toString(r4, e).length === 1), toTime: (r4, e) => {
39602
39635
  if (e.length === 0)
39603
39636
  return [];
39604
- let [{ value: t }] = L(e, 1);
39637
+ let [{ value: t }] = U(e, 1);
39605
39638
  if (typeof t == "string") {
39606
39639
  let n = /^T?(\d{2}(:\d{2}(:\d{2})?)?)/.exec(t);
39607
39640
  if (n)
39608
- return [{ type: c.time, value: ie("T" + n[1]) }];
39641
+ return [{ type: c.time, value: ne("T" + n[1]) }];
39609
39642
  }
39610
39643
  return [];
39611
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : d(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => w((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => w((i2, o, s) => {
39644
+ }, convertsToTime: (r4, e) => e.length === 0 ? [] : d(E.toTime(r4, e).length === 1), indexOf: (r4, e, t) => I((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => I((i2, o, s) => {
39612
39645
  let a = o, u2 = s ? a + s : i2.length;
39613
39646
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, u2);
39614
- }, r4, e, t, n), startsWith: (r4, e, t) => w((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => w((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => w((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => w((t) => t.toUpperCase(), r4, e), lower: (r4, e) => w((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => w((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => w((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => w((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => w((t) => t.length, r4, e), toChars: (r4, e) => w((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => U(Math.abs, r4, e), ceiling: (r4, e) => U(Math.ceil, r4, e), exp: (r4, e) => U(Math.exp, r4, e), floor: (r4, e) => U(Math.floor, r4, e), ln: (r4, e) => U(Math.log, r4, e), log: (r4, e, t) => U((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => U(Math.pow, r4, e, t), round: (r4, e) => U(Math.round, r4, e), sqrt: (r4, e) => U(Math.sqrt, r4, e), truncate: (r4, e) => U((t) => t | 0, r4, e), children: le, descendants: le, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: c.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: c.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: c.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
39615
- let o = S.toDateTime(r4, t.eval(r4, e));
39647
+ }, r4, e, t, n), startsWith: (r4, e, t) => I((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => I((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => I((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => I((t) => t.toUpperCase(), r4, e), lower: (r4, e) => I((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => I((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => I((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => I((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => I((t) => t.length, r4, e), toChars: (r4, e) => I((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => L(Math.abs, r4, e), ceiling: (r4, e) => L(Math.ceil, r4, e), exp: (r4, e) => L(Math.exp, r4, e), floor: (r4, e) => L(Math.floor, r4, e), ln: (r4, e) => L(Math.log, r4, e), log: (r4, e, t) => L((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => L(Math.pow, r4, e, t), round: (r4, e) => L(Math.round, r4, e), sqrt: (r4, e) => L(Math.sqrt, r4, e), truncate: (r4, e) => L((t) => t | 0, r4, e), children: le, descendants: le, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: c.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: c.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: c.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
39648
+ let o = E.toDateTime(r4, t.eval(r4, e));
39616
39649
  if (o.length === 0)
39617
39650
  throw new Error("Invalid start date");
39618
- let s = S.toDateTime(r4, n.eval(r4, e));
39651
+ let s = E.toDateTime(r4, n.eval(r4, e));
39619
39652
  if (s.length === 0)
39620
39653
  throw new Error("Invalid end date");
39621
39654
  let a = i2.eval(r4, e)[0]?.value;
39622
39655
  if (a !== "years" && a !== "months" && a !== "days")
39623
39656
  throw new Error("Invalid units");
39624
- let u2 = Se(o[0].value, s[0].value);
39657
+ let u2 = Ee(o[0].value, s[0].value);
39625
39658
  return [{ type: c.Quantity, value: { value: u2[a], unit: a } }];
39626
39659
  }, is: (r4, e, t) => {
39627
39660
  let n = "";
39628
- return t instanceof q ? n = t.name : t instanceof K && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: c.boolean, value: we(i2, n) })) : [];
39629
- }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: c.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
39661
+ return t instanceof q ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: c.boolean, value: we(i2, n) })) : [];
39662
+ }, not: (r4, e) => E.toBoolean(r4, e).map((t) => ({ type: c.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
39630
39663
  let n = t.value, i2;
39631
39664
  if (typeof n == "string")
39632
39665
  i2 = n;
@@ -39652,25 +39685,25 @@ var S = { empty: (r4, e) => d(e.length === 0), exists: (r4, e, t) => t ? d(e.fil
39652
39685
  let i2 = n.replace("http://hl7.org/fhir/StructureDefinition/", "");
39653
39686
  return e.map((o) => ({ type: c.boolean, value: o.value?.resourceType === i2 }));
39654
39687
  } };
39655
- function w(r4, e, t, ...n) {
39688
+ function I(r4, e, t, ...n) {
39656
39689
  if (t.length === 0)
39657
39690
  return [];
39658
- let [{ value: i2 }] = L(t, 1);
39691
+ let [{ value: i2 }] = U(t, 1);
39659
39692
  if (typeof i2 != "string")
39660
39693
  throw new Error("String function cannot be called with non-string");
39661
39694
  let o = r4(i2, ...n.map((s) => s?.eval(e, t)[0]?.value));
39662
39695
  return o === void 0 ? [] : Array.isArray(o) ? o.map(T) : [T(o)];
39663
39696
  }
39664
- function U(r4, e, t, ...n) {
39697
+ function L(r4, e, t, ...n) {
39665
39698
  if (t.length === 0)
39666
39699
  return [];
39667
- let [{ value: i2 }] = L(t, 1), o = b(i2), s = o ? i2.value : i2;
39700
+ let [{ value: i2 }] = U(t, 1), o = b(i2), s = o ? i2.value : i2;
39668
39701
  if (typeof s != "number")
39669
39702
  throw new Error("Math function cannot be called with non-number");
39670
39703
  let a = r4(s, ...n.map((f) => f.eval(e, t)[0]?.value)), u2 = o ? c.Quantity : t[0].type, l2 = o ? { ...i2, value: a } : a;
39671
39704
  return [{ type: u2, value: l2 }];
39672
39705
  }
39673
- function L(r4, e) {
39706
+ function U(r4, e) {
39674
39707
  if (r4.length !== e)
39675
39708
  throw new Error(`Expected ${e} arguments`);
39676
39709
  for (let t of r4)
@@ -39678,7 +39711,7 @@ function L(r4, e) {
39678
39711
  throw new Error("Expected non-null argument");
39679
39712
  return r4;
39680
39713
  }
39681
- var D = class {
39714
+ var V = class {
39682
39715
  constructor(e) {
39683
39716
  this.value = e;
39684
39717
  }
@@ -39734,15 +39767,15 @@ var _e = class extends Te {
39734
39767
  return this.operator + this.child.toString();
39735
39768
  }
39736
39769
  };
39737
- var Y = class extends j {
39770
+ var J = class extends $ {
39738
39771
  constructor(e, t) {
39739
39772
  super("as", e, t);
39740
39773
  }
39741
39774
  eval(e, t) {
39742
- return S.ofType(e, this.left.eval(e, t), this.right);
39775
+ return E.ofType(e, this.left.eval(e, t), this.right);
39743
39776
  }
39744
39777
  };
39745
- var v = class extends j {
39778
+ var v = class extends $ {
39746
39779
  };
39747
39780
  var R = class extends v {
39748
39781
  constructor(t, n, i2, o) {
@@ -39760,7 +39793,7 @@ var R = class extends v {
39760
39793
  return typeof f == "boolean" ? d(f) : b(s) ? [{ type: c.Quantity, value: { ...s, value: f } }] : [T(f)];
39761
39794
  }
39762
39795
  };
39763
- var Ue = class extends j {
39796
+ var Le = class extends $ {
39764
39797
  constructor(e, t) {
39765
39798
  super("&", e, t);
39766
39799
  }
@@ -39769,7 +39802,7 @@ var Ue = class extends j {
39769
39802
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: c.string, value: o.map((s) => s.value).join("") }] : o;
39770
39803
  }
39771
39804
  };
39772
- var Le = class extends v {
39805
+ var Ue = class extends v {
39773
39806
  constructor(e, t) {
39774
39807
  super("contains", e, t);
39775
39808
  }
@@ -39787,7 +39820,7 @@ var Me = class extends v {
39787
39820
  return n ? d(i2.some((o) => o.value === n.value)) : [];
39788
39821
  }
39789
39822
  };
39790
- var K = class extends j {
39823
+ var H = class extends $ {
39791
39824
  constructor(e, t) {
39792
39825
  super(".", e, t);
39793
39826
  }
@@ -39798,7 +39831,7 @@ var K = class extends j {
39798
39831
  return `${this.left.toString()}.${this.right.toString()}`;
39799
39832
  }
39800
39833
  };
39801
- var oe = class extends j {
39834
+ var ie = class extends $ {
39802
39835
  constructor(e, t) {
39803
39836
  super("|", e, t);
39804
39837
  }
@@ -39825,7 +39858,7 @@ var qe = class extends v {
39825
39858
  return lt(dt(n, i2));
39826
39859
  }
39827
39860
  };
39828
- var $e = class extends v {
39861
+ var je = class extends v {
39829
39862
  constructor(e, t) {
39830
39863
  super("~", e, t);
39831
39864
  }
@@ -39834,7 +39867,7 @@ var $e = class extends v {
39834
39867
  return pt(n, i2);
39835
39868
  }
39836
39869
  };
39837
- var je = class extends v {
39870
+ var $e = class extends v {
39838
39871
  constructor(e, t) {
39839
39872
  super("!~", e, t);
39840
39873
  }
@@ -39843,7 +39876,7 @@ var je = class extends v {
39843
39876
  return lt(pt(n, i2));
39844
39877
  }
39845
39878
  };
39846
- var X = class extends v {
39879
+ var Y = class extends v {
39847
39880
  constructor(e, t) {
39848
39881
  super("is", e, t);
39849
39882
  }
@@ -39891,13 +39924,13 @@ var We = class extends v {
39891
39924
  return i2?.value === true || n?.value === false ? d(true) : !n || !i2 ? [] : d(false);
39892
39925
  }
39893
39926
  };
39894
- var $ = class {
39927
+ var j = class {
39895
39928
  constructor(e, t) {
39896
39929
  this.name = e;
39897
39930
  this.args = t;
39898
39931
  }
39899
39932
  eval(e, t) {
39900
- let n = S[this.name];
39933
+ let n = E[this.name];
39901
39934
  if (!n)
39902
39935
  throw new Error("Unrecognized function: " + this.name);
39903
39936
  return n(e, t, ...this.args);
@@ -39906,7 +39939,7 @@ var $ = class {
39906
39939
  return `${this.name}(${this.args.map((e) => e.toString()).join(", ")})`;
39907
39940
  }
39908
39941
  };
39909
- var Z = class {
39942
+ var X = class {
39910
39943
  constructor(e, t) {
39911
39944
  this.left = e;
39912
39945
  this.expr = t;
@@ -39927,56 +39960,56 @@ var Z = class {
39927
39960
  };
39928
39961
  var pe = ["!=", "!~", "<=", ">=", "{}", "->"];
39929
39962
  var m = { FunctionCall: 0, Dot: 1, Indexer: 2, UnaryAdd: 3, UnarySubtract: 3, Multiply: 4, Divide: 4, IntegerDivide: 4, Modulo: 4, Add: 5, Subtract: 5, Ampersand: 5, Is: 6, As: 6, Union: 7, GreaterThan: 8, GreaterThanOrEquals: 8, LessThan: 8, LessThanOrEquals: 8, Equals: 9, Equivalent: 9, NotEquals: 9, NotEquivalent: 9, In: 10, Contains: 10, And: 11, Xor: 12, Or: 12, Implies: 13, Arrow: 100, Semicolon: 200 };
39930
- var ii = { parse(r4) {
39963
+ var di = { parse(r4) {
39931
39964
  let e = r4.consumeAndParse();
39932
39965
  if (!r4.match(")"))
39933
39966
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
39934
39967
  return e;
39935
39968
  } };
39936
- var oi = { parse(r4, e) {
39969
+ var pi = { parse(r4, e) {
39937
39970
  let t = r4.consumeAndParse();
39938
39971
  if (!r4.match("]"))
39939
39972
  throw new Error("Parse error: expected `]`");
39940
- return new Z(e, t);
39973
+ return new X(e, t);
39941
39974
  }, precedence: m.Indexer };
39942
- var si = { parse(r4, e) {
39975
+ var fi = { parse(r4, e) {
39943
39976
  if (!(e instanceof q))
39944
39977
  throw new Error("Unexpected parentheses");
39945
39978
  let t = [];
39946
39979
  for (; !r4.match(")"); )
39947
39980
  t.push(r4.consumeAndParse()), r4.match(",");
39948
- return new $(e.name, t);
39981
+ return new j(e.name, t);
39949
39982
  }, precedence: m.FunctionCall };
39950
- function ai(r4) {
39983
+ function mi(r4) {
39951
39984
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
39952
39985
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
39953
39986
  }
39954
39987
  function fe() {
39955
- return new ve().registerPrefix("String", { parse: (r4, e) => new D({ type: c.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new D({ type: c.dateTime, value: ie(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new D({ type: c.Quantity, value: ai(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new D({ type: c.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new D({ type: c.boolean, value: true }) }).registerPrefix("false", { parse: () => new D({ type: c.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new q(e.value) }).registerPrefix("{}", { parse: () => new Fe() }).registerPrefix("(", ii).registerInfix("[", oi).registerInfix("(", si).prefix("+", m.UnaryAdd, (r4, e) => new _e("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new R("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new K(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new R("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new R("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new R("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new R("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new oe(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Be(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new qe(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new $e(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new je(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new R("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new R("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new R(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new R(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Ue(r4, t)).infixLeft("and", m.And, (r4, e, t) => new Qe(r4, t)).infixLeft("as", m.As, (r4, e, t) => new Y(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new Le(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new R("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Me(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new X(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new R("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new He(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Ke(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new We(r4, t));
39988
+ return new ve().registerPrefix("String", { parse: (r4, e) => new V({ type: c.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new V({ type: c.dateTime, value: ne(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new V({ type: c.Quantity, value: mi(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new V({ type: c.decimal, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new V({ type: c.boolean, value: true }) }).registerPrefix("false", { parse: () => new V({ type: c.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new q(e.value) }).registerPrefix("{}", { parse: () => new Fe() }).registerPrefix("(", di).registerInfix("[", pi).registerInfix("(", fi).prefix("+", m.UnaryAdd, (r4, e) => new _e("+", e, (t) => t)).prefix("-", m.UnarySubtract, (r4, e) => new R("-", e, e, (t, n) => -n)).infixLeft(".", m.Dot, (r4, e, t) => new H(r4, t)).infixLeft("/", m.Divide, (r4, e, t) => new R("/", r4, t, (n, i2) => n / i2)).infixLeft("*", m.Multiply, (r4, e, t) => new R("*", r4, t, (n, i2) => n * i2)).infixLeft("+", m.Add, (r4, e, t) => new R("+", r4, t, (n, i2) => n + i2)).infixLeft("-", m.Subtract, (r4, e, t) => new R("-", r4, t, (n, i2) => n - i2)).infixLeft("|", m.Union, (r4, e, t) => new ie(r4, t)).infixLeft("=", m.Equals, (r4, e, t) => new Be(r4, t)).infixLeft("!=", m.NotEquals, (r4, e, t) => new qe(r4, t)).infixLeft("~", m.Equivalent, (r4, e, t) => new je(r4, t)).infixLeft("!~", m.NotEquivalent, (r4, e, t) => new $e(r4, t)).infixLeft("<", m.LessThan, (r4, e, t) => new R("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", m.LessThanOrEquals, (r4, e, t) => new R("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", m.GreaterThan, (r4, e, t) => new R(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", m.GreaterThanOrEquals, (r4, e, t) => new R(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", m.Ampersand, (r4, e, t) => new Le(r4, t)).infixLeft("and", m.And, (r4, e, t) => new Qe(r4, t)).infixLeft("as", m.As, (r4, e, t) => new J(r4, t)).infixLeft("contains", m.Contains, (r4, e, t) => new Ue(r4, t)).infixLeft("div", m.Divide, (r4, e, t) => new R("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", m.In, (r4, e, t) => new Me(r4, t)).infixLeft("is", m.Is, (r4, e, t) => new Y(r4, t)).infixLeft("mod", m.Modulo, (r4, e, t) => new R("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", m.Or, (r4, e, t) => new He(r4, t)).infixLeft("xor", m.Xor, (r4, e, t) => new Ke(r4, t)).infixLeft("implies", m.Implies, (r4, e, t) => new We(r4, t));
39956
39989
  }
39957
- var ci = fe();
39958
- var Or = ((f) => (f.BOOLEAN = "BOOLEAN", f.NUMBER = "NUMBER", f.QUANTITY = "QUANTITY", f.TEXT = "TEXT", f.REFERENCE = "REFERENCE", f.CANONICAL = "CANONICAL", f.DATE = "DATE", f.DATETIME = "DATETIME", f.PERIOD = "PERIOD", f.UUID = "UUID", f))(Or || {});
39959
- var hi = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(hi || {});
39960
- var _i = ((x) => (x.READ = "read", x.VREAD = "vread", x.UPDATE = "update", x.PATCH = "patch", x.DELETE = "delete", x.HISTORY = "history", x.HISTORY_INSTANCE = "history-instance", x.HISTORY_TYPE = "history-type", x.HISTORY_SYSTEM = "history-system", x.CREATE = "create", x.SEARCH = "search", x.SEARCH_TYPE = "search-type", x.SEARCH_SYSTEM = "search-system", x.SEARCH_COMPARTMENT = "search-compartment", x.CAPABILITIES = "capabilities", x.TRANSACTION = "transaction", x.BATCH = "batch", x.OPERATION = "operation", x))(_i || {});
39961
- function jr(r4) {
39990
+ var hi = fe();
39991
+ var _r = ((f) => (f.BOOLEAN = "BOOLEAN", f.NUMBER = "NUMBER", f.QUANTITY = "QUANTITY", f.TEXT = "TEXT", f.REFERENCE = "REFERENCE", f.CANONICAL = "CANONICAL", f.DATE = "DATE", f.DATETIME = "DATETIME", f.PERIOD = "PERIOD", f.UUID = "UUID", f))(_r || {});
39992
+ var Si = ((g2) => (g2.EQUALS = "eq", g2.NOT_EQUALS = "ne", g2.GREATER_THAN = "gt", g2.LESS_THAN = "lt", g2.GREATER_THAN_OR_EQUALS = "ge", g2.LESS_THAN_OR_EQUALS = "le", g2.STARTS_AFTER = "sa", g2.ENDS_BEFORE = "eb", g2.APPROXIMATELY = "ap", g2.CONTAINS = "contains", g2.EXACT = "exact", g2.TEXT = "text", g2.NOT = "not", g2.ABOVE = "above", g2.BELOW = "below", g2.IN = "in", g2.NOT_IN = "not-in", g2.OF_TYPE = "of-type", g2.MISSING = "missing", g2.IDENTIFIER = "identifier", g2.ITERATE = "iterate", g2))(Si || {});
39993
+ var $i = ((x) => (x.READ = "read", x.VREAD = "vread", x.UPDATE = "update", x.PATCH = "patch", x.DELETE = "delete", x.HISTORY = "history", x.HISTORY_INSTANCE = "history-instance", x.HISTORY_TYPE = "history-type", x.HISTORY_SYSTEM = "history-system", x.CREATE = "create", x.SEARCH = "search", x.SEARCH_TYPE = "search-type", x.SEARCH_SYSTEM = "search-system", x.SEARCH_COMPARTMENT = "search-compartment", x.CAPABILITIES = "capabilities", x.TRANSACTION = "transaction", x.BATCH = "batch", x.OPERATION = "operation", x))($i || {});
39994
+ function Gr(r4) {
39962
39995
  if (typeof window < "u")
39963
39996
  return window.atob(r4);
39964
39997
  if (typeof Buffer < "u")
39965
39998
  return Buffer.from(r4, "base64").toString("binary");
39966
39999
  throw new Error("Unable to decode base64");
39967
40000
  }
39968
- function Qr(r4) {
40001
+ function zr(r4) {
39969
40002
  if (typeof window < "u")
39970
40003
  return window.btoa(r4);
39971
40004
  if (typeof Buffer < "u")
39972
40005
  return Buffer.from(r4, "binary").toString("base64");
39973
40006
  throw new Error("Unable to encode base64");
39974
40007
  }
39975
- function Dt() {
40008
+ function _t() {
39976
40009
  let r4 = new Uint32Array(28);
39977
- return crypto.getRandomValues(r4), er(r4.buffer);
40010
+ return crypto.getRandomValues(r4), ir(r4.buffer);
39978
40011
  }
39979
- async function Hr(r4) {
40012
+ async function Jr(r4) {
39980
40013
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
39981
40014
  }
39982
40015
  function ye() {
@@ -40009,7 +40042,7 @@ var ze = class {
40009
40042
  return this.cache.keys().next().value;
40010
40043
  }
40011
40044
  };
40012
- var I = { CSS: "text/css", DICOM: "application/dicom", FAVICON: "image/vnd.microsoft.icon", FHIR_JSON: "application/fhir+json", FORM_URL_ENCODED: "application/x-www-form-urlencoded", HL7_V2: "x-application/hl7-v2+er7", HTML: "text/html", JAVASCRIPT: "text/javascript", JSON: "application/json", JSON_PATCH: "application/json-patch+json", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
40045
+ 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", PNG: "image/png", SVG: "image/svg+xml", TEXT: "text/plain", TYPESCRIPT: "text/typescript" };
40013
40046
  var ge = class {
40014
40047
  constructor() {
40015
40048
  this.listeners = {};
@@ -40049,28 +40082,28 @@ var Je = class {
40049
40082
  this.emitter.removeEventListener(e, t);
40050
40083
  }
40051
40084
  };
40052
- var Nt = { "Patient-open": "Patient-open", "Patient-close": "Patient-close", "ImagingStudy-open": "ImagingStudy-open", "ImagingStudy-close": "ImagingStudy-close", "Encounter-open": "Encounter-open", "Encounter-close": "Encounter-close", "DiagnosticReport-open": "DiagnosticReport-open", "DiagnosticReport-close": "DiagnosticReport-close", "DiagnosticReport-select": "DiagnosticReport-select", "DiagnosticReport-update": "DiagnosticReport-update", syncerror: "syncerror" };
40053
- var Hi = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
40054
- var Ft = ["DiagnosticReport-update"];
40055
- function Gr(r4) {
40056
- return Ft.includes(r4);
40085
+ var Lt = { "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" };
40086
+ var Xi = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
40087
+ var Ut = ["DiagnosticReport-update"];
40088
+ function Zr(r4) {
40089
+ return Ut.includes(r4);
40057
40090
  }
40058
- function zr(r4) {
40059
- if (Ft.includes(r4))
40091
+ function en(r4) {
40092
+ if (Ut.includes(r4))
40060
40093
  throw new p(h(`'context.version' is required for '${r4}'.`));
40061
40094
  }
40062
- var Ki = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
40063
- function Wi(r4) {
40064
- return Hi.includes(r4);
40095
+ var Zi = { "Patient-open": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "Patient-close": { patient: { resourceType: "Patient" }, encounter: { resourceType: "Encounter", optional: true } }, "ImagingStudy-open": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "ImagingStudy-close": { study: { resourceType: "ImagingStudy" }, encounter: { resourceType: "Encounter", optional: true }, patient: { resourceType: "Patient", optional: true } }, "Encounter-open": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "Encounter-close": { encounter: { resourceType: "Encounter" }, patient: { resourceType: "Patient" } }, "DiagnosticReport-open": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-close": { report: { resourceType: "DiagnosticReport" }, encounter: { resourceType: "Encounter", optional: true }, study: { resourceType: "ImagingStudy", optional: true, manyAllowed: true }, patient: { resourceType: "Patient" } }, "DiagnosticReport-select": { report: { resourceType: "DiagnosticReport" }, select: { resourceType: "*", isArray: true } }, "DiagnosticReport-update": { report: { resourceType: "DiagnosticReport" }, patient: { resourceType: "Patient", optional: true }, study: { resourceType: "ImagingStudy", optional: true }, updates: { resourceType: "Bundle" } }, syncerror: { operationoutcome: { resourceType: "OperationOutcome" } } };
40096
+ function eo(r4) {
40097
+ return Xi.includes(r4);
40065
40098
  }
40066
- function Jr(r4) {
40099
+ function tn(r4) {
40067
40100
  return !!r4.endpoint;
40068
40101
  }
40069
- function _t(r4) {
40102
+ function Mt(r4) {
40070
40103
  if (!Xe(r4))
40071
40104
  throw new p(h("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
40072
40105
  let { channelType: e, mode: t, topic: n, events: i2 } = r4, o = { "hub.channel.type": e, "hub.mode": t, "hub.topic": n, "hub.events": i2.join(",") };
40073
- return Jr(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
40106
+ return tn(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
40074
40107
  }
40075
40108
  function Xe(r4) {
40076
40109
  if (typeof r4 != "object")
@@ -40079,11 +40112,11 @@ function Xe(r4) {
40079
40112
  if (!(e && t && n && i2) || typeof n != "string" || typeof i2 != "object" || !Array.isArray(i2) || i2.length < 1 || e !== "websocket" || t !== "subscribe" && t !== "unsubscribe")
40080
40113
  return false;
40081
40114
  for (let o of i2)
40082
- if (!Nt[o])
40115
+ if (!Lt[o])
40083
40116
  return false;
40084
- return !(Jr(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
40117
+ return !(tn(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
40085
40118
  }
40086
- function Wr(r4, e, t, n) {
40119
+ function Xr(r4, e, t, n) {
40087
40120
  if (typeof e != "object")
40088
40121
  throw new p(h(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
40089
40122
  if (!(e.id && typeof e.id == "string"))
@@ -40092,30 +40125,30 @@ function Wr(r4, e, t, n) {
40092
40125
  throw new p(h(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
40093
40126
  let i2 = n.resourceType;
40094
40127
  if (i2 !== "*") {
40095
- if (!Wi(e.resourceType))
40128
+ if (!eo(e.resourceType))
40096
40129
  throw new p(h(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
40097
40130
  if (i2 && e.resourceType !== i2)
40098
40131
  throw new p(h(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
40099
40132
  }
40100
40133
  }
40101
- function Gi(r4, e, t, n, i2) {
40134
+ function to(r4, e, t, n, i2) {
40102
40135
  if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), !n.isArray)
40103
- Wr(r4, e.resource, t, n);
40136
+ Xr(r4, e.resource, t, n);
40104
40137
  else {
40105
40138
  let { resources: o } = e;
40106
40139
  if (!o)
40107
40140
  throw new p(h(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
40108
40141
  for (let s of o)
40109
- Wr(r4, s, t, n);
40142
+ Xr(r4, s, t, n);
40110
40143
  }
40111
40144
  }
40112
- function zi(r4, e) {
40113
- let t = /* @__PURE__ */ new Map(), n = Ki[r4];
40145
+ function ro(r4, e) {
40146
+ let t = /* @__PURE__ */ new Map(), n = Zi[r4];
40114
40147
  for (let i2 = 0; i2 < e.length; i2++) {
40115
40148
  let o = e[i2].key;
40116
40149
  if (!n[o])
40117
40150
  throw new p(h(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
40118
- Gi(r4, e[i2], i2, n[o], t);
40151
+ to(r4, e[i2], i2, n[o], t);
40119
40152
  }
40120
40153
  for (let [i2, o] of Object.entries(n)) {
40121
40154
  if (!(o.optional || t.has(i2)))
@@ -40124,17 +40157,17 @@ function zi(r4, e) {
40124
40157
  throw new p(h(`${t.get(i2)} context entries with key '${i2}' found for the '${r4}' event when schema only allows for 1.`));
40125
40158
  }
40126
40159
  }
40127
- function Ut(r4, e, t, n) {
40160
+ function Bt(r4, e, t, n) {
40128
40161
  if (!(r4 && typeof r4 == "string"))
40129
40162
  throw new p(h("Must provide a topic."));
40130
- if (!Nt[e])
40131
- throw new p(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Nt).join(", ")}`));
40163
+ if (!Lt[e])
40164
+ throw new p(h(`Must provide a valid FHIRcast event name. Supported events: ${Object.keys(Lt).join(", ")}`));
40132
40165
  if (typeof t != "object")
40133
40166
  throw new p(h("context must be a context object or array of context objects."));
40134
- if (Ft.includes(e) && !n)
40167
+ if (Ut.includes(e) && !n)
40135
40168
  throw new p(h(`The '${e}' event must contain a 'context.versionId'.`));
40136
40169
  let i2 = Array.isArray(t) ? t : [t];
40137
- return zi(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ye(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
40170
+ return ro(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ye(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
40138
40171
  }
40139
40172
  var Ye = class extends Je {
40140
40173
  constructor(t) {
@@ -40160,31 +40193,31 @@ var Ye = class extends Je {
40160
40193
  this.websocket.close();
40161
40194
  }
40162
40195
  };
40163
- function Ji(r4) {
40164
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = jr(e), n = Array.from(t).reduce((o, s) => {
40196
+ function no(r4) {
40197
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = Gr(e), n = Array.from(t).reduce((o, s) => {
40165
40198
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
40166
40199
  return `${o}%${a}`;
40167
40200
  }, ""), i2 = decodeURIComponent(n);
40168
40201
  return JSON.parse(i2);
40169
40202
  }
40170
- function Yr(r4) {
40203
+ function rn(r4) {
40171
40204
  return r4.split(".").length === 3;
40172
40205
  }
40173
- function Lt(r4) {
40206
+ function qt(r4) {
40174
40207
  let [e, t, n] = r4.split(".");
40175
- return Ji(t);
40208
+ return no(t);
40176
40209
  }
40177
- function Xr(r4) {
40210
+ function nn(r4) {
40178
40211
  try {
40179
- return typeof Lt(r4).login_id == "string";
40212
+ return typeof qt(r4).login_id == "string";
40180
40213
  } catch {
40181
40214
  return false;
40182
40215
  }
40183
40216
  }
40184
- var Yi;
40185
- var k = class {
40217
+ var io;
40218
+ var A = class {
40186
40219
  constructor(e) {
40187
- this[Yi] = "ReadablePromise";
40220
+ this[io] = "ReadablePromise";
40188
40221
  this.status = "pending";
40189
40222
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
40190
40223
  throw this.status = "error", this.error = t, t;
@@ -40216,10 +40249,10 @@ var k = class {
40216
40249
  return this.suspender.finally(e);
40217
40250
  }
40218
40251
  };
40219
- Yi = Symbol.toStringTag;
40252
+ io = Symbol.toStringTag;
40220
40253
  var Ze = class {
40221
40254
  constructor(e) {
40222
- this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Mt());
40255
+ this.storage = e ?? (typeof localStorage < "u" ? localStorage : new jt());
40223
40256
  }
40224
40257
  clear() {
40225
40258
  this.storage.clear();
@@ -40235,10 +40268,10 @@ var Ze = class {
40235
40268
  return t ? JSON.parse(t) : void 0;
40236
40269
  }
40237
40270
  setObject(e, t) {
40238
- this.setString(e, t ? Yt(t) : void 0);
40271
+ this.setString(e, t ? tr(t) : void 0);
40239
40272
  }
40240
40273
  };
40241
- var Mt = class {
40274
+ var jt = class {
40242
40275
  constructor() {
40243
40276
  this.data = /* @__PURE__ */ new Map();
40244
40277
  }
@@ -40261,23 +40294,23 @@ var Mt = class {
40261
40294
  return Array.from(this.data.keys())[e];
40262
40295
  }
40263
40296
  };
40264
- var Xi = I.FHIR_JSON + ", */*; q=0.1";
40265
- var Zi = "https://api.medplum.com/";
40266
- var eo = 1e3;
40267
- var to = 6e4;
40268
- var Zr = "Binary/";
40269
- var en = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
40270
- var ro = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(ro || {});
40271
- var no = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(no || {});
40272
- var io = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(io || {});
40273
- var oo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(oo || {});
40274
- var tn = class extends ge {
40297
+ var oo = k.FHIR_JSON + ", */*; q=0.1";
40298
+ var so = "https://api.medplum.com/";
40299
+ var ao = 1e3;
40300
+ var co = 6e4;
40301
+ var on = "Binary/";
40302
+ var sn = { resourceType: "Device", id: "system", deviceName: [{ name: "System" }] };
40303
+ var uo = ((o) => (o.ClientCredentials = "client_credentials", o.AuthorizationCode = "authorization_code", o.RefreshToken = "refresh_token", o.JwtBearer = "urn:ietf:params:oauth:grant-type:jwt-bearer", o.TokenExchange = "urn:ietf:params:oauth:grant-type:token-exchange", o))(uo || {});
40304
+ var lo = ((o) => (o.AccessToken = "urn:ietf:params:oauth:token-type:access_token", o.RefreshToken = "urn:ietf:params:oauth:token-type:refresh_token", o.IdToken = "urn:ietf:params:oauth:token-type:id_token", o.Saml1Token = "urn:ietf:params:oauth:token-type:saml1", o.Saml2Token = "urn:ietf:params:oauth:token-type:saml2", o))(lo || {});
40305
+ var po = ((o) => (o.ClientSecretBasic = "client_secret_basic", o.ClientSecretPost = "client_secret_post", o.ClientSecretJwt = "client_secret_jwt", o.PrivateKeyJwt = "private_key_jwt", o.None = "none", o))(po || {});
40306
+ var fo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(fo || {});
40307
+ var an = class extends ge {
40275
40308
  constructor(t) {
40276
40309
  super();
40277
40310
  this.initComplete = true;
40278
40311
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
40279
40312
  throw new Error("Base URL must start with http or https");
40280
- if (this.options = t ?? {}, this.fetch = t?.fetch ?? so(), this.storage = t?.storage ?? new Ze(), this.createPdfImpl = t?.createPdf, this.baseUrl = nn(t?.baseUrl ?? Zi), this.fhirBaseUrl = nn(et(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = et(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = et(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = et(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? to, this.cacheTime > 0 ? this.requestCache = new ze(t?.resourceCacheSize ?? eo) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
40313
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? mo(), this.storage = t?.storage ?? new Ze(), this.createPdfImpl = t?.createPdf, this.baseUrl = un(t?.baseUrl ?? so), this.fhirBaseUrl = un(et(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = et(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = et(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = et(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? co, this.cacheTime > 0 ? this.requestCache = new ze(t?.resourceCacheSize ?? ao) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
40281
40314
  this.setAccessToken(t.accessToken), this.initPromise = Promise.resolve();
40282
40315
  else if (this.storage.getInitPromise !== void 0) {
40283
40316
  let n = this.storage.getInitPromise(), i2 = new Promise((o) => {
@@ -40339,7 +40372,7 @@ var tn = class extends ge {
40339
40372
  t.startsWith(this.fhirBaseUrl) && this.autoBatchQueue ? o = new Promise((a, u2) => {
40340
40373
  this.autoBatchQueue.push({ method: "GET", url: t.replace(this.fhirBaseUrl, ""), options: n, resolve: a, reject: u2 }), this.autoBatchTimerId || (this.autoBatchTimerId = setTimeout(() => this.executeAutoBatch(), this.autoBatchTime));
40341
40374
  }) : o = this.request("GET", t, n);
40342
- let s = new k(o);
40375
+ let s = new A(o);
40343
40376
  return this.setCacheEntry(t, s), s;
40344
40377
  }
40345
40378
  post(t, n, i2, o = {}) {
@@ -40349,7 +40382,7 @@ var tn = class extends ge {
40349
40382
  return t = t.toString(), this.setRequestBody(o, n), i2 && this.setRequestContentType(o, i2), this.invalidateUrl(t), this.request("PUT", t, o);
40350
40383
  }
40351
40384
  patch(t, n, i2 = {}) {
40352
- return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, I.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
40385
+ return t = t.toString(), this.setRequestBody(i2, n), this.setRequestContentType(i2, k.JSON_PATCH), this.invalidateUrl(t), this.request("PATCH", t, i2);
40353
40386
  }
40354
40387
  delete(t, n) {
40355
40388
  return t = t.toString(), this.invalidateUrl(t), this.request("DELETE", t, n);
@@ -40397,7 +40430,7 @@ var tn = class extends ge {
40397
40430
  }
40398
40431
  getExternalAuthRedirectUri(t, n, i2, o, s = true) {
40399
40432
  let a = new URL(t);
40400
- if (a.searchParams.set("response_type", "code"), a.searchParams.set("client_id", n), a.searchParams.set("redirect_uri", i2), a.searchParams.set("scope", "openid profile email"), a.searchParams.set("state", JSON.stringify(o)), s) {
40433
+ if (a.searchParams.set("response_type", "code"), a.searchParams.set("client_id", n), a.searchParams.set("redirect_uri", i2), a.searchParams.set("scope", o.scope ?? "openid profile email"), a.searchParams.set("state", JSON.stringify(o)), s) {
40401
40434
  let { codeChallenge: u2, codeChallengeMethod: l2 } = o;
40402
40435
  if (!l2)
40403
40436
  throw new Error("`LoginRequest` for external auth must include a `codeChallengeMethod`.");
@@ -40418,7 +40451,7 @@ var tn = class extends ge {
40418
40451
  let o = this.fhirSearchUrl(t, n), s = o.toString() + "-search", a = this.getCacheEntry(s, i2);
40419
40452
  if (a)
40420
40453
  return a.value;
40421
- let u2 = new k((async () => {
40454
+ let u2 = new A((async () => {
40422
40455
  let l2 = await this.get(o, i2);
40423
40456
  if (l2.entry)
40424
40457
  for (let f of l2.entry)
@@ -40433,14 +40466,14 @@ var tn = class extends ge {
40433
40466
  let s = o.toString() + "-searchOne", a = this.getCacheEntry(s, i2);
40434
40467
  if (a)
40435
40468
  return a.value;
40436
- let u2 = new k(this.search(t, o.searchParams, i2).then((l2) => l2.entry?.[0]?.resource));
40469
+ let u2 = new A(this.search(t, o.searchParams, i2).then((l2) => l2.entry?.[0]?.resource));
40437
40470
  return this.setCacheEntry(s, u2), u2;
40438
40471
  }
40439
40472
  searchResources(t, n, i2) {
40440
40473
  let s = this.fhirSearchUrl(t, n).toString() + "-searchResources", a = this.getCacheEntry(s, i2);
40441
40474
  if (a)
40442
40475
  return a.value;
40443
- let u2 = new k(this.search(t, n, i2).then(sn));
40476
+ let u2 = new A(this.search(t, n, i2).then(dn));
40444
40477
  return this.setCacheEntry(s, u2), u2;
40445
40478
  }
40446
40479
  async *searchResourcePages(t, n, i2) {
@@ -40449,7 +40482,7 @@ var tn = class extends ge {
40449
40482
  let s = new URL(o).searchParams, a = await this.search(t, s, i2), u2 = a.link?.find((l2) => l2.relation === "next");
40450
40483
  if (!a.entry?.length && !u2)
40451
40484
  break;
40452
- yield sn(a), o = u2?.url ? new URL(u2.url) : void 0;
40485
+ yield dn(a), o = u2?.url ? new URL(u2.url) : void 0;
40453
40486
  }
40454
40487
  }
40455
40488
  searchValueSet(t, n, i2) {
@@ -40465,7 +40498,7 @@ var tn = class extends ge {
40465
40498
  if (!n)
40466
40499
  return;
40467
40500
  if (n === "system")
40468
- return en;
40501
+ return sn;
40469
40502
  let [i2, o] = n.split("/");
40470
40503
  if (!(!i2 || !o))
40471
40504
  return this.getCached(i2, o);
@@ -40476,25 +40509,26 @@ var tn = class extends ge {
40476
40509
  readReference(t, n) {
40477
40510
  let i2 = t.reference;
40478
40511
  if (!i2)
40479
- return new k(Promise.reject(new Error("Missing reference")));
40512
+ return new A(Promise.reject(new Error("Missing reference")));
40480
40513
  if (i2 === "system")
40481
- return new k(Promise.resolve(en));
40514
+ return new A(Promise.resolve(sn));
40482
40515
  let [o, s] = i2.split("/");
40483
- return !o || !s ? new k(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
40516
+ return !o || !s ? new A(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
40484
40517
  }
40485
40518
  requestSchema(t) {
40486
- if (Pr(t))
40519
+ if (Ir(t))
40487
40520
  return Promise.resolve();
40488
40521
  let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
40489
40522
  if (i2)
40490
40523
  return i2.value;
40491
- let o = new k((async () => {
40524
+ let o = new A((async () => {
40492
40525
  let s = `{
40493
40526
  StructureDefinitionList(name: "${t}") {
40494
40527
  resourceType,
40495
40528
  name,
40496
40529
  kind,
40497
40530
  description,
40531
+ type,
40498
40532
  snapshot {
40499
40533
  element {
40500
40534
  id,
@@ -40510,6 +40544,7 @@ var tn = class extends ge {
40510
40544
  contentReference,
40511
40545
  type {
40512
40546
  code,
40547
+ profile,
40513
40548
  targetProfile
40514
40549
  },
40515
40550
  binding {
@@ -40527,9 +40562,21 @@ var tn = class extends ge {
40527
40562
  target
40528
40563
  }
40529
40564
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
40530
- br(a.data.StructureDefinitionList);
40565
+ At(a.data.StructureDefinitionList);
40531
40566
  for (let u2 of a.data.SearchParameterList)
40532
- Pt(u2);
40567
+ wt(u2);
40568
+ })());
40569
+ return this.setCacheEntry(n, o), o;
40570
+ }
40571
+ requestProfileSchema(t) {
40572
+ if (Dr(t))
40573
+ return Promise.resolve();
40574
+ let n = t + "-requestSchema", i2 = this.getCacheEntry(n, void 0);
40575
+ if (i2)
40576
+ return i2.value;
40577
+ let o = new A((async () => {
40578
+ let s = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
40579
+ s ? At([s], t) : console.warn(`No StructureDefinition found for ${t}!`);
40533
40580
  })());
40534
40581
  return this.setCacheEntry(n, o), o;
40535
40582
  }
@@ -40566,7 +40613,7 @@ var tn = class extends ge {
40566
40613
  s?.signal?.removeEventListener("abort", f), M instanceof Error ? u2(M) : a(M);
40567
40614
  };
40568
40615
  l2.responseType = "json", l2.onabort = () => P(new Error("Request aborted")), l2.onerror = () => P(new Error("Request error")), o && (l2.upload.onprogress = (M) => o(M), l2.upload.onload = (M) => o(M)), l2.onload = () => {
40569
- l2.status >= 200 && l2.status < 300 ? P(l2.response) : P(new p(De(l2.response || l2.statusText)));
40616
+ l2.status >= 200 && l2.status < 300 ? P(l2.response) : P(new p(Ve(l2.response || l2.statusText)));
40570
40617
  }, l2.open("POST", t), l2.withCredentials = true, l2.setRequestHeader("Authorization", "Bearer " + this.accessToken), l2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), l2.setRequestHeader("Content-Type", i2), l2.setRequestHeader("X-Medplum", "extended"), l2.send(n);
40571
40618
  });
40572
40619
  }
@@ -40578,7 +40625,7 @@ var tn = class extends ge {
40578
40625
  }
40579
40626
  createComment(t, n, i2) {
40580
40627
  let o = this.getProfile(), s, a;
40581
- return t.resourceType === "Encounter" && (s = z(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = z(t)), this.createResource({ resourceType: "Communication", basedOn: [z(t)], encounter: s, subject: a, sender: o ? z(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
40628
+ return t.resourceType === "Encounter" && (s = G(t), a = t.subject), t.resourceType === "ServiceRequest" && (s = t.encounter, a = t.subject), t.resourceType === "Patient" && (a = G(t)), this.createResource({ resourceType: "Communication", basedOn: [G(t)], encounter: s, subject: a, sender: o ? G(o) : void 0, sent: (/* @__PURE__ */ new Date()).toISOString(), payload: [{ contentString: n }] }, i2);
40582
40629
  }
40583
40630
  async updateResource(t, n) {
40584
40631
  if (!t.resourceType)
@@ -40612,28 +40659,28 @@ var tn = class extends ge {
40612
40659
  return this.post(this.fhirBaseUrl.slice(0, -1), t, void 0, n);
40613
40660
  }
40614
40661
  sendEmail(t, n) {
40615
- return this.post("email/v1/send", t, I.JSON, n);
40662
+ return this.post("email/v1/send", t, k.JSON, n);
40616
40663
  }
40617
40664
  graphql(t, n, i2, o) {
40618
- return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, I.JSON, o);
40665
+ return this.post(this.fhirUrl("$graphql"), { query: t, operationName: n, variables: i2 }, k.JSON, o);
40619
40666
  }
40620
40667
  readResourceGraph(t, n, i2, o) {
40621
40668
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
40622
40669
  }
40623
40670
  pushToAgent(t, n, i2, o, s, a) {
40624
- return this.post(this.fhirUrl("Agent", Gt(t), "$push"), { destination: ce(n), body: i2, contentType: o, waitForResponse: s }, I.FHIR_JSON, a);
40671
+ return this.post(this.fhirUrl("Agent", Yt(t), "$push"), { destination: ae(n), body: i2, contentType: o, waitForResponse: s }, k.FHIR_JSON, a);
40625
40672
  }
40626
40673
  getActiveLogin() {
40627
40674
  return this.storage.getObject("activeLogin");
40628
40675
  }
40629
40676
  async setActiveLogin(t) {
40630
- (!this.sessionDetails?.profile || ce(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
40677
+ (!this.sessionDetails?.profile || ae(this.sessionDetails.profile) !== t.profile?.reference) && this.clearActiveLogin(), this.setAccessToken(t.accessToken, t.refreshToken), this.storage.setObject("activeLogin", t), this.addLogin(t), this.refreshPromise = void 0, await this.refreshProfile();
40631
40678
  }
40632
40679
  getAccessToken() {
40633
40680
  return this.accessToken;
40634
40681
  }
40635
40682
  setAccessToken(t, n) {
40636
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = Xr(t);
40683
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.medplumServer = nn(t);
40637
40684
  }
40638
40685
  getLogins() {
40639
40686
  return this.storage.getObject("logins") ?? [];
@@ -40681,11 +40728,11 @@ var tn = class extends ge {
40681
40728
  async download(t, n = {}) {
40682
40729
  this.refreshPromise && await this.refreshPromise;
40683
40730
  let i2 = t.toString();
40684
- return i2.startsWith(Zr) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
40731
+ return i2.startsWith(on) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
40685
40732
  }
40686
40733
  async uploadMedia(t, n, i2, o, s) {
40687
40734
  let a = await this.createBinary(t, i2, n);
40688
- return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: Zr + a.id, title: i2 }, ...o }, s);
40735
+ return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: on + a.id, title: i2 }, ...o }, s);
40689
40736
  }
40690
40737
  async bulkExport(t = "", n, i2, o) {
40691
40738
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -40697,7 +40744,7 @@ var tn = class extends ge {
40697
40744
  i2.Prefer = "respond-async";
40698
40745
  let o = await this.fetchWithRetry(t, n);
40699
40746
  if (o.status === 202) {
40700
- let s = await on(o);
40747
+ let s = await ln(o);
40701
40748
  if (s)
40702
40749
  return this.pollStatus(s);
40703
40750
  }
@@ -40714,7 +40761,7 @@ var tn = class extends ge {
40714
40761
  this.requestCache && this.requestCache.set(t, { requestTime: Date.now(), value: n });
40715
40762
  }
40716
40763
  cacheResource(t) {
40717
- t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new k(Promise.resolve(t)));
40764
+ t?.id && !t.meta?.tag?.some((n) => n.code === "SUBSETTED") && this.setCacheEntry(this.fhirUrl(t.resourceType, t.id).toString(), new A(Promise.resolve(t)));
40718
40765
  }
40719
40766
  deleteCacheEntry(t) {
40720
40767
  this.requestCache && this.requestCache.delete(t);
@@ -40731,7 +40778,7 @@ var tn = class extends ge {
40731
40778
  return;
40732
40779
  let a = t.headers.get("content-type")?.includes("json");
40733
40780
  if (t.status === 404 && !a)
40734
- throw new p(yr);
40781
+ throw new p(vr);
40735
40782
  let u2 = t.headers.get("content-location"), l2 = o.redirect ?? this.options.redirect;
40736
40783
  if (t.status === 201 && u2 && l2 === "follow")
40737
40784
  return this.request("GET", u2, { ...o, body: void 0 });
@@ -40745,7 +40792,7 @@ var tn = class extends ge {
40745
40792
  else
40746
40793
  f = await t.text();
40747
40794
  if (t.status >= 400)
40748
- throw new p(De(f));
40795
+ throw new p(Ve(f));
40749
40796
  return f;
40750
40797
  }
40751
40798
  async fetchWithRetry(t, n) {
@@ -40779,7 +40826,7 @@ var tn = class extends ge {
40779
40826
  this.addFetchOptionsDefaults(s);
40780
40827
  let a = await this.fetchWithRetry(t, s);
40781
40828
  if (a.status !== 202 && (n = false, i2 = a, a.status === 201)) {
40782
- let u2 = await on(a);
40829
+ let u2 = await ln(a);
40783
40830
  u2 && (i2 = await this.fetchWithRetry(u2, s));
40784
40831
  }
40785
40832
  await at(o);
@@ -40793,7 +40840,7 @@ var tn = class extends ge {
40793
40840
  try {
40794
40841
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
40795
40842
  } catch (s) {
40796
- o.reject(new p(De(s)));
40843
+ o.reject(new p(Ve(s)));
40797
40844
  }
40798
40845
  return;
40799
40846
  }
@@ -40805,7 +40852,7 @@ var tn = class extends ge {
40805
40852
  }
40806
40853
  addFetchOptionsDefaults(t) {
40807
40854
  let n = t.headers;
40808
- n || (n = {}, t.headers = n), n.Accept || (n.Accept = Xi), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = I.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
40855
+ n || (n = {}, t.headers = n), n.Accept || (n.Accept = oo), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = k.FHIR_JSON), this.accessToken ? n.Authorization = "Bearer " + this.accessToken : this.basicAuth && (n.Authorization = "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
40809
40856
  }
40810
40857
  setRequestContentType(t, n) {
40811
40858
  t.headers || (t.headers = {});
@@ -40819,20 +40866,20 @@ var tn = class extends ge {
40819
40866
  return this.refresh() ? this.request(t, n, i2) : (this.clearActiveLogin(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new Error("Unauthenticated")));
40820
40867
  }
40821
40868
  async startPkce() {
40822
- let t = Dt();
40869
+ let t = _t();
40823
40870
  sessionStorage.setItem("pkceState", t);
40824
- let n = Dt();
40871
+ let n = _t();
40825
40872
  sessionStorage.setItem("codeVerifier", n);
40826
- let i2 = await Hr(n), o = tr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
40873
+ let i2 = await Jr(n), o = or(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
40827
40874
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
40828
40875
  }
40829
40876
  async requestAuthorization(t) {
40830
40877
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
40831
- i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? rn()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
40878
+ i2.searchParams.set("response_type", "code"), i2.searchParams.set("state", sessionStorage.getItem("pkceState")), i2.searchParams.set("client_id", n.clientId ?? this.clientId), i2.searchParams.set("redirect_uri", n.redirectUri ?? cn()), i2.searchParams.set("code_challenge_method", n.codeChallengeMethod), i2.searchParams.set("code_challenge", n.codeChallenge), i2.searchParams.set("scope", n.scope ?? "openid profile"), window.location.assign(i2.toString());
40832
40879
  }
40833
40880
  processCode(t, n) {
40834
40881
  let i2 = new URLSearchParams();
40835
- if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? rn()), typeof sessionStorage < "u") {
40882
+ if (i2.set("grant_type", "authorization_code"), i2.set("code", t), i2.set("client_id", n?.clientId ?? this.clientId), i2.set("redirect_uri", n?.redirectUri ?? cn()), typeof sessionStorage < "u") {
40836
40883
  let o = sessionStorage.getItem("codeVerifier");
40837
40884
  o && i2.set("code_verifier", o);
40838
40885
  }
@@ -40863,14 +40910,14 @@ var tn = class extends ge {
40863
40910
  return n.append("grant_type", "client_credentials"), n.append("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"), n.append("client_assertion", t), this.fetchTokens(n);
40864
40911
  }
40865
40912
  setBasicAuth(t, n) {
40866
- this.clientId = t, this.clientSecret = n, this.basicAuth = Qr(t + ":" + n);
40913
+ this.clientId = t, this.clientSecret = n, this.basicAuth = zr(t + ":" + n);
40867
40914
  }
40868
40915
  async fhircastSubscribe(t, n) {
40869
40916
  if (!(typeof t == "string" && t !== ""))
40870
40917
  throw new p(h("Invalid topic provided. Topic must be a valid string."));
40871
40918
  if (!(typeof n == "object" && Array.isArray(n) && n.length > 0))
40872
40919
  throw new p(h("Invalid events provided. Events must be an array of event names containing at least one event."));
40873
- let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", _t(i2), I.FORM_URL_ENCODED))["hub.channel.endpoint"];
40920
+ let i2 = { channelType: "websocket", mode: "subscribe", topic: t, events: n }, s = (await this.post("/fhircast/STU3", Mt(i2), k.FORM_URL_ENCODED))["hub.channel.endpoint"];
40874
40921
  if (!s)
40875
40922
  throw new Error("Invalid response!");
40876
40923
  return i2.endpoint = s, i2;
@@ -40880,13 +40927,13 @@ var tn = class extends ge {
40880
40927
  throw new p(h("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
40881
40928
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
40882
40929
  throw new p(h("Provided subscription request must have an endpoint in order to unsubscribe."));
40883
- t.mode = "unsubscribe", await this.post("/fhircast/STU3", _t(t), I.FORM_URL_ENCODED);
40930
+ t.mode = "unsubscribe", await this.post("/fhircast/STU3", Mt(t), k.FORM_URL_ENCODED);
40884
40931
  }
40885
40932
  fhircastConnect(t) {
40886
40933
  return new Ye(t);
40887
40934
  }
40888
40935
  async fhircastPublish(t, n, i2, o) {
40889
- return Gr(n) ? this.post(`/fhircast/STU3/${t}`, Ut(t, n, i2, o), I.JSON) : (zr(n), this.post(`/fhircast/STU3/${t}`, Ut(t, n, i2), I.JSON));
40936
+ return Zr(n) ? this.post(`/fhircast/STU3/${t}`, Bt(t, n, i2, o), k.JSON) : (en(n), this.post(`/fhircast/STU3/${t}`, Bt(t, n, i2), k.JSON));
40890
40937
  }
40891
40938
  async fhircastGetContext(t) {
40892
40939
  return this.get(`/fhircast/STU3/${t}`);
@@ -40895,16 +40942,16 @@ var tn = class extends ge {
40895
40942
  return this.post("admin/projects/" + t + "/invite", n);
40896
40943
  }
40897
40944
  async fetchTokens(t) {
40898
- let n = { method: "POST", headers: { "Content-Type": I.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
40945
+ let n = { method: "POST", headers: { "Content-Type": k.FORM_URL_ENCODED }, body: t.toString(), credentials: "include" }, i2 = n.headers;
40899
40946
  this.basicAuth && (i2.Authorization = `Basic ${this.basicAuth}`);
40900
40947
  let o = await this.fetchWithRetry(this.tokenUrl, n);
40901
40948
  if (!o.ok) {
40902
40949
  this.clearActiveLogin();
40903
40950
  try {
40904
40951
  let a = await o.json();
40905
- throw new p(C(a.error_description));
40952
+ throw new p(w(a.error_description));
40906
40953
  } catch (a) {
40907
- throw new p(C("Failed to fetch tokens"), a);
40954
+ throw new p(w("Failed to fetch tokens"), a);
40908
40955
  }
40909
40956
  }
40910
40957
  let s = await o.json();
@@ -40912,8 +40959,8 @@ var tn = class extends ge {
40912
40959
  }
40913
40960
  async verifyTokens(t) {
40914
40961
  let n = t.access_token;
40915
- if (Yr(n)) {
40916
- let i2 = Lt(n);
40962
+ if (rn(n)) {
40963
+ let i2 = qt(n);
40917
40964
  if (Date.now() >= i2.exp * 1e3)
40918
40965
  throw this.clearActiveLogin(), new Error("Token expired");
40919
40966
  if (i2.cid) {
@@ -40937,21 +40984,21 @@ var tn = class extends ge {
40937
40984
  throw i2;
40938
40985
  }
40939
40986
  };
40940
- function so() {
40987
+ function mo() {
40941
40988
  if (!globalThis.fetch)
40942
40989
  throw new Error("Fetch not available in this environment");
40943
40990
  return globalThis.fetch.bind(globalThis);
40944
40991
  }
40945
- function rn() {
40992
+ function cn() {
40946
40993
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
40947
40994
  }
40948
- function nn(r4) {
40995
+ function un(r4) {
40949
40996
  return r4.endsWith("/") ? r4 : r4 + "/";
40950
40997
  }
40951
40998
  function et(r4, e) {
40952
40999
  return new URL(e, r4).toString();
40953
41000
  }
40954
- async function on(r4) {
41001
+ async function ln(r4) {
40955
41002
  let e = r4.headers.get("content-location");
40956
41003
  if (e)
40957
41004
  return e;
@@ -40959,18 +41006,18 @@ async function on(r4) {
40959
41006
  if (t)
40960
41007
  return t;
40961
41008
  let n = await r4.json();
40962
- if (Ve(n) && n.issue?.[0]?.diagnostics)
41009
+ if (De(n) && n.issue?.[0]?.diagnostics)
40963
41010
  return n.issue[0].diagnostics;
40964
41011
  }
40965
- function sn(r4) {
41012
+ function dn(r4) {
40966
41013
  let e = r4.entry?.map((t) => t.resource) ?? [];
40967
41014
  return Object.assign(e, { bundle: r4 });
40968
41015
  }
40969
- var ao = [...pe, "->", "<<", ">>"];
40970
- var co = fe().registerInfix("->", { precedence: m.Arrow }).registerInfix(";", { precedence: m.Semicolon });
40971
- var uo = [...pe, "eq", "ne", "co"];
40972
- var fo = fe();
40973
- var G = class {
41016
+ var ho = [...pe, "->", "<<", ">>"];
41017
+ var yo = fe().registerInfix("->", { precedence: m.Arrow }).registerInfix(";", { precedence: m.Semicolon });
41018
+ var go = [...pe, "eq", "ne", "co"];
41019
+ var vo = fe();
41020
+ var W = class {
40974
41021
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
40975
41022
  this.segmentSeparator = e;
40976
41023
  this.fieldSeparator = t;
@@ -40986,8 +41033,8 @@ var G = class {
40986
41033
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
40987
41034
  }
40988
41035
  };
40989
- var ln = class r {
40990
- constructor(e, t = new G()) {
41036
+ var hn = class r {
41037
+ constructor(e, t = new W()) {
40991
41038
  this.context = t, this.segments = e;
40992
41039
  }
40993
41040
  get header() {
@@ -41010,7 +41057,7 @@ var ln = class r {
41010
41057
  }
41011
41058
  buildAck() {
41012
41059
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i2 = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a = t?.getField(10)?.toString() ?? "", u2 = t?.getField(12)?.toString() ?? "2.5.1";
41013
- return new r([new xe(["MSH", this.context.getMsh2(), o, s, n, i2, ho(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", u2], this.context), new xe(["MSA", "AA", a, "OK"], this.context)]);
41060
+ return new r([new xe(["MSH", this.context.getMsh2(), o, s, n, i2, So(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", u2], this.context), new xe(["MSA", "AA", a, "OK"], this.context)]);
41014
41061
  }
41015
41062
  buildAckMessageType(e) {
41016
41063
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -41021,13 +41068,13 @@ var ln = class r {
41021
41068
  let n = new Error("Invalid HL7 message");
41022
41069
  throw n.type = "entity.parse.failed", n;
41023
41070
  }
41024
- let t = new G("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
41071
+ let t = new W("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
41025
41072
  return new r(e.split(/[\r\n]+/).map((n) => xe.parse(n, t)), t);
41026
41073
  }
41027
41074
  };
41028
41075
  var xe = class r2 {
41029
- constructor(e, t = new G()) {
41030
- this.context = t, Xt(e) ? this.fields = e.map((n) => ae.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
41076
+ constructor(e, t = new W()) {
41077
+ this.context = t, rr(e) ? this.fields = e.map((n) => se.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
41031
41078
  }
41032
41079
  get(e) {
41033
41080
  return this.fields[e];
@@ -41035,9 +41082,9 @@ var xe = class r2 {
41035
41082
  getField(e) {
41036
41083
  if (this.name === "MSH") {
41037
41084
  if (e === 1)
41038
- return new ae([[this.context.getMsh1()]], this.context);
41085
+ return new se([[this.context.getMsh1()]], this.context);
41039
41086
  if (e === 2)
41040
- return new ae([[this.context.getMsh2()]], this.context);
41087
+ return new se([[this.context.getMsh2()]], this.context);
41041
41088
  if (e > 2)
41042
41089
  return this.fields[e - 1];
41043
41090
  }
@@ -41049,12 +41096,12 @@ var xe = class r2 {
41049
41096
  toString() {
41050
41097
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
41051
41098
  }
41052
- static parse(e, t = new G()) {
41053
- return new r2(e.split(t.fieldSeparator).map((n) => ae.parse(n, t)), t);
41099
+ static parse(e, t = new W()) {
41100
+ return new r2(e.split(t.fieldSeparator).map((n) => se.parse(n, t)), t);
41054
41101
  }
41055
41102
  };
41056
- var ae = class r3 {
41057
- constructor(e, t = new G()) {
41103
+ var se = class r3 {
41104
+ constructor(e, t = new W()) {
41058
41105
  this.context = t, this.components = e;
41059
41106
  }
41060
41107
  get(e, t, n = 0) {
@@ -41067,11 +41114,11 @@ var ae = class r3 {
41067
41114
  toString() {
41068
41115
  return this.components.map((e) => e.join(this.context.componentSeparator)).join(this.context.repetitionSeparator);
41069
41116
  }
41070
- static parse(e, t = new G()) {
41117
+ static parse(e, t = new W()) {
41071
41118
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
41072
41119
  }
41073
41120
  };
41074
- function ho(r4) {
41121
+ function So(r4) {
41075
41122
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
41076
41123
  return i2 > 0 && (n += "." + i2.toString()), n;
41077
41124
  }
@@ -41115,7 +41162,7 @@ var c2 = class extends i {
41115
41162
  e.on("data", (s) => {
41116
41163
  try {
41117
41164
  if (o += s.toString(), o.endsWith(p2 + v2)) {
41118
- let r4 = ln.parse(o.substring(1, o.length - 2));
41165
+ let r4 = hn.parse(o.substring(1, o.length - 2));
41119
41166
  this.dispatchEvent(new d2(this, r4)), o = "";
41120
41167
  }
41121
41168
  } catch (r4) {
@@ -41255,11 +41302,11 @@ var DcmjsDimseScp = class extends dimse.Scp {
41255
41302
  accessToken: App.instance.medplum.getAccessToken(),
41256
41303
  channel: AgentDicomChannel.instance.definition.name,
41257
41304
  remote: "foo",
41258
- contentType: I.JSON,
41305
+ contentType: k.JSON,
41259
41306
  body: JSON.stringify(request.getDataset())
41260
41307
  });
41261
41308
  } catch (err) {
41262
- App.instance.log.error(`DICOM error: ${Kn(err)}`);
41309
+ App.instance.log.error(`DICOM error: ${Yn(err)}`);
41263
41310
  }
41264
41311
  const response = dimse.responses.CStoreResponse.fromRequest(request);
41265
41312
  response.setStatus(dimse.constants.Status.Success);
@@ -41291,7 +41338,7 @@ var AgentHl7Channel = class {
41291
41338
  sendToRemote(msg) {
41292
41339
  const connection = this.connections.get(msg.remote);
41293
41340
  if (connection) {
41294
- connection.hl7Connection.send(ln.parse(msg.body));
41341
+ connection.hl7Connection.send(hn.parse(msg.body));
41295
41342
  }
41296
41343
  }
41297
41344
  handleNewConnection(connection) {
@@ -41316,11 +41363,11 @@ var AgentHl7ChannelConnection = class {
41316
41363
  accessToken: this.channel.app.medplum.getAccessToken(),
41317
41364
  channel: this.channel.definition.name,
41318
41365
  remote: this.remote,
41319
- contentType: I.HL7_V2,
41366
+ contentType: k.HL7_V2,
41320
41367
  body: event.message.toString()
41321
41368
  });
41322
41369
  } catch (err) {
41323
- this.channel.app.log.error(`HL7 error: ${Kn(err)}`);
41370
+ this.channel.app.log.error(`HL7 error: ${Yn(err)}`);
41324
41371
  }
41325
41372
  }
41326
41373
  close() {
@@ -41381,7 +41428,7 @@ var App = class _App {
41381
41428
  this.log.error(`Unknown message type: ${command.type}`);
41382
41429
  }
41383
41430
  } catch (err) {
41384
- this.log.error(`WebSocket error: ${Kn(err)}`);
41431
+ this.log.error(`WebSocket error: ${Yn(err)}`);
41385
41432
  }
41386
41433
  });
41387
41434
  }
@@ -41454,18 +41501,18 @@ var App = class _App {
41454
41501
  host: address.hostname,
41455
41502
  port: parseInt(address.port, 10)
41456
41503
  });
41457
- client.sendAndWait(ln.parse(message.body)).then((response) => {
41504
+ client.sendAndWait(hn.parse(message.body)).then((response) => {
41458
41505
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
41459
41506
  this.addToWebSocketQueue({
41460
41507
  type: "agent:transmit:response",
41461
41508
  channel: message.channel,
41462
41509
  remote: message.remote,
41463
41510
  callback: message.callback,
41464
- contentType: I.HL7_V2,
41511
+ contentType: k.HL7_V2,
41465
41512
  body: response.toString()
41466
41513
  });
41467
41514
  }).catch((err) => {
41468
- this.log.error(`HL7 error: ${Kn(err)}`);
41515
+ this.log.error(`HL7 error: ${Yn(err)}`);
41469
41516
  }).finally(() => {
41470
41517
  client.close();
41471
41518
  });
@@ -41498,7 +41545,7 @@ async function main(argv) {
41498
41545
  process.exit(1);
41499
41546
  }
41500
41547
  const { baseUrl, clientId, clientSecret, agentId } = args;
41501
- const medplum = new tn({ baseUrl, clientId });
41548
+ const medplum = new an({ baseUrl, clientId });
41502
41549
  await medplum.startClientLogin(clientId, clientSecret);
41503
41550
  const app = new App(medplum, agentId);
41504
41551
  await app.start();