ezmedicationinput 0.1.59 → 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 +113 -12
- package/dist/index.js +113 -12
- package/dist/instruction-graph.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8300,10 +8300,20 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8300
8300
|
}
|
|
8301
8301
|
},
|
|
8302
8302
|
{
|
|
8303
|
-
names: ["finger"
|
|
8303
|
+
names: ["finger"],
|
|
8304
|
+
definition: {
|
|
8305
|
+
coding: { code: "7569003", display: "Finger structure" },
|
|
8306
|
+
text: "finger",
|
|
8307
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8308
|
+
routeHint: RouteCode["Topical route"]
|
|
8309
|
+
}
|
|
8310
|
+
},
|
|
8311
|
+
{
|
|
8312
|
+
names: ["fingers"],
|
|
8304
8313
|
definition: {
|
|
8305
8314
|
coding: { code: "7569003", display: "Finger structure" },
|
|
8306
8315
|
text: "fingers",
|
|
8316
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8307
8317
|
routeHint: RouteCode["Topical route"]
|
|
8308
8318
|
}
|
|
8309
8319
|
},
|
|
@@ -8669,6 +8679,22 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8669
8679
|
routeHint: RouteCode["Topical route"]
|
|
8670
8680
|
}
|
|
8671
8681
|
},
|
|
8682
|
+
{
|
|
8683
|
+
names: ["wart", "\u0E2B\u0E39\u0E14"],
|
|
8684
|
+
definition: {
|
|
8685
|
+
text: "wart",
|
|
8686
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8687
|
+
routeHint: RouteCode["Topical route"]
|
|
8688
|
+
}
|
|
8689
|
+
},
|
|
8690
|
+
{
|
|
8691
|
+
names: ["warts"],
|
|
8692
|
+
definition: {
|
|
8693
|
+
text: "warts",
|
|
8694
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8695
|
+
routeHint: RouteCode["Topical route"]
|
|
8696
|
+
}
|
|
8697
|
+
},
|
|
8672
8698
|
{
|
|
8673
8699
|
names: ["spot", "spots", "acne spot", "acne spots", "\u0E08\u0E38\u0E14"],
|
|
8674
8700
|
definition: {
|
|
@@ -19009,6 +19035,21 @@ function actionHasLocalRelationBefore(parts, actionStart, index) {
|
|
|
19009
19035
|
}
|
|
19010
19036
|
return false;
|
|
19011
19037
|
}
|
|
19038
|
+
function actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options) {
|
|
19039
|
+
var _a28;
|
|
19040
|
+
for (let cursor = index - 1; cursor > actionStart; cursor -= 1) {
|
|
19041
|
+
const relation = resolveActionRelationSurface(key(parts[cursor]));
|
|
19042
|
+
if (!relation || !relationHasSemanticClass(relation, "locative")) continue;
|
|
19043
|
+
const siteText = parts.slice(cursor + 1, index).map((part) => part.original).join(" ").trim();
|
|
19044
|
+
if (!siteText) continue;
|
|
19045
|
+
const resolved = resolveBodySitePhrase(siteText, options == null ? void 0 : options.siteCodeMap, {
|
|
19046
|
+
bodySiteContext: (_a28 = options == null ? void 0 : options.context) == null ? void 0 : _a28.bodySiteContext,
|
|
19047
|
+
allowTerminalModifierInheritance: true
|
|
19048
|
+
});
|
|
19049
|
+
if ((resolved == null ? void 0 : resolved.coding) || (resolved == null ? void 0 : resolved.definition)) return true;
|
|
19050
|
+
}
|
|
19051
|
+
return false;
|
|
19052
|
+
}
|
|
19012
19053
|
function actionTailIsRegimenModifier(parts, actionStart, index, definition, options) {
|
|
19013
19054
|
const token = key(parts[index]);
|
|
19014
19055
|
if (!token) return false;
|
|
@@ -19030,7 +19071,8 @@ function actionTailIsRegimenModifier(parts, actionStart, index, definition, opti
|
|
|
19030
19071
|
if (!eventTail.some((part) => Boolean(EVENT_TIMING_TOKENS[key(part)]))) return false;
|
|
19031
19072
|
}
|
|
19032
19073
|
if ((definition == null ? void 0 : definition.argumentParser) === "object-time") return false;
|
|
19033
|
-
|
|
19074
|
+
if (!actionHasLocalRelationBefore(parts, actionStart, index)) return true;
|
|
19075
|
+
return actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options);
|
|
19034
19076
|
}
|
|
19035
19077
|
function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
19036
19078
|
var _a28, _b4, _c3;
|
|
@@ -20179,6 +20221,19 @@ function instructionGraphRoundTripPrimaryAction(clause) {
|
|
|
20179
20221
|
return hasLocalRelation || hasRichArgument;
|
|
20180
20222
|
});
|
|
20181
20223
|
}
|
|
20224
|
+
function instructionGraphPrimarySiteRelation(clause) {
|
|
20225
|
+
var _a28;
|
|
20226
|
+
const graph = clause.instructionGraph;
|
|
20227
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
20228
|
+
if (!graph || !primary || !clause.site) return void 0;
|
|
20229
|
+
return (_a28 = graph.actions.filter(
|
|
20230
|
+
(action) => action.polarity !== "negate" /* Negate */ && action.relation !== void 0 && relationHasSemanticClass(action.relation, "locative") && action.span.start < primary.end && primary.start < action.span.end && actionMatchesCanonicalMethod(action, clause) && action.args.some(
|
|
20231
|
+
(arg) => arg.role === "site" /* Site */ && siteArgumentCoveredByClause(arg, clause)
|
|
20232
|
+
)
|
|
20233
|
+
).sort(
|
|
20234
|
+
(left, right) => left.span.start - right.span.start || left.span.end - right.span.end
|
|
20235
|
+
)[0]) == null ? void 0 : _a28.relation;
|
|
20236
|
+
}
|
|
20182
20237
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
20183
20238
|
var _a28;
|
|
20184
20239
|
const graph = clause.instructionGraph;
|
|
@@ -21120,7 +21175,9 @@ function formatSite(clause, grammar, directObject = false) {
|
|
|
21120
21175
|
const noun = (_p = perTargetNoun != null ? perTargetNoun : resolvedSite == null ? void 0 : resolvedSite.englishObjectText) != null ? _p : `the ${normalizedText}`;
|
|
21121
21176
|
if (directObject) return noun;
|
|
21122
21177
|
const preferredPreposition = resolvedSite == null ? void 0 : resolvedSite.preferredPreposition;
|
|
21123
|
-
|
|
21178
|
+
const primarySiteRelation = instructionGraphPrimarySiteRelation(clause);
|
|
21179
|
+
const sourcePreposition = relationHasSemanticClass(primarySiteRelation, "locative") ? localizeAdviceRelation(primarySiteRelation, "en") : void 0;
|
|
21180
|
+
let preposition = sourcePreposition != null ? sourcePreposition : grammar.sitePreposition;
|
|
21124
21181
|
if (!preposition || preposition === "to" && preferredPreposition && preferredPreposition !== "to") {
|
|
21125
21182
|
preposition = preferredPreposition;
|
|
21126
21183
|
}
|
|
@@ -33642,6 +33699,23 @@ function methodLexicalRule() {
|
|
|
33642
33699
|
];
|
|
33643
33700
|
});
|
|
33644
33701
|
}
|
|
33702
|
+
function routeTokenIsTemporalPrepositionBeforeTiming(context, start, span) {
|
|
33703
|
+
if (span !== 1) return false;
|
|
33704
|
+
const token = context.tokens[start];
|
|
33705
|
+
if (!token || !SITE_ANCHORS.has(normalizeTokenLower(token))) return false;
|
|
33706
|
+
let cursor = start + 1;
|
|
33707
|
+
while (cursor < context.limit) {
|
|
33708
|
+
const candidate = context.tokens[cursor];
|
|
33709
|
+
if (!candidate || context.state.consumed.has(candidate.index)) return false;
|
|
33710
|
+
const lower = normalizeTokenLower(candidate);
|
|
33711
|
+
if (SITE_FILLERS.has(lower)) {
|
|
33712
|
+
cursor += 1;
|
|
33713
|
+
continue;
|
|
33714
|
+
}
|
|
33715
|
+
return Boolean(EVENT_TIMING_TOKENS[lower]);
|
|
33716
|
+
}
|
|
33717
|
+
return false;
|
|
33718
|
+
}
|
|
33645
33719
|
function routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) {
|
|
33646
33720
|
var _a28, _b4, _c3;
|
|
33647
33721
|
if (span !== 1) return false;
|
|
@@ -33677,7 +33751,7 @@ function routeLexicalRule() {
|
|
|
33677
33751
|
continue;
|
|
33678
33752
|
}
|
|
33679
33753
|
if (span === 1 && isMedicationAdministrationMethod(phrase, context.options)) continue;
|
|
33680
|
-
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span)) {
|
|
33754
|
+
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) || routeTokenIsTemporalPrepositionBeforeTiming(context, start, span)) {
|
|
33681
33755
|
continue;
|
|
33682
33756
|
}
|
|
33683
33757
|
const routeCandidates = routePhraseCandidates(phrase);
|
|
@@ -36516,7 +36590,7 @@ function normalizeSegmentLexeme(item) {
|
|
|
36516
36590
|
var _a28;
|
|
36517
36591
|
return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
|
|
36518
36592
|
}
|
|
36519
|
-
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
|
|
36593
|
+
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
|
|
36520
36594
|
var _a28;
|
|
36521
36595
|
const connector = tokens[connectorIndex];
|
|
36522
36596
|
const first = tokens[connectorIndex + 1];
|
|
@@ -36535,7 +36609,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
|
|
|
36535
36609
|
const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
|
|
36536
36610
|
if (!prefixText) return false;
|
|
36537
36611
|
const prefix = parseClauseState(prefixText, options);
|
|
36538
|
-
if (!hasAdministrationHead(prefix))
|
|
36612
|
+
if (!hasAdministrationHead(prefix)) {
|
|
36613
|
+
if (!inheritedAdministrationHead) return false;
|
|
36614
|
+
if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
|
|
36615
|
+
}
|
|
36539
36616
|
if (connectorLower === "then") return true;
|
|
36540
36617
|
const prefixSchedule = prefix.primaryClause.schedule;
|
|
36541
36618
|
return Boolean(
|
|
@@ -36621,6 +36698,7 @@ function parseSigSegments(input, options) {
|
|
|
36621
36698
|
const proceduralActions = parseInstructionActions(input, 0, options);
|
|
36622
36699
|
const segments = [];
|
|
36623
36700
|
let start = 0;
|
|
36701
|
+
let inheritedAdministrationContinuation = false;
|
|
36624
36702
|
let parenDepth = 0;
|
|
36625
36703
|
let scannedOffset = 0;
|
|
36626
36704
|
const scanParens = (end) => {
|
|
@@ -36652,18 +36730,40 @@ function parseSigSegments(input, options) {
|
|
|
36652
36730
|
}
|
|
36653
36731
|
const nextToken = tokens[index + 1];
|
|
36654
36732
|
if (token.original === "," && nextToken) {
|
|
36655
|
-
|
|
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) {
|
|
36656
36743
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36657
36744
|
start = nextToken.sourceEnd;
|
|
36745
|
+
inheritedAdministrationContinuation = true;
|
|
36658
36746
|
index += 1;
|
|
36659
36747
|
scannedOffset = nextToken.sourceEnd;
|
|
36660
36748
|
continue;
|
|
36661
36749
|
}
|
|
36662
|
-
} else
|
|
36663
|
-
|
|
36664
|
-
|
|
36665
|
-
|
|
36666
|
-
|
|
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
|
+
}
|
|
36667
36767
|
}
|
|
36668
36768
|
const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
|
|
36669
36769
|
if (!isBoundary) {
|
|
@@ -36672,6 +36772,7 @@ function parseSigSegments(input, options) {
|
|
|
36672
36772
|
}
|
|
36673
36773
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36674
36774
|
start = token.sourceEnd;
|
|
36775
|
+
inheritedAdministrationContinuation = false;
|
|
36675
36776
|
scannedOffset = token.sourceEnd;
|
|
36676
36777
|
}
|
|
36677
36778
|
pushSegment(segments, input, start, input.length);
|
package/dist/index.js
CHANGED
|
@@ -8150,10 +8150,20 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8150
8150
|
}
|
|
8151
8151
|
},
|
|
8152
8152
|
{
|
|
8153
|
-
names: ["finger"
|
|
8153
|
+
names: ["finger"],
|
|
8154
|
+
definition: {
|
|
8155
|
+
coding: { code: "7569003", display: "Finger structure" },
|
|
8156
|
+
text: "finger",
|
|
8157
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8158
|
+
routeHint: RouteCode["Topical route"]
|
|
8159
|
+
}
|
|
8160
|
+
},
|
|
8161
|
+
{
|
|
8162
|
+
names: ["fingers"],
|
|
8154
8163
|
definition: {
|
|
8155
8164
|
coding: { code: "7569003", display: "Finger structure" },
|
|
8156
8165
|
text: "fingers",
|
|
8166
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8157
8167
|
routeHint: RouteCode["Topical route"]
|
|
8158
8168
|
}
|
|
8159
8169
|
},
|
|
@@ -8519,6 +8529,22 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8519
8529
|
routeHint: RouteCode["Topical route"]
|
|
8520
8530
|
}
|
|
8521
8531
|
},
|
|
8532
|
+
{
|
|
8533
|
+
names: ["wart", "\u0E2B\u0E39\u0E14"],
|
|
8534
|
+
definition: {
|
|
8535
|
+
text: "wart",
|
|
8536
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8537
|
+
routeHint: RouteCode["Topical route"]
|
|
8538
|
+
}
|
|
8539
|
+
},
|
|
8540
|
+
{
|
|
8541
|
+
names: ["warts"],
|
|
8542
|
+
definition: {
|
|
8543
|
+
text: "warts",
|
|
8544
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8545
|
+
routeHint: RouteCode["Topical route"]
|
|
8546
|
+
}
|
|
8547
|
+
},
|
|
8522
8548
|
{
|
|
8523
8549
|
names: ["spot", "spots", "acne spot", "acne spots", "\u0E08\u0E38\u0E14"],
|
|
8524
8550
|
definition: {
|
|
@@ -18859,6 +18885,21 @@ function actionHasLocalRelationBefore(parts, actionStart, index) {
|
|
|
18859
18885
|
}
|
|
18860
18886
|
return false;
|
|
18861
18887
|
}
|
|
18888
|
+
function actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options) {
|
|
18889
|
+
var _a28;
|
|
18890
|
+
for (let cursor = index - 1; cursor > actionStart; cursor -= 1) {
|
|
18891
|
+
const relation = resolveActionRelationSurface(key(parts[cursor]));
|
|
18892
|
+
if (!relation || !relationHasSemanticClass(relation, "locative")) continue;
|
|
18893
|
+
const siteText = parts.slice(cursor + 1, index).map((part) => part.original).join(" ").trim();
|
|
18894
|
+
if (!siteText) continue;
|
|
18895
|
+
const resolved = resolveBodySitePhrase(siteText, options == null ? void 0 : options.siteCodeMap, {
|
|
18896
|
+
bodySiteContext: (_a28 = options == null ? void 0 : options.context) == null ? void 0 : _a28.bodySiteContext,
|
|
18897
|
+
allowTerminalModifierInheritance: true
|
|
18898
|
+
});
|
|
18899
|
+
if ((resolved == null ? void 0 : resolved.coding) || (resolved == null ? void 0 : resolved.definition)) return true;
|
|
18900
|
+
}
|
|
18901
|
+
return false;
|
|
18902
|
+
}
|
|
18862
18903
|
function actionTailIsRegimenModifier(parts, actionStart, index, definition, options) {
|
|
18863
18904
|
const token = key(parts[index]);
|
|
18864
18905
|
if (!token) return false;
|
|
@@ -18880,7 +18921,8 @@ function actionTailIsRegimenModifier(parts, actionStart, index, definition, opti
|
|
|
18880
18921
|
if (!eventTail.some((part) => Boolean(EVENT_TIMING_TOKENS[key(part)]))) return false;
|
|
18881
18922
|
}
|
|
18882
18923
|
if ((definition == null ? void 0 : definition.argumentParser) === "object-time") return false;
|
|
18883
|
-
|
|
18924
|
+
if (!actionHasLocalRelationBefore(parts, actionStart, index)) return true;
|
|
18925
|
+
return actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options);
|
|
18884
18926
|
}
|
|
18885
18927
|
function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
18886
18928
|
var _a28, _b4, _c3;
|
|
@@ -20029,6 +20071,19 @@ function instructionGraphRoundTripPrimaryAction(clause) {
|
|
|
20029
20071
|
return hasLocalRelation || hasRichArgument;
|
|
20030
20072
|
});
|
|
20031
20073
|
}
|
|
20074
|
+
function instructionGraphPrimarySiteRelation(clause) {
|
|
20075
|
+
var _a28;
|
|
20076
|
+
const graph = clause.instructionGraph;
|
|
20077
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
20078
|
+
if (!graph || !primary || !clause.site) return void 0;
|
|
20079
|
+
return (_a28 = graph.actions.filter(
|
|
20080
|
+
(action) => action.polarity !== "negate" /* Negate */ && action.relation !== void 0 && relationHasSemanticClass(action.relation, "locative") && action.span.start < primary.end && primary.start < action.span.end && actionMatchesCanonicalMethod(action, clause) && action.args.some(
|
|
20081
|
+
(arg) => arg.role === "site" /* Site */ && siteArgumentCoveredByClause(arg, clause)
|
|
20082
|
+
)
|
|
20083
|
+
).sort(
|
|
20084
|
+
(left, right) => left.span.start - right.span.start || left.span.end - right.span.end
|
|
20085
|
+
)[0]) == null ? void 0 : _a28.relation;
|
|
20086
|
+
}
|
|
20032
20087
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
20033
20088
|
var _a28;
|
|
20034
20089
|
const graph = clause.instructionGraph;
|
|
@@ -20970,7 +21025,9 @@ function formatSite(clause, grammar, directObject = false) {
|
|
|
20970
21025
|
const noun = (_p = perTargetNoun != null ? perTargetNoun : resolvedSite == null ? void 0 : resolvedSite.englishObjectText) != null ? _p : `the ${normalizedText}`;
|
|
20971
21026
|
if (directObject) return noun;
|
|
20972
21027
|
const preferredPreposition = resolvedSite == null ? void 0 : resolvedSite.preferredPreposition;
|
|
20973
|
-
|
|
21028
|
+
const primarySiteRelation = instructionGraphPrimarySiteRelation(clause);
|
|
21029
|
+
const sourcePreposition = relationHasSemanticClass(primarySiteRelation, "locative") ? localizeAdviceRelation(primarySiteRelation, "en") : void 0;
|
|
21030
|
+
let preposition = sourcePreposition != null ? sourcePreposition : grammar.sitePreposition;
|
|
20974
21031
|
if (!preposition || preposition === "to" && preferredPreposition && preferredPreposition !== "to") {
|
|
20975
21032
|
preposition = preferredPreposition;
|
|
20976
21033
|
}
|
|
@@ -33492,6 +33549,23 @@ function methodLexicalRule() {
|
|
|
33492
33549
|
];
|
|
33493
33550
|
});
|
|
33494
33551
|
}
|
|
33552
|
+
function routeTokenIsTemporalPrepositionBeforeTiming(context, start, span) {
|
|
33553
|
+
if (span !== 1) return false;
|
|
33554
|
+
const token = context.tokens[start];
|
|
33555
|
+
if (!token || !SITE_ANCHORS.has(normalizeTokenLower(token))) return false;
|
|
33556
|
+
let cursor = start + 1;
|
|
33557
|
+
while (cursor < context.limit) {
|
|
33558
|
+
const candidate = context.tokens[cursor];
|
|
33559
|
+
if (!candidate || context.state.consumed.has(candidate.index)) return false;
|
|
33560
|
+
const lower = normalizeTokenLower(candidate);
|
|
33561
|
+
if (SITE_FILLERS.has(lower)) {
|
|
33562
|
+
cursor += 1;
|
|
33563
|
+
continue;
|
|
33564
|
+
}
|
|
33565
|
+
return Boolean(EVENT_TIMING_TOKENS[lower]);
|
|
33566
|
+
}
|
|
33567
|
+
return false;
|
|
33568
|
+
}
|
|
33495
33569
|
function routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) {
|
|
33496
33570
|
var _a28, _b4, _c3;
|
|
33497
33571
|
if (span !== 1) return false;
|
|
@@ -33527,7 +33601,7 @@ function routeLexicalRule() {
|
|
|
33527
33601
|
continue;
|
|
33528
33602
|
}
|
|
33529
33603
|
if (span === 1 && isMedicationAdministrationMethod(phrase, context.options)) continue;
|
|
33530
|
-
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span)) {
|
|
33604
|
+
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) || routeTokenIsTemporalPrepositionBeforeTiming(context, start, span)) {
|
|
33531
33605
|
continue;
|
|
33532
33606
|
}
|
|
33533
33607
|
const routeCandidates = routePhraseCandidates(phrase);
|
|
@@ -36366,7 +36440,7 @@ function normalizeSegmentLexeme(item) {
|
|
|
36366
36440
|
var _a28;
|
|
36367
36441
|
return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
|
|
36368
36442
|
}
|
|
36369
|
-
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
|
|
36443
|
+
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
|
|
36370
36444
|
var _a28;
|
|
36371
36445
|
const connector = tokens[connectorIndex];
|
|
36372
36446
|
const first = tokens[connectorIndex + 1];
|
|
@@ -36385,7 +36459,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
|
|
|
36385
36459
|
const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
|
|
36386
36460
|
if (!prefixText) return false;
|
|
36387
36461
|
const prefix = parseClauseState(prefixText, options);
|
|
36388
|
-
if (!hasAdministrationHead(prefix))
|
|
36462
|
+
if (!hasAdministrationHead(prefix)) {
|
|
36463
|
+
if (!inheritedAdministrationHead) return false;
|
|
36464
|
+
if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
|
|
36465
|
+
}
|
|
36389
36466
|
if (connectorLower === "then") return true;
|
|
36390
36467
|
const prefixSchedule = prefix.primaryClause.schedule;
|
|
36391
36468
|
return Boolean(
|
|
@@ -36471,6 +36548,7 @@ function parseSigSegments(input, options) {
|
|
|
36471
36548
|
const proceduralActions = parseInstructionActions(input, 0, options);
|
|
36472
36549
|
const segments = [];
|
|
36473
36550
|
let start = 0;
|
|
36551
|
+
let inheritedAdministrationContinuation = false;
|
|
36474
36552
|
let parenDepth = 0;
|
|
36475
36553
|
let scannedOffset = 0;
|
|
36476
36554
|
const scanParens = (end) => {
|
|
@@ -36502,18 +36580,40 @@ function parseSigSegments(input, options) {
|
|
|
36502
36580
|
}
|
|
36503
36581
|
const nextToken = tokens[index + 1];
|
|
36504
36582
|
if (token.original === "," && nextToken) {
|
|
36505
|
-
|
|
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) {
|
|
36506
36593
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36507
36594
|
start = nextToken.sourceEnd;
|
|
36595
|
+
inheritedAdministrationContinuation = true;
|
|
36508
36596
|
index += 1;
|
|
36509
36597
|
scannedOffset = nextToken.sourceEnd;
|
|
36510
36598
|
continue;
|
|
36511
36599
|
}
|
|
36512
|
-
} else
|
|
36513
|
-
|
|
36514
|
-
|
|
36515
|
-
|
|
36516
|
-
|
|
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
|
+
}
|
|
36517
36617
|
}
|
|
36518
36618
|
const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
|
|
36519
36619
|
if (!isBoundary) {
|
|
@@ -36522,6 +36622,7 @@ function parseSigSegments(input, options) {
|
|
|
36522
36622
|
}
|
|
36523
36623
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36524
36624
|
start = token.sourceEnd;
|
|
36625
|
+
inheritedAdministrationContinuation = false;
|
|
36525
36626
|
scannedOffset = token.sourceEnd;
|
|
36526
36627
|
}
|
|
36527
36628
|
pushSegment(segments, input, start, input.length);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdviceFrame, AdviceModality, CanonicalInstructionGraph, CanonicalSigClause, ParseOptions } from "./types";
|
|
1
|
+
import { AdviceFrame, AdviceModality, AdviceRelation, CanonicalInstructionGraph, CanonicalSigClause, ParseOptions } from "./types";
|
|
2
2
|
export declare function parseInstructionActions(sourceText: string, baseOffset?: number, options?: ParseOptions): AdviceFrame[];
|
|
3
3
|
export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph): void;
|
|
4
4
|
export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions): CanonicalInstructionGraph | undefined;
|
|
@@ -8,6 +8,7 @@ export declare function instructionGraphTextParticipatesInRelation(graph: Canoni
|
|
|
8
8
|
export declare function instructionGraphSingleActionRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
|
|
9
9
|
export declare function instructionGraphRichPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
|
|
10
10
|
export declare function instructionGraphRoundTripPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
|
|
11
|
+
export declare function instructionGraphPrimarySiteRelation(clause: CanonicalSigClause): AdviceRelation | undefined;
|
|
11
12
|
export declare function instructionGraphPrimaryAdministrationModality(clause: CanonicalSigClause): AdviceModality | undefined;
|
|
12
13
|
export declare function instructionGraphHasNovelNonWarningContent(graph: CanonicalInstructionGraph, representedTexts: readonly string[]): boolean;
|
|
13
14
|
export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph, locale?: string, options?: {
|