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.cjs
CHANGED
|
@@ -1919,7 +1919,8 @@ var instruction_action_terminology_default = {
|
|
|
1919
1919
|
},
|
|
1920
1920
|
aliases: [
|
|
1921
1921
|
"drink",
|
|
1922
|
-
"\u0E14\u0E37\u0E48\u0E21"
|
|
1922
|
+
"\u0E14\u0E37\u0E48\u0E21",
|
|
1923
|
+
"drinking"
|
|
1923
1924
|
],
|
|
1924
1925
|
procedural: false,
|
|
1925
1926
|
acceptsAmount: true,
|
|
@@ -3548,6 +3549,21 @@ var instruction_concept_terminology_default = {
|
|
|
3548
3549
|
"sleep",
|
|
3549
3550
|
"\u0E19\u0E2D\u0E19"
|
|
3550
3551
|
]
|
|
3552
|
+
},
|
|
3553
|
+
{
|
|
3554
|
+
code: "dissolved",
|
|
3555
|
+
role: "result",
|
|
3556
|
+
display: "dissolved",
|
|
3557
|
+
i18n: {
|
|
3558
|
+
th: "\u0E25\u0E30\u0E25\u0E32\u0E22\u0E2B\u0E21\u0E14"
|
|
3559
|
+
},
|
|
3560
|
+
aliases: [
|
|
3561
|
+
"dissolved",
|
|
3562
|
+
"fully dissolved",
|
|
3563
|
+
"completely dissolved",
|
|
3564
|
+
"\u0E25\u0E30\u0E25\u0E32\u0E22\u0E2B\u0E21\u0E14",
|
|
3565
|
+
"\u0E25\u0E30\u0E25\u0E32\u0E22\u0E08\u0E19\u0E2B\u0E21\u0E14"
|
|
3566
|
+
]
|
|
3551
3567
|
}
|
|
3552
3568
|
]
|
|
3553
3569
|
};
|
|
@@ -4116,7 +4132,10 @@ var symptom_terminology_default = {
|
|
|
4116
4132
|
"pain",
|
|
4117
4133
|
"ache",
|
|
4118
4134
|
"aches",
|
|
4119
|
-
"pains"
|
|
4135
|
+
"pains",
|
|
4136
|
+
"painful",
|
|
4137
|
+
"hurt",
|
|
4138
|
+
"hurts"
|
|
4120
4139
|
],
|
|
4121
4140
|
definition: {
|
|
4122
4141
|
coding: {
|
|
@@ -4131,6 +4150,10 @@ var symptom_terminology_default = {
|
|
|
4131
4150
|
],
|
|
4132
4151
|
i18n: {
|
|
4133
4152
|
th: "\u0E1B\u0E27\u0E14"
|
|
4153
|
+
},
|
|
4154
|
+
conditionI18n: {
|
|
4155
|
+
en: "painful",
|
|
4156
|
+
th: "\u0E1B\u0E27\u0E14"
|
|
4134
4157
|
}
|
|
4135
4158
|
}
|
|
4136
4159
|
},
|
|
@@ -7135,7 +7158,11 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
7135
7158
|
},
|
|
7136
7159
|
{
|
|
7137
7160
|
names: ["tongue", "tongues"],
|
|
7138
|
-
definition: {
|
|
7161
|
+
definition: {
|
|
7162
|
+
coding: { code: "21974007", display: "Tongue" },
|
|
7163
|
+
i18n: { th: "\u0E25\u0E34\u0E49\u0E19" },
|
|
7164
|
+
routeHint: RouteCode["Sublingual route"]
|
|
7165
|
+
}
|
|
7139
7166
|
},
|
|
7140
7167
|
{
|
|
7141
7168
|
names: ["lip", "lips"],
|
|
@@ -9884,7 +9911,8 @@ var relation_terminology_default = {
|
|
|
9884
9911
|
{
|
|
9885
9912
|
canonical: "outside",
|
|
9886
9913
|
aliases: [
|
|
9887
|
-
"outside"
|
|
9914
|
+
"outside",
|
|
9915
|
+
"outside of"
|
|
9888
9916
|
],
|
|
9889
9917
|
locative: true,
|
|
9890
9918
|
realization: {
|
|
@@ -10159,6 +10187,46 @@ var relation_terminology_default = {
|
|
|
10159
10187
|
strategy: "prefix"
|
|
10160
10188
|
}
|
|
10161
10189
|
}
|
|
10190
|
+
},
|
|
10191
|
+
{
|
|
10192
|
+
canonical: "at",
|
|
10193
|
+
aliases: [
|
|
10194
|
+
"at"
|
|
10195
|
+
],
|
|
10196
|
+
realization: {
|
|
10197
|
+
en: {
|
|
10198
|
+
surface: "at",
|
|
10199
|
+
strategy: "prefix"
|
|
10200
|
+
},
|
|
10201
|
+
th: {
|
|
10202
|
+
surface: "\u0E15\u0E23\u0E07",
|
|
10203
|
+
strategy: "prefix",
|
|
10204
|
+
omitOuterSitePreposition: true
|
|
10205
|
+
}
|
|
10206
|
+
},
|
|
10207
|
+
grammar: {
|
|
10208
|
+
qualifierTarget: "site"
|
|
10209
|
+
}
|
|
10210
|
+
},
|
|
10211
|
+
{
|
|
10212
|
+
canonical: "where",
|
|
10213
|
+
aliases: [
|
|
10214
|
+
"where"
|
|
10215
|
+
],
|
|
10216
|
+
realization: {
|
|
10217
|
+
en: {
|
|
10218
|
+
surface: "where",
|
|
10219
|
+
strategy: "prefix"
|
|
10220
|
+
},
|
|
10221
|
+
th: {
|
|
10222
|
+
surface: "\u0E17\u0E35\u0E48",
|
|
10223
|
+
strategy: "prefix",
|
|
10224
|
+
omitOuterSitePreposition: true
|
|
10225
|
+
}
|
|
10226
|
+
},
|
|
10227
|
+
grammar: {
|
|
10228
|
+
qualifierTarget: "symptom"
|
|
10229
|
+
}
|
|
10162
10230
|
}
|
|
10163
10231
|
]
|
|
10164
10232
|
};
|
|
@@ -12640,6 +12708,7 @@ function matchBodySiteLocativeRelation(words, start = 0) {
|
|
|
12640
12708
|
return relation ? { relation, length: 1 } : void 0;
|
|
12641
12709
|
}
|
|
12642
12710
|
function parseBodySiteFeatures(text, coding, customSiteMap) {
|
|
12711
|
+
var _a26;
|
|
12643
12712
|
const normalized = normalizeBodySiteKey(text);
|
|
12644
12713
|
if (!normalized) {
|
|
12645
12714
|
return buildNominalFeatures(text, normalized, coding, customSiteMap);
|
|
@@ -12688,30 +12757,49 @@ function parseBodySiteFeatures(text, coding, customSiteMap) {
|
|
|
12688
12757
|
whole: buildNominalFeatures(wholeText, normalizeBodySiteKey(wholeText), void 0, customSiteMap)
|
|
12689
12758
|
};
|
|
12690
12759
|
}
|
|
12760
|
+
if (words.length > 1 && (firstWord === "left" || firstWord === "right") && !lookupDefinitionForCanonical(normalized, customSiteMap)) {
|
|
12761
|
+
const wholeText = words.slice(1).join(" ");
|
|
12762
|
+
const wholeCanonical = normalizeBodySiteKey(wholeText);
|
|
12763
|
+
const wholeDefinition = lookupDefinitionForCanonical(wholeCanonical, customSiteMap);
|
|
12764
|
+
if (((_a26 = wholeDefinition == null ? void 0 : wholeDefinition.coding) == null ? void 0 : _a26.code) || (wholeDefinition == null ? void 0 : wholeDefinition.routeHint)) {
|
|
12765
|
+
return {
|
|
12766
|
+
kind: "partitive",
|
|
12767
|
+
part: `${firstWord} side`,
|
|
12768
|
+
relationKey: "side",
|
|
12769
|
+
whole: buildNominalFeatures(wholeText, wholeCanonical, void 0, customSiteMap),
|
|
12770
|
+
attributive: true
|
|
12771
|
+
};
|
|
12772
|
+
}
|
|
12773
|
+
}
|
|
12691
12774
|
return buildNominalFeatures(text, normalized, coding, customSiteMap);
|
|
12692
12775
|
}
|
|
12693
12776
|
function renderNominalObject(features) {
|
|
12694
12777
|
return features.article === "bare" ? features.text : `the ${features.text}`;
|
|
12695
12778
|
}
|
|
12696
12779
|
function renderBodySiteObject(features) {
|
|
12697
|
-
var _a26, _b3;
|
|
12780
|
+
var _a26, _b3, _c2;
|
|
12698
12781
|
switch (features.kind) {
|
|
12699
12782
|
case "locative": {
|
|
12700
12783
|
const surface = (_b3 = (_a26 = getBodySiteRelationRealization(features.relation, "en")) == null ? void 0 : _a26.surface) != null ? _b3 : features.relation;
|
|
12701
12784
|
return `${surface} ${renderBodySiteObject(features.target)}`;
|
|
12702
12785
|
}
|
|
12703
12786
|
case "partitive":
|
|
12787
|
+
if (features.attributive) {
|
|
12788
|
+
const side = (_c2 = features.part.split(/\s+/u)[0]) != null ? _c2 : features.part;
|
|
12789
|
+
return features.whole.article === "bare" ? `${side} ${features.whole.text}` : `the ${side} ${features.whole.text}`;
|
|
12790
|
+
}
|
|
12704
12791
|
return `${features.part.startsWith("both") || features.part.startsWith("bilateral") ? features.part : `the ${features.part}`} of ${renderNominalObject(features.whole)}`;
|
|
12705
12792
|
case "nominal":
|
|
12706
12793
|
return renderNominalObject(features);
|
|
12707
12794
|
}
|
|
12708
12795
|
}
|
|
12709
12796
|
function featureDisplayText(features) {
|
|
12797
|
+
var _a26;
|
|
12710
12798
|
switch (features.kind) {
|
|
12711
12799
|
case "locative":
|
|
12712
12800
|
return `${features.relation} ${featureDisplayText(features.target)}`;
|
|
12713
12801
|
case "partitive":
|
|
12714
|
-
return `${features.part} of ${features.whole.text}`;
|
|
12802
|
+
return features.attributive ? `${(_a26 = features.part.split(/\s+/u)[0]) != null ? _a26 : features.part} ${features.whole.text}` : `${features.part} of ${features.whole.text}`;
|
|
12715
12803
|
case "nominal":
|
|
12716
12804
|
return features.text;
|
|
12717
12805
|
}
|
|
@@ -12786,6 +12874,103 @@ function inferPreferredPreposition(canonical, features, definition) {
|
|
|
12786
12874
|
}
|
|
12787
12875
|
return void 0;
|
|
12788
12876
|
}
|
|
12877
|
+
function withBodySiteQualifier(features, qualifier) {
|
|
12878
|
+
return __spreadProps(__spreadValues({}, features), { qualifier });
|
|
12879
|
+
}
|
|
12880
|
+
var BODY_SITE_QUALIFIER_MATCHERS = (() => {
|
|
12881
|
+
var _a26, _b3;
|
|
12882
|
+
const matchers = [];
|
|
12883
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12884
|
+
for (const definition of listBodySiteRelationDefinitions()) {
|
|
12885
|
+
const target = definition.grammar.qualifierTarget;
|
|
12886
|
+
if (!target) continue;
|
|
12887
|
+
const surfaces = [
|
|
12888
|
+
definition.canonical,
|
|
12889
|
+
...definition.aliases,
|
|
12890
|
+
(_a26 = definition.realization.en) == null ? void 0 : _a26.surface,
|
|
12891
|
+
(_b3 = definition.realization.th) == null ? void 0 : _b3.surface
|
|
12892
|
+
];
|
|
12893
|
+
for (const surface of surfaces) {
|
|
12894
|
+
const normalizedSurface = surface ? normalizeBodySiteKey(surface) : "";
|
|
12895
|
+
if (!normalizedSurface) continue;
|
|
12896
|
+
const key2 = `${definition.canonical}|${target}|${normalizedSurface}`;
|
|
12897
|
+
if (seen.has(key2)) continue;
|
|
12898
|
+
seen.add(key2);
|
|
12899
|
+
matchers.push({
|
|
12900
|
+
relation: definition.canonical,
|
|
12901
|
+
target,
|
|
12902
|
+
marker: ` ${normalizedSurface} `
|
|
12903
|
+
});
|
|
12904
|
+
}
|
|
12905
|
+
}
|
|
12906
|
+
return matchers.sort((left, right) => right.marker.length - left.marker.length);
|
|
12907
|
+
})();
|
|
12908
|
+
function matchBodySiteQualifier(lookupCanonical) {
|
|
12909
|
+
let best;
|
|
12910
|
+
for (const matcher of BODY_SITE_QUALIFIER_MATCHERS) {
|
|
12911
|
+
const index = lookupCanonical.lastIndexOf(matcher.marker);
|
|
12912
|
+
if (index <= 0 || index + matcher.marker.length >= lookupCanonical.length) continue;
|
|
12913
|
+
const candidate = {
|
|
12914
|
+
relation: matcher.relation,
|
|
12915
|
+
target: matcher.target,
|
|
12916
|
+
start: index,
|
|
12917
|
+
end: index + matcher.marker.length
|
|
12918
|
+
};
|
|
12919
|
+
if (!best || candidate.start > best.start || candidate.start === best.start && candidate.end > best.end) best = candidate;
|
|
12920
|
+
}
|
|
12921
|
+
return best;
|
|
12922
|
+
}
|
|
12923
|
+
function qualifiedBodySitePhrase(lookupCanonical, customSiteMap, context) {
|
|
12924
|
+
var _a26, _b3, _c2, _d, _e, _f, _g, _h;
|
|
12925
|
+
const match = matchBodySiteQualifier(lookupCanonical);
|
|
12926
|
+
if (!match) return void 0;
|
|
12927
|
+
const base = resolveBodySitePhrase(lookupCanonical.slice(0, match.start), customSiteMap, context);
|
|
12928
|
+
if (!base) return void 0;
|
|
12929
|
+
const targetText = lookupCanonical.slice(match.end);
|
|
12930
|
+
const realization = getBodySiteRelationRealization(match.relation, "en");
|
|
12931
|
+
if (!realization) return void 0;
|
|
12932
|
+
if (match.target === "symptom") {
|
|
12933
|
+
const symptom = resolveSymptomDefinition(targetText);
|
|
12934
|
+
if (!symptom) return void 0;
|
|
12935
|
+
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;
|
|
12936
|
+
const qualifier2 = {
|
|
12937
|
+
kind: "symptom",
|
|
12938
|
+
relation: match.relation,
|
|
12939
|
+
text: targetText,
|
|
12940
|
+
canonical: (_f = (_e = symptom.text) == null ? void 0 : _e.toLowerCase()) != null ? _f : targetText,
|
|
12941
|
+
coding: symptom.coding ? __spreadValues({}, symptom.coding) : void 0,
|
|
12942
|
+
i18n: __spreadValues(__spreadValues({ en: conditionText }, (_g = symptom.i18n) != null ? _g : {}), (_h = symptom.conditionI18n) != null ? _h : {})
|
|
12943
|
+
};
|
|
12944
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
12945
|
+
lookupCanonical,
|
|
12946
|
+
resolutionCanonical: `${base.resolutionCanonical} ${match.relation} ${qualifier2.canonical}`,
|
|
12947
|
+
canonical: `${base.canonical} ${match.relation} ${qualifier2.canonical}`,
|
|
12948
|
+
displayText: `${base.displayText} ${realization.surface} ${conditionText}`,
|
|
12949
|
+
features: withBodySiteQualifier(base.features, qualifier2),
|
|
12950
|
+
englishObjectText: `${base.englishObjectText} ${realization.surface} ${conditionText}`
|
|
12951
|
+
});
|
|
12952
|
+
}
|
|
12953
|
+
const target = resolveBodySitePhrase(targetText, customSiteMap, context);
|
|
12954
|
+
if (!target) return void 0;
|
|
12955
|
+
if (base.resolutionCanonical === target.resolutionCanonical) return base;
|
|
12956
|
+
if (!(base.coding || base.definition || base.spatialRelation)) return void 0;
|
|
12957
|
+
if (!(target.coding || target.definition || target.spatialRelation)) return void 0;
|
|
12958
|
+
const qualifier = {
|
|
12959
|
+
kind: "site",
|
|
12960
|
+
relation: match.relation,
|
|
12961
|
+
text: target.displayText,
|
|
12962
|
+
targetText: target.displayText,
|
|
12963
|
+
targetCoding: target.coding ? __spreadValues({}, target.coding) : void 0
|
|
12964
|
+
};
|
|
12965
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
12966
|
+
lookupCanonical,
|
|
12967
|
+
resolutionCanonical: `${base.resolutionCanonical} ${match.relation} ${target.resolutionCanonical}`,
|
|
12968
|
+
canonical: `${base.canonical} ${match.relation} ${target.canonical}`,
|
|
12969
|
+
displayText: `${base.displayText} ${realization.surface} ${target.displayText}`,
|
|
12970
|
+
features: withBodySiteQualifier(base.features, qualifier),
|
|
12971
|
+
englishObjectText: `${base.englishObjectText} ${realization.surface} ${target.englishObjectText}`
|
|
12972
|
+
});
|
|
12973
|
+
}
|
|
12789
12974
|
function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
12790
12975
|
var _a26, _b3, _c2, _d, _e, _f, _g, _h;
|
|
12791
12976
|
const trimmed = text.trim().replace(/\s+/g, " ");
|
|
@@ -12793,6 +12978,8 @@ function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
|
12793
12978
|
return void 0;
|
|
12794
12979
|
}
|
|
12795
12980
|
const lookupCanonical = normalizeBodySiteKey(trimmed);
|
|
12981
|
+
const qualified = qualifiedBodySitePhrase(lookupCanonical, customSiteMap, context);
|
|
12982
|
+
if (qualified) return qualified;
|
|
12796
12983
|
const contextualCanonical = resolveContextualBodySiteAlias(lookupCanonical, context);
|
|
12797
12984
|
const displaySourceText = contextualCanonical != null ? contextualCanonical : trimmed;
|
|
12798
12985
|
const displayText = normalizeSiteDisplayText(displaySourceText, customSiteMap);
|
|
@@ -12800,9 +12987,17 @@ function resolveBodySitePhrase(text, customSiteMap, context) {
|
|
|
12800
12987
|
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];
|
|
12801
12988
|
const preliminaryFeatures = parseBodySiteFeatures(displayText, void 0, customSiteMap);
|
|
12802
12989
|
const terminal = directDefinition || !(context == null ? void 0 : context.allowTerminalModifierInheritance) || preliminaryFeatures.kind !== "nominal" || !terminalInheritanceIsLicensed(canonical) ? void 0 : longestTerminalBodySiteDefinition(canonical, customSiteMap);
|
|
12803
|
-
const
|
|
12804
|
-
const coding = buildBodySiteCoding(definition);
|
|
12990
|
+
const baseDefinition = directDefinition != null ? directDefinition : terminal == null ? void 0 : terminal.definition;
|
|
12805
12991
|
const finalDisplayText = (_f = directDefinition == null ? void 0 : directDefinition.text) != null ? _f : displayText;
|
|
12992
|
+
let inheritedDefinition;
|
|
12993
|
+
if (!baseDefinition) {
|
|
12994
|
+
const candidateFeatures = parseBodySiteFeatures(finalDisplayText, void 0, customSiteMap);
|
|
12995
|
+
if (candidateFeatures.kind === "partitive" && candidateFeatures.attributive) {
|
|
12996
|
+
inheritedDefinition = lookupDefinitionForCanonical(candidateFeatures.whole.canonical, customSiteMap);
|
|
12997
|
+
}
|
|
12998
|
+
}
|
|
12999
|
+
const definition = baseDefinition != null ? baseDefinition : inheritedDefinition;
|
|
13000
|
+
const coding = buildBodySiteCoding(definition);
|
|
12806
13001
|
const features = parseBodySiteFeatures(finalDisplayText, coding, customSiteMap);
|
|
12807
13002
|
const spatialRelation = (_g = definition == null ? void 0 : definition.spatialRelation) != null ? _g : buildSpatialRelation(features, finalDisplayText, customSiteMap);
|
|
12808
13003
|
return {
|
|
@@ -15971,6 +16166,28 @@ function normalizePeriodRange(low, high, unit) {
|
|
|
15971
16166
|
}
|
|
15972
16167
|
return { low, high, unit };
|
|
15973
16168
|
}
|
|
16169
|
+
var FIXED_PERIOD_SECONDS = {
|
|
16170
|
+
["s" /* Second */]: 1,
|
|
16171
|
+
["min" /* Minute */]: 60,
|
|
16172
|
+
["h" /* Hour */]: 60 * 60,
|
|
16173
|
+
["d" /* Day */]: 24 * 60 * 60,
|
|
16174
|
+
["wk" /* Week */]: 7 * 24 * 60 * 60
|
|
16175
|
+
};
|
|
16176
|
+
function normalizeMixedPeriodRange(low, lowUnit, high, highUnit) {
|
|
16177
|
+
if (lowUnit === highUnit) {
|
|
16178
|
+
const normalized = normalizePeriodRange(low, high, lowUnit);
|
|
16179
|
+
return normalized.low <= normalized.high ? normalized : void 0;
|
|
16180
|
+
}
|
|
16181
|
+
const lowScale = FIXED_PERIOD_SECONDS[lowUnit];
|
|
16182
|
+
const highScale = FIXED_PERIOD_SECONDS[highUnit];
|
|
16183
|
+
if (!lowScale || !highScale) return void 0;
|
|
16184
|
+
const unit = lowScale <= highScale ? lowUnit : highUnit;
|
|
16185
|
+
const unitScale = FIXED_PERIOD_SECONDS[unit];
|
|
16186
|
+
const normalizedLow = Math.round(low * lowScale / unitScale * 1e3) / 1e3;
|
|
16187
|
+
const normalizedHigh = Math.round(high * highScale / unitScale * 1e3) / 1e3;
|
|
16188
|
+
if (normalizedLow > normalizedHigh) return void 0;
|
|
16189
|
+
return { low: normalizedLow, high: normalizedHigh, unit };
|
|
16190
|
+
}
|
|
15974
16191
|
function periodUnitSuffix(unit) {
|
|
15975
16192
|
switch (unit) {
|
|
15976
16193
|
case "min" /* Minute */:
|
|
@@ -16933,6 +17150,9 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16933
17150
|
const conditionalTail = relationHasGrammarFeature(rawRelation, "conditionalTail");
|
|
16934
17151
|
const secondaryConditionalTail = relationHasGrammarFeature(nextRelation, "conditionalTail");
|
|
16935
17152
|
const relation = conditionalTail ? void 0 : rawRelation;
|
|
17153
|
+
const secondaryActivityTarget = nextRelationIndex >= 0 ? resolveMedicationInstructionAction(key(parts[nextRelationIndex + 1]), options) : void 0;
|
|
17154
|
+
const secondaryActivityRelation = nextRelationIndex >= 0 && secondaryActivityTarget && relationHasGrammarFeature(nextRelation, "activityFallback") ? nextRelation : void 0;
|
|
17155
|
+
const frameRelation = secondaryActivityRelation != null ? secondaryActivityRelation : relation;
|
|
16936
17156
|
const amount = definition.acceptsAmount ? parseQuantityArgument(parts, argumentStart, segmentEnd, input, offset, options) : void 0;
|
|
16937
17157
|
const duration = parseAnyDurationArgument(parts, argumentStart, segmentEnd, input, offset);
|
|
16938
17158
|
let semanticEnd = conditionalTail && relIndex >= 0 ? relIndex : secondaryConditionalTail && nextRelationIndex >= 0 ? nextRelationIndex : segmentEnd;
|
|
@@ -16955,6 +17175,16 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16955
17175
|
separableParticleIndex: actionMatch.separableParticleIndex
|
|
16956
17176
|
});
|
|
16957
17177
|
const args = parsed.args;
|
|
17178
|
+
if (secondaryActivityRelation && nextRelationIndex >= 0) {
|
|
17179
|
+
pushArgument(args, argumentFromParts(
|
|
17180
|
+
parts,
|
|
17181
|
+
nextRelationIndex + 1,
|
|
17182
|
+
segmentEnd,
|
|
17183
|
+
input,
|
|
17184
|
+
"activity" /* Activity */,
|
|
17185
|
+
options
|
|
17186
|
+
));
|
|
17187
|
+
}
|
|
16958
17188
|
if (definition.argumentParser === "preposed-duration" && !args.some((arg) => arg.role === "duration" /* Duration */)) {
|
|
16959
17189
|
return void 0;
|
|
16960
17190
|
}
|
|
@@ -16985,7 +17215,7 @@ function buildActionFrame(parts, segmentStart, segmentEnd, input, offset, sequen
|
|
|
16985
17215
|
}) : void 0,
|
|
16986
17216
|
codings
|
|
16987
17217
|
},
|
|
16988
|
-
relation,
|
|
17218
|
+
relation: frameRelation,
|
|
16989
17219
|
args,
|
|
16990
17220
|
span,
|
|
16991
17221
|
sourceText: input.slice(span.start - offset, span.end - offset),
|
|
@@ -17161,6 +17391,10 @@ function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
|
17161
17391
|
end = ACTION_COORDINATION_CONNECTORS.has(previousKey) ? index - 1 : index;
|
|
17162
17392
|
break;
|
|
17163
17393
|
}
|
|
17394
|
+
if (/^[,;:]$/u.test(currentKey) && INSTRUCTION_START_WORDS.has(key(parts[index + 1]))) {
|
|
17395
|
+
end = index;
|
|
17396
|
+
break;
|
|
17397
|
+
}
|
|
17164
17398
|
if (ACTION_DIRECTIVE_BOUNDARIES.has(currentKey) && !prefixedActionAt(parts, index, options) && !resultativeLeadAt(parts, index, options)) {
|
|
17165
17399
|
end = index;
|
|
17166
17400
|
break;
|
|
@@ -17699,15 +17933,26 @@ function promoteDoseFromDefiningAction(clause, actions, options) {
|
|
|
17699
17933
|
}
|
|
17700
17934
|
function canonicalPrimaryAdministrationSpan(clause, frames) {
|
|
17701
17935
|
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];
|
|
17702
|
-
if (semantic)
|
|
17703
|
-
|
|
17936
|
+
if (semantic) {
|
|
17937
|
+
let best;
|
|
17938
|
+
for (const evidence of clause.evidence) {
|
|
17939
|
+
if (evidence.rule !== "hpsg.lex.method") continue;
|
|
17940
|
+
for (const span of evidence.spans) {
|
|
17941
|
+
if (span.start < semantic.span.start || semantic.span.end < span.end) continue;
|
|
17942
|
+
const candidate = { start: span.start, end: span.end };
|
|
17943
|
+
if (!best || candidate.end - candidate.start < best.end - best.start || candidate.end - candidate.start === best.end - best.start && candidate.start < best.start) {
|
|
17944
|
+
best = candidate;
|
|
17945
|
+
}
|
|
17946
|
+
}
|
|
17947
|
+
}
|
|
17948
|
+
return best != null ? best : { start: semantic.span.start, end: semantic.span.end };
|
|
17949
|
+
}
|
|
17704
17950
|
for (const evidence of clause.evidence) {
|
|
17705
17951
|
if (evidence.rule !== "hpsg.lex.method") continue;
|
|
17706
|
-
|
|
17952
|
+
const span = evidence.spans[0];
|
|
17953
|
+
if (span) return { start: span.start, end: span.end };
|
|
17707
17954
|
}
|
|
17708
|
-
|
|
17709
|
-
spans.sort((left, right) => left.start - right.start || left.end - right.end);
|
|
17710
|
-
return spans[0];
|
|
17955
|
+
return void 0;
|
|
17711
17956
|
}
|
|
17712
17957
|
function buildInstructionGraph(input, clause, options) {
|
|
17713
17958
|
const actions = [];
|
|
@@ -17855,7 +18100,7 @@ function actionLabel(frame, locale, roundtripSafe = false) {
|
|
|
17855
18100
|
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;
|
|
17856
18101
|
}
|
|
17857
18102
|
var DEFAULT_ACTION_REALIZER = (c) => {
|
|
17858
|
-
var _a26, _b3, _c2, _d;
|
|
18103
|
+
var _a26, _b3, _c2, _d, _e;
|
|
17859
18104
|
const objectArgs = c.frame.args.filter(
|
|
17860
18105
|
(arg) => arg.role === "theme" /* Theme */ || arg.role === "object" /* Object */ || arg.role === "site" /* Site */ || arg.role === "substance" /* Substance */
|
|
17861
18106
|
);
|
|
@@ -17868,7 +18113,9 @@ var DEFAULT_ACTION_REALIZER = (c) => {
|
|
|
17868
18113
|
const relationTargetArg = objectArgs.length > 1 ? objectArgs[1] : void 0;
|
|
17869
18114
|
const relationTarget = relationTargetArg ? translatedArgument(relationTargetArg, c.locale) : void 0;
|
|
17870
18115
|
const withTarget = relationHasGrammarFeature(c.frame.relation, "accompanimentComplement") ? relationTarget : void 0;
|
|
17871
|
-
|
|
18116
|
+
const activityRelation = c.activity && relationHasGrammarFeature(c.frame.relation, "activityFallback") ? (_e = localizeAdviceRelation(c.frame.relation, c.locale)) != null ? _e : c.frame.relation : void 0;
|
|
18117
|
+
const activitySuffix = activityRelation && c.activity ? c.thai ? `${activityRelation}${c.activity}` : ` ${activityRelation} ${c.activity}` : "";
|
|
18118
|
+
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}`;
|
|
17872
18119
|
};
|
|
17873
18120
|
var SOURCE_FAITHFUL_REALIZER = (c) => {
|
|
17874
18121
|
const sourceIsThai = /[\u0E00-\u0E7F]/.test(c.frame.sourceText);
|
|
@@ -17999,13 +18246,17 @@ var LEAVE_DURATION_REALIZER = (c) => {
|
|
|
17999
18246
|
};
|
|
18000
18247
|
var DURATION_REALIZER = (c) => c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""}` : `${c.label}${c.duration ? ` for ${c.duration}` : ""}`;
|
|
18001
18248
|
var DURATION_ACTIVITY_REALIZER = (c) => {
|
|
18002
|
-
var _a26;
|
|
18003
|
-
|
|
18004
|
-
if (
|
|
18005
|
-
|
|
18006
|
-
|
|
18249
|
+
var _a26, _b3;
|
|
18250
|
+
const target = (_a26 = c.activity) != null ? _a26 : c.result;
|
|
18251
|
+
if (!target) return `${c.label}${c.duration ? ` ${c.duration}` : ""}`;
|
|
18252
|
+
if (c.frame.relation) {
|
|
18253
|
+
const relation = (_b3 = localizeAdviceRelation(c.frame.relation, c.locale)) != null ? _b3 : c.frame.relation;
|
|
18254
|
+
if (relationHasSemanticClass(c.frame.relation, "interval")) {
|
|
18255
|
+
return c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation}${target}` : `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation} ${target}`;
|
|
18256
|
+
}
|
|
18257
|
+
return c.thai ? `${c.label}${c.duration ? ` ${c.duration}` : ""}${relation}${target}` : `${c.label}${c.duration ? ` ${c.duration}` : ""} ${relation} ${target}`;
|
|
18007
18258
|
}
|
|
18008
|
-
return `${c.label}${c.duration ? ` ${c.duration}` : ""} ${
|
|
18259
|
+
return `${c.label}${c.duration ? ` ${c.duration}` : ""} ${target}`;
|
|
18009
18260
|
};
|
|
18010
18261
|
var ACTIVITY_REALIZER = (c) => {
|
|
18011
18262
|
var _a26, _b3, _c2;
|
|
@@ -18397,6 +18648,28 @@ function instructionGraphRichPrimaryAction(clause) {
|
|
|
18397
18648
|
return (rich || suppliesMissingHead) && (!dose || matchesDose(action));
|
|
18398
18649
|
});
|
|
18399
18650
|
}
|
|
18651
|
+
function instructionGraphRoundTripPrimaryAction(clause) {
|
|
18652
|
+
const graph = clause.instructionGraph;
|
|
18653
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
18654
|
+
if (!graph || !primary) return void 0;
|
|
18655
|
+
return graph.actions.find((action) => {
|
|
18656
|
+
if (action.span.end <= primary.start || action.span.start >= primary.end) return false;
|
|
18657
|
+
const hasLocalRelation = relationHasGrammarFeature(action.relation, "roundtripRichRelation");
|
|
18658
|
+
const hasRichArgument = action.args.some(
|
|
18659
|
+
(arg) => [
|
|
18660
|
+
"time" /* Time */,
|
|
18661
|
+
"duration" /* Duration */,
|
|
18662
|
+
"material" /* Material */,
|
|
18663
|
+
"activity" /* Activity */,
|
|
18664
|
+
"result" /* Result */,
|
|
18665
|
+
"destination" /* Destination */,
|
|
18666
|
+
"substance" /* Substance */,
|
|
18667
|
+
"manner" /* Manner */
|
|
18668
|
+
].indexOf(arg.role) >= 0 || (arg.role === "object" /* Object */ || arg.role === "theme" /* Theme */) && /\b(?:new|replacement|another|fresh)\b/i.test(arg.text)
|
|
18669
|
+
);
|
|
18670
|
+
return hasLocalRelation || hasRichArgument;
|
|
18671
|
+
});
|
|
18672
|
+
}
|
|
18400
18673
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
18401
18674
|
var _a26;
|
|
18402
18675
|
const graph = clause.instructionGraph;
|
|
@@ -19528,7 +19801,7 @@ function applyEnglishAdministrationModality(verb, clause) {
|
|
|
19528
19801
|
return `${prefix} ${verb.charAt(0).toLowerCase()}${verb.slice(1)}`;
|
|
19529
19802
|
}
|
|
19530
19803
|
function formatLong(clause, options) {
|
|
19531
|
-
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
|
|
19804
|
+
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;
|
|
19532
19805
|
const schedule = scheduleOf(clause);
|
|
19533
19806
|
const grammar = resolveRouteGrammar(clause);
|
|
19534
19807
|
const baseVerb = resolveMethodVerb(clause, grammar);
|
|
@@ -19656,38 +19929,20 @@ function formatLong(clause, options) {
|
|
|
19656
19929
|
const richGraphAdministrationSentence = richPrimaryGraphText ? formatPatientInstructionSentence(
|
|
19657
19930
|
[richPrimaryGraphText, ...graphRegimenTail].filter(Boolean).join(" ")
|
|
19658
19931
|
) : void 0;
|
|
19659
|
-
const primaryGraphAction = roundTrip
|
|
19660
|
-
var _a27;
|
|
19661
|
-
const primary = (_a27 = clause.instructionGraph) == null ? void 0 : _a27.primaryAdministrationSpan;
|
|
19662
|
-
if (!primary || action.span.end <= primary.start || action.span.start >= primary.end) return false;
|
|
19663
|
-
const hasLocalRelation = relationHasGrammarFeature(action.relation, "roundtripRichRelation");
|
|
19664
|
-
const hasRichArgument = action.args.some(
|
|
19665
|
-
(arg) => [
|
|
19666
|
-
"time" /* Time */,
|
|
19667
|
-
"duration" /* Duration */,
|
|
19668
|
-
"material" /* Material */,
|
|
19669
|
-
"activity" /* Activity */,
|
|
19670
|
-
"result" /* Result */,
|
|
19671
|
-
"destination" /* Destination */,
|
|
19672
|
-
"substance" /* Substance */,
|
|
19673
|
-
"manner" /* Manner */
|
|
19674
|
-
].indexOf(arg.role) >= 0 || (arg.role === "object" /* Object */ || arg.role === "theme" /* Theme */) && /\b(?:new|replacement|another|fresh)\b/i.test(arg.text)
|
|
19675
|
-
);
|
|
19676
|
-
return hasLocalRelation || hasRichArgument;
|
|
19677
|
-
}) : void 0;
|
|
19932
|
+
const primaryGraphAction = roundTrip ? instructionGraphRoundTripPrimaryAction(clause) : void 0;
|
|
19678
19933
|
const instructionPhrases = [];
|
|
19679
19934
|
const hasCodedAdditionalInstruction = Boolean(
|
|
19680
|
-
(
|
|
19935
|
+
(_s = clause.additionalInstructions) == null ? void 0 : _s.some((instruction) => {
|
|
19681
19936
|
var _a27;
|
|
19682
19937
|
return (_a27 = instruction.coding) == null ? void 0 : _a27.code;
|
|
19683
19938
|
})
|
|
19684
19939
|
);
|
|
19685
19940
|
const normalizeInstruction = (value) => value.toLowerCase().replace(/[\s,;:.()]+/g, " ").trim();
|
|
19686
|
-
const graphWarnings = (
|
|
19941
|
+
const graphWarnings = (_u = (_t = clause.instructionGraph) == null ? void 0 : _t.actions.filter(
|
|
19687
19942
|
(action) => action.polarity === "negate" /* Negate */
|
|
19688
|
-
)) != null ?
|
|
19689
|
-
const positionedGraph = Boolean((
|
|
19690
|
-
const graphOwnedAdditional = ((
|
|
19943
|
+
)) != null ? _u : [];
|
|
19944
|
+
const positionedGraph = Boolean((_v = clause.instructionGraph) == null ? void 0 : _v.primaryAdministrationSpan);
|
|
19945
|
+
const graphOwnedAdditional = ((_w = clause.additionalInstructions) != null ? _w : []).filter((instruction) => {
|
|
19691
19946
|
var _a27, _b4;
|
|
19692
19947
|
if (((_a27 = instruction.coding) == null ? void 0 : _a27.code) || !instruction.text || !clause.instructionGraph) return false;
|
|
19693
19948
|
const normalized = normalizeInstruction(instruction.text);
|
|
@@ -19697,7 +19952,7 @@ function formatLong(clause, options) {
|
|
|
19697
19952
|
});
|
|
19698
19953
|
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));
|
|
19699
19954
|
});
|
|
19700
|
-
const additionalForDirectRendering = ((
|
|
19955
|
+
const additionalForDirectRendering = ((_x = clause.additionalInstructions) != null ? _x : []).filter(
|
|
19701
19956
|
(instruction) => graphOwnedAdditional.indexOf(instruction) === -1 && instruction !== integratedThinLayer
|
|
19702
19957
|
);
|
|
19703
19958
|
const additionalTexts = additionalForDirectRendering.map((instruction) => {
|
|
@@ -19706,8 +19961,8 @@ function formatLong(clause, options) {
|
|
|
19706
19961
|
}).filter((text) => Boolean(text));
|
|
19707
19962
|
const additionalSemanticSourceTexts = additionalTexts.slice();
|
|
19708
19963
|
for (const instruction of additionalForDirectRendering) {
|
|
19709
|
-
for (const frame of (
|
|
19710
|
-
const source = (
|
|
19964
|
+
for (const frame of (_y = instruction.frames) != null ? _y : []) {
|
|
19965
|
+
const source = (_z = frame.sourceText) == null ? void 0 : _z.trim();
|
|
19711
19966
|
if (source && additionalSemanticSourceTexts.indexOf(source) === -1) {
|
|
19712
19967
|
additionalSemanticSourceTexts.push(source);
|
|
19713
19968
|
}
|
|
@@ -19768,18 +20023,18 @@ function formatLong(clause, options) {
|
|
|
19768
20023
|
omitSourceTexts: postGraphOmissions,
|
|
19769
20024
|
position: "post"
|
|
19770
20025
|
}) : void 0;
|
|
19771
|
-
const graphInstruction = (
|
|
20026
|
+
const graphInstruction = (_A = graphWholeInstruction != null ? graphWholeInstruction : postGraphInstruction) != null ? _A : !positionedGraph && clause.instructionGraph && instructionGraphHasNovelNonWarningContent(clause.instructionGraph, representedInstructionTexts) ? realizeInstructionGraph(clause.instructionGraph, "en", {
|
|
19772
20027
|
includeWarnings: false,
|
|
19773
20028
|
omitCanonicalAdministration: clause,
|
|
19774
20029
|
preferSourceText: roundTrip,
|
|
19775
20030
|
roundtripSafe: roundTrip,
|
|
19776
20031
|
omitSourceTexts: postGraphOmissions
|
|
19777
20032
|
}) : void 0;
|
|
19778
|
-
const primarySpanForFlow = (
|
|
19779
|
-
const graphActionsForFlow = (
|
|
20033
|
+
const primarySpanForFlow = (_B = clause.instructionGraph) == null ? void 0 : _B.primaryAdministrationSpan;
|
|
20034
|
+
const graphActionsForFlow = (_D = (_C = clause.instructionGraph) == null ? void 0 : _C.actions) != null ? _D : [];
|
|
19780
20035
|
const lastPreActionForFlow = primarySpanForFlow ? graphActionsForFlow.filter((action) => action.span.end <= primarySpanForFlow.start).sort((a, b) => b.span.end - a.span.end)[0] : void 0;
|
|
19781
20036
|
const firstPostActionForFlow = primarySpanForFlow ? graphActionsForFlow.filter((action) => action.span.start >= primarySpanForFlow.end).sort((a, b) => a.span.start - b.span.start)[0] : void 0;
|
|
19782
|
-
const graphFlowSource = (
|
|
20037
|
+
const graphFlowSource = (_F = (_E = clause.instructionGraph) == null ? void 0 : _E.sourceText) != null ? _F : clause.rawText;
|
|
19783
20038
|
const noStrongBoundaryForFlow = (start, end) => !/[.!?;]/u.test(graphFlowSource.slice(start, end));
|
|
19784
20039
|
const preFlowsIntoAdministration = Boolean(
|
|
19785
20040
|
!roundTrip && preGraphInstruction && primarySpanForFlow && lastPreActionForFlow && lastPreActionForFlow.polarity !== "negate" /* Negate */ && noStrongBoundaryForFlow(lastPreActionForFlow.span.end, primarySpanForFlow.start)
|
|
@@ -19795,9 +20050,9 @@ function formatLong(clause, options) {
|
|
|
19795
20050
|
);
|
|
19796
20051
|
if (patientInstruction) instructionPhrases.push(patientInstruction);
|
|
19797
20052
|
const trailingInstructionText = instructionPhrases.join(" ").trim() || void 0;
|
|
19798
|
-
const hasExplicitMethod = Boolean(((
|
|
19799
|
-
const graphSourceIsEnglish = !((
|
|
19800
|
-
if (roundTrip && !hasExplicitMethod && graphSourceIsEnglish && ((
|
|
20053
|
+
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));
|
|
20054
|
+
const graphSourceIsEnglish = !((_K = clause.instructionGraph) == null ? void 0 : _K.sourceLocale) || !clause.instructionGraph.sourceLocale.toLowerCase().startsWith("th");
|
|
20055
|
+
if (roundTrip && !hasExplicitMethod && graphSourceIsEnglish && ((_L = clause.instructionGraph) == null ? void 0 : _L.sourceText.trim())) {
|
|
19801
20056
|
return clause.instructionGraph.sourceText.trim();
|
|
19802
20057
|
}
|
|
19803
20058
|
if (!canonicalClauseHasAdministrationSemantics(clause)) {
|
|
@@ -19807,10 +20062,20 @@ function formatLong(clause, options) {
|
|
|
19807
20062
|
roundtripSafe: roundTrip
|
|
19808
20063
|
}) : void 0;
|
|
19809
20064
|
const wholeGraphText = formatPatientInstructionSentence(wholeGraph);
|
|
19810
|
-
|
|
20065
|
+
const parts = [];
|
|
20066
|
+
for (const value of [wholeGraphText, ...instructionPhrases]) {
|
|
20067
|
+
if (!value) continue;
|
|
20068
|
+
const normalized = normalizeInstruction(value);
|
|
20069
|
+
if (parts.some((existing) => {
|
|
20070
|
+
const candidate = normalizeInstruction(existing);
|
|
20071
|
+
return candidate === normalized || candidate.includes(normalized) || normalized.includes(candidate);
|
|
20072
|
+
})) continue;
|
|
20073
|
+
parts.push(value);
|
|
20074
|
+
}
|
|
20075
|
+
return parts.join(" ").trim() || `${verb}.`;
|
|
19811
20076
|
}
|
|
19812
20077
|
const leadingInstructionText = preFlowsIntoAdministration ? void 0 : preGraphInstruction ? formatPatientInstructionSentence(preGraphInstruction) : void 0;
|
|
19813
|
-
const graphRepresentsDose = !clause.dose || Boolean((
|
|
20078
|
+
const graphRepresentsDose = !clause.dose || Boolean((_M = clause.instructionGraph) == null ? void 0 : _M.actions.some(
|
|
19814
20079
|
(action) => action.args.some(
|
|
19815
20080
|
(arg) => {
|
|
19816
20081
|
var _a27, _b4, _c3, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2;
|
|
@@ -19819,26 +20084,26 @@ function formatLong(clause, options) {
|
|
|
19819
20084
|
)
|
|
19820
20085
|
));
|
|
19821
20086
|
const hasAdministrationTiming = Boolean(
|
|
19822
|
-
schedule.frequency !== void 0 || schedule.frequencyMax !== void 0 || schedule.period !== void 0 || schedule.periodMax !== void 0 || ((
|
|
20087
|
+
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
|
|
19823
20088
|
);
|
|
19824
20089
|
const graphCanStandAlone = Boolean(
|
|
19825
|
-
!hasExplicitMethod && trailingInstructionText && ((
|
|
20090
|
+
!hasExplicitMethod && trailingInstructionText && ((_R = clause.instructionGraph) == null ? void 0 : _R.actions.length) && !clause.route && !clause.site && !hasAdministrationTiming && graphRepresentsDose
|
|
19826
20091
|
);
|
|
19827
20092
|
if (graphCanStandAlone) return trailingInstructionText;
|
|
19828
20093
|
const primarySourceSentence = primaryGraphAction ? formatPatientInstructionSentence(primaryGraphAction.sourceText) : void 0;
|
|
19829
|
-
const primaryActionIndex = primaryGraphAction ? (
|
|
19830
|
-
const entersPrimaryWithThen = primaryActionIndex !== void 0 && primaryActionIndex >= 0 ? (
|
|
20094
|
+
const primaryActionIndex = primaryGraphAction ? (_S = clause.instructionGraph) == null ? void 0 : _S.actions.indexOf(primaryGraphAction) : void 0;
|
|
20095
|
+
const entersPrimaryWithThen = primaryActionIndex !== void 0 && primaryActionIndex >= 0 ? (_U = (_T = clause.instructionGraph) == null ? void 0 : _T.relations) == null ? void 0 : _U.some(
|
|
19831
20096
|
(relation) => relationHasSemanticClass(relation.kind, "sequence") && relation.toActionIndex === primaryActionIndex && relation.fromActionIndex !== void 0
|
|
19832
20097
|
) : false;
|
|
19833
20098
|
const richPrimaryActionIndex = richPrimaryGraphAction && clause.instructionGraph ? clause.instructionGraph.actions.indexOf(richPrimaryGraphAction) : -1;
|
|
19834
20099
|
const graphContinuesWithThen = richPrimaryActionIndex >= 0 && Boolean(
|
|
19835
|
-
(
|
|
20100
|
+
(_W = (_V = clause.instructionGraph) == null ? void 0 : _V.relations) == null ? void 0 : _W.some(
|
|
19836
20101
|
(relation) => relationHasSemanticClass(relation.kind, "sequence") && relation.fromActionIndex === richPrimaryActionIndex
|
|
19837
20102
|
)
|
|
19838
20103
|
);
|
|
19839
20104
|
const sequenceRelation = getUniqueAdviceRelationByGrammarFeature("defaultSequenceRelation");
|
|
19840
20105
|
if (!sequenceRelation) throw new Error("Missing declarative default sequence relation");
|
|
19841
|
-
const sequenceSurface = (
|
|
20106
|
+
const sequenceSurface = (_X = localizeAdviceRelation(sequenceRelation, "en")) != null ? _X : sequenceRelation;
|
|
19842
20107
|
const compose = (base) => {
|
|
19843
20108
|
var _a27;
|
|
19844
20109
|
let effectiveBase = (_a27 = richGraphAdministrationSentence != null ? richGraphAdministrationSentence : primarySourceSentence) != null ? _a27 : base;
|
|
@@ -19984,8 +20249,8 @@ var advice_terminology_default = {
|
|
|
19984
20249
|
{ surface: "drive", lemma: "drive", partOfSpeech: "verb", semanticClass: "activity" },
|
|
19985
20250
|
{ surface: "driving", lemma: "drive", partOfSpeech: "verb", semanticClass: "activity" },
|
|
19986
20251
|
{ surface: "eat", lemma: "eat", partOfSpeech: "verb", semanticClass: "ingest" },
|
|
19987
|
-
{ surface: "cause", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect" },
|
|
19988
|
-
{ surface: "causes", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect" },
|
|
20252
|
+
{ surface: "cause", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect", i18n: { th: "\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E40\u0E01\u0E34\u0E14" } },
|
|
20253
|
+
{ surface: "causes", lemma: "cause", partOfSpeech: "verb", semanticClass: "effect", realizerProfile: "effect", i18n: { th: "\u0E17\u0E33\u0E43\u0E2B\u0E49\u0E40\u0E01\u0E34\u0E14" } },
|
|
19989
20254
|
{ surface: "use", lemma: "use", partOfSpeech: "verb", semanticClass: "administration" },
|
|
19990
20255
|
{ surface: "take", lemma: "take", partOfSpeech: "verb", semanticClass: "administration" },
|
|
19991
20256
|
{ surface: "apply", lemma: "apply", partOfSpeech: "verb", semanticClass: "administration" },
|
|
@@ -20819,6 +21084,7 @@ function mapSemanticClassToRole(semanticClass) {
|
|
|
20819
21084
|
return (_a26 = enumValue(AdviceArgumentRole, configured)) != null ? _a26 : "object" /* Object */;
|
|
20820
21085
|
}
|
|
20821
21086
|
function classifyArgument(text) {
|
|
21087
|
+
var _a26, _b3, _c2, _d, _e;
|
|
20822
21088
|
const cleaned = cleanFreeText(text);
|
|
20823
21089
|
const normalized = normalizeAdditionalInstructionKey(cleaned);
|
|
20824
21090
|
if (!normalized) {
|
|
@@ -20833,6 +21099,21 @@ function classifyArgument(text) {
|
|
|
20833
21099
|
concept.conceptId
|
|
20834
21100
|
);
|
|
20835
21101
|
}
|
|
21102
|
+
const symptom = resolveSymptomDefinition(normalized);
|
|
21103
|
+
if (symptom) {
|
|
21104
|
+
const coding = symptom.coding ? __spreadValues({}, symptom.coding) : void 0;
|
|
21105
|
+
return {
|
|
21106
|
+
role: "object" /* Object */,
|
|
21107
|
+
text: cleaned,
|
|
21108
|
+
normalized: (_b3 = (_a26 = symptom.text) == null ? void 0 : _a26.toLowerCase()) != null ? _b3 : normalized,
|
|
21109
|
+
conceptId: (_d = (_c2 = coding == null ? void 0 : coding.code) != null ? _c2 : symptom.text) != null ? _d : normalized,
|
|
21110
|
+
coding,
|
|
21111
|
+
codings: coding ? [coding] : void 0,
|
|
21112
|
+
i18n: __spreadValues({
|
|
21113
|
+
en: symptom.text ? symptom.text.charAt(0).toLowerCase() + symptom.text.slice(1) : cleaned
|
|
21114
|
+
}, (_e = symptom.i18n) != null ? _e : {})
|
|
21115
|
+
};
|
|
21116
|
+
}
|
|
20836
21117
|
const parts = normalized.split(" ");
|
|
20837
21118
|
if (parts.length >= 2) {
|
|
20838
21119
|
const first = parts[0];
|
|
@@ -21472,8 +21753,9 @@ var AVOIDANCE_ADVICE_PREDICATE_REALIZER = ({ frame, argText, modalityText }) =>
|
|
|
21472
21753
|
};
|
|
21473
21754
|
var EFFECT_ADVICE_PREDICATE_REALIZER = ({ frame, argText, modalityText }) => {
|
|
21474
21755
|
const effectiveModality = modalityText != null ? modalityText : capitalizeSentence("may" /* May */);
|
|
21475
|
-
const
|
|
21476
|
-
|
|
21756
|
+
const thai = /[\u0E00-\u0E7F]/u.test(frame.predicate.lemma);
|
|
21757
|
+
const predicate = thai ? `${effectiveModality}${frame.predicate.lemma}` : `${effectiveModality} ${frame.predicate.lemma}`;
|
|
21758
|
+
return argText ? `${predicate}${thai ? "" : " "}${argText}` : predicate;
|
|
21477
21759
|
};
|
|
21478
21760
|
var ADVICE_PREDICATE_REALIZERS = {
|
|
21479
21761
|
default: DEFAULT_ADVICE_PREDICATE_REALIZER,
|
|
@@ -25152,7 +25434,7 @@ function buildRoutePhraseThai(clause, grammar, hasSite) {
|
|
|
25152
25434
|
return text;
|
|
25153
25435
|
}
|
|
25154
25436
|
function formatSiteThai(clause, grammar) {
|
|
25155
|
-
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;
|
|
25437
|
+
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;
|
|
25156
25438
|
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());
|
|
25157
25439
|
const lower = text == null ? void 0 : text.toLowerCase();
|
|
25158
25440
|
const codingCode = (_g = (_f = clause.site) == null ? void 0 : _f.coding) == null ? void 0 : _g.code;
|
|
@@ -25167,20 +25449,22 @@ function formatSiteThai(clause, grammar) {
|
|
|
25167
25449
|
if (isVaginalRoute && isVaginaSite) {
|
|
25168
25450
|
return void 0;
|
|
25169
25451
|
}
|
|
25170
|
-
const
|
|
25452
|
+
const resolvedSite = text ? resolveBodySitePhrase(text) : void 0;
|
|
25453
|
+
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;
|
|
25454
|
+
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);
|
|
25171
25455
|
if (!translated) {
|
|
25172
25456
|
return void 0;
|
|
25173
25457
|
}
|
|
25174
|
-
if (((
|
|
25458
|
+
if (((_z = clause.route) == null ? void 0 : _z.code) === RouteCode["Nasal route"]) {
|
|
25175
25459
|
return `\u0E40\u0E02\u0E49\u0E32${translated}`;
|
|
25176
25460
|
}
|
|
25177
|
-
const spatialRelation = (
|
|
25461
|
+
const spatialRelation = (_A = clause.site) == null ? void 0 : _A.spatialRelation;
|
|
25178
25462
|
const spatialRealization = (spatialRelation == null ? void 0 : spatialRelation.relationText) ? getBodySiteRelationRealization(spatialRelation.relationText, "th") : void 0;
|
|
25179
25463
|
const spatialTargetThai = spatialRelation ? translateSpatialTargetThai(spatialRelation) : void 0;
|
|
25180
25464
|
if (spatialRealization && (spatialRealization.omitOuterSitePreposition || (spatialTargetThai == null ? void 0 : spatialTargetThai.startsWith("\u0E1A\u0E23\u0E34\u0E40\u0E27\u0E13")))) {
|
|
25181
25465
|
return translated;
|
|
25182
25466
|
}
|
|
25183
|
-
const preposition = (
|
|
25467
|
+
const preposition = (_B = grammar.sitePreposition) != null ? _B : "\u0E17\u0E35\u0E48";
|
|
25184
25468
|
if (translated.startsWith(preposition)) {
|
|
25185
25469
|
return translated;
|
|
25186
25470
|
}
|
|
@@ -25224,6 +25508,18 @@ function translateSpatialSiteThai(site, relation) {
|
|
|
25224
25508
|
}
|
|
25225
25509
|
return realization.strategy === "suffix" ? `${target}${realization.surface}` : `${realization.surface}${target}`;
|
|
25226
25510
|
}
|
|
25511
|
+
function appendBodySiteQualifierThai(base, qualifier) {
|
|
25512
|
+
var _a26, _b3, _c2, _d;
|
|
25513
|
+
if (!qualifier) return base;
|
|
25514
|
+
const realization = getBodySiteRelationRealization(qualifier.relation, "th");
|
|
25515
|
+
if (!realization) return base;
|
|
25516
|
+
const relation = realization.surface;
|
|
25517
|
+
if (qualifier.kind === "symptom") {
|
|
25518
|
+
return `${base}${relation}${(_b3 = (_a26 = qualifier.i18n) == null ? void 0 : _a26.th) != null ? _b3 : qualifier.text}`;
|
|
25519
|
+
}
|
|
25520
|
+
const target = (_d = translateSiteThai(qualifier.targetText, (_c2 = qualifier.targetCoding) == null ? void 0 : _c2.code)) != null ? _d : qualifier.targetText;
|
|
25521
|
+
return `${base}${relation}${target}`;
|
|
25522
|
+
}
|
|
25227
25523
|
function translateSiteThai(site, code, spatialRelation) {
|
|
25228
25524
|
if (!site) {
|
|
25229
25525
|
if (code) {
|
|
@@ -25235,25 +25531,28 @@ function translateSiteThai(site, code, spatialRelation) {
|
|
|
25235
25531
|
if (!normalized) {
|
|
25236
25532
|
return site;
|
|
25237
25533
|
}
|
|
25534
|
+
const resolvedPhrase = resolveBodySitePhrase(site);
|
|
25535
|
+
const qualifier = resolvedPhrase == null ? void 0 : resolvedPhrase.features.qualifier;
|
|
25536
|
+
const qualified = (value) => appendBodySiteQualifierThai(value, qualifier);
|
|
25238
25537
|
const spatial = translateSpatialSiteThai(site, spatialRelation);
|
|
25239
25538
|
if (spatial) {
|
|
25240
|
-
return spatial;
|
|
25539
|
+
return qualified(spatial);
|
|
25241
25540
|
}
|
|
25242
25541
|
if (code) {
|
|
25243
25542
|
const translatedByCode = THAI_SITE_CODE_TRANSLATIONS[code];
|
|
25244
25543
|
if (translatedByCode) {
|
|
25245
|
-
return translatedByCode;
|
|
25544
|
+
return qualified(translatedByCode);
|
|
25246
25545
|
}
|
|
25247
25546
|
}
|
|
25248
25547
|
const definitionTranslation = THAI_SITE_DEFINITION_TRANSLATIONS[normalized];
|
|
25249
25548
|
if (definitionTranslation) {
|
|
25250
|
-
return definitionTranslation;
|
|
25549
|
+
return qualified(definitionTranslation);
|
|
25251
25550
|
}
|
|
25252
25551
|
const direct = THAI_SITE_TRANSLATIONS[normalized];
|
|
25253
25552
|
if (direct) {
|
|
25254
|
-
return direct;
|
|
25553
|
+
return qualified(direct);
|
|
25255
25554
|
}
|
|
25256
|
-
return site;
|
|
25555
|
+
return qualified(site);
|
|
25257
25556
|
}
|
|
25258
25557
|
function describeDayOfWeekThai(schedule) {
|
|
25259
25558
|
var _a26;
|
|
@@ -25580,7 +25879,7 @@ function formatLongThai(clause, options) {
|
|
|
25580
25879
|
segments.push(sitePart);
|
|
25581
25880
|
}
|
|
25582
25881
|
const body = segments.filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
25583
|
-
const richPrimaryGraphAction = (options == null ? void 0 : options.realizationMode)
|
|
25882
|
+
const richPrimaryGraphAction = (options == null ? void 0 : options.realizationMode) === "roundtrip" ? instructionGraphRoundTripPrimaryAction(clause) : instructionGraphRichPrimaryAction(clause);
|
|
25584
25883
|
const richPrimaryGraphText = richPrimaryGraphAction ? realizeInstructionAction(richPrimaryGraphAction, "th") : void 0;
|
|
25585
25884
|
const richPrimaryHasSite = Boolean(
|
|
25586
25885
|
richPrimaryGraphAction == null ? void 0 : richPrimaryGraphAction.args.some((arg) => arg.role === "site" /* Site */)
|
|
@@ -25704,7 +26003,24 @@ function formatLongThai(clause, options) {
|
|
|
25704
26003
|
roundtripSafe: roundTrip
|
|
25705
26004
|
}) : void 0;
|
|
25706
26005
|
const wholeGraphText = formatPatientInstructionSentence2(wholeGraph);
|
|
25707
|
-
|
|
26006
|
+
const parts = [];
|
|
26007
|
+
const normalizedInstruction2 = (value) => value.toLowerCase().replace(/[\s,;:.()]+/gu, " ").trim();
|
|
26008
|
+
for (const value of [
|
|
26009
|
+
leadingInstructionText,
|
|
26010
|
+
wholeGraphText,
|
|
26011
|
+
directInstruction,
|
|
26012
|
+
graphInstructionText,
|
|
26013
|
+
fallbackPatientInstruction
|
|
26014
|
+
]) {
|
|
26015
|
+
if (!value) continue;
|
|
26016
|
+
const normalized = normalizedInstruction2(value);
|
|
26017
|
+
if (parts.some((existing) => {
|
|
26018
|
+
const candidate = normalizedInstruction2(existing);
|
|
26019
|
+
return candidate === normalized || candidate.includes(normalized) || normalized.includes(candidate);
|
|
26020
|
+
})) continue;
|
|
26021
|
+
parts.push(value);
|
|
26022
|
+
}
|
|
26023
|
+
return parts.join(" ").trim() || `${verb}.`;
|
|
25708
26024
|
}
|
|
25709
26025
|
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));
|
|
25710
26026
|
const graphRepresentsDose = !clause.dose || Boolean((_C = clause.instructionGraph) == null ? void 0 : _C.actions.some(
|
|
@@ -28303,6 +28619,38 @@ function separatedIntervalRule() {
|
|
|
28303
28619
|
];
|
|
28304
28620
|
}
|
|
28305
28621
|
const unitToken = context.tokens[start + 2];
|
|
28622
|
+
const explicitLowUnit = unitToken && !context.state.consumed.has(unitToken.index) ? mapIntervalUnit(normalizeTokenLower(unitToken)) : void 0;
|
|
28623
|
+
const explicitRangeConnectorToken = context.tokens[start + 3];
|
|
28624
|
+
const explicitRangeConnector = explicitRangeConnectorToken && !context.state.consumed.has(explicitRangeConnectorToken.index) ? normalizeTokenLower(explicitRangeConnectorToken) : void 0;
|
|
28625
|
+
const explicitHighToken = context.tokens[start + 4];
|
|
28626
|
+
const explicitHighLower = explicitHighToken && !context.state.consumed.has(explicitHighToken.index) ? normalizeTokenLower(explicitHighToken) : void 0;
|
|
28627
|
+
const explicitHighUnitToken = context.tokens[start + 5];
|
|
28628
|
+
const explicitHighUnit = explicitHighUnitToken && !context.state.consumed.has(explicitHighUnitToken.index) ? mapIntervalUnit(normalizeTokenLower(explicitHighUnitToken)) : void 0;
|
|
28629
|
+
if (explicitLowUnit && explicitRangeConnector && RANGE_CONNECTORS.has(explicitRangeConnector) && explicitHighToken && explicitHighLower && explicitHighUnit && explicitHighUnitToken && /^[0-9]+(?:\.[0-9]+)?$/.test(quantityLower) && /^[0-9]+(?:\.[0-9]+)?$/.test(explicitHighLower)) {
|
|
28630
|
+
const normalizedRange = normalizeMixedPeriodRange(
|
|
28631
|
+
parseFloat(quantityLower),
|
|
28632
|
+
explicitLowUnit,
|
|
28633
|
+
parseFloat(explicitHighLower),
|
|
28634
|
+
explicitHighUnit
|
|
28635
|
+
);
|
|
28636
|
+
if (normalizedRange) {
|
|
28637
|
+
return [lexicalSign({
|
|
28638
|
+
type: "schedule-sign",
|
|
28639
|
+
rule: "hpsg.lex.schedule.separatedMixedUnitIntervalRange",
|
|
28640
|
+
tokens: [lead, quantity, unitToken, explicitRangeConnectorToken, explicitHighToken, explicitHighUnitToken],
|
|
28641
|
+
synsem: {
|
|
28642
|
+
head: { schedule: {
|
|
28643
|
+
period: normalizedRange.low,
|
|
28644
|
+
periodMax: normalizedRange.high,
|
|
28645
|
+
periodUnit: normalizedRange.unit
|
|
28646
|
+
} },
|
|
28647
|
+
valence: {},
|
|
28648
|
+
cont: { clauseKind: "administration" }
|
|
28649
|
+
},
|
|
28650
|
+
score: 14
|
|
28651
|
+
})];
|
|
28652
|
+
}
|
|
28653
|
+
}
|
|
28306
28654
|
const rangeConnector = unitToken && !context.state.consumed.has(unitToken.index) ? normalizeTokenLower(unitToken) : void 0;
|
|
28307
28655
|
const highToken = context.tokens[start + 3];
|
|
28308
28656
|
const highLower = highToken && !context.state.consumed.has(highToken.index) ? normalizeTokenLower(highToken) : void 0;
|
|
@@ -31116,6 +31464,21 @@ function hasSystemicCueBeforeSiteAbbreviation(context, start) {
|
|
|
31116
31464
|
}
|
|
31117
31465
|
return sawNonOcularDose;
|
|
31118
31466
|
}
|
|
31467
|
+
function anchorTargetsTypedNonSiteConcept(context, start) {
|
|
31468
|
+
var _a26;
|
|
31469
|
+
const current = (_a26 = tokensAvailable(context, start, 1)) == null ? void 0 : _a26[0];
|
|
31470
|
+
if (!current || !resolveActionRelationSurface(normalizeTokenLower(current))) return false;
|
|
31471
|
+
for (let cursor = start + 1; cursor < Math.min(context.limit, start + 4); cursor += 1) {
|
|
31472
|
+
const candidate = context.tokens[cursor];
|
|
31473
|
+
if (!candidate || context.state.consumed.has(candidate.index)) break;
|
|
31474
|
+
const lower = normalizeTokenLower(candidate);
|
|
31475
|
+
if (isPunctuation(lower)) break;
|
|
31476
|
+
const concept = resolveMedicationInstructionConcept(lower, context.options);
|
|
31477
|
+
if (!concept) continue;
|
|
31478
|
+
return concept.role !== "site" /* Site */ && concept.role !== "destination" /* Destination */;
|
|
31479
|
+
}
|
|
31480
|
+
return false;
|
|
31481
|
+
}
|
|
31119
31482
|
function contextSuggestsNonOcularSite(context) {
|
|
31120
31483
|
var _a26, _b3, _c2, _d, _e, _f;
|
|
31121
31484
|
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, " ");
|
|
@@ -31134,7 +31497,7 @@ function siteLexicalRule() {
|
|
|
31134
31497
|
}
|
|
31135
31498
|
const signs = [];
|
|
31136
31499
|
const lower = normalizeTokenLower(token);
|
|
31137
|
-
if (tokenBelongsToContextualPrnReasonLead(context, start)) {
|
|
31500
|
+
if (tokenBelongsToContextualPrnReasonLead(context, start) || anchorTargetsTypedNonSiteConcept(context, start)) {
|
|
31138
31501
|
return signs;
|
|
31139
31502
|
}
|
|
31140
31503
|
const siteCandidate = getPrimarySiteMeaningCandidate(token);
|
|
@@ -31177,7 +31540,7 @@ function siteLexicalRule() {
|
|
|
31177
31540
|
if (candidate.kind === "NUMBER" /* Number */) {
|
|
31178
31541
|
break;
|
|
31179
31542
|
}
|
|
31180
|
-
if (getDayOfWeekMeaning(candidate)) {
|
|
31543
|
+
if (getDayOfWeekMeaning(candidate) || ACTION_SEQUENCE_MARKERS.has(candidateLower)) {
|
|
31181
31544
|
break;
|
|
31182
31545
|
}
|
|
31183
31546
|
if (coordinationStartsAction(context, cursor)) break;
|