ezmedicationinput 0.1.57 → 0.1.58
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/body-site-grammar.d.ts +18 -0
- package/dist/hpsg/timing-lexicon.d.ts +6 -0
- package/dist/index.cjs +447 -84
- package/dist/index.js +447 -84
- package/dist/instruction-graph.d.ts +1 -0
- package/dist/relation-terminology.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1783,7 +1783,8 @@ var instruction_action_terminology_default = {
|
|
|
1783
1783
|
},
|
|
1784
1784
|
aliases: [
|
|
1785
1785
|
"drink",
|
|
1786
|
-
"\u0E14\u0E37\u0E48\u0E21"
|
|
1786
|
+
"\u0E14\u0E37\u0E48\u0E21",
|
|
1787
|
+
"drinking"
|
|
1787
1788
|
],
|
|
1788
1789
|
procedural: false,
|
|
1789
1790
|
acceptsAmount: true,
|
|
@@ -3412,6 +3413,21 @@ var instruction_concept_terminology_default = {
|
|
|
3412
3413
|
"sleep",
|
|
3413
3414
|
"\u0E19\u0E2D\u0E19"
|
|
3414
3415
|
]
|
|
3416
|
+
},
|
|
3417
|
+
{
|
|
3418
|
+
code: "dissolved",
|
|
3419
|
+
role: "result",
|
|
3420
|
+
display: "dissolved",
|
|
3421
|
+
i18n: {
|
|
3422
|
+
th: "\u0E25\u0E30\u0E25\u0E32\u0E22\u0E2B\u0E21\u0E14"
|
|
3423
|
+
},
|
|
3424
|
+
aliases: [
|
|
3425
|
+
"dissolved",
|
|
3426
|
+
"fully dissolved",
|
|
3427
|
+
"completely dissolved",
|
|
3428
|
+
"\u0E25\u0E30\u0E25\u0E32\u0E22\u0E2B\u0E21\u0E14",
|
|
3429
|
+
"\u0E25\u0E30\u0E25\u0E32\u0E22\u0E08\u0E19\u0E2B\u0E21\u0E14"
|
|
3430
|
+
]
|
|
3415
3431
|
}
|
|
3416
3432
|
]
|
|
3417
3433
|
};
|
|
@@ -3980,7 +3996,10 @@ var symptom_terminology_default = {
|
|
|
3980
3996
|
"pain",
|
|
3981
3997
|
"ache",
|
|
3982
3998
|
"aches",
|
|
3983
|
-
"pains"
|
|
3999
|
+
"pains",
|
|
4000
|
+
"painful",
|
|
4001
|
+
"hurt",
|
|
4002
|
+
"hurts"
|
|
3984
4003
|
],
|
|
3985
4004
|
definition: {
|
|
3986
4005
|
coding: {
|
|
@@ -3995,6 +4014,10 @@ var symptom_terminology_default = {
|
|
|
3995
4014
|
],
|
|
3996
4015
|
i18n: {
|
|
3997
4016
|
th: "\u0E1B\u0E27\u0E14"
|
|
4017
|
+
},
|
|
4018
|
+
conditionI18n: {
|
|
4019
|
+
en: "painful",
|
|
4020
|
+
th: "\u0E1B\u0E27\u0E14"
|
|
3998
4021
|
}
|
|
3999
4022
|
}
|
|
4000
4023
|
},
|
|
@@ -6999,7 +7022,11 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
6999
7022
|
},
|
|
7000
7023
|
{
|
|
7001
7024
|
names: ["tongue", "tongues"],
|
|
7002
|
-
definition: {
|
|
7025
|
+
definition: {
|
|
7026
|
+
coding: { code: "21974007", display: "Tongue" },
|
|
7027
|
+
i18n: { th: "\u0E25\u0E34\u0E49\u0E19" },
|
|
7028
|
+
routeHint: RouteCode["Sublingual route"]
|
|
7029
|
+
}
|
|
7003
7030
|
},
|
|
7004
7031
|
{
|
|
7005
7032
|
names: ["lip", "lips"],
|
|
@@ -9748,7 +9775,8 @@ var relation_terminology_default = {
|
|
|
9748
9775
|
{
|
|
9749
9776
|
canonical: "outside",
|
|
9750
9777
|
aliases: [
|
|
9751
|
-
"outside"
|
|
9778
|
+
"outside",
|
|
9779
|
+
"outside of"
|
|
9752
9780
|
],
|
|
9753
9781
|
locative: true,
|
|
9754
9782
|
realization: {
|
|
@@ -10023,6 +10051,46 @@ var relation_terminology_default = {
|
|
|
10023
10051
|
strategy: "prefix"
|
|
10024
10052
|
}
|
|
10025
10053
|
}
|
|
10054
|
+
},
|
|
10055
|
+
{
|
|
10056
|
+
canonical: "at",
|
|
10057
|
+
aliases: [
|
|
10058
|
+
"at"
|
|
10059
|
+
],
|
|
10060
|
+
realization: {
|
|
10061
|
+
en: {
|
|
10062
|
+
surface: "at",
|
|
10063
|
+
strategy: "prefix"
|
|
10064
|
+
},
|
|
10065
|
+
th: {
|
|
10066
|
+
surface: "\u0E15\u0E23\u0E07",
|
|
10067
|
+
strategy: "prefix",
|
|
10068
|
+
omitOuterSitePreposition: true
|
|
10069
|
+
}
|
|
10070
|
+
},
|
|
10071
|
+
grammar: {
|
|
10072
|
+
qualifierTarget: "site"
|
|
10073
|
+
}
|
|
10074
|
+
},
|
|
10075
|
+
{
|
|
10076
|
+
canonical: "where",
|
|
10077
|
+
aliases: [
|
|
10078
|
+
"where"
|
|
10079
|
+
],
|
|
10080
|
+
realization: {
|
|
10081
|
+
en: {
|
|
10082
|
+
surface: "where",
|
|
10083
|
+
strategy: "prefix"
|
|
10084
|
+
},
|
|
10085
|
+
th: {
|
|
10086
|
+
surface: "\u0E17\u0E35\u0E48",
|
|
10087
|
+
strategy: "prefix",
|
|
10088
|
+
omitOuterSitePreposition: true
|
|
10089
|
+
}
|
|
10090
|
+
},
|
|
10091
|
+
grammar: {
|
|
10092
|
+
qualifierTarget: "symptom"
|
|
10093
|
+
}
|
|
10026
10094
|
}
|
|
10027
10095
|
]
|
|
10028
10096
|
};
|
|
@@ -12504,6 +12572,7 @@ function matchBodySiteLocativeRelation(words, start = 0) {
|
|
|
12504
12572
|
return relation ? { relation, length: 1 } : void 0;
|
|
12505
12573
|
}
|
|
12506
12574
|
function parseBodySiteFeatures(text, coding, customSiteMap) {
|
|
12575
|
+
var _a26;
|
|
12507
12576
|
const normalized = normalizeBodySiteKey(text);
|
|
12508
12577
|
if (!normalized) {
|
|
12509
12578
|
return buildNominalFeatures(text, normalized, coding, customSiteMap);
|
|
@@ -12552,30 +12621,49 @@ function parseBodySiteFeatures(text, coding, customSiteMap) {
|
|
|
12552
12621
|
whole: buildNominalFeatures(wholeText, normalizeBodySiteKey(wholeText), void 0, customSiteMap)
|
|
12553
12622
|
};
|
|
12554
12623
|
}
|
|
12624
|
+
if (words.length > 1 && (firstWord === "left" || firstWord === "right") && !lookupDefinitionForCanonical(normalized, customSiteMap)) {
|
|
12625
|
+
const wholeText = words.slice(1).join(" ");
|
|
12626
|
+
const wholeCanonical = normalizeBodySiteKey(wholeText);
|
|
12627
|
+
const wholeDefinition = lookupDefinitionForCanonical(wholeCanonical, customSiteMap);
|
|
12628
|
+
if (((_a26 = wholeDefinition == null ? void 0 : wholeDefinition.coding) == null ? void 0 : _a26.code) || (wholeDefinition == null ? void 0 : wholeDefinition.routeHint)) {
|
|
12629
|
+
return {
|
|
12630
|
+
kind: "partitive",
|
|
12631
|
+
part: `${firstWord} side`,
|
|
12632
|
+
relationKey: "side",
|
|
12633
|
+
whole: buildNominalFeatures(wholeText, wholeCanonical, void 0, customSiteMap),
|
|
12634
|
+
attributive: true
|
|
12635
|
+
};
|
|
12636
|
+
}
|
|
12637
|
+
}
|
|
12555
12638
|
return buildNominalFeatures(text, normalized, coding, customSiteMap);
|
|
12556
12639
|
}
|
|
12557
12640
|
function renderNominalObject(features) {
|
|
12558
12641
|
return features.article === "bare" ? features.text : `the ${features.text}`;
|
|
12559
12642
|
}
|
|
12560
12643
|
function renderBodySiteObject(features) {
|
|
12561
|
-
var _a26, _b3;
|
|
12644
|
+
var _a26, _b3, _c2;
|
|
12562
12645
|
switch (features.kind) {
|
|
12563
12646
|
case "locative": {
|
|
12564
12647
|
const surface = (_b3 = (_a26 = getBodySiteRelationRealization(features.relation, "en")) == null ? void 0 : _a26.surface) != null ? _b3 : features.relation;
|
|
12565
12648
|
return `${surface} ${renderBodySiteObject(features.target)}`;
|
|
12566
12649
|
}
|
|
12567
12650
|
case "partitive":
|
|
12651
|
+
if (features.attributive) {
|
|
12652
|
+
const side = (_c2 = features.part.split(/\s+/u)[0]) != null ? _c2 : features.part;
|
|
12653
|
+
return features.whole.article === "bare" ? `${side} ${features.whole.text}` : `the ${side} ${features.whole.text}`;
|
|
12654
|
+
}
|
|
12568
12655
|
return `${features.part.startsWith("both") || features.part.startsWith("bilateral") ? features.part : `the ${features.part}`} of ${renderNominalObject(features.whole)}`;
|
|
12569
12656
|
case "nominal":
|
|
12570
12657
|
return renderNominalObject(features);
|
|
12571
12658
|
}
|
|
12572
12659
|
}
|
|
12573
12660
|
function featureDisplayText(features) {
|
|
12661
|
+
var _a26;
|
|
12574
12662
|
switch (features.kind) {
|
|
12575
12663
|
case "locative":
|
|
12576
12664
|
return `${features.relation} ${featureDisplayText(features.target)}`;
|
|
12577
12665
|
case "partitive":
|
|
12578
|
-
return `${features.part} of ${features.whole.text}`;
|
|
12666
|
+
return features.attributive ? `${(_a26 = features.part.split(/\s+/u)[0]) != null ? _a26 : features.part} ${features.whole.text}` : `${features.part} of ${features.whole.text}`;
|
|
12579
12667
|
case "nominal":
|
|
12580
12668
|
return features.text;
|
|
12581
12669
|
}
|
|
@@ -12650,6 +12738,103 @@ function inferPreferredPreposition(canonical, features, definition) {
|
|
|
12650
12738
|
}
|
|
12651
12739
|
return void 0;
|
|
12652
12740
|
}
|
|
12741
|
+
function withBodySiteQualifier(features, qualifier) {
|
|
12742
|
+
return __spreadProps(__spreadValues({}, features), { qualifier });
|
|
12743
|
+
}
|
|
12744
|
+
var BODY_SITE_QUALIFIER_MATCHERS = (() => {
|
|
12745
|
+
var _a26, _b3;
|
|
12746
|
+
const matchers = [];
|
|
12747
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12748
|
+
for (const definition of listBodySiteRelationDefinitions()) {
|
|
12749
|
+
const target = definition.grammar.qualifierTarget;
|
|
12750
|
+
if (!target) continue;
|
|
12751
|
+
const surfaces = [
|
|
12752
|
+
definition.canonical,
|
|
12753
|
+
...definition.aliases,
|
|
12754
|
+
(_a26 = definition.realization.en) == null ? void 0 : _a26.surface,
|
|
12755
|
+
(_b3 = definition.realization.th) == null ? void 0 : _b3.surface
|
|
12756
|
+
];
|
|
12757
|
+
for (const surface of surfaces) {
|
|
12758
|
+
const normalizedSurface = surface ? normalizeBodySiteKey(surface) : "";
|
|
12759
|
+
if (!normalizedSurface) continue;
|
|
12760
|
+
const key2 = `${definition.canonical}|${target}|${normalizedSurface}`;
|
|
12761
|
+
if (seen.has(key2)) continue;
|
|
12762
|
+
seen.add(key2);
|
|
12763
|
+
matchers.push({
|
|
12764
|
+
relation: definition.canonical,
|
|
12765
|
+
target,
|
|
12766
|
+
marker: ` ${normalizedSurface} `
|
|
12767
|
+
});
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
return matchers.sort((left, right) => right.marker.length - left.marker.length);
|
|
12771
|
+
})();
|
|
12772
|
+
function matchBodySiteQualifier(lookupCanonical) {
|
|
12773
|
+
let best;
|
|
12774
|
+
for (const matcher of BODY_SITE_QUALIFIER_MATCHERS) {
|
|
12775
|
+
const index = lookupCanonical.lastIndexOf(matcher.marker);
|
|
12776
|
+
if (index <= 0 || index + matcher.marker.length >= lookupCanonical.length) continue;
|
|
12777
|
+
const candidate = {
|
|
12778
|
+
relation: matcher.relation,
|
|
12779
|
+
target: matcher.target,
|
|
12780
|
+
start: index,
|
|
12781
|
+
end: index + matcher.marker.length
|
|
12782
|
+
};
|
|
12783
|
+
if (!best || candidate.start > best.start || candidate.start === best.start && candidate.end > best.end) best = candidate;
|
|
12784
|
+
}
|
|
12785
|
+
return best;
|
|
12786
|
+
}
|
|
12787
|
+
function qualifiedBodySitePhrase(lookupCanonical, customSiteMap, context) {
|
|
12788
|
+
var _a26, _b3, _c2, _d, _e, _f, _g, _h;
|
|
12789
|
+
const match = matchBodySiteQualifier(lookupCanonical);
|
|
12790
|
+
if (!match) return void 0;
|
|
12791
|
+
const base = resolveBodySitePhrase(lookupCanonical.slice(0, match.start), customSiteMap, context);
|
|
12792
|
+
if (!base) return void 0;
|
|
12793
|
+
const targetText = lookupCanonical.slice(match.end);
|
|
12794
|
+
const realization = getBodySiteRelationRealization(match.relation, "en");
|
|
12795
|
+
if (!realization) return void 0;
|
|
12796
|
+
if (match.target === "symptom") {
|
|
12797
|
+
const symptom = resolveSymptomDefinition(targetText);
|
|
12798
|
+
if (!symptom) return void 0;
|
|
12799
|
+
const conditionText = (_d = (_c2 = (_a26 = symptom.conditionI18n) == null ? void 0 : _a26.en) != null ? _c2 : (_b3 = symptom.text) == null ? void 0 : _b3.toLowerCase()) != null ? _d : targetText;
|
|
12800
|
+
const qualifier2 = {
|
|
12801
|
+
kind: "symptom",
|
|
12802
|
+
relation: match.relation,
|
|
12803
|
+
text: targetText,
|
|
12804
|
+
canonical: (_f = (_e = symptom.text) == null ? void 0 : _e.toLowerCase()) != null ? _f : targetText,
|
|
12805
|
+
coding: symptom.coding ? __spreadValues({}, symptom.coding) : void 0,
|
|
12806
|
+
i18n: __spreadValues(__spreadValues({ en: conditionText }, (_g = symptom.i18n) != null ? _g : {}), (_h = symptom.conditionI18n) != null ? _h : {})
|
|
12807
|
+
};
|
|
12808
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
12809
|
+
lookupCanonical,
|
|
12810
|
+
resolutionCanonical: `${base.resolutionCanonical} ${match.relation} ${qualifier2.canonical}`,
|
|
12811
|
+
canonical: `${base.canonical} ${match.relation} ${qualifier2.canonical}`,
|
|
12812
|
+
displayText: `${base.displayText} ${realization.surface} ${conditionText}`,
|
|
12813
|
+
features: withBodySiteQualifier(base.features, qualifier2),
|
|
12814
|
+
englishObjectText: `${base.englishObjectText} ${realization.surface} ${conditionText}`
|
|
12815
|
+
});
|
|
12816
|
+
}
|
|
12817
|
+
const target = resolveBodySitePhrase(targetText, customSiteMap, context);
|
|
12818
|
+
if (!target) return void 0;
|
|
12819
|
+
if (base.resolutionCanonical === target.resolutionCanonical) return base;
|
|
12820
|
+
if (!(base.coding || base.definition || base.spatialRelation)) return void 0;
|
|
12821
|
+
if (!(target.coding || target.definition || target.spatialRelation)) return void 0;
|
|
12822
|
+
const qualifier = {
|
|
12823
|
+
kind: "site",
|
|
12824
|
+
relation: match.relation,
|
|
12825
|
+
text: target.displayText,
|
|
12826
|
+
targetText: target.displayText,
|
|
12827
|
+
targetCoding: target.coding ? __spreadValues({}, target.coding) : void 0
|
|
12828
|
+
};
|
|
12829
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
12830
|
+
lookupCanonical,
|
|
12831
|
+
resolutionCanonical: `${base.resolutionCanonical} ${match.relation} ${target.resolutionCanonical}`,
|
|
12832
|
+
canonical: `${base.canonical} ${match.relation} ${target.canonical}`,
|
|
12833
|
+
displayText: `${base.displayText} ${realization.surface} ${target.displayText}`,
|
|
12834
|
+
features: withBodySiteQualifier(base.features, qualifier),
|
|
12835
|
+
englishObjectText: `${base.englishObjectText} ${realization.surface} ${target.englishObjectText}`
|
|
12836
|
+
});
|
|
12837
|
+
}
|
|
12653
12838
|
function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
12654
12839
|
var _a26, _b3, _c2, _d, _e, _f, _g, _h;
|
|
12655
12840
|
const trimmed = text.trim().replace(/\s+/g, " ");
|
|
@@ -12657,6 +12842,8 @@ function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
|
12657
12842
|
return void 0;
|
|
12658
12843
|
}
|
|
12659
12844
|
const lookupCanonical = normalizeBodySiteKey(trimmed);
|
|
12845
|
+
const qualified = qualifiedBodySitePhrase(lookupCanonical, customSiteMap, context);
|
|
12846
|
+
if (qualified) return qualified;
|
|
12660
12847
|
const contextualCanonical = resolveContextualBodySiteAlias(lookupCanonical, context);
|
|
12661
12848
|
const displaySourceText = contextualCanonical != null ? contextualCanonical : trimmed;
|
|
12662
12849
|
const displayText = normalizeSiteDisplayText(displaySourceText, customSiteMap);
|
|
@@ -12664,9 +12851,17 @@ function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
|
12664
12851
|
const directDefinition = (_e = (_d = (_c2 = (_b3 = (_a26 = lookupBodySiteDefinition(customSiteMap, lookupCanonical)) != null ? _a26 : contextualCanonical ? lookupBodySiteDefinition(customSiteMap, contextualCanonical) : void 0) != null ? _b3 : contextualCanonical ? DEFAULT_BODY_SITE_SNOMED[contextualCanonical] : void 0) != null ? _c2 : DEFAULT_BODY_SITE_SNOMED[lookupCanonical]) != null ? _d : lookupBodySiteDefinition(customSiteMap, canonical)) != null ? _e : DEFAULT_BODY_SITE_SNOMED[canonical];
|
|
12665
12852
|
const preliminaryFeatures = parseBodySiteFeatures(displayText, void 0, customSiteMap);
|
|
12666
12853
|
const terminal = directDefinition || !(context == null ? void 0 : context.allowTerminalModifierInheritance) || preliminaryFeatures.kind !== "nominal" || !terminalInheritanceIsLicensed(canonical) ? void 0 : longestTerminalBodySiteDefinition(canonical, customSiteMap);
|
|
12667
|
-
const
|
|
12668
|
-
const coding = buildBodySiteCoding(definition);
|
|
12854
|
+
const baseDefinition = directDefinition != null ? directDefinition : terminal == null ? void 0 : terminal.definition;
|
|
12669
12855
|
const finalDisplayText = (_f = directDefinition == null ? void 0 : directDefinition.text) != null ? _f : displayText;
|
|
12856
|
+
let inheritedDefinition;
|
|
12857
|
+
if (!baseDefinition) {
|
|
12858
|
+
const candidateFeatures = parseBodySiteFeatures(finalDisplayText, void 0, customSiteMap);
|
|
12859
|
+
if (candidateFeatures.kind === "partitive" && candidateFeatures.attributive) {
|
|
12860
|
+
inheritedDefinition = lookupDefinitionForCanonical(candidateFeatures.whole.canonical, customSiteMap);
|
|
12861
|
+
}
|
|
12862
|
+
}
|
|
12863
|
+
const definition = baseDefinition != null ? baseDefinition : inheritedDefinition;
|
|
12864
|
+
const coding = buildBodySiteCoding(definition);
|
|
12670
12865
|
const features = parseBodySiteFeatures(finalDisplayText, coding, customSiteMap);
|
|
12671
12866
|
const spatialRelation = (_g = definition == null ? void 0 : definition.spatialRelation) != null ? _g : buildSpatialRelation(features, finalDisplayText, customSiteMap);
|
|
12672
12867
|
return {
|
|
@@ -15835,6 +16030,28 @@ function normalizePeriodRange(low, high, unit) {
|
|
|
15835
16030
|
}
|
|
15836
16031
|
return { low, high, unit };
|
|
15837
16032
|
}
|
|
16033
|
+
var FIXED_PERIOD_SECONDS = {
|
|
16034
|
+
["s" /* Second */]: 1,
|
|
16035
|
+
["min" /* Minute */]: 60,
|
|
16036
|
+
["h" /* Hour */]: 60 * 60,
|
|
16037
|
+
["d" /* Day */]: 24 * 60 * 60,
|
|
16038
|
+
["wk" /* Week */]: 7 * 24 * 60 * 60
|
|
16039
|
+
};
|
|
16040
|
+
function normalizeMixedPeriodRange(low, lowUnit, high, highUnit) {
|
|
16041
|
+
if (lowUnit === highUnit) {
|
|
16042
|
+
const normalized = normalizePeriodRange(low, high, lowUnit);
|
|
16043
|
+
return normalized.low <= normalized.high ? normalized : void 0;
|
|
16044
|
+
}
|
|
16045
|
+
const lowScale = FIXED_PERIOD_SECONDS[lowUnit];
|
|
16046
|
+
const highScale = FIXED_PERIOD_SECONDS[highUnit];
|
|
16047
|
+
if (!lowScale || !highScale) return void 0;
|
|
16048
|
+
const unit = lowScale <= highScale ? lowUnit : highUnit;
|
|
16049
|
+
const unitScale = FIXED_PERIOD_SECONDS[unit];
|
|
16050
|
+
const normalizedLow = Math.round(low * lowScale / unitScale * 1e3) / 1e3;
|
|
16051
|
+
const normalizedHigh = Math.round(high * highScale / unitScale * 1e3) / 1e3;
|
|
16052
|
+
if (normalizedLow > normalizedHigh) return void 0;
|
|
16053
|
+
return { low: normalizedLow, high: normalizedHigh, unit };
|
|
16054
|
+
}
|
|
15838
16055
|
function periodUnitSuffix(unit) {
|
|
15839
16056
|
switch (unit) {
|
|
15840
16057
|
case "min" /* Minute */:
|
|
@@ -16797,6 +17014,9 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16797
17014
|
const conditionalTail = relationHasGrammarFeature(rawRelation, "conditionalTail");
|
|
16798
17015
|
const secondaryConditionalTail = relationHasGrammarFeature(nextRelation, "conditionalTail");
|
|
16799
17016
|
const relation = conditionalTail ? void 0 : rawRelation;
|
|
17017
|
+
const secondaryActivityTarget = nextRelationIndex >= 0 ? resolveMedicationInstructionAction(key(parts[nextRelationIndex + 1]), options) : void 0;
|
|
17018
|
+
const secondaryActivityRelation = nextRelationIndex >= 0 && secondaryActivityTarget && relationHasGrammarFeature(nextRelation, "activityFallback") ? nextRelation : void 0;
|
|
17019
|
+
const frameRelation = secondaryActivityRelation != null ? secondaryActivityRelation : relation;
|
|
16800
17020
|
const amount = definition.acceptsAmount ? parseQuantityArgument(parts, argumentStart, segmentEnd, input, offset, options) : void 0;
|
|
16801
17021
|
const duration = parseAnyDurationArgument(parts, argumentStart, segmentEnd, input, offset);
|
|
16802
17022
|
let semanticEnd = conditionalTail && relIndex >= 0 ? relIndex : secondaryConditionalTail && nextRelationIndex >= 0 ? nextRelationIndex : segmentEnd;
|
|
@@ -16819,6 +17039,16 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16819
17039
|
separableParticleIndex: actionMatch.separableParticleIndex
|
|
16820
17040
|
});
|
|
16821
17041
|
const args = parsed.args;
|
|
17042
|
+
if (secondaryActivityRelation && nextRelationIndex >= 0) {
|
|
17043
|
+
pushArgument(args, argumentFromParts(
|
|
17044
|
+
parts,
|
|
17045
|
+
nextRelationIndex + 1,
|
|
17046
|
+
segmentEnd,
|
|
17047
|
+
input,
|
|
17048
|
+
"activity" /* Activity */,
|
|
17049
|
+
options
|
|
17050
|
+
));
|
|
17051
|
+
}
|
|
16822
17052
|
if (definition.argumentParser === "preposed-duration" && !args.some((arg) => arg.role === "duration" /* Duration */)) {
|
|
16823
17053
|
return void 0;
|
|
16824
17054
|
}
|
|
@@ -16849,7 +17079,7 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16849
17079
|
}) : void 0,
|
|
16850
17080
|
codings
|
|
16851
17081
|
},
|
|
16852
|
-
relation,
|
|
17082
|
+
relation: frameRelation,
|
|
16853
17083
|
args,
|
|
16854
17084
|
span,
|
|
16855
17085
|
sourceText: input.slice(span.start - offset, span.end - offset),
|
|
@@ -17025,6 +17255,10 @@ function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
|
17025
17255
|
end = ACTION_COORDINATION_CONNECTORS.has(previousKey) ? index - 1 : index;
|
|
17026
17256
|
break;
|
|
17027
17257
|
}
|
|
17258
|
+
if (/^[,;:]$/u.test(currentKey) && INSTRUCTION_START_WORDS.has(key(parts[index + 1]))) {
|
|
17259
|
+
end = index;
|
|
17260
|
+
break;
|
|
17261
|
+
}
|
|
17028
17262
|
if (ACTION_DIRECTIVE_BOUNDARIES.has(currentKey) && !prefixedActionAt(parts, index, options) && !resultativeLeadAt(parts, index, options)) {
|
|
17029
17263
|
end = index;
|
|
17030
17264
|
break;
|
|
@@ -17563,15 +17797,26 @@ function promoteDoseFromDefiningAction(clause, actions, options) {
|
|
|
17563
17797
|
}
|
|
17564
17798
|
function canonicalPrimaryAdministrationSpan(clause, frames) {
|
|
17565
17799
|
const semantic = frames.filter((frame) => frame.polarity !== "negate" /* Negate */ && actionMatchesCanonicalMethod(frame, clause)).slice().sort((left, right) => left.span.start - right.span.start || left.span.end - right.span.end)[0];
|
|
17566
|
-
if (semantic)
|
|
17567
|
-
|
|
17800
|
+
if (semantic) {
|
|
17801
|
+
let best;
|
|
17802
|
+
for (const evidence of clause.evidence) {
|
|
17803
|
+
if (evidence.rule !== "hpsg.lex.method") continue;
|
|
17804
|
+
for (const span of evidence.spans) {
|
|
17805
|
+
if (span.start < semantic.span.start || semantic.span.end < span.end) continue;
|
|
17806
|
+
const candidate = { start: span.start, end: span.end };
|
|
17807
|
+
if (!best || candidate.end - candidate.start < best.end - best.start || candidate.end - candidate.start === best.end - best.start && candidate.start < best.start) {
|
|
17808
|
+
best = candidate;
|
|
17809
|
+
}
|
|
17810
|
+
}
|
|
17811
|
+
}
|
|
17812
|
+
return best != null ? best : { start: semantic.span.start, end: semantic.span.end };
|
|
17813
|
+
}
|
|
17568
17814
|
for (const evidence of clause.evidence) {
|
|
17569
17815
|
if (evidence.rule !== "hpsg.lex.method") continue;
|
|
17570
|
-
|
|
17816
|
+
const span = evidence.spans[0];
|
|
17817
|
+
if (span) return { start: span.start, end: span.end };
|
|
17571
17818
|
}
|
|
17572
|
-
|
|
17573
|
-
spans.sort((left, right) => left.start - right.start || left.end - right.end);
|
|
17574
|
-
return spans[0];
|
|
17819
|
+
return void 0;
|
|
17575
17820
|
}
|
|
17576
17821
|
function buildInstructionGraph(input, clause, options) {
|
|
17577
17822
|
const actions = [];
|
|
@@ -17719,7 +17964,7 @@ function actionLabel(frame, locale, roundtripSafe = false) {
|
|
|
17719
17964
|
return (_i = (_h = (_g = (_f = (_d = (_c2 = roundtripSafe ? (_a26 = definition == null ? void 0 : definition.roundtripI18n) == null ? void 0 : _a26[language] : void 0) != null ? _c2 : (_b3 = frame.predicate.i18n) == null ? void 0 : _b3[language]) != null ? _d : language === "en" ? frame.predicate.display : void 0) != null ? _f : (_e = definition == null ? void 0 : definition.i18n) == null ? void 0 : _e[language]) != null ? _g : definition == null ? void 0 : definition.display) != null ? _h : frame.predicate.display) != null ? _i : frame.predicate.lemma;
|
|
17720
17965
|
}
|
|
17721
17966
|
var DEFAULT_ACTION_REALIZER = (c) => {
|
|
17722
|
-
var _a26, _b3, _c2, _d;
|
|
17967
|
+
var _a26, _b3, _c2, _d, _e;
|
|
17723
17968
|
const objectArgs = c.frame.args.filter(
|
|
17724
17969
|
(arg) => arg.role === "theme" /* Theme */ || arg.role === "object" /* Object */ || arg.role === "site" /* Site */ || arg.role === "substance" /* Substance */
|
|
17725
17970
|
);
|
|
@@ -17732,7 +17977,9 @@ var DEFAULT_ACTION_REALIZER = (c) => {
|
|
|
17732
17977
|
const relationTargetArg = objectArgs.length > 1 ? objectArgs[1] : void 0;
|
|
17733
17978
|
const relationTarget = relationTargetArg ? translatedArgument(relationTargetArg, c.locale) : void 0;
|
|
17734
17979
|
const withTarget = relationHasGrammarFeature(c.frame.relation, "accompanimentComplement") ? relationTarget : void 0;
|
|
17735
|
-
|
|
17980
|
+
const activityRelation = c.activity && relationHasGrammarFeature(c.frame.relation, "activityFallback") ? (_e = localizeAdviceRelation(c.frame.relation, c.locale)) != null ? _e : c.frame.relation : void 0;
|
|
17981
|
+
const activitySuffix = activityRelation && c.activity ? c.thai ? `${activityRelation}${c.activity}` : ` ${activityRelation} ${c.activity}` : "";
|
|
17982
|
+
return c.thai ? `${c.label}${object != null ? object : ""}${amount ? ` ${amount}` : ""}${c.duration ? ` ${c.duration}` : ""}${withTarget ? `\u0E23\u0E48\u0E27\u0E21\u0E01\u0E31\u0E1A${withTarget}` : ""}${activitySuffix}` : `${c.label}${object ? ` ${object}` : ""}${amount ? ` ${amount}` : ""}${c.duration ? ` for ${c.duration}` : ""}${withTarget ? ` with ${withTarget}` : ""}${activitySuffix}`;
|
|
17736
17983
|
};
|
|
17737
17984
|
var SOURCE_FAITHFUL_REALIZER = (c) => {
|
|
17738
17985
|
const sourceIsThai = /[\u0E00-\u0E7F]/.test(c.frame.sourceText);
|
|
@@ -17863,13 +18110,17 @@ var LEAVE_DURATION_REALIZER = (c) => {
|
|
|
17863
18110
|
};
|
|
17864
18111
|
var DURATION_REALIZER = (c) => c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""}` : `${c.label}${c.duration ? ` for ${c.duration}` : ""}`;
|
|
17865
18112
|
var DURATION_ACTIVITY_REALIZER = (c) => {
|
|
17866
|
-
var _a26;
|
|
17867
|
-
|
|
17868
|
-
if (
|
|
17869
|
-
|
|
17870
|
-
|
|
18113
|
+
var _a26, _b3;
|
|
18114
|
+
const target = (_a26 = c.activity) != null ? _a26 : c.result;
|
|
18115
|
+
if (!target) return `${c.label}${c.duration ? ` ${c.duration}` : ""}`;
|
|
18116
|
+
if (c.frame.relation) {
|
|
18117
|
+
const relation = (_b3 = localizeAdviceRelation(c.frame.relation, c.locale)) != null ? _b3 : c.frame.relation;
|
|
18118
|
+
if (relationHasSemanticClass(c.frame.relation, "interval")) {
|
|
18119
|
+
return c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation}${target}` : `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation} ${target}`;
|
|
18120
|
+
}
|
|
18121
|
+
return c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""}${relation}${target}` : `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation} ${target}`;
|
|
17871
18122
|
}
|
|
17872
|
-
return `${c.label}${c.duration ? ` ${c.duration}` : ""} ${
|
|
18123
|
+
return `${c.label}${c.duration ? ` ${c.duration}` : ""} ${target}`;
|
|
17873
18124
|
};
|
|
17874
18125
|
var ACTIVITY_REALIZER = (c) => {
|
|
17875
18126
|
var _a26, _b3, _c2;
|
|
@@ -18261,6 +18512,28 @@ function instructionGraphRichPrimaryAction(clause) {
|
|
|
18261
18512
|
return (rich || suppliesMissingHead) && (!dose || matchesDose(action));
|
|
18262
18513
|
});
|
|
18263
18514
|
}
|
|
18515
|
+
function instructionGraphRoundTripPrimaryAction(clause) {
|
|
18516
|
+
const graph = clause.instructionGraph;
|
|
18517
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
18518
|
+
if (!graph || !primary) return void 0;
|
|
18519
|
+
return graph.actions.find((action) => {
|
|
18520
|
+
if (action.span.end <= primary.start || action.span.start >= primary.end) return false;
|
|
18521
|
+
const hasLocalRelation = relationHasGrammarFeature(action.relation, "roundtripRichRelation");
|
|
18522
|
+
const hasRichArgument = action.args.some(
|
|
18523
|
+
(arg) => [
|
|
18524
|
+
"time" /* Time */,
|
|
18525
|
+
"duration" /* Duration */,
|
|
18526
|
+
"material" /* Material */,
|
|
18527
|
+
"activity" /* Activity */,
|
|
18528
|
+
"result" /* Result */,
|
|
18529
|
+
"destination" /* Destination */,
|
|
18530
|
+
"substance" /* Substance */,
|
|
18531
|
+
"manner" /* Manner */
|
|
18532
|
+
].indexOf(arg.role) >= 0 || (arg.role === "object" /* Object */ || arg.role === "theme" /* Theme */) && /\b(?:new|replacement|another|fresh)\b/i.test(arg.text)
|
|
18533
|
+
);
|
|
18534
|
+
return hasLocalRelation || hasRichArgument;
|
|
18535
|
+
});
|
|
18536
|
+
}
|
|
18264
18537
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
18265
18538
|
var _a26;
|
|
18266
18539
|
const graph = clause.instructionGraph;
|
|
@@ -19392,7 +19665,7 @@ function applyEnglishAdministrationModality(verb, clause) {
|
|
|
19392
19665
|
return `${prefix} ${verb.charAt(0).toLowerCase()}${verb.slice(1)}`;
|
|
19393
19666
|
}
|
|
19394
19667
|
function formatLong(clause, options) {
|
|
19395
|
-
var _a26, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X
|
|
19668
|
+
var _a26, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X;
|
|
19396
19669
|
const schedule = scheduleOf(clause);
|
|
19397
19670
|
const grammar = resolveRouteGrammar(clause);
|
|
19398
19671
|
const baseVerb = resolveMethodVerb(clause, grammar);
|
|
@@ -19520,38 +19793,20 @@ function formatLong(clause, options) {
|
|
|
19520
19793
|
const richGraphAdministrationSentence = richPrimaryGraphText ? formatPatientInstructionSentence(
|
|
19521
19794
|
[richPrimaryGraphText, ...graphRegimenTail].filter(Boolean).join(" ")
|
|
19522
19795
|
) : void 0;
|
|
19523
|
-
const primaryGraphAction = roundTrip
|
|
19524
|
-
var _a27;
|
|
19525
|
-
const primary = (_a27 = clause.instructionGraph) == null ? void 0 : _a27.primaryAdministrationSpan;
|
|
19526
|
-
if (!primary || action.span.end <= primary.start || action.span.start >= primary.end) return false;
|
|
19527
|
-
const hasLocalRelation = relationHasGrammarFeature(action.relation, "roundtripRichRelation");
|
|
19528
|
-
const hasRichArgument = action.args.some(
|
|
19529
|
-
(arg) => [
|
|
19530
|
-
"time" /* Time */,
|
|
19531
|
-
"duration" /* Duration */,
|
|
19532
|
-
"material" /* Material */,
|
|
19533
|
-
"activity" /* Activity */,
|
|
19534
|
-
"result" /* Result */,
|
|
19535
|
-
"destination" /* Destination */,
|
|
19536
|
-
"substance" /* Substance */,
|
|
19537
|
-
"manner" /* Manner */
|
|
19538
|
-
].indexOf(arg.role) >= 0 || (arg.role === "object" /* Object */ || arg.role === "theme" /* Theme */) && /\b(?:new|replacement|another|fresh)\b/i.test(arg.text)
|
|
19539
|
-
);
|
|
19540
|
-
return hasLocalRelation || hasRichArgument;
|
|
19541
|
-
}) : void 0;
|
|
19796
|
+
const primaryGraphAction = roundTrip ? instructionGraphRoundTripPrimaryAction(clause) : void 0;
|
|
19542
19797
|
const instructionPhrases = [];
|
|
19543
19798
|
const hasCodedAdditionalInstruction = Boolean(
|
|
19544
|
-
(
|
|
19799
|
+
(_s = clause.additionalInstructions) == null ? void 0 : _s.some((instruction) => {
|
|
19545
19800
|
var _a27;
|
|
19546
19801
|
return (_a27 = instruction.coding) == null ? void 0 : _a27.code;
|
|
19547
19802
|
})
|
|
19548
19803
|
);
|
|
19549
19804
|
const normalizeInstruction = (value) => value.toLowerCase().replace(/[\s,;:.()]+/g, " ").trim();
|
|
19550
|
-
const graphWarnings = (
|
|
19805
|
+
const graphWarnings = (_u = (_t = clause.instructionGraph) == null ? void 0 : _t.actions.filter(
|
|
19551
19806
|
(action) => action.polarity === "negate" /* Negate */
|
|
19552
|
-
)) != null ?
|
|
19553
|
-
const positionedGraph = Boolean((
|
|
19554
|
-
const graphOwnedAdditional = ((
|
|
19807
|
+
)) != null ? _u : [];
|
|
19808
|
+
const positionedGraph = Boolean((_v = clause.instructionGraph) == null ? void 0 : _v.primaryAdministrationSpan);
|
|
19809
|
+
const graphOwnedAdditional = ((_w = clause.additionalInstructions) != null ? _w : []).filter((instruction) => {
|
|
19555
19810
|
var _a27, _b4;
|
|
19556
19811
|
if (((_a27 = instruction.coding) == null ? void 0 : _a27.code) || !instruction.text || !clause.instructionGraph) return false;
|
|
19557
19812
|
const normalized = normalizeInstruction(instruction.text);
|
|
@@ -19561,7 +19816,7 @@ function formatLong(clause, options) {
|
|
|
19561
19816
|
});
|
|
19562
19817
|
return instructionGraphRepresentsText(clause.instructionGraph, instruction.text) && (representedByWarning || !((_b4 = instruction.frames) == null ? void 0 : _b4.length) || positionedGraph && instructionGraphSingleActionRepresentsText(clause.instructionGraph, instruction.text) && instructionGraphTextParticipatesInRelation(clause.instructionGraph, instruction.text) || !canonicalClauseHasAdministrationSemantics(clause) && instructionGraphSingleActionRepresentsText(clause.instructionGraph, instruction.text));
|
|
19563
19818
|
});
|
|
19564
|
-
const additionalForDirectRendering = ((
|
|
19819
|
+
const additionalForDirectRendering = ((_x = clause.additionalInstructions) != null ? _x : []).filter(
|
|
19565
19820
|
(instruction) => graphOwnedAdditional.indexOf(instruction) === -1 && instruction !== integratedThinLayer
|
|
19566
19821
|
);
|
|
19567
19822
|
const additionalTexts = additionalForDirectRendering.map((instruction) => {
|
|
@@ -19570,8 +19825,8 @@ function formatLong(clause, options) {
|
|
|
19570
19825
|
}).filter((text) => Boolean(text));
|
|
19571
19826
|
const additionalSemanticSourceTexts = additionalTexts.slice();
|
|
19572
19827
|
for (const instruction of additionalForDirectRendering) {
|
|
19573
|
-
for (const frame of (
|
|
19574
|
-
const source = (
|
|
19828
|
+
for (const frame of (_y = instruction.frames) != null ? _y : []) {
|
|
19829
|
+
const source = (_z = frame.sourceText) == null ? void 0 : _z.trim();
|
|
19575
19830
|
if (source && additionalSemanticSourceTexts.indexOf(source) === -1) {
|
|
19576
19831
|
additionalSemanticSourceTexts.push(source);
|
|
19577
19832
|
}
|
|
@@ -19632,18 +19887,18 @@ function formatLong(clause, options) {
|
|
|
19632
19887
|
omitSourceTexts: postGraphOmissions,
|
|
19633
19888
|
position: "post"
|
|
19634
19889
|
}) : void 0;
|
|
19635
|
-
const graphInstruction = (
|
|
19890
|
+
const graphInstruction = (_A = graphWholeInstruction != null ? graphWholeInstruction : postGraphInstruction) != null ? _A : !positionedGraph && clause.instructionGraph && instructionGraphHasNovelNonWarningContent(clause.instructionGraph, representedInstructionTexts) ? realizeInstructionGraph(clause.instructionGraph, "en", {
|
|
19636
19891
|
includeWarnings: false,
|
|
19637
19892
|
omitCanonicalAdministration: clause,
|
|
19638
19893
|
preferSourceText: roundTrip,
|
|
19639
19894
|
roundtripSafe: roundTrip,
|
|
19640
19895
|
omitSourceTexts: postGraphOmissions
|
|
19641
19896
|
}) : void 0;
|
|
19642
|
-
const primarySpanForFlow = (
|
|
19643
|
-
const graphActionsForFlow = (
|
|
19897
|
+
const primarySpanForFlow = (_B = clause.instructionGraph) == null ? void 0 : _B.primaryAdministrationSpan;
|
|
19898
|
+
const graphActionsForFlow = (_D = (_C = clause.instructionGraph) == null ? void 0 : _C.actions) != null ? _D : [];
|
|
19644
19899
|
const lastPreActionForFlow = primarySpanForFlow ? graphActionsForFlow.filter((action) => action.span.end <= primarySpanForFlow.start).sort((a, b) => b.span.end - a.span.end)[0] : void 0;
|
|
19645
19900
|
const firstPostActionForFlow = primarySpanForFlow ? graphActionsForFlow.filter((action) => action.span.start >= primarySpanForFlow.end).sort((a, b) => a.span.start - b.span.start)[0] : void 0;
|
|
19646
|
-
const graphFlowSource = (
|
|
19901
|
+
const graphFlowSource = (_F = (_E = clause.instructionGraph) == null ? void 0 : _E.sourceText) != null ? _F : clause.rawText;
|
|
19647
19902
|
const noStrongBoundaryForFlow = (start, end) => !/[.!?;]/u.test(graphFlowSource.slice(start, end));
|
|
19648
19903
|
const preFlowsIntoAdministration = Boolean(
|
|
19649
19904
|
!roundTrip && preGraphInstruction && primarySpanForFlow && lastPreActionForFlow && lastPreActionForFlow.polarity !== "negate" /* Negate */ && noStrongBoundaryForFlow(lastPreActionForFlow.span.end, primarySpanForFlow.start)
|
|
@@ -19659,9 +19914,9 @@ function formatLong(clause, options) {
|
|
|
19659
19914
|
);
|
|
19660
19915
|
if (patientInstruction) instructionPhrases.push(patientInstruction);
|
|
19661
19916
|
const trailingInstructionText = instructionPhrases.join(" ").trim() || void 0;
|
|
19662
|
-
const hasExplicitMethod = Boolean(((
|
|
19663
|
-
const graphSourceIsEnglish = !((
|
|
19664
|
-
if (roundTrip && !hasExplicitMethod && graphSourceIsEnglish && ((
|
|
19917
|
+
const hasExplicitMethod = Boolean(((_H = (_G = clause.method) == null ? void 0 : _G.text) == null ? void 0 : _H.trim()) || ((_J = (_I = clause.method) == null ? void 0 : _I.coding) == null ? void 0 : _J.code));
|
|
19918
|
+
const graphSourceIsEnglish = !((_K = clause.instructionGraph) == null ? void 0 : _K.sourceLocale) || !clause.instructionGraph.sourceLocale.toLowerCase().startsWith("th");
|
|
19919
|
+
if (roundTrip && !hasExplicitMethod && graphSourceIsEnglish && ((_L = clause.instructionGraph) == null ? void 0 : _L.sourceText.trim())) {
|
|
19665
19920
|
return clause.instructionGraph.sourceText.trim();
|
|
19666
19921
|
}
|
|
19667
19922
|
if (!canonicalClauseHasAdministrationSemantics(clause)) {
|
|
@@ -19671,10 +19926,20 @@ function formatLong(clause, options) {
|
|
|
19671
19926
|
roundtripSafe: roundTrip
|
|
19672
19927
|
}) : void 0;
|
|
19673
19928
|
const wholeGraphText = formatPatientInstructionSentence(wholeGraph);
|
|
19674
|
-
|
|
19929
|
+
const parts = [];
|
|
19930
|
+
for (const value of [wholeGraphText, ...instructionPhrases]) {
|
|
19931
|
+
if (!value) continue;
|
|
19932
|
+
const normalized = normalizeInstruction(value);
|
|
19933
|
+
if (parts.some((existing) => {
|
|
19934
|
+
const candidate = normalizeInstruction(existing);
|
|
19935
|
+
return candidate === normalized || candidate.includes(normalized) || normalized.includes(candidate);
|
|
19936
|
+
})) continue;
|
|
19937
|
+
parts.push(value);
|
|
19938
|
+
}
|
|
19939
|
+
return parts.join(" ").trim() || `${verb}.`;
|
|
19675
19940
|
}
|
|
19676
19941
|
const leadingInstructionText = preFlowsIntoAdministration ? void 0 : preGraphInstruction ? formatPatientInstructionSentence(preGraphInstruction) : void 0;
|
|
19677
|
-
const graphRepresentsDose = !clause.dose || Boolean((
|
|
19942
|
+
const graphRepresentsDose = !clause.dose || Boolean((_M = clause.instructionGraph) == null ? void 0 : _M.actions.some(
|
|
19678
19943
|
(action) => action.args.some(
|
|
19679
19944
|
(arg) => {
|
|
19680
19945
|
var _a27, _b4, _c3, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
|
|
@@ -19683,26 +19948,26 @@ function formatLong(clause, options) {
|
|
|
19683
19948
|
)
|
|
19684
19949
|
));
|
|
19685
19950
|
const hasAdministrationTiming = Boolean(
|
|
19686
|
-
schedule.frequency !== void 0 || schedule.frequencyMax !== void 0 || schedule.period !== void 0 || schedule.periodMax !== void 0 || ((
|
|
19951
|
+
schedule.frequency !== void 0 || schedule.frequencyMax !== void 0 || schedule.period !== void 0 || schedule.periodMax !== void 0 || ((_N = schedule.when) == null ? void 0 : _N.length) || ((_O = schedule.dayOfWeek) == null ? void 0 : _O.length) || ((_P = schedule.timeOfDay) == null ? void 0 : _P.length) || schedule.count !== void 0 || schedule.countMax !== void 0 || schedule.timingCode || schedule.duration !== void 0 || schedule.durationMax !== void 0 || schedule.durationUnit !== void 0 || schedule.offset !== void 0 || schedule.offsetMin !== void 0 || schedule.offsetMax !== void 0 || Boolean((_Q = schedule.activityTiming) == null ? void 0 : _Q.length) || schedule.occurrenceCap !== void 0
|
|
19687
19952
|
);
|
|
19688
19953
|
const graphCanStandAlone = Boolean(
|
|
19689
|
-
!hasExplicitMethod && trailingInstructionText && ((
|
|
19954
|
+
!hasExplicitMethod && trailingInstructionText && ((_R = clause.instructionGraph) == null ? void 0 : _R.actions.length) && !clause.route && !clause.site && !hasAdministrationTiming && graphRepresentsDose
|
|
19690
19955
|
);
|
|
19691
19956
|
if (graphCanStandAlone) return trailingInstructionText;
|
|
19692
19957
|
const primarySourceSentence = primaryGraphAction ? formatPatientInstructionSentence(primaryGraphAction.sourceText) : void 0;
|
|
19693
|
-
const primaryActionIndex = primaryGraphAction ? (
|
|
19694
|
-
const entersPrimaryWithThen = primaryActionIndex !== void 0 && primaryActionIndex >= 0 ? (
|
|
19958
|
+
const primaryActionIndex = primaryGraphAction ? (_S = clause.instructionGraph) == null ? void 0 : _S.actions.indexOf(primaryGraphAction) : void 0;
|
|
19959
|
+
const entersPrimaryWithThen = primaryActionIndex !== void 0 && primaryActionIndex >= 0 ? (_U = (_T = clause.instructionGraph) == null ? void 0 : _T.relations) == null ? void 0 : _U.some(
|
|
19695
19960
|
(relation) => relationHasSemanticClass(relation.kind, "sequence") && relation.toActionIndex === primaryActionIndex && relation.fromActionIndex !== void 0
|
|
19696
19961
|
) : false;
|
|
19697
19962
|
const richPrimaryActionIndex = richPrimaryGraphAction && clause.instructionGraph ? clause.instructionGraph.actions.indexOf(richPrimaryGraphAction) : -1;
|
|
19698
19963
|
const graphContinuesWithThen = richPrimaryActionIndex >= 0 && Boolean(
|
|
19699
|
-
(
|
|
19964
|
+
(_W = (_V = clause.instructionGraph) == null ? void 0 : _V.relations) == null ? void 0 : _W.some(
|
|
19700
19965
|
(relation) => relationHasSemanticClass(relation.kind, "sequence") && relation.fromActionIndex === richPrimaryActionIndex
|
|
19701
19966
|
)
|
|
19702
19967
|
);
|
|
19703
19968
|
const sequenceRelation = getUniqueAdviceRelationByGrammarFeature("defaultSequenceRelation");
|
|
19704
19969
|
if (!sequenceRelation) throw new Error("Missing declarative default sequence relation");
|
|
19705
|
-
const sequenceSurface = (
|
|
19970
|
+
const sequenceSurface = (_X = localizeAdviceRelation(sequenceRelation, "en")) != null ? _X : sequenceRelation;
|
|
19706
19971
|
const compose = (base) => {
|
|
19707
19972
|
var _a27;
|
|
19708
19973
|
let effectiveBase = (_a27 = richGraphAdministrationSentence != null ? richGraphAdministrationSentence : primarySourceSentence) != null ? _a27 : base;
|
|
@@ -19848,8 +20113,8 @@ var advice_terminology_default = {
|
|
|
19848
20113
|
{ surface: "drive", lemma: "drive", partOfSpeech: "verb", semanticClass: "activity" },
|
|
19849
20114
|
{ surface: "driving", lemma: "drive", partOfSpeech: "verb", semanticClass: "activity" },
|
|
19850
20115
|
{ surface: "eat", lemma: "eat", partOfSpeech: "verb", semanticClass: "ingest" },
|
|
19851
|
-
{ surface: "cause", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect" },
|
|
19852
|
-
{ surface: "causes", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect" },
|
|
20116
|
+
{ surface: "cause", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect", i18n: { th: "\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E40\u0E01\u0E34\u0E14" } },
|
|
20117
|
+
{ surface: "causes", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect", i18n: { th: "\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E40\u0E01\u0E34\u0E14" } },
|
|
19853
20118
|
{ surface: "use", lemma: "use", partOfSpeech: "verb", semanticClass: "administration" },
|
|
19854
20119
|
{ surface: "take", lemma: "take", partOfSpeech: "verb", semanticClass: "administration" },
|
|
19855
20120
|
{ surface: "apply", lemma: "apply", partOfSpeech: "verb", semanticClass: "administration" },
|
|
@@ -20683,6 +20948,7 @@ function mapSemanticClassToRole(semanticClass) {
|
|
|
20683
20948
|
return (_a26 = enumValue(AdviceArgumentRole, configured)) != null ? _a26 : "object" /* Object */;
|
|
20684
20949
|
}
|
|
20685
20950
|
function classifyArgument(text) {
|
|
20951
|
+
var _a26, _b3, _c2, _d, _e;
|
|
20686
20952
|
const cleaned = cleanFreeText(text);
|
|
20687
20953
|
const normalized = normalizeAdditionalInstructionKey(cleaned);
|
|
20688
20954
|
if (!normalized) {
|
|
@@ -20697,6 +20963,21 @@ function classifyArgument(text) {
|
|
|
20697
20963
|
concept.conceptId
|
|
20698
20964
|
);
|
|
20699
20965
|
}
|
|
20966
|
+
const symptom = resolveSymptomDefinition(normalized);
|
|
20967
|
+
if (symptom) {
|
|
20968
|
+
const coding = symptom.coding ? __spreadValues({}, symptom.coding) : void 0;
|
|
20969
|
+
return {
|
|
20970
|
+
role: "object" /* Object */,
|
|
20971
|
+
text: cleaned,
|
|
20972
|
+
normalized: (_b3 = (_a26 = symptom.text) == null ? void 0 : _a26.toLowerCase()) != null ? _b3 : normalized,
|
|
20973
|
+
conceptId: (_d = (_c2 = coding == null ? void 0 : coding.code) != null ? _c2 : symptom.text) != null ? _d : normalized,
|
|
20974
|
+
coding,
|
|
20975
|
+
codings: coding ? [coding] : void 0,
|
|
20976
|
+
i18n: __spreadValues({
|
|
20977
|
+
en: symptom.text ? symptom.text.charAt(0).toLowerCase() + symptom.text.slice(1) : cleaned
|
|
20978
|
+
}, (_e = symptom.i18n) != null ? _e : {})
|
|
20979
|
+
};
|
|
20980
|
+
}
|
|
20700
20981
|
const parts = normalized.split(" ");
|
|
20701
20982
|
if (parts.length >= 2) {
|
|
20702
20983
|
const first = parts[0];
|
|
@@ -21336,8 +21617,9 @@ var AVOIDANCE_ADVICE_PREDICATE_REALIZER = ({ frame, argText, modalityText }) =>
|
|
|
21336
21617
|
};
|
|
21337
21618
|
var EFFECT_ADVICE_PREDICATE_REALIZER = ({ frame, argText, modalityText }) => {
|
|
21338
21619
|
const effectiveModality = modalityText != null ? modalityText : capitalizeSentence("may" /* May */);
|
|
21339
|
-
const
|
|
21340
|
-
|
|
21620
|
+
const thai = /[\u0E00-\u0E7F]/u.test(frame.predicate.lemma);
|
|
21621
|
+
const predicate = thai ? `${effectiveModality}${frame.predicate.lemma}` : `${effectiveModality} ${frame.predicate.lemma}`;
|
|
21622
|
+
return argText ? `${predicate}${thai ? "" : " "}${argText}` : predicate;
|
|
21341
21623
|
};
|
|
21342
21624
|
var ADVICE_PREDICATE_REALIZERS = {
|
|
21343
21625
|
default: DEFAULT_ADVICE_PREDICATE_REALIZER,
|
|
@@ -25016,7 +25298,7 @@ function buildRoutePhraseThai(clause, grammar, hasSite) {
|
|
|
25016
25298
|
return text;
|
|
25017
25299
|
}
|
|
25018
25300
|
function formatSiteThai(clause, grammar) {
|
|
25019
|
-
var _a26, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
25301
|
+
var _a26, _b3, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
25020
25302
|
const text = ((_b3 = (_a26 = clause.site) == null ? void 0 : _a26.text) == null ? void 0 : _b3.trim()) || ((_e = (_d = (_c2 = clause.site) == null ? void 0 : _c2.coding) == null ? void 0 : _d.display) == null ? void 0 : _e.trim());
|
|
25021
25303
|
const lower = text == null ? void 0 : text.toLowerCase();
|
|
25022
25304
|
const codingCode = (_g = (_f = clause.site) == null ? void 0 : _f.coding) == null ? void 0 : _g.code;
|
|
@@ -25031,20 +25313,22 @@ function formatSiteThai(clause, grammar) {
|
|
|
25031
25313
|
if (isVaginalRoute && isVaginaSite) {
|
|
25032
25314
|
return void 0;
|
|
25033
25315
|
}
|
|
25034
|
-
const
|
|
25316
|
+
const resolvedSite = text ? resolveBodySitePhrase(text) : void 0;
|
|
25317
|
+
const structuralTranslation = ((_l = clause.site) == null ? void 0 : _l.spatialRelation) || (resolvedSite == null ? void 0 : resolvedSite.features.qualifier) ? text ? translateSiteThai(text, codingCode, (_m = clause.site) == null ? void 0 : _m.spatialRelation) : translateSpatialSiteThai(void 0, (_n = clause.site) == null ? void 0 : _n.spatialRelation) : void 0;
|
|
25318
|
+
const translated = (_y = (_v = (_r = (_o = perTargetSiteThai(clause)) != null ? _o : structuralTranslation) != null ? _r : (_q = (_p = clause.site) == null ? void 0 : _p.i18n) == null ? void 0 : _q.th) != null ? _v : (_u = (_t = (_s = clause.site) == null ? void 0 : _s.coding) == null ? void 0 : _t.i18n) == null ? void 0 : _u.th) != null ? _y : text ? translateSiteThai(text, codingCode, (_w = clause.site) == null ? void 0 : _w.spatialRelation) : translateSpatialSiteThai(void 0, (_x = clause.site) == null ? void 0 : _x.spatialRelation);
|
|
25035
25319
|
if (!translated) {
|
|
25036
25320
|
return void 0;
|
|
25037
25321
|
}
|
|
25038
|
-
if (((
|
|
25322
|
+
if (((_z = clause.route) == null ? void 0 : _z.code) === RouteCode["Nasal route"]) {
|
|
25039
25323
|
return `\u0E40\u0E02\u0E49\u0E32${translated}`;
|
|
25040
25324
|
}
|
|
25041
|
-
const spatialRelation = (
|
|
25325
|
+
const spatialRelation = (_A = clause.site) == null ? void 0 : _A.spatialRelation;
|
|
25042
25326
|
const spatialRealization = (spatialRelation == null ? void 0 : spatialRelation.relationText) ? getBodySiteRelationRealization(spatialRelation.relationText, "th") : void 0;
|
|
25043
25327
|
const spatialTargetThai = spatialRelation ? translateSpatialTargetThai(spatialRelation) : void 0;
|
|
25044
25328
|
if (spatialRealization && (spatialRealization.omitOuterSitePreposition || (spatialTargetThai == null ? void 0 : spatialTargetThai.startsWith("\u0E1A\u0E23\u0E34\u0E40\u0E27\u0E13")))) {
|
|
25045
25329
|
return translated;
|
|
25046
25330
|
}
|
|
25047
|
-
const preposition = (
|
|
25331
|
+
const preposition = (_B = grammar.sitePreposition) != null ? _B : "\u0E17\u0E35\u0E48";
|
|
25048
25332
|
if (translated.startsWith(preposition)) {
|
|
25049
25333
|
return translated;
|
|
25050
25334
|
}
|
|
@@ -25088,6 +25372,18 @@ function translateSpatialSiteThai(site, relation) {
|
|
|
25088
25372
|
}
|
|
25089
25373
|
return realization.strategy === "suffix" ? `${target}${realization.surface}` : `${realization.surface}${target}`;
|
|
25090
25374
|
}
|
|
25375
|
+
function appendBodySiteQualifierThai(base, qualifier) {
|
|
25376
|
+
var _a26, _b3, _c2, _d;
|
|
25377
|
+
if (!qualifier) return base;
|
|
25378
|
+
const realization = getBodySiteRelationRealization(qualifier.relation, "th");
|
|
25379
|
+
if (!realization) return base;
|
|
25380
|
+
const relation = realization.surface;
|
|
25381
|
+
if (qualifier.kind === "symptom") {
|
|
25382
|
+
return `${base}${relation}${(_b3 = (_a26 = qualifier.i18n) == null ? void 0 : _a26.th) != null ? _b3 : qualifier.text}`;
|
|
25383
|
+
}
|
|
25384
|
+
const target = (_d = translateSiteThai(qualifier.targetText, (_c2 = qualifier.targetCoding) == null ? void 0 : _c2.code)) != null ? _d : qualifier.targetText;
|
|
25385
|
+
return `${base}${relation}${target}`;
|
|
25386
|
+
}
|
|
25091
25387
|
function translateSiteThai(site, code, spatialRelation) {
|
|
25092
25388
|
if (!site) {
|
|
25093
25389
|
if (code) {
|
|
@@ -25099,25 +25395,28 @@ function translateSiteThai(site, code, spatialRelation) {
|
|
|
25099
25395
|
if (!normalized) {
|
|
25100
25396
|
return site;
|
|
25101
25397
|
}
|
|
25398
|
+
const resolvedPhrase = resolveBodySitePhrase(site);
|
|
25399
|
+
const qualifier = resolvedPhrase == null ? void 0 : resolvedPhrase.features.qualifier;
|
|
25400
|
+
const qualified = (value) => appendBodySiteQualifierThai(value, qualifier);
|
|
25102
25401
|
const spatial = translateSpatialSiteThai(site, spatialRelation);
|
|
25103
25402
|
if (spatial) {
|
|
25104
|
-
return spatial;
|
|
25403
|
+
return qualified(spatial);
|
|
25105
25404
|
}
|
|
25106
25405
|
if (code) {
|
|
25107
25406
|
const translatedByCode = THAI_SITE_CODE_TRANSLATIONS[code];
|
|
25108
25407
|
if (translatedByCode) {
|
|
25109
|
-
return translatedByCode;
|
|
25408
|
+
return qualified(translatedByCode);
|
|
25110
25409
|
}
|
|
25111
25410
|
}
|
|
25112
25411
|
const definitionTranslation = THAI_SITE_DEFINITION_TRANSLATIONS[normalized];
|
|
25113
25412
|
if (definitionTranslation) {
|
|
25114
|
-
return definitionTranslation;
|
|
25413
|
+
return qualified(definitionTranslation);
|
|
25115
25414
|
}
|
|
25116
25415
|
const direct = THAI_SITE_TRANSLATIONS[normalized];
|
|
25117
25416
|
if (direct) {
|
|
25118
|
-
return direct;
|
|
25417
|
+
return qualified(direct);
|
|
25119
25418
|
}
|
|
25120
|
-
return site;
|
|
25419
|
+
return qualified(site);
|
|
25121
25420
|
}
|
|
25122
25421
|
function describeDayOfWeekThai(schedule) {
|
|
25123
25422
|
var _a26;
|
|
@@ -25444,7 +25743,7 @@ function formatLongThai(clause, options) {
|
|
|
25444
25743
|
segments.push(sitePart);
|
|
25445
25744
|
}
|
|
25446
25745
|
const body = segments.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
25447
|
-
const richPrimaryGraphAction = (options == null ? void 0 : options.realizationMode)
|
|
25746
|
+
const richPrimaryGraphAction = (options == null ? void 0 : options.realizationMode) === "roundtrip" ? instructionGraphRoundTripPrimaryAction(clause) : instructionGraphRichPrimaryAction(clause);
|
|
25448
25747
|
const richPrimaryGraphText = richPrimaryGraphAction ? realizeInstructionAction(richPrimaryGraphAction, "th") : void 0;
|
|
25449
25748
|
const richPrimaryHasSite = Boolean(
|
|
25450
25749
|
richPrimaryGraphAction == null ? void 0 : richPrimaryGraphAction.args.some((arg) => arg.role === "site" /* Site */)
|
|
@@ -25568,7 +25867,24 @@ function formatLongThai(clause, options) {
|
|
|
25568
25867
|
roundtripSafe: roundTrip
|
|
25569
25868
|
}) : void 0;
|
|
25570
25869
|
const wholeGraphText = formatPatientInstructionSentence2(wholeGraph);
|
|
25571
|
-
|
|
25870
|
+
const parts = [];
|
|
25871
|
+
const normalizedInstruction2 = (value) => value.toLowerCase().replace(/[\s,;:.()]+/gu, " ").trim();
|
|
25872
|
+
for (const value of [
|
|
25873
|
+
leadingInstructionText,
|
|
25874
|
+
wholeGraphText,
|
|
25875
|
+
directInstruction,
|
|
25876
|
+
graphInstructionText,
|
|
25877
|
+
fallbackPatientInstruction
|
|
25878
|
+
]) {
|
|
25879
|
+
if (!value) continue;
|
|
25880
|
+
const normalized = normalizedInstruction2(value);
|
|
25881
|
+
if (parts.some((existing) => {
|
|
25882
|
+
const candidate = normalizedInstruction2(existing);
|
|
25883
|
+
return candidate === normalized || candidate.includes(normalized) || normalized.includes(candidate);
|
|
25884
|
+
})) continue;
|
|
25885
|
+
parts.push(value);
|
|
25886
|
+
}
|
|
25887
|
+
return parts.join(" ").trim() || `${verb}.`;
|
|
25572
25888
|
}
|
|
25573
25889
|
const hasExplicitMethod = Boolean(((_z = (_y = clause.method) == null ? void 0 : _y.text) == null ? void 0 : _z.trim()) || ((_B = (_A = clause.method) == null ? void 0 : _A.coding) == null ? void 0 : _B.code));
|
|
25574
25890
|
const graphRepresentsDose = !clause.dose || Boolean((_C = clause.instructionGraph) == null ? void 0 : _C.actions.some(
|
|
@@ -28167,6 +28483,38 @@ function separatedIntervalRule() {
|
|
|
28167
28483
|
];
|
|
28168
28484
|
}
|
|
28169
28485
|
const unitToken = context.tokens[start + 2];
|
|
28486
|
+
const explicitLowUnit = unitToken && !context.state.consumed.has(unitToken.index) ? mapIntervalUnit(normalizeTokenLower(unitToken)) : void 0;
|
|
28487
|
+
const explicitRangeConnectorToken = context.tokens[start + 3];
|
|
28488
|
+
const explicitRangeConnector = explicitRangeConnectorToken && !context.state.consumed.has(explicitRangeConnectorToken.index) ? normalizeTokenLower(explicitRangeConnectorToken) : void 0;
|
|
28489
|
+
const explicitHighToken = context.tokens[start + 4];
|
|
28490
|
+
const explicitHighLower = explicitHighToken && !context.state.consumed.has(explicitHighToken.index) ? normalizeTokenLower(explicitHighToken) : void 0;
|
|
28491
|
+
const explicitHighUnitToken = context.tokens[start + 5];
|
|
28492
|
+
const explicitHighUnit = explicitHighUnitToken && !context.state.consumed.has(explicitHighUnitToken.index) ? mapIntervalUnit(normalizeTokenLower(explicitHighUnitToken)) : void 0;
|
|
28493
|
+
if (explicitLowUnit && explicitRangeConnector && RANGE_CONNECTORS.has(explicitRangeConnector) && explicitHighToken && explicitHighLower && explicitHighUnit && explicitHighUnitToken && /^[0-9]+(?:\.[0-9]+)?$/.test(quantityLower) && /^[0-9]+(?:\.[0-9]+)?$/.test(explicitHighLower)) {
|
|
28494
|
+
const normalizedRange = normalizeMixedPeriodRange(
|
|
28495
|
+
parseFloat(quantityLower),
|
|
28496
|
+
explicitLowUnit,
|
|
28497
|
+
parseFloat(explicitHighLower),
|
|
28498
|
+
explicitHighUnit
|
|
28499
|
+
);
|
|
28500
|
+
if (normalizedRange) {
|
|
28501
|
+
return [lexicalSign({
|
|
28502
|
+
type: "schedule-sign",
|
|
28503
|
+
rule: "hpsg.lex.schedule.separatedMixedUnitIntervalRange",
|
|
28504
|
+
tokens: [lead, quantity, unitToken, explicitRangeConnectorToken, explicitHighToken, explicitHighUnitToken],
|
|
28505
|
+
synsem: {
|
|
28506
|
+
head: { schedule: {
|
|
28507
|
+
period: normalizedRange.low,
|
|
28508
|
+
periodMax: normalizedRange.high,
|
|
28509
|
+
periodUnit: normalizedRange.unit
|
|
28510
|
+
} },
|
|
28511
|
+
valence: {},
|
|
28512
|
+
cont: { clauseKind: "administration" }
|
|
28513
|
+
},
|
|
28514
|
+
score: 14
|
|
28515
|
+
})];
|
|
28516
|
+
}
|
|
28517
|
+
}
|
|
28170
28518
|
const rangeConnector = unitToken && !context.state.consumed.has(unitToken.index) ? normalizeTokenLower(unitToken) : void 0;
|
|
28171
28519
|
const highToken = context.tokens[start + 3];
|
|
28172
28520
|
const highLower = highToken && !context.state.consumed.has(highToken.index) ? normalizeTokenLower(highToken) : void 0;
|
|
@@ -30980,6 +31328,21 @@ function hasSystemicCueBeforeSiteAbbreviation(context, start) {
|
|
|
30980
31328
|
}
|
|
30981
31329
|
return sawNonOcularDose;
|
|
30982
31330
|
}
|
|
31331
|
+
function anchorTargetsTypedNonSiteConcept(context, start) {
|
|
31332
|
+
var _a26;
|
|
31333
|
+
const current = (_a26 = tokensAvailable(context, start, 1)) == null ? void 0 : _a26[0];
|
|
31334
|
+
if (!current || !resolveActionRelationSurface(normalizeTokenLower(current))) return false;
|
|
31335
|
+
for (let cursor = start + 1; cursor < Math.min(context.limit, start + 4); cursor += 1) {
|
|
31336
|
+
const candidate = context.tokens[cursor];
|
|
31337
|
+
if (!candidate || context.state.consumed.has(candidate.index)) break;
|
|
31338
|
+
const lower = normalizeTokenLower(candidate);
|
|
31339
|
+
if (isPunctuation(lower)) break;
|
|
31340
|
+
const concept = resolveMedicationInstructionConcept(lower, context.options);
|
|
31341
|
+
if (!concept) continue;
|
|
31342
|
+
return concept.role !== "site" /* Site */ && concept.role !== "destination" /* Destination */;
|
|
31343
|
+
}
|
|
31344
|
+
return false;
|
|
31345
|
+
}
|
|
30983
31346
|
function contextSuggestsNonOcularSite(context) {
|
|
30984
31347
|
var _a26, _b3, _c2, _d, _e, _f;
|
|
30985
31348
|
const dosageForm = (_c2 = (_b3 = (_a26 = context.options) == null ? void 0 : _a26.context) == null ? void 0 : _b3.dosageForm) == null ? void 0 : _c2.trim().toLowerCase().replace(/\s+/g, " ");
|
|
@@ -30998,7 +31361,7 @@ function siteLexicalRule() {
|
|
|
30998
31361
|
}
|
|
30999
31362
|
const signs = [];
|
|
31000
31363
|
const lower = normalizeTokenLower(token);
|
|
31001
|
-
if (tokenBelongsToContextualPrnReasonLead(context, start)) {
|
|
31364
|
+
if (tokenBelongsToContextualPrnReasonLead(context, start) || anchorTargetsTypedNonSiteConcept(context, start)) {
|
|
31002
31365
|
return signs;
|
|
31003
31366
|
}
|
|
31004
31367
|
const siteCandidate = getPrimarySiteMeaningCandidate(token);
|
|
@@ -31041,7 +31404,7 @@ function siteLexicalRule() {
|
|
|
31041
31404
|
if (candidate.kind === "NUMBER" /* Number */) {
|
|
31042
31405
|
break;
|
|
31043
31406
|
}
|
|
31044
|
-
if (getDayOfWeekMeaning(candidate)) {
|
|
31407
|
+
if (getDayOfWeekMeaning(candidate) || ACTION_SEQUENCE_MARKERS.has(candidateLower)) {
|
|
31045
31408
|
break;
|
|
31046
31409
|
}
|
|
31047
31410
|
if (coordinationStartsAction(context, cursor)) break;
|