@medplum/agent 3.0.4 → 3.0.5

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.
@@ -4124,15 +4124,15 @@ var require_dcmjs = __commonJS({
4124
4124
  return Array.from(iter);
4125
4125
  }
4126
4126
  function _iterableToArrayLimit(arr, i2) {
4127
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
4128
- if (_i == null)
4127
+ var _i2 = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
4128
+ if (_i2 == null)
4129
4129
  return;
4130
4130
  var _arr = [];
4131
4131
  var _n2 = true;
4132
4132
  var _d = false;
4133
4133
  var _s, _e2;
4134
4134
  try {
4135
- for (_i = _i.call(arr); !(_n2 = (_s = _i.next()).done); _n2 = true) {
4135
+ for (_i2 = _i2.call(arr); !(_n2 = (_s = _i2.next()).done); _n2 = true) {
4136
4136
  _arr.push(_s.value);
4137
4137
  if (i2 && _arr.length === i2)
4138
4138
  break;
@@ -4142,8 +4142,8 @@ var require_dcmjs = __commonJS({
4142
4142
  _e2 = err2;
4143
4143
  } finally {
4144
4144
  try {
4145
- if (!_n2 && _i["return"] != null)
4146
- _i["return"]();
4145
+ if (!_n2 && _i2["return"] != null)
4146
+ _i2["return"]();
4147
4147
  } finally {
4148
4148
  if (_d)
4149
4149
  throw _e2;
@@ -9540,17 +9540,17 @@ var require_dcmjs = __commonJS({
9540
9540
  key: "readBytes",
9541
9541
  value: function readBytes(stream, length2) {
9542
9542
  var BACKSLASH = String.fromCharCode(VM_DELIMITER);
9543
- var ds2 = stream.readAsciiString(length2);
9544
- ds2 = ds2.replace(/[^0-9.\\\-+e]/gi, "");
9545
- if (ds2.indexOf(BACKSLASH) !== -1) {
9546
- var dsArray = ds2.split(BACKSLASH);
9547
- ds2 = dsArray.map(function(ds3) {
9548
- return ds3 === "" ? null : Number(ds3);
9543
+ var ds = stream.readAsciiString(length2);
9544
+ ds = ds.replace(/[^0-9.\\\-+e]/gi, "");
9545
+ if (ds.indexOf(BACKSLASH) !== -1) {
9546
+ var dsArray = ds.split(BACKSLASH);
9547
+ ds = dsArray.map(function(ds2) {
9548
+ return ds2 === "" ? null : Number(ds2);
9549
9549
  });
9550
9550
  } else {
9551
- ds2 = [ds2 === "" ? null : Number(ds2)];
9551
+ ds = [ds === "" ? null : Number(ds)];
9552
9552
  }
9553
- return ds2;
9553
+ return ds;
9554
9554
  }
9555
9555
  }, {
9556
9556
  key: "formatValue",
@@ -9580,8 +9580,8 @@ var require_dcmjs = __commonJS({
9580
9580
  key: "writeBytes",
9581
9581
  value: function writeBytes(stream, value, writeOptions) {
9582
9582
  var _this7 = this;
9583
- var val = Array.isArray(value) ? value.map(function(ds2) {
9584
- return _this7.formatValue(ds2);
9583
+ var val = Array.isArray(value) ? value.map(function(ds) {
9584
+ return _this7.formatValue(ds);
9585
9585
  }) : [this.formatValue(value)];
9586
9586
  return _get(_getPrototypeOf(DecimalString2.prototype), "writeBytes", this).call(this, stream, val, writeOptions);
9587
9587
  }
@@ -11402,8 +11402,8 @@ var require_dcmjs = __commonJS({
11402
11402
  }, {
11403
11403
  key: "isMultiframeDataset",
11404
11404
  value: function isMultiframeDataset() {
11405
- var ds2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.dataset;
11406
- var sopClassUID = ds2.SOPClassUID.replace(/[^0-9.]/g, "");
11405
+ var ds = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.dataset;
11406
+ var sopClassUID = ds.SOPClassUID.replace(/[^0-9.]/g, "");
11407
11407
  return Normalizer2.isMultiframeSOPClassUID(sopClassUID);
11408
11408
  }
11409
11409
  }, {
@@ -11444,16 +11444,16 @@ var require_dcmjs = __commonJS({
11444
11444
  }
11445
11445
  this.derivation = new DerivedImage(this.datasets);
11446
11446
  this.dataset = this.derivation.dataset;
11447
- var ds2 = this.dataset;
11447
+ var ds = this.dataset;
11448
11448
  var referenceDataset = this.datasets[0];
11449
- ds2.NumberOfFrames = this.datasets.length;
11450
- ds2.SOPClassUID = referenceDataset.SOPClassUID;
11451
- ds2.Rows = referenceDataset.Rows;
11452
- ds2.Columns = referenceDataset.Columns;
11453
- ds2.BitsAllocated = referenceDataset.BitsAllocated;
11454
- ds2.PixelRepresentation = referenceDataset.PixelRepresentation;
11455
- ds2.RescaleSlope = referenceDataset.RescaleSlope || "1";
11456
- ds2.RescaleIntercept = referenceDataset.RescaleIntercept || "0";
11449
+ ds.NumberOfFrames = this.datasets.length;
11450
+ ds.SOPClassUID = referenceDataset.SOPClassUID;
11451
+ ds.Rows = referenceDataset.Rows;
11452
+ ds.Columns = referenceDataset.Columns;
11453
+ ds.BitsAllocated = referenceDataset.BitsAllocated;
11454
+ ds.PixelRepresentation = referenceDataset.PixelRepresentation;
11455
+ ds.RescaleSlope = referenceDataset.RescaleSlope || "1";
11456
+ ds.RescaleIntercept = referenceDataset.RescaleIntercept || "0";
11457
11457
  var referencePosition = referenceDataset.ImagePositionPatient;
11458
11458
  var rowVector = referenceDataset.ImageOrientationPatient.slice(0, 3);
11459
11459
  var columnVector = referenceDataset.ImageOrientationPatient.slice(3, 6);
@@ -11468,43 +11468,43 @@ var require_dcmjs = __commonJS({
11468
11468
  distanceDatasetPairs.sort(function(a, b2) {
11469
11469
  return b2[0] - a[0];
11470
11470
  });
11471
- if (ds2.BitsAllocated !== 16) {
11471
+ if (ds.BitsAllocated !== 16) {
11472
11472
  log.error("Only works with 16 bit data, not " + String(this.dataset.BitsAllocated));
11473
11473
  }
11474
11474
  if (referenceDataset._vrMap && !referenceDataset._vrMap.PixelData) {
11475
11475
  log.warn("No vr map given for pixel data, using OW");
11476
- ds2._vrMap = {
11476
+ ds._vrMap = {
11477
11477
  PixelData: "OW"
11478
11478
  };
11479
11479
  } else {
11480
- ds2._vrMap = {
11480
+ ds._vrMap = {
11481
11481
  PixelData: referenceDataset._vrMap.PixelData
11482
11482
  };
11483
11483
  }
11484
11484
  var frameSize = referenceDataset.PixelData.byteLength;
11485
- ds2.PixelData = new ArrayBuffer(ds2.NumberOfFrames * frameSize);
11485
+ ds.PixelData = new ArrayBuffer(ds.NumberOfFrames * frameSize);
11486
11486
  var frame = 0;
11487
11487
  distanceDatasetPairs.forEach(function(pair) {
11488
11488
  var dataset = pair[1];
11489
11489
  var pixels = new Uint16Array(dataset.PixelData);
11490
- var frameView = new Uint16Array(ds2.PixelData, frame * frameSize, frameSize / 2);
11490
+ var frameView = new Uint16Array(ds.PixelData, frame * frameSize, frameSize / 2);
11491
11491
  try {
11492
11492
  frameView.set(pixels);
11493
11493
  } catch (e) {
11494
11494
  if (e instanceof RangeError) {
11495
- var message2 = "Error inserting pixels in PixelData\n" + "frameSize ".concat(frameSize, "\n") + "NumberOfFrames ".concat(ds2.NumberOfFrames, "\n") + "pair ".concat(pair, "\n") + "dataset PixelData size ".concat(dataset.PixelData.length);
11495
+ var message2 = "Error inserting pixels in PixelData\n" + "frameSize ".concat(frameSize, "\n") + "NumberOfFrames ".concat(ds.NumberOfFrames, "\n") + "pair ".concat(pair, "\n") + "dataset PixelData size ".concat(dataset.PixelData.length);
11496
11496
  log.error(message2);
11497
11497
  }
11498
11498
  }
11499
11499
  frame++;
11500
11500
  });
11501
- if (ds2.NumberOfFrames < 2) {
11501
+ if (ds.NumberOfFrames < 2) {
11502
11502
  log.error("Cannot populate shared groups uniquely without multiple frames");
11503
11503
  }
11504
11504
  var _distanceDatasetPairs = _slicedToArray(distanceDatasetPairs[0], 2), distance0 = _distanceDatasetPairs[0], dataset0 = _distanceDatasetPairs[1];
11505
11505
  var distance1 = distanceDatasetPairs[1][0];
11506
11506
  var SpacingBetweenSlices = Math.abs(distance1 - distance0);
11507
- ds2.SharedFunctionalGroupsSequence = {
11507
+ ds.SharedFunctionalGroupsSequence = {
11508
11508
  PlaneOrientationSequence: {
11509
11509
  ImageOrientationPatient: dataset0.ImageOrientationPatient
11510
11510
  },
@@ -11514,14 +11514,14 @@ var require_dcmjs = __commonJS({
11514
11514
  SliceThickness: SpacingBetweenSlices
11515
11515
  }
11516
11516
  };
11517
- ds2.ReferencedSeriesSequence = {
11517
+ ds.ReferencedSeriesSequence = {
11518
11518
  SeriesInstanceUID: dataset0.SeriesInstanceUID,
11519
11519
  ReferencedInstanceSequence: []
11520
11520
  };
11521
- ds2.PerFrameFunctionalGroupsSequence = [];
11521
+ ds.PerFrameFunctionalGroupsSequence = [];
11522
11522
  distanceDatasetPairs.forEach(function(pair) {
11523
11523
  var dataset = pair[1];
11524
- ds2.PerFrameFunctionalGroupsSequence.push({
11524
+ ds.PerFrameFunctionalGroupsSequence.push({
11525
11525
  PlanePositionSequence: {
11526
11526
  ImagePositionPatient: dataset.ImagePositionPatient
11527
11527
  },
@@ -11530,7 +11530,7 @@ var require_dcmjs = __commonJS({
11530
11530
  WindowWidth: dataset.WindowWidth
11531
11531
  }
11532
11532
  });
11533
- ds2.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
11533
+ ds.ReferencedSeriesSequence.ReferencedInstanceSequence.push({
11534
11534
  ReferencedSOPClassUID: dataset.SOPClassUID,
11535
11535
  ReferencedSOPInstanceUID: dataset.SOPInstanceUID
11536
11536
  });
@@ -11550,29 +11550,29 @@ var require_dcmjs = __commonJS({
11550
11550
  }, {
11551
11551
  key: "normalizeMultiframe",
11552
11552
  value: function normalizeMultiframe() {
11553
- var ds2 = this.dataset;
11554
- if (!ds2.NumberOfFrames) {
11553
+ var ds = this.dataset;
11554
+ if (!ds.NumberOfFrames) {
11555
11555
  log.error("Missing number or frames not supported");
11556
11556
  return;
11557
11557
  }
11558
- if (!ds2.PixelRepresentation) {
11559
- ds2.PixelRepresentation = 1;
11558
+ if (!ds.PixelRepresentation) {
11559
+ ds.PixelRepresentation = 1;
11560
11560
  }
11561
- if (!ds2.StudyID || ds2.StudyID === "") {
11562
- ds2.StudyID = "No Study ID";
11561
+ if (!ds.StudyID || ds.StudyID === "") {
11562
+ ds.StudyID = "No Study ID";
11563
11563
  }
11564
11564
  var validLateralities = ["R", "L"];
11565
- if (validLateralities.indexOf(ds2.Laterality) === -1) {
11566
- delete ds2.Laterality;
11565
+ if (validLateralities.indexOf(ds.Laterality) === -1) {
11566
+ delete ds.Laterality;
11567
11567
  }
11568
- if (!ds2.PresentationLUTShape) {
11569
- ds2.PresentationLUTShape = "IDENTITY";
11568
+ if (!ds.PresentationLUTShape) {
11569
+ ds.PresentationLUTShape = "IDENTITY";
11570
11570
  }
11571
- if (!ds2.SharedFunctionalGroupsSequence) {
11571
+ if (!ds.SharedFunctionalGroupsSequence) {
11572
11572
  log.error("Can only process multiframe data with SharedFunctionalGroupsSequence");
11573
11573
  }
11574
- if (ds2.BodyPartExamined === "PROSTATE") {
11575
- ds2.SharedFunctionalGroupsSequence.FrameAnatomySequence = {
11574
+ if (ds.BodyPartExamined === "PROSTATE") {
11575
+ ds.SharedFunctionalGroupsSequence.FrameAnatomySequence = {
11576
11576
  AnatomicRegionSequence: {
11577
11577
  CodeValue: "T-9200B",
11578
11578
  CodingSchemeDesignator: "SRT",
@@ -11581,18 +11581,18 @@ var require_dcmjs = __commonJS({
11581
11581
  FrameLaterality: "U"
11582
11582
  };
11583
11583
  }
11584
- var rescaleIntercept = ds2.RescaleIntercept || 0;
11585
- var rescaleSlope = ds2.RescaleSlope || 1;
11586
- ds2.SharedFunctionalGroupsSequence.PixelValueTransformationSequence = {
11584
+ var rescaleIntercept = ds.RescaleIntercept || 0;
11585
+ var rescaleSlope = ds.RescaleSlope || 1;
11586
+ ds.SharedFunctionalGroupsSequence.PixelValueTransformationSequence = {
11587
11587
  RescaleIntercept: rescaleIntercept,
11588
11588
  RescaleSlope: rescaleSlope,
11589
11589
  RescaleType: "US"
11590
11590
  };
11591
11591
  var frameNumber = 1;
11592
11592
  this.datasets.forEach(function(dataset) {
11593
- if (ds2.NumberOfFrames === 1)
11594
- ds2.PerFrameFunctionalGroupsSequence = [ds2.PerFrameFunctionalGroupsSequence];
11595
- ds2.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
11593
+ if (ds.NumberOfFrames === 1)
11594
+ ds.PerFrameFunctionalGroupsSequence = [ds.PerFrameFunctionalGroupsSequence];
11595
+ ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence = {
11596
11596
  FrameAcquisitionDuration: 0,
11597
11597
  StackID: 1,
11598
11598
  InStackPositionNumber: frameNumber,
@@ -11600,30 +11600,30 @@ var require_dcmjs = __commonJS({
11600
11600
  };
11601
11601
  var frameTime = dataset.AcquisitionDate + dataset.AcquisitionTime;
11602
11602
  if (!isNaN(frameTime)) {
11603
- var frameContentSequence = ds2.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence;
11603
+ var frameContentSequence = ds.PerFrameFunctionalGroupsSequence[frameNumber - 1].FrameContentSequence;
11604
11604
  frameContentSequence.FrameAcquisitionDateTime = frameTime;
11605
11605
  frameContentSequence.FrameReferenceDateTime = frameTime;
11606
11606
  }
11607
11607
  frameNumber++;
11608
11608
  });
11609
- if (ds2.WindowCenter && ds2.WindowWidth) {
11610
- if (!Array.isArray(ds2.WindowCenter)) {
11611
- ds2.WindowCenter = [ds2.WindowCenter];
11609
+ if (ds.WindowCenter && ds.WindowWidth) {
11610
+ if (!Array.isArray(ds.WindowCenter)) {
11611
+ ds.WindowCenter = [ds.WindowCenter];
11612
11612
  }
11613
- if (!Array.isArray(ds2.WindowWidth)) {
11614
- ds2.WindowWidth = [ds2.WindowWidth];
11613
+ if (!Array.isArray(ds.WindowWidth)) {
11614
+ ds.WindowWidth = [ds.WindowWidth];
11615
11615
  }
11616
11616
  }
11617
- if (!ds2.WindowCenter || !ds2.WindowWidth) {
11618
- ds2.WindowCenter = [];
11619
- ds2.WindowWidth = [];
11620
- if (ds2.PerFrameFunctionalGroupsSequence) {
11617
+ if (!ds.WindowCenter || !ds.WindowWidth) {
11618
+ ds.WindowCenter = [];
11619
+ ds.WindowWidth = [];
11620
+ if (ds.PerFrameFunctionalGroupsSequence) {
11621
11621
  var wcww = {
11622
11622
  center: 0,
11623
11623
  width: 0,
11624
11624
  count: 0
11625
11625
  };
11626
- ds2.PerFrameFunctionalGroupsSequence.forEach(function(functionalGroup) {
11626
+ ds.PerFrameFunctionalGroupsSequence.forEach(function(functionalGroup) {
11627
11627
  if (functionalGroup.FrameVOILUT) {
11628
11628
  var wc = functionalGroup.FrameVOILUTSequence.WindowCenter;
11629
11629
  var ww = functionalGroup.FrameVOILUTSequence.WindowWidth;
@@ -11641,16 +11641,16 @@ var require_dcmjs = __commonJS({
11641
11641
  }
11642
11642
  });
11643
11643
  if (wcww.count > 0) {
11644
- ds2.WindowCenter.push(String(wcww.center / wcww.count));
11645
- ds2.WindowWidth.push(String(wcww.width / wcww.count));
11644
+ ds.WindowCenter.push(String(wcww.center / wcww.count));
11645
+ ds.WindowWidth.push(String(wcww.width / wcww.count));
11646
11646
  }
11647
11647
  }
11648
11648
  }
11649
- if (ds2.WindowCenter.length === 0) {
11650
- ds2.WindowCenter = [300];
11649
+ if (ds.WindowCenter.length === 0) {
11650
+ ds.WindowCenter = [300];
11651
11651
  }
11652
- if (ds2.WindowWidth.length === 0) {
11653
- ds2.WindowWidth = [500];
11652
+ if (ds.WindowWidth.length === 0) {
11653
+ ds.WindowWidth = [500];
11654
11654
  }
11655
11655
  }
11656
11656
  }], [{
@@ -11697,12 +11697,12 @@ var require_dcmjs = __commonJS({
11697
11697
  key: "normalizeMultiframe",
11698
11698
  value: function normalizeMultiframe() {
11699
11699
  _get(_getPrototypeOf(MRImageNormalizer2.prototype), "normalizeMultiframe", this).call(this);
11700
- var ds2 = this.dataset;
11701
- if (!ds2.ImageType || !ds2.ImageType.constructor || ds2.ImageType.constructor.name != "Array" || ds2.ImageType.length != 4) {
11702
- ds2.ImageType = ["ORIGINAL", "PRIMARY", "OTHER", "NONE"];
11700
+ var ds = this.dataset;
11701
+ if (!ds.ImageType || !ds.ImageType.constructor || ds.ImageType.constructor.name != "Array" || ds.ImageType.length != 4) {
11702
+ ds.ImageType = ["ORIGINAL", "PRIMARY", "OTHER", "NONE"];
11703
11703
  }
11704
- ds2.SharedFunctionalGroupsSequence.MRImageFrameTypeSequence = {
11705
- FrameType: ds2.ImageType,
11704
+ ds.SharedFunctionalGroupsSequence.MRImageFrameTypeSequence = {
11705
+ FrameType: ds.ImageType,
11706
11706
  PixelPresentation: "MONOCHROME",
11707
11707
  VolumetricProperties: "VOLUME",
11708
11708
  VolumeBasedCalculationTechnique: "NONE",
@@ -11818,9 +11818,9 @@ var require_dcmjs = __commonJS({
11818
11818
  key: "normalize",
11819
11819
  value: function normalize2() {
11820
11820
  _get(_getPrototypeOf(PMImageNormalizer2.prototype), "normalize", this).call(this);
11821
- var ds2 = this.datasets[0];
11822
- if (ds2.BitsAllocated !== 32) {
11823
- log.error("Only works with 32 bit data, not " + String(ds2.BitsAllocated));
11821
+ var ds = this.datasets[0];
11822
+ if (ds.BitsAllocated !== 32) {
11823
+ log.error("Only works with 32 bit data, not " + String(ds.BitsAllocated));
11824
11824
  }
11825
11825
  }
11826
11826
  }]);
@@ -14093,9 +14093,9 @@ var require_dcmjs = __commonJS({
14093
14093
  NumberOfFrames += referencedFramesPerSegment[i2].length;
14094
14094
  }
14095
14095
  seg.setNumberOfFrames(NumberOfFrames);
14096
- for (var _i = 0; _i < segmentIndicies.length; _i++) {
14097
- var segmentIndex = segmentIndicies[_i];
14098
- var referencedFrameIndicies = referencedFramesPerSegment[_i];
14096
+ for (var _i2 = 0; _i2 < segmentIndicies.length; _i2++) {
14097
+ var segmentIndex = segmentIndicies[_i2];
14098
+ var referencedFrameIndicies = referencedFramesPerSegment[_i2];
14099
14099
  var referencedFrameNumbers = referencedFrameIndicies.map(function(element) {
14100
14100
  return element + 1;
14101
14101
  });
@@ -14776,11 +14776,11 @@ var require_dcmjs = __commonJS({
14776
14776
  var bodyLength = rleArray.length % 2 === 0 ? rleArray.length : rleArray.length + 1;
14777
14777
  var encodedFrameBuffer = new ArrayBuffer(headerLength + bodyLength);
14778
14778
  var headerView = new Uint32Array(encodedFrameBuffer, 0, 16);
14779
- for (var _i = 0; _i < headerView.length; _i++) {
14780
- headerView[_i] = header[_i];
14781
- }
14782
14779
  for (var _i2 = 0; _i2 < headerView.length; _i2++) {
14783
- rleArray.push(headerView[_i2]);
14780
+ headerView[_i2] = header[_i2];
14781
+ }
14782
+ for (var _i22 = 0; _i22 < headerView.length; _i22++) {
14783
+ rleArray.push(headerView[_i22]);
14784
14784
  }
14785
14785
  var bodyView = new Uint8Array(encodedFrameBuffer, 64);
14786
14786
  for (var _i3 = 0; _i3 < rleArray.length; _i3++) {
@@ -15481,20 +15481,20 @@ var require_dcmjs = __commonJS({
15481
15481
  referencedFramesPerSegment2[i2] = [];
15482
15482
  }
15483
15483
  }
15484
- var _loop22 = function _loop23(_i2) {
15485
- var labelmap2D = labelmaps2D[_i2];
15486
- if (labelmaps2D[_i2]) {
15484
+ var _loop22 = function _loop23(_i3) {
15485
+ var labelmap2D = labelmaps2D[_i3];
15486
+ if (labelmaps2D[_i3]) {
15487
15487
  var segmentsOnLabelmap = labelmap2D.segmentsOnLabelmap;
15488
15488
  segmentsOnLabelmap.forEach(function(segmentIndex2) {
15489
15489
  if (segmentIndex2 !== 0) {
15490
- referencedFramesPerSegment2[segmentIndex2].push(_i2);
15490
+ referencedFramesPerSegment2[segmentIndex2].push(_i3);
15491
15491
  numberOfFrames++;
15492
15492
  }
15493
15493
  });
15494
15494
  }
15495
15495
  };
15496
- for (var _i = 0; _i < labelmaps2D.length; _i++) {
15497
- _loop22(_i);
15496
+ for (var _i2 = 0; _i2 < labelmaps2D.length; _i2++) {
15497
+ _loop22(_i2);
15498
15498
  }
15499
15499
  referencedFramesPerLabelmap[labelmapIndex2] = referencedFramesPerSegment2;
15500
15500
  };
@@ -25844,8 +25844,8 @@ var require_fecha_umd = __commonJS({
25844
25844
  };
25845
25845
  function assign(origObj) {
25846
25846
  var args = [];
25847
- for (var _i = 1; _i < arguments.length; _i++) {
25848
- args[_i - 1] = arguments[_i];
25847
+ for (var _i2 = 1; _i2 < arguments.length; _i2++) {
25848
+ args[_i2 - 1] = arguments[_i2];
25849
25849
  }
25850
25850
  for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
25851
25851
  var obj = args_1[_a];
@@ -39151,7 +39151,7 @@ __export(main_exports, {
39151
39151
  module.exports = __toCommonJS(main_exports);
39152
39152
 
39153
39153
  // ../core/dist/esm/index.mjs
39154
- var Me = class {
39154
+ var Ne = class {
39155
39155
  constructor(e, t) {
39156
39156
  this.operator = e;
39157
39157
  this.child = t;
@@ -39170,7 +39170,7 @@ var H = class {
39170
39170
  return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
39171
39171
  }
39172
39172
  };
39173
- var Ne = class {
39173
+ var Fe = class {
39174
39174
  constructor() {
39175
39175
  this.prefixParselets = {};
39176
39176
  this.infixParselets = {};
@@ -39194,10 +39194,10 @@ var Ne = class {
39194
39194
  }, precedence: t });
39195
39195
  }
39196
39196
  construct(e) {
39197
- return new Pt(e, this.prefixParselets, this.infixParselets);
39197
+ return new wt(e, this.prefixParselets, this.infixParselets);
39198
39198
  }
39199
39199
  };
39200
- var Pt = class {
39200
+ var wt = class {
39201
39201
  constructor(e, t, n) {
39202
39202
  this.tokens = e, this.prefixParselets = t, this.infixParselets = n;
39203
39203
  }
@@ -39248,12 +39248,12 @@ var Pt = class {
39248
39248
  return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
39249
39249
  }
39250
39250
  };
39251
- var wt = "ok";
39252
- var Fe = "created";
39253
- var It = "not-modified";
39254
- var kt = "not-found";
39255
- var _e = "accepted";
39256
- var Ar = { resourceType: "OperationOutcome", id: kt, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
39251
+ var At = "ok";
39252
+ var _e = "created";
39253
+ var kt = "not-modified";
39254
+ var Ot = "not-found";
39255
+ var Ue = "accepted";
39256
+ var Ar = { resourceType: "OperationOutcome", id: Ot, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
39257
39257
  function E(r4, e) {
39258
39258
  return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r4 }, expression: e ? [e] : void 0 }] };
39259
39259
  }
@@ -39266,66 +39266,66 @@ function Ir(r4) {
39266
39266
  function ae(r4) {
39267
39267
  return typeof r4 == "object" && r4 !== null && r4.resourceType === "OperationOutcome";
39268
39268
  }
39269
- function Ot(r4) {
39270
- return r4.id === wt || r4.id === Fe || r4.id === It || r4.id === _e;
39269
+ function Vt(r4) {
39270
+ return r4.id === At || r4.id === _e || r4.id === kt || r4.id === Ue;
39271
39271
  }
39272
39272
  var p = class extends Error {
39273
39273
  constructor(e, t) {
39274
39274
  super(kr(e)), this.outcome = e, this.cause = t;
39275
39275
  }
39276
39276
  };
39277
- function Ue(r4) {
39278
- return r4 instanceof p ? r4.outcome : ae(r4) ? r4 : E(di(r4));
39277
+ function Le(r4) {
39278
+ return r4 instanceof p ? r4.outcome : ae(r4) ? r4 : E(ui(r4));
39279
39279
  }
39280
- function di(r4) {
39280
+ function ui(r4) {
39281
39281
  return r4 ? typeof r4 == "string" ? r4 : r4 instanceof Error ? r4.message : ae(r4) ? kr(r4) : typeof r4 == "object" && "code" in r4 && typeof r4.code == "string" ? r4.code : JSON.stringify(r4) : "Unknown error";
39282
39282
  }
39283
39283
  function kr(r4) {
39284
- let e = r4.issue?.map(pi) ?? [];
39284
+ let e = r4.issue?.map(li) ?? [];
39285
39285
  return e.length > 0 ? e.join("; ") : "Unknown error";
39286
39286
  }
39287
- function pi(r4) {
39287
+ function li(r4) {
39288
39288
  let e;
39289
39289
  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;
39290
39290
  }
39291
39291
  function Y(r4) {
39292
- let e = Z(r4), t = mi(r4);
39292
+ let e = Z(r4), t = pi(r4);
39293
39293
  return t === e ? { reference: e } : { reference: e, display: t };
39294
39294
  }
39295
39295
  function Z(r4) {
39296
- return ve(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
39296
+ return Te(r4) ? r4.reference : `${r4.resourceType}/${r4.id}`;
39297
39297
  }
39298
- function Le(r4) {
39298
+ function Be(r4) {
39299
39299
  if (r4)
39300
- return ve(r4) ? r4.reference.split("/")[1] : r4.id;
39300
+ return Te(r4) ? r4.reference.split("/")[1] : r4.id;
39301
39301
  }
39302
- function fi(r4) {
39302
+ function di(r4) {
39303
39303
  return r4.resourceType === "Patient" || r4.resourceType === "Practitioner" || r4.resourceType === "RelatedPerson";
39304
39304
  }
39305
- function mi(r4) {
39306
- if (fi(r4)) {
39307
- let e = hi(r4);
39305
+ function pi(r4) {
39306
+ if (di(r4)) {
39307
+ let e = fi(r4);
39308
39308
  if (e)
39309
39309
  return e;
39310
39310
  }
39311
39311
  if (r4.resourceType === "Device") {
39312
- let e = gi(r4);
39312
+ let e = mi(r4);
39313
39313
  if (e)
39314
39314
  return e;
39315
39315
  }
39316
39316
  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 : Z(r4);
39317
39317
  }
39318
- function hi(r4) {
39318
+ function fi(r4) {
39319
39319
  let e = r4.name;
39320
39320
  if (e && e.length > 0)
39321
- return Ge(e[0]);
39321
+ return He(e[0]);
39322
39322
  }
39323
- function gi(r4) {
39323
+ function mi(r4) {
39324
39324
  let e = r4.deviceName;
39325
39325
  if (e && e.length > 0)
39326
39326
  return e[0].name;
39327
39327
  }
39328
- function Be(r4, e) {
39328
+ function qe(r4, e) {
39329
39329
  let t = new Date(r4);
39330
39330
  t.setUTCHours(0, 0, 0, 0);
39331
39331
  let n = e ? new Date(e) : /* @__PURE__ */ new Date();
@@ -39344,12 +39344,12 @@ function Fr(r4, ...e) {
39344
39344
  return t;
39345
39345
  }
39346
39346
  function _r(r4, e) {
39347
- return JSON.stringify(r4, yi, e ? 2 : void 0);
39347
+ return JSON.stringify(r4, hi, e ? 2 : void 0);
39348
39348
  }
39349
- function yi(r4, e) {
39350
- return !xi(r4) && T(e) ? void 0 : e;
39349
+ function hi(r4, e) {
39350
+ return !gi(r4) && T(e) ? void 0 : e;
39351
39351
  }
39352
- function xi(r4) {
39352
+ function gi(r4) {
39353
39353
  return !!/\d+$/.exec(r4);
39354
39354
  }
39355
39355
  function T(r4) {
@@ -39385,13 +39385,13 @@ function qr(r4) {
39385
39385
  function R(r4) {
39386
39386
  return r4 ? r4.charAt(0).toUpperCase() + r4.substring(1) : "";
39387
39387
  }
39388
- var Nt = (r4) => new Promise((e) => {
39388
+ var Ft = (r4) => new Promise((e) => {
39389
39389
  setTimeout(e, r4);
39390
39390
  });
39391
39391
  function Qr(r4, e) {
39392
39392
  return new URL(r4, e).toString().replace("http://", "ws://").replace("https://", "wss://");
39393
39393
  }
39394
- function Ge(r4, e) {
39394
+ function He(r4, e) {
39395
39395
  let t = [];
39396
39396
  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) {
39397
39397
  let n = le(r4.text);
@@ -39403,18 +39403,18 @@ function Ge(r4, e) {
39403
39403
  function le(r4) {
39404
39404
  return typeof r4 == "string" ? r4 : void 0;
39405
39405
  }
39406
- function Li(r4, e) {
39406
+ function _i(r4, e) {
39407
39407
  let t = e.max && e.max === Number.MAX_SAFE_INTEGER ? Number.POSITIVE_INFINITY : e.max;
39408
39408
  return { path: r4, description: "", type: e.type ?? [], min: e.min ?? 0, max: t ?? 1, isArray: !!t && t > 1, constraints: [] };
39409
39409
  }
39410
39410
  function Hr(r4) {
39411
39411
  let e = /* @__PURE__ */ Object.create(null);
39412
39412
  for (let [t, n] of Object.entries(r4))
39413
- e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, Li(i2, o)])), constraints: [], innerTypes: [] };
39413
+ e[t] = { name: t, elements: Object.fromEntries(Object.entries(n.elements).map(([i2, o]) => [i2, _i(i2, o)])), constraints: [], innerTypes: [] };
39414
39414
  return e;
39415
39415
  }
39416
39416
  var Wr = { Element: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, BackboneElement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] } } }, Address: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, line: { max: 9007199254740991, type: [{ code: "string" }] }, city: { type: [{ code: "string" }] }, district: { type: [{ code: "string" }] }, state: { type: [{ code: "string" }] }, postalCode: { type: [{ code: "string" }] }, country: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Age: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Annotation: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "author[x]": { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Organization"] }, { code: "string" }] }, time: { type: [{ code: "dateTime" }] }, text: { min: 1, type: [{ code: "markdown" }] } } }, Attachment: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, contentType: { type: [{ code: "code" }] }, language: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] }, url: { type: [{ code: "url" }] }, size: { type: [{ code: "unsignedInt" }] }, hash: { type: [{ code: "base64Binary" }] }, title: { type: [{ code: "string" }] }, creation: { type: [{ code: "dateTime" }] } } }, CodeableConcept: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, coding: { max: 9007199254740991, type: [{ code: "Coding" }] }, text: { type: [{ code: "string" }] } } }, Coding: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "uri" }] }, version: { type: [{ code: "string" }] }, code: { type: [{ code: "code" }] }, display: { type: [{ code: "string" }] }, userSelected: { type: [{ code: "boolean" }] } } }, ContactDetail: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "string" }] }, telecom: { max: 9007199254740991, type: [{ code: "ContactPoint" }] } } }, ContactPoint: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, system: { type: [{ code: "code" }] }, value: { type: [{ code: "string" }] }, use: { type: [{ code: "code" }] }, rank: { type: [{ code: "positiveInt" }] }, period: { type: [{ code: "Period" }] } } }, Contributor: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { min: 1, type: [{ code: "string" }] }, contact: { max: 9007199254740991, type: [{ code: "ContactDetail" }] } } }, Count: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, DataRequirement: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, "subject[x]": { type: [{ code: "CodeableConcept" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Group"] }] }, mustSupport: { max: 9007199254740991, type: [{ code: "string" }] }, codeFilter: { max: 9007199254740991, type: [{ code: "DataRequirementCodeFilter" }] }, dateFilter: { max: 9007199254740991, type: [{ code: "DataRequirementDateFilter" }] }, limit: { type: [{ code: "positiveInt" }] }, sort: { max: 9007199254740991, type: [{ code: "DataRequirementSort" }] } } }, Distance: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Dosage: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, sequence: { type: [{ code: "integer" }] }, text: { type: [{ code: "string" }] }, additionalInstruction: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] }, patientInstruction: { type: [{ code: "string" }] }, timing: { type: [{ code: "Timing" }] }, "asNeeded[x]": { type: [{ code: "boolean" }, { code: "CodeableConcept" }] }, site: { type: [{ code: "CodeableConcept" }] }, route: { type: [{ code: "CodeableConcept" }] }, method: { type: [{ code: "CodeableConcept" }] }, doseAndRate: { max: 9007199254740991, type: [{ code: "DosageDoseAndRate" }] }, maxDosePerPeriod: { type: [{ code: "Ratio" }] }, maxDosePerAdministration: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, maxDosePerLifetime: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Duration: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, ElementDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, path: { min: 1, type: [{ code: "string" }] }, representation: { max: 9007199254740991, type: [{ code: "code" }] }, sliceName: { type: [{ code: "string" }] }, sliceIsConstraining: { type: [{ code: "boolean" }] }, label: { type: [{ code: "string" }] }, code: { max: 9007199254740991, type: [{ code: "Coding" }] }, slicing: { type: [{ code: "ElementDefinitionSlicing" }] }, short: { type: [{ code: "string" }] }, definition: { type: [{ code: "markdown" }] }, comment: { type: [{ code: "markdown" }] }, requirements: { type: [{ code: "markdown" }] }, alias: { max: 9007199254740991, type: [{ code: "string" }] }, min: { type: [{ code: "unsignedInt" }] }, max: { type: [{ code: "string" }] }, base: { type: [{ code: "ElementDefinitionBase" }] }, contentReference: { type: [{ code: "uri" }] }, type: { max: 9007199254740991, type: [{ code: "ElementDefinitionType" }] }, "defaultValue[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, meaningWhenMissing: { type: [{ code: "markdown" }] }, orderMeaning: { type: [{ code: "string" }] }, "fixed[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, "pattern[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] }, example: { max: 9007199254740991, type: [{ code: "ElementDefinitionExample" }] }, "minValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, "maxValue[x]": { type: [{ code: "date" }, { code: "dateTime" }, { code: "instant" }, { code: "time" }, { code: "decimal" }, { code: "integer" }, { code: "positiveInt" }, { code: "unsignedInt" }, { code: "Quantity" }] }, maxLength: { type: [{ code: "integer" }] }, condition: { max: 9007199254740991, type: [{ code: "id" }] }, constraint: { max: 9007199254740991, type: [{ code: "ElementDefinitionConstraint" }] }, mustSupport: { type: [{ code: "boolean" }] }, isModifier: { type: [{ code: "boolean" }] }, isModifierReason: { type: [{ code: "string" }] }, isSummary: { type: [{ code: "boolean" }] }, binding: { type: [{ code: "ElementDefinitionBinding" }] }, mapping: { max: 9007199254740991, type: [{ code: "ElementDefinitionMapping" }] } } }, Expression: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, description: { type: [{ code: "string" }] }, name: { type: [{ code: "id" }] }, language: { min: 1, type: [{ code: "code" }] }, expression: { type: [{ code: "string" }] }, reference: { type: [{ code: "uri" }] } } }, Extension: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, url: { min: 1, type: [{ code: "uri" }] }, "value[x]": { type: [{ code: "base64Binary" }, { code: "boolean" }, { code: "canonical" }, { code: "code" }, { code: "date" }, { code: "dateTime" }, { code: "decimal" }, { code: "id" }, { code: "instant" }, { code: "integer" }, { code: "markdown" }, { code: "oid" }, { code: "positiveInt" }, { code: "string" }, { code: "time" }, { code: "unsignedInt" }, { code: "uri" }, { code: "url" }, { code: "uuid" }, { code: "Address" }, { code: "Age" }, { code: "Annotation" }, { code: "Attachment" }, { code: "CodeableConcept" }, { code: "Coding" }, { code: "ContactPoint" }, { code: "Count" }, { code: "Distance" }, { code: "Duration" }, { code: "HumanName" }, { code: "Identifier" }, { code: "Money" }, { code: "Period" }, { code: "Quantity" }, { code: "Range" }, { code: "Ratio" }, { code: "Reference" }, { code: "SampledData" }, { code: "Signature" }, { code: "Timing" }, { code: "ContactDetail" }, { code: "Contributor" }, { code: "DataRequirement" }, { code: "Expression" }, { code: "ParameterDefinition" }, { code: "RelatedArtifact" }, { code: "TriggerDefinition" }, { code: "UsageContext" }, { code: "Dosage" }, { code: "Meta" }] } } }, HumanName: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, text: { type: [{ code: "string" }] }, family: { type: [{ code: "string" }] }, given: { max: 9007199254740991, type: [{ code: "string" }] }, prefix: { max: 9007199254740991, type: [{ code: "string" }] }, suffix: { max: 9007199254740991, type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] } } }, Identifier: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, use: { type: [{ code: "code" }] }, type: { type: [{ code: "CodeableConcept" }] }, system: { type: [{ code: "uri" }] }, value: { type: [{ code: "string" }] }, period: { type: [{ code: "Period" }] }, assigner: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MarketingStatus: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, country: { min: 1, type: [{ code: "CodeableConcept" }] }, jurisdiction: { type: [{ code: "CodeableConcept" }] }, status: { min: 1, type: [{ code: "CodeableConcept" }] }, dateRange: { min: 1, type: [{ code: "Period" }] }, restoreDate: { type: [{ code: "dateTime" }] } } }, Meta: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, versionId: { type: [{ code: "id" }] }, lastUpdated: { type: [{ code: "instant" }] }, source: { type: [{ code: "uri" }] }, profile: { max: 9007199254740991, type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] }, security: { max: 9007199254740991, type: [{ code: "Coding" }] }, tag: { max: 9007199254740991, type: [{ code: "Coding" }] }, project: { type: [{ code: "uri" }] }, author: { type: [{ code: "Reference" }] }, account: { type: [{ code: "Reference" }] }, compartment: { max: 9007199254740991, type: [{ code: "Reference" }] } } }, Money: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, currency: { type: [{ code: "code" }] } } }, Narrative: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, status: { min: 1, type: [{ code: "code" }] }, div: { min: 1, type: [{ code: "xhtml" }] } } }, ParameterDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, name: { type: [{ code: "code" }] }, use: { min: 1, type: [{ code: "code" }] }, min: { type: [{ code: "integer" }] }, max: { type: [{ code: "string" }] }, documentation: { type: [{ code: "string" }] }, type: { min: 1, type: [{ code: "code" }] }, profile: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/StructureDefinition"] }] } } }, Period: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, start: { type: [{ code: "dateTime" }] }, end: { type: [{ code: "dateTime" }] } } }, Population: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "age[x]": { type: [{ code: "Range" }, { code: "CodeableConcept" }] }, gender: { type: [{ code: "CodeableConcept" }] }, race: { type: [{ code: "CodeableConcept" }] }, physiologicalCondition: { type: [{ code: "CodeableConcept" }] } } }, ProdCharacteristic: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, height: { type: [{ code: "Quantity" }] }, width: { type: [{ code: "Quantity" }] }, depth: { type: [{ code: "Quantity" }] }, weight: { type: [{ code: "Quantity" }] }, nominalVolume: { type: [{ code: "Quantity" }] }, externalDiameter: { type: [{ code: "Quantity" }] }, shape: { type: [{ code: "string" }] }, color: { max: 9007199254740991, type: [{ code: "string" }] }, imprint: { max: 9007199254740991, type: [{ code: "string" }] }, image: { max: 9007199254740991, type: [{ code: "Attachment" }] }, scoring: { type: [{ code: "CodeableConcept" }] } } }, ProductShelfLife: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, identifier: { type: [{ code: "Identifier" }] }, type: { min: 1, type: [{ code: "CodeableConcept" }] }, period: { min: 1, type: [{ code: "Quantity" }] }, specialPrecautionsForStorage: { max: 9007199254740991, type: [{ code: "CodeableConcept" }] } } }, Quantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, Range: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, low: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, high: { type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] } } }, Ratio: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, numerator: { type: [{ code: "Quantity" }] }, denominator: { type: [{ code: "Quantity" }] } } }, Reference: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, reference: { type: [{ code: "string" }] }, type: { type: [{ code: "uri" }] }, identifier: { type: [{ code: "Identifier" }] }, display: { type: [{ code: "string" }] } } }, RelatedArtifact: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, label: { type: [{ code: "string" }] }, display: { type: [{ code: "string" }] }, citation: { type: [{ code: "markdown" }] }, url: { type: [{ code: "url" }] }, document: { type: [{ code: "Attachment" }] }, resource: { type: [{ code: "canonical", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Resource"] }] } } }, SampledData: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, origin: { min: 1, type: [{ code: "Quantity", profile: ["http://hl7.org/fhir/StructureDefinition/SimpleQuantity"] }] }, period: { min: 1, type: [{ code: "decimal" }] }, factor: { type: [{ code: "decimal" }] }, lowerLimit: { type: [{ code: "decimal" }] }, upperLimit: { type: [{ code: "decimal" }] }, dimensions: { min: 1, type: [{ code: "positiveInt" }] }, data: { type: [{ code: "string" }] } } }, Signature: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, max: 9007199254740991, type: [{ code: "Coding" }] }, when: { min: 1, type: [{ code: "instant" }] }, who: { min: 1, type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, onBehalfOf: { type: [{ code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Practitioner", "http://hl7.org/fhir/StructureDefinition/PractitionerRole", "http://hl7.org/fhir/StructureDefinition/RelatedPerson", "http://hl7.org/fhir/StructureDefinition/Patient", "http://hl7.org/fhir/StructureDefinition/Device", "http://hl7.org/fhir/StructureDefinition/Organization"] }] }, targetFormat: { type: [{ code: "code" }] }, sigFormat: { type: [{ code: "code" }] }, data: { type: [{ code: "base64Binary" }] } } }, SubstanceAmount: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, "amount[x]": { type: [{ code: "Quantity" }, { code: "Range" }, { code: "string" }] }, amountType: { type: [{ code: "CodeableConcept" }] }, amountText: { type: [{ code: "string" }] }, referenceRange: { type: [{ code: "SubstanceAmountReferenceRange" }] } } }, Timing: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, modifierExtension: { max: 9007199254740991, type: [{ code: "Extension" }] }, event: { max: 9007199254740991, type: [{ code: "dateTime" }] }, repeat: { type: [{ code: "TimingRepeat" }] }, code: { type: [{ code: "CodeableConcept" }] } } }, TriggerDefinition: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, type: { min: 1, type: [{ code: "code" }] }, name: { type: [{ code: "string" }] }, "timing[x]": { type: [{ code: "Timing" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/Schedule"] }, { code: "date" }, { code: "dateTime" }] }, data: { max: 9007199254740991, type: [{ code: "DataRequirement" }] }, condition: { type: [{ code: "Expression" }] } } }, UsageContext: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, code: { min: 1, type: [{ code: "Coding" }] }, "value[x]": { min: 1, type: [{ code: "CodeableConcept" }, { code: "Quantity" }, { code: "Range" }, { code: "Reference", targetProfile: ["http://hl7.org/fhir/StructureDefinition/PlanDefinition", "http://hl7.org/fhir/StructureDefinition/ResearchStudy", "http://hl7.org/fhir/StructureDefinition/InsurancePlan", "http://hl7.org/fhir/StructureDefinition/HealthcareService", "http://hl7.org/fhir/StructureDefinition/Group", "http://hl7.org/fhir/StructureDefinition/Location", "http://hl7.org/fhir/StructureDefinition/Organization"] }] } } }, MoneyQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, SimpleQuantity: { elements: { id: { type: [{ code: "string" }] }, extension: { max: 9007199254740991, type: [{ code: "Extension" }] }, value: { type: [{ code: "decimal" }] }, comparator: { max: 0, type: [{ code: "code" }] }, unit: { type: [{ code: "string" }] }, system: { type: [{ code: "uri" }] }, code: { type: [{ code: "code" }] } } }, 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" }] } } } };
39417
- var He = { base64Binary: /^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/, canonical: /^\S*$/, code: /^[^\s]+( [^\s]+)*$/, date: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/, dateTime: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/, id: /^[A-Za-z0-9\-.]{1,64}$/, instant: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/, markdown: /^[\s\S]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\s\S]+$/, time: /^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/, uri: /^\S*$/, url: /^\S*$/, uuid: /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, xhtml: /.*/ };
39417
+ var We = { base64Binary: /^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/, canonical: /^\S*$/, code: /^[^\s]+( [^\s]+)*$/, date: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/, dateTime: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/, id: /^[A-Za-z0-9\-.]{1,64}$/, instant: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/, markdown: /^[\s\S]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\s\S]+$/, time: /^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/, uri: /^\S*$/, url: /^\S*$/, uuid: /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, xhtml: /.*/ };
39418
39418
  function f(r4) {
39419
39419
  return [{ type: l.boolean, value: r4 }];
39420
39420
  }
@@ -39434,10 +39434,10 @@ function L(r4, e) {
39434
39434
  function I(r4, e, t) {
39435
39435
  if (!r4.value)
39436
39436
  return;
39437
- let n = Je(r4.type, e, t?.profileUrl);
39438
- return n ? Hi(r4, e, n) : Wi(r4, e);
39437
+ let n = Ye(r4.type, e, t?.profileUrl);
39438
+ return n ? Qi(r4, e, n) : Gi(r4, e);
39439
39439
  }
39440
- function Hi(r4, e, t) {
39440
+ function Qi(r4, e, t) {
39441
39441
  let n = r4.value, i2 = t.type;
39442
39442
  if (!i2 || i2.length === 0)
39443
39443
  return;
@@ -39465,7 +39465,7 @@ function Hi(r4, e, t) {
39465
39465
  function Yr(r4, e) {
39466
39466
  return e === "Resource" && U(r4) && (e = r4.resourceType), { type: e, value: r4 };
39467
39467
  }
39468
- function Wi(r4, e) {
39468
+ function Gi(r4, e) {
39469
39469
  let t = r4.value;
39470
39470
  if (!t || typeof t != "object")
39471
39471
  return;
@@ -39483,7 +39483,7 @@ function Wi(r4, e) {
39483
39483
  if (!T(n))
39484
39484
  return Array.isArray(n) ? n.map(g) : g(n);
39485
39485
  }
39486
- function Ke(r4) {
39486
+ function ze(r4) {
39487
39487
  let e = [];
39488
39488
  for (let t of r4) {
39489
39489
  let n = false;
@@ -39496,28 +39496,28 @@ function Ke(r4) {
39496
39496
  }
39497
39497
  return e;
39498
39498
  }
39499
- function Qt(r4) {
39499
+ function Gt(r4) {
39500
39500
  return f(!N(r4));
39501
39501
  }
39502
- function Gt(r4, e) {
39502
+ function Ht(r4, e) {
39503
39503
  return r4.length === 0 || e.length === 0 ? [] : r4.length !== e.length ? f(false) : f(r4.every((t, n) => N(rn(t, e[n]))));
39504
39504
  }
39505
39505
  function rn(r4, e) {
39506
39506
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39507
- return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : P(t) && P(n) ? f(sn(t, n)) : f(typeof t == "object" && typeof n == "object" ? Wt(r4, e) : t === n);
39507
+ return typeof t == "number" && typeof n == "number" ? f(Math.abs(t - n) < 1e-8) : P(t) && P(n) ? f(sn(t, n)) : f(typeof t == "object" && typeof n == "object" ? Kt(r4, e) : t === n);
39508
39508
  }
39509
- function Ht(r4, e) {
39510
- return r4.length === 0 && e.length === 0 ? f(true) : r4.length !== e.length ? f(false) : (r4.sort(Zr), e.sort(Zr), f(r4.every((t, n) => N(Ki(t, e[n])))));
39509
+ function Wt(r4, e) {
39510
+ return r4.length === 0 && e.length === 0 ? f(true) : r4.length !== e.length ? f(false) : (r4.sort(Zr), e.sort(Zr), f(r4.every((t, n) => N(Hi(t, e[n])))));
39511
39511
  }
39512
- function Ki(r4, e) {
39512
+ function Hi(r4, e) {
39513
39513
  let { type: t, value: n } = r4, { type: i2, value: o } = e, s = n?.valueOf(), a = o?.valueOf();
39514
- return typeof s == "number" && typeof a == "number" ? f(Math.abs(s - a) < 0.01) : P(s) && P(a) ? f(sn(s, a)) : f(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" ? Wt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
39514
+ return typeof s == "number" && typeof a == "number" ? f(Math.abs(s - a) < 0.01) : P(s) && P(a) ? f(sn(s, a)) : f(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" ? Kt({ ...s, id: void 0 }, { ...a, id: void 0 }) : typeof s == "string" && typeof a == "string" ? s.toLowerCase() === a.toLowerCase() : s === a);
39515
39515
  }
39516
39516
  function Zr(r4, e) {
39517
39517
  let t = r4.value?.valueOf(), n = e.value?.valueOf();
39518
39518
  return typeof t == "number" && typeof n == "number" ? t - n : typeof t == "string" && typeof n == "string" ? t.localeCompare(n) : 0;
39519
39519
  }
39520
- function ze(r4, e) {
39520
+ function Je(r4, e) {
39521
39521
  let { value: t } = r4;
39522
39522
  if (t == null)
39523
39523
  return false;
@@ -39530,7 +39530,7 @@ function ze(r4, e) {
39530
39530
  case "Date":
39531
39531
  return nn(t);
39532
39532
  case "DateTime":
39533
- return We(t);
39533
+ return Ke(t);
39534
39534
  case "Time":
39535
39535
  return typeof t == "string" && !!/^T\d/.exec(t);
39536
39536
  case "Period":
@@ -39542,13 +39542,13 @@ function ze(r4, e) {
39542
39542
  }
39543
39543
  }
39544
39544
  function nn(r4) {
39545
- return typeof r4 == "string" && !!He.date.exec(r4);
39545
+ return typeof r4 == "string" && !!We.date.exec(r4);
39546
39546
  }
39547
- function We(r4) {
39548
- return typeof r4 == "string" && !!He.dateTime.exec(r4);
39547
+ function Ke(r4) {
39548
+ return typeof r4 == "string" && !!We.dateTime.exec(r4);
39549
39549
  }
39550
39550
  function on(r4) {
39551
- return !!(r4 && typeof r4 == "object" && ("start" in r4 && We(r4.start) || "end" in r4 && We(r4.end)));
39551
+ return !!(r4 && typeof r4 == "object" && ("start" in r4 && Ke(r4.start) || "end" in r4 && Ke(r4.end)));
39552
39552
  }
39553
39553
  function P(r4) {
39554
39554
  return !!(r4 && typeof r4 == "object" && "value" in r4 && typeof r4.value == "number");
@@ -39556,14 +39556,14 @@ function P(r4) {
39556
39556
  function sn(r4, e) {
39557
39557
  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);
39558
39558
  }
39559
- function Wt(r4, e) {
39559
+ function Kt(r4, e) {
39560
39560
  let t = Object.keys(r4), n = Object.keys(e);
39561
39561
  if (t.length !== n.length)
39562
39562
  return false;
39563
39563
  for (let i2 of t) {
39564
39564
  let o = r4[i2], s = e[i2];
39565
39565
  if (en(o) && en(s)) {
39566
- if (!Wt(o, s))
39566
+ if (!Kt(o, s))
39567
39567
  return false;
39568
39568
  } else if (o !== s)
39569
39569
  return false;
@@ -39577,53 +39577,53 @@ function tn(r4, e) {
39577
39577
  if (e) {
39578
39578
  if (typeof e != "object")
39579
39579
  throw new Error("Primitive extension must be an object");
39580
- return zi(r4 ?? {}, e);
39580
+ return Wi(r4 ?? {}, e);
39581
39581
  }
39582
39582
  return r4;
39583
39583
  }
39584
- function zi(r4, e) {
39584
+ function Wi(r4, e) {
39585
39585
  return delete e.__proto__, delete e.constructor, Object.assign(r4, e);
39586
39586
  }
39587
- function $t(r4) {
39588
- return new Jt(r4).parse();
39587
+ function Qt(r4) {
39588
+ return new Yt(r4).parse();
39589
39589
  }
39590
- var Se = Hr(Wr);
39591
- var Zt = /* @__PURE__ */ Object.create(null);
39590
+ var Ee = Hr(Wr);
39591
+ var Xt = /* @__PURE__ */ Object.create(null);
39592
39592
  var an = /* @__PURE__ */ Object.create(null);
39593
- function zt(r4) {
39593
+ function Jt(r4) {
39594
39594
  let e;
39595
- return r4 ? (e = an[r4], e || (e = an[r4] = /* @__PURE__ */ Object.create(null))) : e = Se, e;
39595
+ return r4 ? (e = an[r4], e || (e = an[r4] = /* @__PURE__ */ Object.create(null))) : e = Ee, e;
39596
39596
  }
39597
- function Xt(r4, e) {
39597
+ function er(r4, e) {
39598
39598
  let t = Array.isArray(r4) ? r4 : r4.entry?.map((n) => n.resource) ?? [];
39599
39599
  for (let n of t)
39600
- er(n, e);
39600
+ tr(n, e);
39601
39601
  }
39602
- function er(r4, e) {
39602
+ function tr(r4, e) {
39603
39603
  if (!r4?.name)
39604
39604
  throw new Error("Failed loading StructureDefinition from bundle");
39605
39605
  if (r4.resourceType !== "StructureDefinition")
39606
39606
  return;
39607
- let t = $t(r4), n = zt(e);
39608
- n[r4.name] = t, e && r4.url === e && (Zt[e] = t);
39607
+ let t = Qt(r4), n = Jt(e);
39608
+ n[r4.name] = t, e && r4.url === e && (Xt[e] = t);
39609
39609
  for (let i2 of t.innerTypes)
39610
39610
  i2.parentType = t, n[i2.name] = i2;
39611
39611
  }
39612
39612
  function pn(r4) {
39613
- return !!Se[r4];
39613
+ return !!Ee[r4];
39614
39614
  }
39615
- function Ee(r4, e) {
39616
- let t = zt(e)[r4];
39617
- return !t && e && (t = zt()[r4]), t;
39615
+ function be(r4, e) {
39616
+ let t = Jt(e)[r4];
39617
+ return !t && e && (t = Jt()[r4]), t;
39618
39618
  }
39619
39619
  function mn(r4) {
39620
- return !!Zt[r4];
39620
+ return !!Xt[r4];
39621
39621
  }
39622
- var Jt = class {
39622
+ var Yt = class {
39623
39623
  constructor(e) {
39624
39624
  if (!e.snapshot?.element || e.snapshot.element.length === 0)
39625
39625
  throw new Error(`No snapshot defined for StructureDefinition '${e.name}'`);
39626
- 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: Xi(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
39626
+ 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: Yi(e), elements: {}, constraints: this.parseElementDefinition(this.root).constraints, innerTypes: [], summaryProperties: /* @__PURE__ */ new Set(), mandatoryProperties: /* @__PURE__ */ new Set() }, this.innerTypes = [];
39627
39627
  }
39628
39628
  parse() {
39629
39629
  let e = this.next();
@@ -39632,7 +39632,7 @@ var Jt = class {
39632
39632
  this.parseSliceStart(e);
39633
39633
  else if (e.id?.includes(":")) {
39634
39634
  if (this.slicingContext?.current) {
39635
- let t = Kt(e, this.slicingContext.path);
39635
+ let t = zt(e, this.slicingContext.path);
39636
39636
  this.slicingContext.current.elements[t] = this.parseElementDefinition(e);
39637
39637
  }
39638
39638
  } else {
@@ -39641,13 +39641,13 @@ var Jt = class {
39641
39641
  let n = this.backboneContext;
39642
39642
  for (; n; ) {
39643
39643
  if (e.path?.startsWith(n.path + ".")) {
39644
- n.type.elements[Kt(e, n.path)] = t;
39644
+ n.type.elements[zt(e, n.path)] = t;
39645
39645
  break;
39646
39646
  }
39647
39647
  n = n.parent;
39648
39648
  }
39649
39649
  if (!n) {
39650
- let i2 = Kt(e, this.root.path);
39650
+ let i2 = zt(e, this.root.path);
39651
39651
  e.isSummary && this.resourceSchema.summaryProperties?.add(i2.replace("[x]", "")), t.min > 0 && this.resourceSchema.mandatoryProperties?.add(i2.replace("[x]", "")), this.resourceSchema.elements[i2] = t;
39652
39652
  }
39653
39653
  this.checkFieldExit(e);
@@ -39662,10 +39662,10 @@ var Jt = class {
39662
39662
  enterInnerType(e) {
39663
39663
  for (; this.backboneContext && !pe(this.backboneContext?.path, e.path); )
39664
39664
  this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
39665
- this.backboneContext = { type: { name: Yt(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: pe(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
39665
+ this.backboneContext = { type: { name: Zt(e), title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path ?? "", parent: pe(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
39666
39666
  }
39667
39667
  enterSlice(e, t) {
39668
- Zi(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
39668
+ Ji(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
39669
39669
  if (n.type !== "value" && n.type !== "pattern" && n.type !== "type")
39670
39670
  throw new Error(`Unsupported slicing discriminator type: ${n.type}`);
39671
39671
  return { path: n.path, type: n.type };
@@ -39708,7 +39708,7 @@ var Jt = class {
39708
39708
  parseElementDefinitionType(e) {
39709
39709
  return (e.type ?? []).map((t) => {
39710
39710
  let n;
39711
- return (t.code === "BackboneElement" || t.code === "Element") && (n = Yt(e)), n || (n = Fr(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
39711
+ return (t.code === "BackboneElement" || t.code === "Element") && (n = Zt(e)), n || (n = Fr(t, "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type")?.valueUrl), n || (n = t.code ?? ""), { code: n, targetProfile: t.targetProfile, profile: t.profile };
39712
39712
  });
39713
39713
  }
39714
39714
  parseElementDefinition(e) {
@@ -39719,10 +39719,10 @@ var Jt = class {
39719
39719
  function un(r4) {
39720
39720
  return r4 === "*" ? Number.POSITIVE_INFINITY : Number.parseInt(r4, 10);
39721
39721
  }
39722
- function Kt(r4, e = "") {
39723
- return Yi(r4.path, e);
39722
+ function zt(r4, e = "") {
39723
+ return zi(r4.path, e);
39724
39724
  }
39725
- function Yi(r4, e) {
39725
+ function zi(r4, e) {
39726
39726
  return r4 ? e && r4.startsWith(e) ? r4.substring(e.length + 1) : r4 : "";
39727
39727
  }
39728
39728
  function pe(r4, e) {
@@ -39731,34 +39731,34 @@ function pe(r4, e) {
39731
39731
  function ln(r4) {
39732
39732
  return Array.isArray(r4) && r4.length > 0 ? r4[0] : T(r4) ? void 0 : r4;
39733
39733
  }
39734
- function Zi(r4) {
39734
+ function Ji(r4) {
39735
39735
  let e = r4.slicing?.discriminator;
39736
39736
  return !!(r4.type?.some((t) => t.code === "Extension") && e?.length === 1 && e[0].type === "value" && e[0].path === "url");
39737
39737
  }
39738
- function Xi(r4) {
39738
+ function Yi(r4) {
39739
39739
  let e = r4.description;
39740
39740
  return e?.startsWith(`Base StructureDefinition for ${r4.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r4.name} Type: `.length)), e;
39741
39741
  }
39742
39742
  var l = { Address: "Address", Age: "Age", Annotation: "Annotation", Attachment: "Attachment", BackboneElement: "BackboneElement", CodeableConcept: "CodeableConcept", Coding: "Coding", ContactDetail: "ContactDetail", ContactPoint: "ContactPoint", Contributor: "Contributor", Count: "Count", DataRequirement: "DataRequirement", Distance: "Distance", Dosage: "Dosage", Duration: "Duration", Expression: "Expression", Extension: "Extension", HumanName: "HumanName", Identifier: "Identifier", MarketingStatus: "MarketingStatus", Meta: "Meta", Money: "Money", Narrative: "Narrative", ParameterDefinition: "ParameterDefinition", Period: "Period", Population: "Population", ProdCharacteristic: "ProdCharacteristic", ProductShelfLife: "ProductShelfLife", Quantity: "Quantity", Range: "Range", Ratio: "Ratio", Reference: "Reference", RelatedArtifact: "RelatedArtifact", SampledData: "SampledData", Signature: "Signature", SubstanceAmount: "SubstanceAmount", SystemString: "http://hl7.org/fhirpath/System.String", Timing: "Timing", TriggerDefinition: "TriggerDefinition", UsageContext: "UsageContext", base64Binary: "base64Binary", boolean: "boolean", canonical: "canonical", code: "code", date: "date", dateTime: "dateTime", decimal: "decimal", id: "id", instant: "instant", integer: "integer", markdown: "markdown", oid: "oid", positiveInt: "positiveInt", string: "string", time: "time", unsignedInt: "unsignedInt", uri: "uri", url: "url", uuid: "uuid" };
39743
- function rr(r4) {
39743
+ function nr(r4) {
39744
39744
  for (let e of r4.base ?? []) {
39745
39745
  let t = F.types[e];
39746
39746
  t || (t = { searchParamsDetails: {} }, F.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;
39747
39747
  }
39748
39748
  }
39749
- function Yt(r4) {
39749
+ function Zt(r4) {
39750
39750
  let e = r4.type?.[0]?.code;
39751
- return e === "BackboneElement" || e === "Element" ? eo((r4.base?.path ?? r4.path)?.split(".")) : e;
39751
+ return e === "BackboneElement" || e === "Element" ? Zi((r4.base?.path ?? r4.path)?.split(".")) : e;
39752
39752
  }
39753
- function eo(r4) {
39753
+ function Zi(r4) {
39754
39754
  return r4.length === 1 ? r4[0] : r4.map(R).join("");
39755
39755
  }
39756
- function Je(r4, e, t) {
39757
- let n = Ee(r4, t);
39756
+ function Ye(r4, e, t) {
39757
+ let n = be(r4, t);
39758
39758
  if (n)
39759
- return io(n.elements, e);
39759
+ return ro(n.elements, e);
39760
39760
  }
39761
- function io(r4, e) {
39761
+ function ro(r4, e) {
39762
39762
  let t = r4[e] ?? r4[e + "[x]"];
39763
39763
  if (t)
39764
39764
  return t;
@@ -39774,7 +39774,7 @@ function io(r4, e) {
39774
39774
  function U(r4) {
39775
39775
  return !!(r4 && typeof r4 == "object" && "resourceType" in r4);
39776
39776
  }
39777
- function ve(r4) {
39777
+ function Te(r4) {
39778
39778
  return !!(r4 && typeof r4 == "object" && "reference" in r4);
39779
39779
  }
39780
39780
  var F = { types: {} };
@@ -39789,7 +39789,7 @@ function fe(r4) {
39789
39789
  return r4;
39790
39790
  }
39791
39791
  }
39792
- var be = () => [];
39792
+ var Re = () => [];
39793
39793
  var C = { empty: (r4, e) => f(e.length === 0 || e.every((t) => T(t.value))), hasValue: (r4, e) => f(e.length !== 0), exists: (r4, e, t) => t ? f(e.filter((n) => N(t.eval(r4, [n]))).length > 0) : f(e.length > 0 && e.every((n) => !T(n.value))), all: (r4, e, t) => f(e.every((n) => N(t.eval(r4, [n])))), allTrue: (r4, e) => {
39794
39794
  for (let t of e)
39795
39795
  if (!t.value)
@@ -39810,12 +39810,12 @@ var C = { empty: (r4, e) => f(e.length === 0 || e.every((t) => T(t.value))), has
39810
39810
  if (!t.value)
39811
39811
  return f(true);
39812
39812
  return f(false);
39813
- }, subsetOf: be, supersetOf: be, count: (r4, e) => [{ type: l.integer, value: e.length }], distinct: (r4, e) => {
39813
+ }, subsetOf: Re, supersetOf: Re, count: (r4, e) => [{ type: l.integer, value: e.length }], distinct: (r4, e) => {
39814
39814
  let t = [];
39815
39815
  for (let n of e)
39816
39816
  t.some((i2) => i2.value === n.value) || t.push(n);
39817
39817
  return t;
39818
- }, isDistinct: (r4, e) => f(e.length === C.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => N(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: be, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
39818
+ }, isDistinct: (r4, e) => f(e.length === C.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => N(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: Re, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
39819
39819
  if (e.length > 1)
39820
39820
  throw new Error("Expected input length one for single()");
39821
39821
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -39847,7 +39847,7 @@ var C = { empty: (r4, e) => f(e.length === 0 || e.every((t) => T(t.value))), has
39847
39847
  if (!t)
39848
39848
  return e;
39849
39849
  let n = t.eval(r4, e);
39850
- return Ke([...e, ...n]);
39850
+ return ze([...e, ...n]);
39851
39851
  }, combine: (r4, e, t) => {
39852
39852
  if (!t)
39853
39853
  return e;
@@ -39917,7 +39917,7 @@ var C = { empty: (r4, e) => f(e.length === 0 || e.every((t) => T(t.value))), has
39917
39917
  }, convertsToTime: (r4, e) => e.length === 0 ? [] : f(C.toTime(r4, e).length === 1), indexOf: (r4, e, t) => V((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => V((i2, o, s) => {
39918
39918
  let a = o, c2 = s ? a + s : i2.length;
39919
39919
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
39920
- }, r4, e, t, n), startsWith: (r4, e, t) => V((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => V((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => V((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => V((t) => t.toUpperCase(), r4, e), lower: (r4, e) => V((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => V((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => V((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => V((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => V((t) => t.length, r4, e), toChars: (r4, e) => V((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => B(Math.abs, r4, e), ceiling: (r4, e) => B(Math.ceil, r4, e), exp: (r4, e) => B(Math.exp, r4, e), floor: (r4, e) => B(Math.floor, r4, e), ln: (r4, e) => B(Math.log, r4, e), log: (r4, e, t) => B((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => B(Math.pow, r4, e, t), round: (r4, e) => B(Math.round, r4, e), sqrt: (r4, e) => B(Math.sqrt, r4, e), truncate: (r4, e) => B((t) => t | 0, r4, e), children: be, descendants: be, trace: (r4, e, t) => e, now: () => [{ type: l.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: l.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: l.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
39920
+ }, r4, e, t, n), startsWith: (r4, e, t) => V((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => V((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => V((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => V((t) => t.toUpperCase(), r4, e), lower: (r4, e) => V((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => V((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => V((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => V((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => V((t) => t.length, r4, e), toChars: (r4, e) => V((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => B(Math.abs, r4, e), ceiling: (r4, e) => B(Math.ceil, r4, e), exp: (r4, e) => B(Math.exp, r4, e), floor: (r4, e) => B(Math.floor, r4, e), ln: (r4, e) => B(Math.log, r4, e), log: (r4, e, t) => B((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => B(Math.pow, r4, e, t), round: (r4, e) => B(Math.round, r4, e), sqrt: (r4, e) => B(Math.sqrt, r4, e), truncate: (r4, e) => B((t) => t | 0, r4, e), children: Re, descendants: Re, trace: (r4, e, t) => e, now: () => [{ type: l.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: l.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: l.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
39921
39921
  let o = C.toDateTime(r4, t.eval(r4, e));
39922
39922
  if (o.length === 0)
39923
39923
  throw new Error("Invalid start date");
@@ -39927,11 +39927,11 @@ var C = { empty: (r4, e) => f(e.length === 0 || e.every((t) => T(t.value))), has
39927
39927
  let a = i2.eval(r4, e)[0]?.value;
39928
39928
  if (a !== "years" && a !== "months" && a !== "days")
39929
39929
  throw new Error("Invalid units");
39930
- let c2 = Be(o[0].value, s[0].value);
39930
+ let c2 = qe(o[0].value, s[0].value);
39931
39931
  return [{ type: l.Quantity, value: { value: c2[a], unit: a } }];
39932
39932
  }, is: (r4, e, t) => {
39933
39933
  let n = "";
39934
- return t instanceof j ? n = t.name : t instanceof W && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: l.boolean, value: ze(i2, n) })) : [];
39934
+ return t instanceof j ? n = t.name : t instanceof W && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: l.boolean, value: Je(i2, n) })) : [];
39935
39935
  }, not: (r4, e) => C.toBoolean(r4, e).map((t) => ({ type: l.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
39936
39936
  let n = t.value, i2;
39937
39937
  if (typeof n == "string")
@@ -40019,7 +40019,7 @@ var j = class {
40019
40019
  return this.name;
40020
40020
  }
40021
40021
  };
40022
- var Ze = class {
40022
+ var Xe = class {
40023
40023
  eval() {
40024
40024
  return [];
40025
40025
  }
@@ -40027,7 +40027,7 @@ var Ze = class {
40027
40027
  return "{}";
40028
40028
  }
40029
40029
  };
40030
- var Xe = class extends Me {
40030
+ var et = class extends Ne {
40031
40031
  constructor(t, n, i2) {
40032
40032
  super(t, n);
40033
40033
  this.impl = i2;
@@ -40065,7 +40065,7 @@ var w = class extends b {
40065
40065
  return typeof d2 == "boolean" ? f(d2) : P(s) ? [{ type: l.Quantity, value: { ...s, value: d2 } }] : [g(d2)];
40066
40066
  }
40067
40067
  };
40068
- var et = class extends H {
40068
+ var tt = class extends H {
40069
40069
  constructor(e, t) {
40070
40070
  super("&", e, t);
40071
40071
  }
@@ -40074,7 +40074,7 @@ var et = class extends H {
40074
40074
  return o.length > 0 && o.every((s) => typeof s.value == "string") ? [{ type: l.string, value: o.map((s) => s.value).join("") }] : o;
40075
40075
  }
40076
40076
  };
40077
- var tt = class extends b {
40077
+ var rt = class extends b {
40078
40078
  constructor(e, t) {
40079
40079
  super("contains", e, t);
40080
40080
  }
@@ -40083,7 +40083,7 @@ var tt = class extends b {
40083
40083
  return f(n.some((o) => o.value === i2[0].value));
40084
40084
  }
40085
40085
  };
40086
- var rt = class extends b {
40086
+ var nt = class extends b {
40087
40087
  constructor(e, t) {
40088
40088
  super("in", e, t);
40089
40089
  }
@@ -40109,43 +40109,43 @@ var me = class extends H {
40109
40109
  }
40110
40110
  eval(e, t) {
40111
40111
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
40112
- return Ke([...n, ...i2]);
40112
+ return ze([...n, ...i2]);
40113
40113
  }
40114
40114
  };
40115
- var nt = class extends b {
40115
+ var it = class extends b {
40116
40116
  constructor(e, t) {
40117
40117
  super("=", e, t);
40118
40118
  }
40119
40119
  eval(e, t) {
40120
40120
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
40121
- return Gt(n, i2);
40121
+ return Ht(n, i2);
40122
40122
  }
40123
40123
  };
40124
- var it = class extends b {
40124
+ var ot = class extends b {
40125
40125
  constructor(e, t) {
40126
40126
  super("!=", e, t);
40127
40127
  }
40128
40128
  eval(e, t) {
40129
40129
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
40130
- return Qt(Gt(n, i2));
40130
+ return Gt(Ht(n, i2));
40131
40131
  }
40132
40132
  };
40133
- var ot = class extends b {
40133
+ var st = class extends b {
40134
40134
  constructor(e, t) {
40135
40135
  super("~", e, t);
40136
40136
  }
40137
40137
  eval(e, t) {
40138
40138
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
40139
- return Ht(n, i2);
40139
+ return Wt(n, i2);
40140
40140
  }
40141
40141
  };
40142
- var st = class extends b {
40142
+ var at = class extends b {
40143
40143
  constructor(e, t) {
40144
40144
  super("!~", e, t);
40145
40145
  }
40146
40146
  eval(e, t) {
40147
40147
  let n = this.left.eval(e, t), i2 = this.right.eval(e, t);
40148
- return Qt(Ht(n, i2));
40148
+ return Gt(Wt(n, i2));
40149
40149
  }
40150
40150
  };
40151
40151
  var re = class extends b {
@@ -40157,10 +40157,10 @@ var re = class extends b {
40157
40157
  if (n.length !== 1)
40158
40158
  return [];
40159
40159
  let i2 = this.right.name;
40160
- return f(ze(n[0], i2));
40160
+ return f(Je(n[0], i2));
40161
40161
  }
40162
40162
  };
40163
- var at = class extends b {
40163
+ var ct = class extends b {
40164
40164
  constructor(e, t) {
40165
40165
  super("and", e, t);
40166
40166
  }
@@ -40169,7 +40169,7 @@ var at = class extends b {
40169
40169
  return n?.value === true && i2?.value === true ? f(true) : n?.value === false || i2?.value === false ? f(false) : [];
40170
40170
  }
40171
40171
  };
40172
- var ct = class extends b {
40172
+ var ut = class extends b {
40173
40173
  constructor(e, t) {
40174
40174
  super("or", e, t);
40175
40175
  }
@@ -40178,7 +40178,7 @@ var ct = class extends b {
40178
40178
  return n?.value === false && i2?.value === false ? f(false) : n?.value || i2?.value ? f(true) : [];
40179
40179
  }
40180
40180
  };
40181
- var ut = class extends b {
40181
+ var lt = class extends b {
40182
40182
  constructor(e, t) {
40183
40183
  super("xor", e, t);
40184
40184
  }
@@ -40187,7 +40187,7 @@ var ut = class extends b {
40187
40187
  return !n || !i2 ? [] : f(n.value !== i2.value);
40188
40188
  }
40189
40189
  };
40190
- var lt = class extends b {
40190
+ var dt = class extends b {
40191
40191
  constructor(e, t) {
40192
40192
  super("implies", e, t);
40193
40193
  }
@@ -40230,21 +40230,21 @@ var ne = class {
40230
40230
  return `${this.left.toString()}[${this.expr.toString()}]`;
40231
40231
  }
40232
40232
  };
40233
- var Ce = ["!=", "!~", "<=", ">=", "{}", "->"];
40233
+ var Pe = ["!=", "!~", "<=", ">=", "{}", "->"];
40234
40234
  var h = { 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 };
40235
- var ao = { parse(r4) {
40235
+ var oo = { parse(r4) {
40236
40236
  let e = r4.consumeAndParse();
40237
40237
  if (!r4.match(")"))
40238
40238
  throw new Error("Parse error: expected `)` got `" + r4.peek()?.value + "`");
40239
40239
  return e;
40240
40240
  } };
40241
- var co = { parse(r4, e) {
40241
+ var so = { parse(r4, e) {
40242
40242
  let t = r4.consumeAndParse();
40243
40243
  if (!r4.match("]"))
40244
40244
  throw new Error("Parse error: expected `]`");
40245
40245
  return new ne(e, t);
40246
40246
  }, precedence: h.Indexer };
40247
- var uo = { parse(r4, e) {
40247
+ var ao = { parse(r4, e) {
40248
40248
  if (!(e instanceof j))
40249
40249
  throw new Error("Unexpected parentheses");
40250
40250
  let t = [];
@@ -40252,25 +40252,25 @@ var uo = { parse(r4, e) {
40252
40252
  t.push(r4.consumeAndParse()), r4.match(",");
40253
40253
  return new G(e.name, t);
40254
40254
  }, precedence: h.FunctionCall };
40255
- function lo(r4) {
40255
+ function co(r4) {
40256
40256
  let e = r4.split(" "), t = parseFloat(e[0]), n = e[1];
40257
40257
  return n?.startsWith("'") && n.endsWith("'") ? n = n.substring(1, n.length - 1) : n = "{" + n + "}", { value: t, unit: n };
40258
40258
  }
40259
- function Pe() {
40260
- return new Ne().registerPrefix("String", { parse: (r4, e) => new D({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new D({ type: l.dateTime, value: fe(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new D({ type: l.Quantity, value: lo(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new D({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new D({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new D({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new j(e.value) }).registerPrefix("{}", { parse: () => new Ze() }).registerPrefix("(", ao).registerInfix("[", co).registerInfix("(", uo).prefix("+", h.UnaryAdd, (r4, e) => new Xe("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new w("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new W(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new w("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new w("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new w("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new w("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new me(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new nt(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new it(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new ot(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new st(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new w("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new w("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new w(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new w(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new et(r4, t)).infixLeft("and", h.And, (r4, e, t) => new at(r4, t)).infixLeft("as", h.As, (r4, e, t) => new te(r4, t)).infixLeft("contains", h.Contains, (r4, e, t) => new tt(r4, t)).infixLeft("div", h.Divide, (r4, e, t) => new w("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", h.In, (r4, e, t) => new rt(r4, t)).infixLeft("is", h.Is, (r4, e, t) => new re(r4, t)).infixLeft("mod", h.Modulo, (r4, e, t) => new w("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", h.Or, (r4, e, t) => new ct(r4, t)).infixLeft("xor", h.Xor, (r4, e, t) => new ut(r4, t)).infixLeft("implies", h.Implies, (r4, e, t) => new lt(r4, t));
40259
+ function we() {
40260
+ return new Fe().registerPrefix("String", { parse: (r4, e) => new D({ type: l.string, value: e.value }) }).registerPrefix("DateTime", { parse: (r4, e) => new D({ type: l.dateTime, value: fe(e.value) }) }).registerPrefix("Quantity", { parse: (r4, e) => new D({ type: l.Quantity, value: co(e.value) }) }).registerPrefix("Number", { parse: (r4, e) => new D({ type: e.value.includes(".") ? l.decimal : l.integer, value: parseFloat(e.value) }) }).registerPrefix("true", { parse: () => new D({ type: l.boolean, value: true }) }).registerPrefix("false", { parse: () => new D({ type: l.boolean, value: false }) }).registerPrefix("Symbol", { parse: (r4, e) => new j(e.value) }).registerPrefix("{}", { parse: () => new Xe() }).registerPrefix("(", oo).registerInfix("[", so).registerInfix("(", ao).prefix("+", h.UnaryAdd, (r4, e) => new et("+", e, (t) => t)).prefix("-", h.UnarySubtract, (r4, e) => new w("-", e, e, (t, n) => -n)).infixLeft(".", h.Dot, (r4, e, t) => new W(r4, t)).infixLeft("/", h.Divide, (r4, e, t) => new w("/", r4, t, (n, i2) => n / i2)).infixLeft("*", h.Multiply, (r4, e, t) => new w("*", r4, t, (n, i2) => n * i2)).infixLeft("+", h.Add, (r4, e, t) => new w("+", r4, t, (n, i2) => n + i2)).infixLeft("-", h.Subtract, (r4, e, t) => new w("-", r4, t, (n, i2) => n - i2)).infixLeft("|", h.Union, (r4, e, t) => new me(r4, t)).infixLeft("=", h.Equals, (r4, e, t) => new it(r4, t)).infixLeft("!=", h.NotEquals, (r4, e, t) => new ot(r4, t)).infixLeft("~", h.Equivalent, (r4, e, t) => new st(r4, t)).infixLeft("!~", h.NotEquivalent, (r4, e, t) => new at(r4, t)).infixLeft("<", h.LessThan, (r4, e, t) => new w("<", r4, t, (n, i2) => n < i2)).infixLeft("<=", h.LessThanOrEquals, (r4, e, t) => new w("<=", r4, t, (n, i2) => n <= i2)).infixLeft(">", h.GreaterThan, (r4, e, t) => new w(">", r4, t, (n, i2) => n > i2)).infixLeft(">=", h.GreaterThanOrEquals, (r4, e, t) => new w(">=", r4, t, (n, i2) => n >= i2)).infixLeft("&", h.Ampersand, (r4, e, t) => new tt(r4, t)).infixLeft("and", h.And, (r4, e, t) => new ct(r4, t)).infixLeft("as", h.As, (r4, e, t) => new te(r4, t)).infixLeft("contains", h.Contains, (r4, e, t) => new rt(r4, t)).infixLeft("div", h.Divide, (r4, e, t) => new w("div", r4, t, (n, i2) => n / i2 | 0)).infixLeft("in", h.In, (r4, e, t) => new nt(r4, t)).infixLeft("is", h.Is, (r4, e, t) => new re(r4, t)).infixLeft("mod", h.Modulo, (r4, e, t) => new w("mod", r4, t, (n, i2) => n % i2)).infixLeft("or", h.Or, (r4, e, t) => new ut(r4, t)).infixLeft("xor", h.Xor, (r4, e, t) => new lt(r4, t)).infixLeft("implies", h.Implies, (r4, e, t) => new dt(r4, t));
40261
40261
  }
40262
- var po = Pe();
40262
+ var uo = we();
40263
40263
  var vn = ((d2) => (d2.BOOLEAN = "BOOLEAN", d2.NUMBER = "NUMBER", d2.QUANTITY = "QUANTITY", d2.TEXT = "TEXT", d2.REFERENCE = "REFERENCE", d2.CANONICAL = "CANONICAL", d2.DATE = "DATE", d2.DATETIME = "DATETIME", d2.PERIOD = "PERIOD", d2.UUID = "UUID", d2))(vn || {});
40264
- var vo = ((x) => (x.EQUALS = "eq", x.NOT_EQUALS = "ne", x.GREATER_THAN = "gt", x.LESS_THAN = "lt", x.GREATER_THAN_OR_EQUALS = "ge", x.LESS_THAN_OR_EQUALS = "le", x.STARTS_AFTER = "sa", x.ENDS_BEFORE = "eb", x.APPROXIMATELY = "ap", x.CONTAINS = "contains", x.EXACT = "exact", x.TEXT = "text", x.NOT = "not", x.ABOVE = "above", x.BELOW = "below", x.IN = "in", x.NOT_IN = "not-in", x.OF_TYPE = "of-type", x.MISSING = "missing", x.IDENTIFIER = "identifier", x.ITERATE = "iterate", x))(vo || {});
40265
- var Bo = ((S) => (S.READ = "read", S.VREAD = "vread", S.UPDATE = "update", S.PATCH = "patch", S.DELETE = "delete", S.HISTORY = "history", S.HISTORY_INSTANCE = "history-instance", S.HISTORY_TYPE = "history-type", S.HISTORY_SYSTEM = "history-system", S.CREATE = "create", S.SEARCH = "search", S.SEARCH_TYPE = "search-type", S.SEARCH_SYSTEM = "search-system", S.SEARCH_COMPARTMENT = "search-compartment", S.CAPABILITIES = "capabilities", S.TRANSACTION = "transaction", S.BATCH = "batch", S.OPERATION = "operation", S))(Bo || {});
40266
- function On(r4) {
40264
+ var yo = ((x) => (x.EQUALS = "eq", x.NOT_EQUALS = "ne", x.GREATER_THAN = "gt", x.LESS_THAN = "lt", x.GREATER_THAN_OR_EQUALS = "ge", x.LESS_THAN_OR_EQUALS = "le", x.STARTS_AFTER = "sa", x.ENDS_BEFORE = "eb", x.APPROXIMATELY = "ap", x.CONTAINS = "contains", x.EXACT = "exact", x.TEXT = "text", x.NOT = "not", x.ABOVE = "above", x.BELOW = "below", x.IN = "in", x.NOT_IN = "not-in", x.OF_TYPE = "of-type", x.MISSING = "missing", x.IDENTIFIER = "identifier", x.ITERATE = "iterate", x))(yo || {});
40265
+ var Lo = ((S) => (S.READ = "read", S.VREAD = "vread", S.UPDATE = "update", S.PATCH = "patch", S.DELETE = "delete", S.HISTORY = "history", S.HISTORY_INSTANCE = "history-instance", S.HISTORY_TYPE = "history-type", S.HISTORY_SYSTEM = "history-system", S.CREATE = "create", S.SEARCH = "search", S.SEARCH_TYPE = "search-type", S.SEARCH_SYSTEM = "search-system", S.SEARCH_COMPARTMENT = "search-compartment", S.CAPABILITIES = "capabilities", S.TRANSACTION = "transaction", S.BATCH = "batch", S.OPERATION = "operation", S))(Lo || {});
40266
+ function In(r4) {
40267
40267
  if (typeof window < "u")
40268
40268
  return window.atob(r4);
40269
40269
  if (typeof Buffer < "u")
40270
40270
  return Buffer.from(r4, "base64").toString("binary");
40271
40271
  throw new Error("Unable to decode base64");
40272
40272
  }
40273
- function Vn(r4) {
40273
+ function kn(r4) {
40274
40274
  if (typeof window < "u")
40275
40275
  return window.btoa(r4);
40276
40276
  if (typeof Buffer < "u")
@@ -40281,7 +40281,7 @@ function ur() {
40281
40281
  let r4 = new Uint32Array(28);
40282
40282
  return crypto.getRandomValues(r4), Br(r4.buffer);
40283
40283
  }
40284
- async function Dn(r4) {
40284
+ async function On(r4) {
40285
40285
  return crypto.subtle.digest("SHA-256", new TextEncoder().encode(r4));
40286
40286
  }
40287
40287
  function ie() {
@@ -40290,7 +40290,7 @@ function ie() {
40290
40290
  return (r4 === "x" ? e : e & 3 | 8).toString(16);
40291
40291
  });
40292
40292
  }
40293
- var pt = class {
40293
+ var ft = class {
40294
40294
  constructor(e = 10) {
40295
40295
  this.max = e, this.cache = /* @__PURE__ */ new Map();
40296
40296
  }
@@ -40315,7 +40315,7 @@ var pt = class {
40315
40315
  }
40316
40316
  };
40317
40317
  var M = { 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", PING: "x-application/ping" };
40318
- var Ae = class {
40318
+ var Ie = class {
40319
40319
  constructor() {
40320
40320
  this.listeners = {};
40321
40321
  }
@@ -40342,7 +40342,7 @@ var Ae = class {
40342
40342
  };
40343
40343
  var oe = class {
40344
40344
  constructor() {
40345
- this.emitter = new Ae();
40345
+ this.emitter = new Ie();
40346
40346
  }
40347
40347
  dispatchEvent(e) {
40348
40348
  this.emitter.dispatchEvent(e);
@@ -40355,29 +40355,29 @@ var oe = class {
40355
40355
  }
40356
40356
  };
40357
40357
  var lr = { "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" };
40358
- var zo = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
40358
+ var Ko = ["Patient", "Encounter", "ImagingStudy", "DiagnosticReport", "OperationOutcome", "Bundle"];
40359
40359
  var dr = ["DiagnosticReport-update"];
40360
- function Fn(r4) {
40360
+ function Mn(r4) {
40361
40361
  return dr.includes(r4);
40362
40362
  }
40363
- function _n(r4) {
40363
+ function Nn(r4) {
40364
40364
  if (dr.includes(r4))
40365
40365
  throw new p(m(`'context.version' is required for '${r4}'.`));
40366
40366
  }
40367
- var Jo = { "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" } } };
40368
- function Yo(r4) {
40369
- return zo.includes(r4);
40367
+ var zo = { "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" } } };
40368
+ function Jo(r4) {
40369
+ return Ko.includes(r4);
40370
40370
  }
40371
- function Un(r4) {
40371
+ function Fn(r4) {
40372
40372
  return !!r4.endpoint;
40373
40373
  }
40374
40374
  function pr(r4) {
40375
- if (!mt(r4))
40375
+ if (!ht(r4))
40376
40376
  throw new p(m("subscriptionRequest must be an object conforming to SubscriptionRequest type."));
40377
40377
  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(",") };
40378
- return Un(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
40378
+ return Fn(r4) && (o.endpoint = r4.endpoint), new URLSearchParams(o).toString();
40379
40379
  }
40380
- function mt(r4) {
40380
+ function ht(r4) {
40381
40381
  if (typeof r4 != "object")
40382
40382
  return false;
40383
40383
  let { channelType: e, mode: t, topic: n, events: i2 } = r4;
@@ -40386,9 +40386,9 @@ function mt(r4) {
40386
40386
  for (let o of i2)
40387
40387
  if (!lr[o])
40388
40388
  return false;
40389
- return !(Un(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
40389
+ return !(Fn(r4) && !(typeof r4.endpoint == "string" && r4.endpoint.startsWith("ws")));
40390
40390
  }
40391
- function Nn(r4, e, t, n) {
40391
+ function Dn(r4, e, t, n) {
40392
40392
  if (typeof e != "object")
40393
40393
  throw new p(m(`context[${t}] is invalid. Context must contain a single valid FHIR resource! Resource is not an object.`));
40394
40394
  if (!(e.id && typeof e.id == "string"))
@@ -40397,30 +40397,30 @@ function Nn(r4, e, t, n) {
40397
40397
  throw new p(m(`context[${t}] is invalid. Resource must contain a resource type. No resource type found.`));
40398
40398
  let i2 = n.resourceType;
40399
40399
  if (i2 !== "*") {
40400
- if (!Yo(e.resourceType))
40400
+ if (!Jo(e.resourceType))
40401
40401
  throw new p(m(`context[${t}] is invalid. Resource must contain a valid FHIRcast resource type. Resource type is not a known resource type.`));
40402
40402
  if (i2 && e.resourceType !== i2)
40403
40403
  throw new p(m(`context[${t}] is invalid. context[${t}] for the '${r4}' event should contain resource of type ${i2}.`));
40404
40404
  }
40405
40405
  }
40406
- function Zo(r4, e, t, n, i2) {
40406
+ function Yo(r4, e, t, n, i2) {
40407
40407
  if (i2.set(e.key, (i2.get(e.key) ?? 0) + 1), !n.isArray)
40408
- Nn(r4, e.resource, t, n);
40408
+ Dn(r4, e.resource, t, n);
40409
40409
  else {
40410
40410
  let { resources: o } = e;
40411
40411
  if (!o)
40412
40412
  throw new p(m(`context[${t}] is invalid. context[${t}] for the '${r4}' with key '${String(e.key)}' should contain an array of resources on the key 'resources'.`));
40413
40413
  for (let s of o)
40414
- Nn(r4, s, t, n);
40414
+ Dn(r4, s, t, n);
40415
40415
  }
40416
40416
  }
40417
- function Xo(r4, e) {
40418
- let t = /* @__PURE__ */ new Map(), n = Jo[r4];
40417
+ function Zo(r4, e) {
40418
+ let t = /* @__PURE__ */ new Map(), n = zo[r4];
40419
40419
  for (let i2 = 0; i2 < e.length; i2++) {
40420
40420
  let o = e[i2].key;
40421
40421
  if (!n[o])
40422
40422
  throw new p(m(`Key '${o}' not found for event '${r4}'. Make sure to add only valid keys.`));
40423
- Zo(r4, e[i2], i2, n[o], t);
40423
+ Yo(r4, e[i2], i2, n[o], t);
40424
40424
  }
40425
40425
  for (let [i2, o] of Object.entries(n)) {
40426
40426
  if (!(o.optional || t.has(i2)))
@@ -40439,13 +40439,13 @@ function fr(r4, e, t, n) {
40439
40439
  if (dr.includes(e) && !n)
40440
40440
  throw new p(m(`The '${e}' event must contain a 'context.versionId'.`));
40441
40441
  let i2 = Array.isArray(t) ? t : [t];
40442
- return Xo(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ie(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
40442
+ return Zo(e, i2), { timestamp: (/* @__PURE__ */ new Date()).toISOString(), id: ie(), event: { "hub.topic": r4, "hub.event": e, context: i2, ...n ? { "context.versionId": n } : {} } };
40443
40443
  }
40444
- var ft = class extends oe {
40444
+ var mt = class extends oe {
40445
40445
  constructor(e) {
40446
40446
  if (super(), this.subRequest = e, !e.endpoint)
40447
40447
  throw new p(m("Subscription request should contain an endpoint."));
40448
- if (!mt(e))
40448
+ if (!ht(e))
40449
40449
  throw new p(m("Subscription request failed validation."));
40450
40450
  let t = new WebSocket(e.endpoint);
40451
40451
  t.addEventListener("open", () => {
@@ -40464,39 +40464,39 @@ var ft = class extends oe {
40464
40464
  this.websocket.close();
40465
40465
  }
40466
40466
  };
40467
- function es(r4) {
40468
- let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = On(e), n = Array.from(t).reduce((o, s) => {
40467
+ function Xo(r4) {
40468
+ let e = r4.replace(/-/g, "+").replace(/_/g, "/"), t = In(e), n = Array.from(t).reduce((o, s) => {
40469
40469
  let a = ("00" + s.charCodeAt(0).toString(16)).slice(-2);
40470
40470
  return `${o}%${a}`;
40471
40471
  }, ""), i2 = decodeURIComponent(n);
40472
40472
  return JSON.parse(i2);
40473
40473
  }
40474
- function Ln(r4) {
40474
+ function _n(r4) {
40475
40475
  return r4.split(".").length === 3;
40476
40476
  }
40477
- function ht(r4) {
40477
+ function gt(r4) {
40478
40478
  let [e, t, n] = r4.split(".");
40479
- return es(t);
40479
+ return Xo(t);
40480
40480
  }
40481
- function Bn(r4) {
40481
+ function Un(r4) {
40482
40482
  try {
40483
- return typeof ht(r4).login_id == "string";
40483
+ return typeof gt(r4).login_id == "string";
40484
40484
  } catch {
40485
40485
  return false;
40486
40486
  }
40487
40487
  }
40488
- function qn(r4) {
40488
+ function Ln(r4) {
40489
40489
  try {
40490
- let t = ht(r4).exp;
40490
+ let t = gt(r4).exp;
40491
40491
  return typeof t == "number" ? t * 1e3 : void 0;
40492
40492
  } catch {
40493
40493
  return;
40494
40494
  }
40495
40495
  }
40496
- var ts;
40496
+ var es;
40497
40497
  var k = class {
40498
40498
  constructor(e) {
40499
- this[ts] = "ReadablePromise";
40499
+ this[es] = "ReadablePromise";
40500
40500
  this.status = "pending";
40501
40501
  this.suspender = e.then((t) => (this.status = "success", this.response = t, t), (t) => {
40502
40502
  throw this.status = "error", this.error = t, t;
@@ -40528,8 +40528,8 @@ var k = class {
40528
40528
  return this.suspender.finally(e);
40529
40529
  }
40530
40530
  };
40531
- ts = Symbol.toStringTag;
40532
- var Ie = class {
40531
+ es = Symbol.toStringTag;
40532
+ var ke = class {
40533
40533
  constructor(e) {
40534
40534
  this.storage = e ?? (typeof localStorage < "u" ? localStorage : new mr());
40535
40535
  }
@@ -40613,7 +40613,7 @@ var hr = class extends oe {
40613
40613
  }
40614
40614
  }
40615
40615
  };
40616
- var ke = class extends oe {
40616
+ var Oe = class extends oe {
40617
40617
  constructor(...e) {
40618
40618
  super(), this.criteria = new Set(e);
40619
40619
  }
@@ -40629,12 +40629,12 @@ var ke = class extends oe {
40629
40629
  };
40630
40630
  var gr = class {
40631
40631
  constructor(e) {
40632
- this.criteria = e, this.emitter = new ke(e), this.refCount = 1;
40632
+ this.criteria = e, this.emitter = new Oe(e), this.refCount = 1;
40633
40633
  }
40634
40634
  };
40635
- var gt = class {
40635
+ var yt = class {
40636
40636
  constructor(e, t) {
40637
- if (!(e instanceof yt))
40637
+ if (!(e instanceof xt))
40638
40638
  throw new p(m("First arg of constructor should be a `MedplumClient`"));
40639
40639
  let n;
40640
40640
  try {
@@ -40643,7 +40643,7 @@ var gt = class {
40643
40643
  throw new p(m("Not a valid URL"));
40644
40644
  }
40645
40645
  let i2 = new hr(n);
40646
- this.medplum = e, this.ws = i2, this.masterSubEmitter = new ke(), this.criteriaEntries = /* @__PURE__ */ new Map(), this.criteriaEntriesBySubscriptionId = /* @__PURE__ */ new Map(), this.wsClosed = false, this.setupWebSocketListeners();
40646
+ this.medplum = e, this.ws = i2, this.masterSubEmitter = new Oe(), this.criteriaEntries = /* @__PURE__ */ new Map(), this.criteriaEntriesBySubscriptionId = /* @__PURE__ */ new Map(), this.wsClosed = false, this.setupWebSocketListeners();
40647
40647
  }
40648
40648
  setupWebSocketListeners() {
40649
40649
  let e = this.ws;
@@ -40655,7 +40655,7 @@ var gt = class {
40655
40655
  return;
40656
40656
  }
40657
40657
  this.masterSubEmitter?.dispatchEvent({ type: "message", payload: n });
40658
- let o = this.criteriaEntriesBySubscriptionId.get(Le(i2.subscription));
40658
+ let o = this.criteriaEntriesBySubscriptionId.get(Be(i2.subscription));
40659
40659
  if (!o) {
40660
40660
  console.warn("Received notification for criteria the SubscriptionManager is not listening for");
40661
40661
  return;
@@ -40730,27 +40730,27 @@ var gt = class {
40730
40730
  return this.criteriaEntries.size;
40731
40731
  }
40732
40732
  getMasterEmitter() {
40733
- return this.masterSubEmitter || (this.masterSubEmitter = new ke(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
40733
+ return this.masterSubEmitter || (this.masterSubEmitter = new Oe(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
40734
40734
  }
40735
40735
  };
40736
- var rs = M.FHIR_JSON + ", */*; q=0.1";
40737
- var ns = "https://api.medplum.com/";
40738
- var is = 1e3;
40739
- var os = 6e4;
40740
- var ss = 0;
40741
- var $n = "Binary/";
40742
- var Qn = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
40743
- var as = ((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))(as || {});
40744
- var cs = ((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))(cs || {});
40745
- var us = ((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))(us || {});
40746
- var ls = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(ls || {});
40747
- var yt = class extends Ae {
40736
+ var ts = M.FHIR_JSON + ", */*; q=0.1";
40737
+ var rs = "https://api.medplum.com/";
40738
+ var ns = 1e3;
40739
+ var is = 6e4;
40740
+ var os = 0;
40741
+ var qn = "Binary/";
40742
+ var jn = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
40743
+ var ss = ((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))(ss || {});
40744
+ var as = ((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))(as || {});
40745
+ var cs = ((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))(cs || {});
40746
+ var us = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer", e))(us || {});
40747
+ var xt = class extends Ie {
40748
40748
  constructor(t) {
40749
40749
  super();
40750
40750
  this.initComplete = true;
40751
40751
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
40752
40752
  throw new Error("Base URL must start with http or https");
40753
- if (this.options = t ?? {}, this.fetch = t?.fetch ?? ds(), this.storage = t?.storage ?? new Ie(), this.createPdfImpl = t?.createPdf, this.baseUrl = Hn(t?.baseUrl ?? ns), this.fhirBaseUrl = Hn(xt(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = xt(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = xt(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = xt(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? ss : os), this.cacheTime > 0 ? this.requestCache = new pt(t?.resourceCacheSize ?? is) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
40753
+ if (this.options = t ?? {}, this.fetch = t?.fetch ?? ls(), this.storage = t?.storage ?? new ke(), this.createPdfImpl = t?.createPdf, this.baseUrl = Qn(t?.baseUrl ?? rs), this.fhirBaseUrl = Qn(vt(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = vt(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = vt(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = vt(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? os : is), this.cacheTime > 0 ? this.requestCache = new ft(t?.resourceCacheSize ?? ns) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
40754
40754
  this.setAccessToken(t.accessToken), this.initPromise = Promise.resolve();
40755
40755
  else if (this.storage.getInitPromise !== void 0) {
40756
40756
  let n = this.storage.getInitPromise(), i2 = new Promise((o) => {
@@ -40943,7 +40943,7 @@ var yt = class extends Ae {
40943
40943
  if (!n)
40944
40944
  return;
40945
40945
  if (n === "system")
40946
- return Qn;
40946
+ return jn;
40947
40947
  let [i2, o] = n.split("/");
40948
40948
  if (!(!i2 || !o))
40949
40949
  return this.getCached(i2, o);
@@ -40956,7 +40956,7 @@ var yt = class extends Ae {
40956
40956
  if (!i2)
40957
40957
  return new k(Promise.reject(new Error("Missing reference")));
40958
40958
  if (i2 === "system")
40959
- return new k(Promise.resolve(Qn));
40959
+ return new k(Promise.resolve(jn));
40960
40960
  let [o, s] = i2.split("/");
40961
40961
  return !o || !s ? new k(Promise.reject(new Error("Invalid reference"))) : this.readResource(o, s, n);
40962
40962
  }
@@ -41007,9 +41007,9 @@ var yt = class extends Ae {
41007
41007
  target
41008
41008
  }
41009
41009
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
41010
- Xt(a.data.StructureDefinitionList);
41010
+ er(a.data.StructureDefinitionList);
41011
41011
  for (let c2 of a.data.SearchParameterList)
41012
- rr(c2);
41012
+ nr(c2);
41013
41013
  })());
41014
41014
  return this.setCacheEntry(n, o), o;
41015
41015
  }
@@ -41024,10 +41024,10 @@ var yt = class extends Ae {
41024
41024
  let a = this.fhirUrl("StructureDefinition", "$expand-profile");
41025
41025
  a.search = new URLSearchParams({ url: t }).toString();
41026
41026
  let c2 = await this.get(a.toString());
41027
- return yr(c2).map((u2) => (er(u2, u2.url), u2.url));
41027
+ return yr(c2).map((u2) => (tr(u2, u2.url), u2.url));
41028
41028
  } else {
41029
41029
  let a = await this.searchOne("StructureDefinition", { url: t, _sort: "-_lastUpdated" });
41030
- return a ? (Xt([a], t), [t]) : (console.warn(`No StructureDefinition found for ${t}!`), []);
41030
+ return a ? (er([a], t), [t]) : (console.warn(`No StructureDefinition found for ${t}!`), []);
41031
41031
  }
41032
41032
  })());
41033
41033
  return this.setCacheEntry(i2, s), s;
@@ -41065,7 +41065,7 @@ var yt = class extends Ae {
41065
41065
  s?.signal?.removeEventListener("abort", d2), A instanceof Error ? c2(A) : a(A);
41066
41066
  };
41067
41067
  u2.responseType = "json", u2.onabort = () => v2(new Error("Request aborted")), u2.onerror = () => v2(new Error("Request error")), o && (u2.upload.onprogress = (A) => o(A), u2.upload.onload = (A) => o(A)), u2.onload = () => {
41068
- u2.status >= 200 && u2.status < 300 ? v2(u2.response) : v2(new p(Ue(u2.response || u2.statusText)));
41068
+ u2.status >= 200 && u2.status < 300 ? v2(u2.response) : v2(new p(Le(u2.response || u2.statusText)));
41069
41069
  }, u2.open("POST", t), u2.withCredentials = true, u2.setRequestHeader("Authorization", "Bearer " + this.accessToken), u2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), u2.setRequestHeader("Content-Type", i2), u2.setRequestHeader("X-Medplum", "extended"), u2.send(n);
41070
41070
  });
41071
41071
  }
@@ -41120,7 +41120,7 @@ var yt = class extends Ae {
41120
41120
  return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
41121
41121
  }
41122
41122
  pushToAgent(t, n, i2, o, s, a) {
41123
- return this.post(this.fhirUrl("Agent", Le(t), "$push"), { destination: typeof n == "string" ? n : Z(n), body: i2, contentType: o, waitForResponse: s }, M.FHIR_JSON, a);
41123
+ return this.post(this.fhirUrl("Agent", Be(t), "$push"), { destination: typeof n == "string" ? n : Z(n), body: i2, contentType: o, waitForResponse: s }, M.FHIR_JSON, a);
41124
41124
  }
41125
41125
  getActiveLogin() {
41126
41126
  return this.storage.getObject("activeLogin");
@@ -41132,7 +41132,7 @@ var yt = class extends Ae {
41132
41132
  return this.accessToken;
41133
41133
  }
41134
41134
  setAccessToken(t, n) {
41135
- this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = qn(t), this.medplumServer = Bn(t);
41135
+ this.accessToken = t, this.refreshToken = n, this.sessionDetails = void 0, this.accessTokenExpires = Ln(t), this.medplumServer = Un(t);
41136
41136
  }
41137
41137
  getLogins() {
41138
41138
  return this.storage.getObject("logins") ?? [];
@@ -41180,11 +41180,11 @@ var yt = class extends Ae {
41180
41180
  async download(t, n = {}) {
41181
41181
  this.refreshPromise && await this.refreshPromise;
41182
41182
  let i2 = t.toString();
41183
- return i2.startsWith($n) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
41183
+ return i2.startsWith(qn) && (t = this.fhirUrl(i2)), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
41184
41184
  }
41185
41185
  async uploadMedia(t, n, i2, o, s) {
41186
41186
  let a = await this.createBinary(t, i2, n);
41187
- return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: $n + a.id, title: i2 }, ...o }, s);
41187
+ return this.createResource({ resourceType: "Media", status: "completed", content: { contentType: n, url: qn + a.id, title: i2 }, ...o }, s);
41188
41188
  }
41189
41189
  async bulkExport(t = "", n, i2, o) {
41190
41190
  let s = t && `${t}/`, a = this.fhirUrl(`${s}$export`);
@@ -41223,18 +41223,18 @@ var yt = class extends Ae {
41223
41223
  throw new p(Ar);
41224
41224
  let u2 = await this.parseBody(s, c2), d2 = i2.redirect ?? this.options.redirect;
41225
41225
  if ((s.status === 200 || s.status === 201) && d2 === "follow") {
41226
- let A = await Wn(s, u2);
41226
+ let A = await Gn(s, u2);
41227
41227
  if (A)
41228
41228
  return this.request("GET", A, { ...i2, body: void 0 });
41229
41229
  }
41230
41230
  let v2 = i2.headers?.Prefer;
41231
41231
  if (s.status === 202 && v2 === "respond-async") {
41232
- let br = await Wn(s, u2) ?? o.statusUrl;
41232
+ let br = await Gn(s, u2) ?? o.statusUrl;
41233
41233
  if (br)
41234
41234
  return this.pollStatus(br, i2, o);
41235
41235
  }
41236
41236
  if (s.status >= 400)
41237
- throw new p(Ue(u2));
41237
+ throw new p(Le(u2));
41238
41238
  return u2;
41239
41239
  }
41240
41240
  async parseBody(t, n) {
@@ -41259,7 +41259,7 @@ var yt = class extends Ae {
41259
41259
  } catch (c2) {
41260
41260
  this.retryCatch(a, i2, c2);
41261
41261
  }
41262
- await Nt(o);
41262
+ await Ft(o);
41263
41263
  }
41264
41264
  return s;
41265
41265
  }
@@ -41274,7 +41274,7 @@ var yt = class extends Ae {
41274
41274
  console.log(`< ${t.status} ${t.statusText}`), t.headers && t.headers.forEach((n, i2) => console.log(`< ${i2}: ${n}`));
41275
41275
  }
41276
41276
  async pollStatus(t, n, i2) {
41277
- return i2.pollCount === void 0 ? (n.redirect = "follow", i2.statusUrl = t, i2.pollCount = 1) : (await Nt(1e3), i2.pollCount++), this.request("GET", t, n, i2);
41277
+ return i2.pollCount === void 0 ? (n.redirect = "follow", i2.statusUrl = t, i2.pollCount = 1) : (await Ft(1e3), i2.pollCount++), this.request("GET", t, n, i2);
41278
41278
  }
41279
41279
  async executeAutoBatch() {
41280
41280
  let t = [...this.autoBatchQueue];
@@ -41283,19 +41283,19 @@ var yt = class extends Ae {
41283
41283
  try {
41284
41284
  o.resolve(await this.request(o.method, this.fhirBaseUrl + o.url, o.options));
41285
41285
  } catch (s) {
41286
- o.reject(new p(Ue(s)));
41286
+ o.reject(new p(Le(s)));
41287
41287
  }
41288
41288
  return;
41289
41289
  }
41290
41290
  let n = { resourceType: "Bundle", type: "batch", entry: t.map((o) => ({ request: { method: o.method, url: o.url }, resource: o.options.body ? JSON.parse(o.options.body) : void 0 })) }, i2 = await this.post(this.fhirBaseUrl.slice(0, -1), n);
41291
41291
  for (let o = 0; o < t.length; o++) {
41292
41292
  let s = t[o], a = i2.entry?.[o];
41293
- a?.response?.outcome && !Ot(a.response.outcome) ? s.reject(new p(a.response.outcome)) : s.resolve(a?.resource);
41293
+ a?.response?.outcome && !Vt(a.response.outcome) ? s.reject(new p(a.response.outcome)) : s.resolve(a?.resource);
41294
41294
  }
41295
41295
  }
41296
41296
  addFetchOptionsDefaults(t) {
41297
41297
  let n = t.headers;
41298
- n || (n = {}, t.headers = n), n.Accept || (n.Accept = rs), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = M.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");
41298
+ n || (n = {}, t.headers = n), n.Accept || (n.Accept = ts), n["X-Medplum"] = "extended", t.body && !n["Content-Type"] && (n["Content-Type"] = M.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");
41299
41299
  }
41300
41300
  setRequestContentType(t, n) {
41301
41301
  t.headers || (t.headers = {});
@@ -41313,16 +41313,16 @@ var yt = class extends Ae {
41313
41313
  sessionStorage.setItem("pkceState", t);
41314
41314
  let n = ur();
41315
41315
  sessionStorage.setItem("codeVerifier", n);
41316
- let i2 = await Dn(n), o = qr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
41316
+ let i2 = await On(n), o = qr(i2).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
41317
41317
  return sessionStorage.setItem("codeChallenge", o), { codeChallengeMethod: "S256", codeChallenge: o };
41318
41318
  }
41319
41319
  async requestAuthorization(t) {
41320
41320
  let n = await this.ensureCodeChallenge(t ?? {}), i2 = new URL(this.authorizeUrl);
41321
- 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 ?? Gn()), 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());
41321
+ 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 ?? $n()), 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());
41322
41322
  }
41323
41323
  processCode(t, n) {
41324
41324
  let i2 = new URLSearchParams();
41325
- 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 ?? Gn()), typeof sessionStorage < "u") {
41325
+ 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 ?? $n()), typeof sessionStorage < "u") {
41326
41326
  let o = sessionStorage.getItem("codeVerifier");
41327
41327
  o && i2.set("code_verifier", o);
41328
41328
  }
@@ -41356,7 +41356,7 @@ var yt = class extends Ae {
41356
41356
  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);
41357
41357
  }
41358
41358
  setBasicAuth(t, n) {
41359
- this.clientId = t, this.clientSecret = n, this.basicAuth = Vn(t + ":" + n);
41359
+ this.clientId = t, this.clientSecret = n, this.basicAuth = kn(t + ":" + n);
41360
41360
  }
41361
41361
  async fhircastSubscribe(t, n) {
41362
41362
  if (!(typeof t == "string" && t !== ""))
@@ -41369,17 +41369,17 @@ var yt = class extends Ae {
41369
41369
  return i2.endpoint = s, i2;
41370
41370
  }
41371
41371
  async fhircastUnsubscribe(t) {
41372
- if (!mt(t))
41372
+ if (!ht(t))
41373
41373
  throw new p(m("Invalid topic or subscriptionRequest. SubscriptionRequest must be an object."));
41374
41374
  if (!(t.endpoint && typeof t.endpoint == "string" && t.endpoint.startsWith("ws")))
41375
41375
  throw new p(m("Provided subscription request must have an endpoint in order to unsubscribe."));
41376
41376
  t.mode = "unsubscribe", await this.post("/fhircast/STU3", pr(t), M.FORM_URL_ENCODED);
41377
41377
  }
41378
41378
  fhircastConnect(t) {
41379
- return new ft(t);
41379
+ return new mt(t);
41380
41380
  }
41381
41381
  async fhircastPublish(t, n, i2, o) {
41382
- return Fn(n) ? this.post(`/fhircast/STU3/${t}`, fr(t, n, i2, o), M.JSON) : (_n(n), this.post(`/fhircast/STU3/${t}`, fr(t, n, i2), M.JSON));
41382
+ return Mn(n) ? this.post(`/fhircast/STU3/${t}`, fr(t, n, i2, o), M.JSON) : (Nn(n), this.post(`/fhircast/STU3/${t}`, fr(t, n, i2), M.JSON));
41383
41383
  }
41384
41384
  async fhircastGetContext(t) {
41385
41385
  return this.get(`/fhircast/STU3/${t}`);
@@ -41410,8 +41410,8 @@ var yt = class extends Ae {
41410
41410
  }
41411
41411
  async verifyTokens(t) {
41412
41412
  let n = t.access_token;
41413
- if (Ln(n)) {
41414
- let i2 = ht(n);
41413
+ if (_n(n)) {
41414
+ let i2 = gt(n);
41415
41415
  if (Date.now() >= i2.exp * 1e3)
41416
41416
  throw this.clearActiveLogin(), new Error("Token expired");
41417
41417
  if (i2.cid) {
@@ -41435,7 +41435,7 @@ var yt = class extends Ae {
41435
41435
  throw i2;
41436
41436
  }
41437
41437
  getSubscriptionManager() {
41438
- return this.subscriptionManager || (this.subscriptionManager = new gt(this, Qr("/ws/subscriptions-r4", this.baseUrl))), this.subscriptionManager;
41438
+ return this.subscriptionManager || (this.subscriptionManager = new yt(this, Qr("/ws/subscriptions-r4", this.baseUrl))), this.subscriptionManager;
41439
41439
  }
41440
41440
  subscribeToCriteria(t) {
41441
41441
  return this.getSubscriptionManager().addCriteria(t);
@@ -41447,21 +41447,21 @@ var yt = class extends Ae {
41447
41447
  return this.getSubscriptionManager().getMasterEmitter();
41448
41448
  }
41449
41449
  };
41450
- function ds() {
41450
+ function ls() {
41451
41451
  if (!globalThis.fetch)
41452
41452
  throw new Error("Fetch not available in this environment");
41453
41453
  return globalThis.fetch.bind(globalThis);
41454
41454
  }
41455
- function Gn() {
41455
+ function $n() {
41456
41456
  return typeof window > "u" ? "" : window.location.protocol + "//" + window.location.host + "/";
41457
41457
  }
41458
- function Hn(r4) {
41458
+ function Qn(r4) {
41459
41459
  return r4.endsWith("/") ? r4 : r4 + "/";
41460
41460
  }
41461
- function xt(r4, e) {
41461
+ function vt(r4, e) {
41462
41462
  return new URL(e, r4).toString();
41463
41463
  }
41464
- async function Wn(r4, e) {
41464
+ async function Gn(r4, e) {
41465
41465
  let t = r4.headers.get("content-location");
41466
41466
  if (t)
41467
41467
  return t;
@@ -41475,10 +41475,10 @@ function yr(r4) {
41475
41475
  let e = r4.entry?.map((t) => t.resource) ?? [];
41476
41476
  return Object.assign(e, { bundle: r4 });
41477
41477
  }
41478
- var Ss = [...Ce, "->", "<<", ">>", "=="];
41479
- var Rs = Pe().registerInfix("->", { precedence: h.Arrow }).registerInfix(";", { precedence: h.Semicolon });
41480
- var Bs = [...Ce, "eq", "ne", "co"];
41481
- var $s = Pe();
41478
+ var Ts = [...Pe, "->", "<<", ">>", "=="];
41479
+ var bs = we().registerInfix("->", { precedence: h.Arrow }).registerInfix(";", { precedence: h.Semicolon });
41480
+ var Ls = [...Pe, "eq", "ne", "co"];
41481
+ var js = we();
41482
41482
  var J = class {
41483
41483
  constructor(e = "\r", t = "|", n = "^", i2 = "~", o = "\\", s = "&") {
41484
41484
  this.segmentSeparator = e;
@@ -41495,7 +41495,7 @@ var J = class {
41495
41495
  return this.componentSeparator + this.repetitionSeparator + this.escapeCharacter + this.subcomponentSeparator;
41496
41496
  }
41497
41497
  };
41498
- var ci = class r {
41498
+ var si = class r {
41499
41499
  constructor(e, t = new J()) {
41500
41500
  this.context = t, this.segments = e;
41501
41501
  }
@@ -41519,7 +41519,7 @@ var ci = class r {
41519
41519
  }
41520
41520
  buildAck() {
41521
41521
  let e = /* @__PURE__ */ new Date(), t = this.getSegment("MSH"), n = t?.getField(3)?.toString() ?? "", i2 = t?.getField(4)?.toString() ?? "", o = t?.getField(5)?.toString() ?? "", s = t?.getField(6)?.toString() ?? "", a = t?.getField(10)?.toString() ?? "", c2 = t?.getField(12)?.toString() ?? "2.5.1";
41522
- return new r([new De(["MSH", this.context.getMsh2(), o, s, n, i2, Gs(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new De(["MSA", "AA", a, "OK"], this.context)]);
41522
+ return new r([new Me(["MSH", this.context.getMsh2(), o, s, n, i2, Qs(e), "", this.buildAckMessageType(t), e.getTime().toString(), "P", c2], this.context), new Me(["MSA", "AA", a, "OK"], this.context)]);
41523
41523
  }
41524
41524
  buildAckMessageType(e) {
41525
41525
  let t = e?.getField(9), n = t?.getComponent(2), i2 = t?.getComponent(3), o = "ACK";
@@ -41531,12 +41531,12 @@ var ci = class r {
41531
41531
  throw n.type = "entity.parse.failed", n;
41532
41532
  }
41533
41533
  let t = new J("\r", e.charAt(3), e.charAt(4), e.charAt(5), e.charAt(6), e.charAt(7));
41534
- return new r(e.split(/[\r\n]+/).map((n) => De.parse(n, t)), t);
41534
+ return new r(e.split(/[\r\n]+/).map((n) => Me.parse(n, t)), t);
41535
41535
  }
41536
41536
  };
41537
- var De = class r2 {
41537
+ var Me = class r2 {
41538
41538
  constructor(e, t = new J()) {
41539
- this.context = t, Ur(e) ? this.fields = e.map((n) => xe.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
41539
+ this.context = t, Ur(e) ? this.fields = e.map((n) => ve.parse(n, t)) : this.fields = e, this.name = this.fields[0].components[0][0];
41540
41540
  }
41541
41541
  get(e) {
41542
41542
  return this.fields[e];
@@ -41544,9 +41544,9 @@ var De = class r2 {
41544
41544
  getField(e) {
41545
41545
  if (this.name === "MSH") {
41546
41546
  if (e === 1)
41547
- return new xe([[this.context.getMsh1()]], this.context);
41547
+ return new ve([[this.context.getMsh1()]], this.context);
41548
41548
  if (e === 2)
41549
- return new xe([[this.context.getMsh2()]], this.context);
41549
+ return new ve([[this.context.getMsh2()]], this.context);
41550
41550
  if (e > 2)
41551
41551
  return this.fields[e - 1];
41552
41552
  }
@@ -41559,10 +41559,10 @@ var De = class r2 {
41559
41559
  return this.fields.map((e) => e.toString()).join(this.context.fieldSeparator);
41560
41560
  }
41561
41561
  static parse(e, t = new J()) {
41562
- return new r2(e.split(t.fieldSeparator).map((n) => xe.parse(n, t)), t);
41562
+ return new r2(e.split(t.fieldSeparator).map((n) => ve.parse(n, t)), t);
41563
41563
  }
41564
41564
  };
41565
- var xe = class r3 {
41565
+ var ve = class r3 {
41566
41566
  constructor(e, t = new J()) {
41567
41567
  this.context = t, this.components = e;
41568
41568
  }
@@ -41580,12 +41580,12 @@ var xe = class r3 {
41580
41580
  return new r3(e.split(t.repetitionSeparator).map((n) => n.split(t.componentSeparator)), t);
41581
41581
  }
41582
41582
  };
41583
- function Gs(r4) {
41583
+ function Qs(r4) {
41584
41584
  let e = r4 instanceof Date ? r4 : new Date(r4), n = e.toISOString().replace(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i2 = e.getUTCMilliseconds();
41585
41585
  return i2 > 0 && (n += "." + i2.toString()), n;
41586
41586
  }
41587
41587
  var Er = ((o) => (o[o.NONE = 0] = "NONE", o[o.ERROR = 1] = "ERROR", o[o.WARN = 2] = "WARN", o[o.INFO = 3] = "INFO", o[o.DEBUG = 4] = "DEBUG", o))(Er || {});
41588
- var ui = class {
41588
+ var ai = class {
41589
41589
  constructor(e, t = {}, n = 3) {
41590
41590
  this.write = e;
41591
41591
  this.metadata = t;
@@ -41654,7 +41654,7 @@ var c = class extends i {
41654
41654
  t.on("data", (s) => {
41655
41655
  try {
41656
41656
  if (o += s.toString(), o.endsWith(p2 + v)) {
41657
- let r4 = ci.parse(o.substring(1, o.length - 2));
41657
+ let r4 = si.parse(o.substring(1, o.length - 2));
41658
41658
  this.dispatchEvent(new d(this, r4)), o = "";
41659
41659
  }
41660
41660
  } catch (r4) {
@@ -41841,7 +41841,7 @@ var DcmjsDimseScp = class extends dimse.Scp {
41841
41841
  });
41842
41842
  response.setStatus(dimse.constants.Status.Success);
41843
41843
  } catch (err) {
41844
- App.instance.log.error(`DICOM error: ${di(err)}`);
41844
+ App.instance.log.error(`DICOM error: ${ui(err)}`);
41845
41845
  response.setStatus(dimse.constants.Status.ProcessingFailure);
41846
41846
  }
41847
41847
  return response;
@@ -41872,7 +41872,7 @@ var AgentHl7Channel = class {
41872
41872
  sendToRemote(msg) {
41873
41873
  const connection = this.connections.get(msg.remote);
41874
41874
  if (connection) {
41875
- connection.hl7Connection.send(ci.parse(msg.body));
41875
+ connection.hl7Connection.send(si.parse(msg.body));
41876
41876
  }
41877
41877
  }
41878
41878
  handleNewConnection(connection) {
@@ -41901,7 +41901,7 @@ var AgentHl7ChannelConnection = class {
41901
41901
  body: event.message.toString()
41902
41902
  });
41903
41903
  } catch (err) {
41904
- this.channel.app.log.error(`HL7 error: ${di(err)}`);
41904
+ this.channel.app.log.error(`HL7 error: ${ui(err)}`);
41905
41905
  }
41906
41906
  }
41907
41907
  close() {
@@ -41923,7 +41923,7 @@ var App = class _App {
41923
41923
  this.live = false;
41924
41924
  this.shutdown = false;
41925
41925
  _App.instance = this;
41926
- this.log = new ui((msg) => console.log(msg), void 0, logLevel);
41926
+ this.log = new ai((msg) => console.log(msg), void 0, logLevel);
41927
41927
  }
41928
41928
  async start() {
41929
41929
  this.log.info("Medplum service starting...");
@@ -41965,7 +41965,7 @@ var App = class _App {
41965
41965
  this.webSocket.binaryType = "nodebuffer";
41966
41966
  this.webSocket.addEventListener("error", (err) => {
41967
41967
  if (!this.shutdown) {
41968
- this.log.error(di(err.error));
41968
+ this.log.error(ui(err.error));
41969
41969
  }
41970
41970
  });
41971
41971
  this.webSocket.addEventListener("open", async () => {
@@ -42019,7 +42019,7 @@ var App = class _App {
42019
42019
  this.log.error(`Unknown message type: ${command.type}`);
42020
42020
  }
42021
42021
  } catch (err) {
42022
- this.log.error(`WebSocket error: ${di(err)}`);
42022
+ this.log.error(`WebSocket error: ${ui(err)}`);
42023
42023
  }
42024
42024
  });
42025
42025
  }
@@ -42085,7 +42085,7 @@ var App = class _App {
42085
42085
  try {
42086
42086
  await this.sendToWebSocket(msg);
42087
42087
  } catch (err) {
42088
- this.log.error(`WebSocket error: ${di(err)}`);
42088
+ this.log.error(`WebSocket error: ${ui(err)}`);
42089
42089
  this.webSocketQueue.unshift(msg);
42090
42090
  throw err;
42091
42091
  }
@@ -42141,7 +42141,7 @@ ${stdout}`);
42141
42141
  body: stdout
42142
42142
  });
42143
42143
  } catch (err) {
42144
- this.log.error(`Error during ping attempt to ${message.remote ?? "NO_IP_GIVEN"}: ${di(err)}`);
42144
+ this.log.error(`Error during ping attempt to ${message.remote ?? "NO_IP_GIVEN"}: ${ui(err)}`);
42145
42145
  this.addToWebSocketQueue({
42146
42146
  type: "agent:error",
42147
42147
  body: err.message
@@ -42168,7 +42168,7 @@ ${stdout}`);
42168
42168
  host: address.hostname,
42169
42169
  port: parseInt(address.port, 10)
42170
42170
  });
42171
- client.sendAndWait(ci.parse(message.body)).then((response) => {
42171
+ client.sendAndWait(si.parse(message.body)).then((response) => {
42172
42172
  this.log.info(`Response: ${response.toString().replaceAll("\r", "\n")}`);
42173
42173
  this.addToWebSocketQueue({
42174
42174
  type: "agent:transmit:response",
@@ -42179,7 +42179,7 @@ ${stdout}`);
42179
42179
  body: response.toString()
42180
42180
  });
42181
42181
  }).catch((err) => {
42182
- this.log.error(`HL7 error: ${di(err)}`);
42182
+ this.log.error(`HL7 error: ${ui(err)}`);
42183
42183
  }).finally(() => {
42184
42184
  client.close();
42185
42185
  });
@@ -42212,7 +42212,7 @@ async function main(argv) {
42212
42212
  process.exit(1);
42213
42213
  }
42214
42214
  const { baseUrl, clientId, clientSecret, agentId } = args;
42215
- const medplum = new yt({ baseUrl, clientId });
42215
+ const medplum = new xt({ baseUrl, clientId });
42216
42216
  await medplum.startClientLogin(clientId, clientSecret);
42217
42217
  const app = new App(medplum, agentId, dp(args.logLevel ?? "INFO"));
42218
42218
  await app.start();