ezmedicationinput 0.1.60 → 0.1.61

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.
package/dist/index.cjs CHANGED
@@ -36590,7 +36590,7 @@ function normalizeSegmentLexeme(item) {
36590
36590
  var _a28;
36591
36591
  return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
36592
36592
  }
36593
- function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
36593
+ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
36594
36594
  var _a28;
36595
36595
  const connector = tokens[connectorIndex];
36596
36596
  const first = tokens[connectorIndex + 1];
@@ -36609,7 +36609,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
36609
36609
  const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
36610
36610
  if (!prefixText) return false;
36611
36611
  const prefix = parseClauseState(prefixText, options);
36612
- if (!hasAdministrationHead(prefix)) return false;
36612
+ if (!hasAdministrationHead(prefix)) {
36613
+ if (!inheritedAdministrationHead) return false;
36614
+ if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
36615
+ }
36613
36616
  if (connectorLower === "then") return true;
36614
36617
  const prefixSchedule = prefix.primaryClause.schedule;
36615
36618
  return Boolean(
@@ -36695,6 +36698,7 @@ function parseSigSegments(input, options) {
36695
36698
  const proceduralActions = parseInstructionActions(input, 0, options);
36696
36699
  const segments = [];
36697
36700
  let start = 0;
36701
+ let inheritedAdministrationContinuation = false;
36698
36702
  let parenDepth = 0;
36699
36703
  let scannedOffset = 0;
36700
36704
  const scanParens = (end) => {
@@ -36726,18 +36730,40 @@ function parseSigSegments(input, options) {
36726
36730
  }
36727
36731
  const nextToken = tokens[index + 1];
36728
36732
  if (token.original === "," && nextToken) {
36729
- if (scheduleOnlyAdministrationContinuation(input, tokens, index + 1, start, options) || doseBearingAdministrationContinuation(input, tokens, index + 1, start, options)) {
36733
+ const scheduleContinuation = scheduleOnlyAdministrationContinuation(
36734
+ input,
36735
+ tokens,
36736
+ index + 1,
36737
+ start,
36738
+ options,
36739
+ inheritedAdministrationContinuation
36740
+ );
36741
+ const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index + 1, start, options);
36742
+ if (scheduleContinuation || doseContinuation) {
36730
36743
  pushSegment(segments, input, start, token.sourceStart);
36731
36744
  start = nextToken.sourceEnd;
36745
+ inheritedAdministrationContinuation = true;
36732
36746
  index += 1;
36733
36747
  scannedOffset = nextToken.sourceEnd;
36734
36748
  continue;
36735
36749
  }
36736
- } else if (scheduleOnlyAdministrationContinuation(input, tokens, index, start, options) || doseBearingAdministrationContinuation(input, tokens, index, start, options)) {
36737
- pushSegment(segments, input, start, token.sourceStart);
36738
- start = token.sourceEnd;
36739
- scannedOffset = token.sourceEnd;
36740
- continue;
36750
+ } else {
36751
+ const scheduleContinuation = scheduleOnlyAdministrationContinuation(
36752
+ input,
36753
+ tokens,
36754
+ index,
36755
+ start,
36756
+ options,
36757
+ inheritedAdministrationContinuation
36758
+ );
36759
+ const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index, start, options);
36760
+ if (scheduleContinuation || doseContinuation) {
36761
+ pushSegment(segments, input, start, token.sourceStart);
36762
+ start = token.sourceEnd;
36763
+ inheritedAdministrationContinuation = true;
36764
+ scannedOffset = token.sourceEnd;
36765
+ continue;
36766
+ }
36741
36767
  }
36742
36768
  const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
36743
36769
  if (!isBoundary) {
@@ -36746,6 +36772,7 @@ function parseSigSegments(input, options) {
36746
36772
  }
36747
36773
  pushSegment(segments, input, start, token.sourceStart);
36748
36774
  start = token.sourceEnd;
36775
+ inheritedAdministrationContinuation = false;
36749
36776
  scannedOffset = token.sourceEnd;
36750
36777
  }
36751
36778
  pushSegment(segments, input, start, input.length);
package/dist/index.js CHANGED
@@ -36440,7 +36440,7 @@ function normalizeSegmentLexeme(item) {
36440
36440
  var _a28;
36441
36441
  return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
36442
36442
  }
36443
- function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
36443
+ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
36444
36444
  var _a28;
36445
36445
  const connector = tokens[connectorIndex];
36446
36446
  const first = tokens[connectorIndex + 1];
@@ -36459,7 +36459,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
36459
36459
  const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
36460
36460
  if (!prefixText) return false;
36461
36461
  const prefix = parseClauseState(prefixText, options);
36462
- if (!hasAdministrationHead(prefix)) return false;
36462
+ if (!hasAdministrationHead(prefix)) {
36463
+ if (!inheritedAdministrationHead) return false;
36464
+ if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
36465
+ }
36463
36466
  if (connectorLower === "then") return true;
36464
36467
  const prefixSchedule = prefix.primaryClause.schedule;
36465
36468
  return Boolean(
@@ -36545,6 +36548,7 @@ function parseSigSegments(input, options) {
36545
36548
  const proceduralActions = parseInstructionActions(input, 0, options);
36546
36549
  const segments = [];
36547
36550
  let start = 0;
36551
+ let inheritedAdministrationContinuation = false;
36548
36552
  let parenDepth = 0;
36549
36553
  let scannedOffset = 0;
36550
36554
  const scanParens = (end) => {
@@ -36576,18 +36580,40 @@ function parseSigSegments(input, options) {
36576
36580
  }
36577
36581
  const nextToken = tokens[index + 1];
36578
36582
  if (token.original === "," && nextToken) {
36579
- if (scheduleOnlyAdministrationContinuation(input, tokens, index + 1, start, options) || doseBearingAdministrationContinuation(input, tokens, index + 1, start, options)) {
36583
+ const scheduleContinuation = scheduleOnlyAdministrationContinuation(
36584
+ input,
36585
+ tokens,
36586
+ index + 1,
36587
+ start,
36588
+ options,
36589
+ inheritedAdministrationContinuation
36590
+ );
36591
+ const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index + 1, start, options);
36592
+ if (scheduleContinuation || doseContinuation) {
36580
36593
  pushSegment(segments, input, start, token.sourceStart);
36581
36594
  start = nextToken.sourceEnd;
36595
+ inheritedAdministrationContinuation = true;
36582
36596
  index += 1;
36583
36597
  scannedOffset = nextToken.sourceEnd;
36584
36598
  continue;
36585
36599
  }
36586
- } else if (scheduleOnlyAdministrationContinuation(input, tokens, index, start, options) || doseBearingAdministrationContinuation(input, tokens, index, start, options)) {
36587
- pushSegment(segments, input, start, token.sourceStart);
36588
- start = token.sourceEnd;
36589
- scannedOffset = token.sourceEnd;
36590
- continue;
36600
+ } else {
36601
+ const scheduleContinuation = scheduleOnlyAdministrationContinuation(
36602
+ input,
36603
+ tokens,
36604
+ index,
36605
+ start,
36606
+ options,
36607
+ inheritedAdministrationContinuation
36608
+ );
36609
+ const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index, start, options);
36610
+ if (scheduleContinuation || doseContinuation) {
36611
+ pushSegment(segments, input, start, token.sourceStart);
36612
+ start = token.sourceEnd;
36613
+ inheritedAdministrationContinuation = true;
36614
+ scannedOffset = token.sourceEnd;
36615
+ continue;
36616
+ }
36591
36617
  }
36592
36618
  const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
36593
36619
  if (!isBoundary) {
@@ -36596,6 +36622,7 @@ function parseSigSegments(input, options) {
36596
36622
  }
36597
36623
  pushSegment(segments, input, start, token.sourceStart);
36598
36624
  start = token.sourceEnd;
36625
+ inheritedAdministrationContinuation = false;
36599
36626
  scannedOffset = token.sourceEnd;
36600
36627
  }
36601
36628
  pushSegment(segments, input, start, input.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.60",
3
+ "version": "0.1.61",
4
4
  "description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",