ezmedicationinput 0.1.59 → 0.1.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +78 -4
- package/dist/index.js +78 -4
- package/dist/instruction-graph.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8300,10 +8300,20 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8300
8300
|
}
|
|
8301
8301
|
},
|
|
8302
8302
|
{
|
|
8303
|
-
names: ["finger"
|
|
8303
|
+
names: ["finger"],
|
|
8304
|
+
definition: {
|
|
8305
|
+
coding: { code: "7569003", display: "Finger structure" },
|
|
8306
|
+
text: "finger",
|
|
8307
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8308
|
+
routeHint: RouteCode["Topical route"]
|
|
8309
|
+
}
|
|
8310
|
+
},
|
|
8311
|
+
{
|
|
8312
|
+
names: ["fingers"],
|
|
8304
8313
|
definition: {
|
|
8305
8314
|
coding: { code: "7569003", display: "Finger structure" },
|
|
8306
8315
|
text: "fingers",
|
|
8316
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8307
8317
|
routeHint: RouteCode["Topical route"]
|
|
8308
8318
|
}
|
|
8309
8319
|
},
|
|
@@ -8669,6 +8679,22 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8669
8679
|
routeHint: RouteCode["Topical route"]
|
|
8670
8680
|
}
|
|
8671
8681
|
},
|
|
8682
|
+
{
|
|
8683
|
+
names: ["wart", "\u0E2B\u0E39\u0E14"],
|
|
8684
|
+
definition: {
|
|
8685
|
+
text: "wart",
|
|
8686
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8687
|
+
routeHint: RouteCode["Topical route"]
|
|
8688
|
+
}
|
|
8689
|
+
},
|
|
8690
|
+
{
|
|
8691
|
+
names: ["warts"],
|
|
8692
|
+
definition: {
|
|
8693
|
+
text: "warts",
|
|
8694
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8695
|
+
routeHint: RouteCode["Topical route"]
|
|
8696
|
+
}
|
|
8697
|
+
},
|
|
8672
8698
|
{
|
|
8673
8699
|
names: ["spot", "spots", "acne spot", "acne spots", "\u0E08\u0E38\u0E14"],
|
|
8674
8700
|
definition: {
|
|
@@ -19009,6 +19035,21 @@ function actionHasLocalRelationBefore(parts, actionStart, index) {
|
|
|
19009
19035
|
}
|
|
19010
19036
|
return false;
|
|
19011
19037
|
}
|
|
19038
|
+
function actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options) {
|
|
19039
|
+
var _a28;
|
|
19040
|
+
for (let cursor = index - 1; cursor > actionStart; cursor -= 1) {
|
|
19041
|
+
const relation = resolveActionRelationSurface(key(parts[cursor]));
|
|
19042
|
+
if (!relation || !relationHasSemanticClass(relation, "locative")) continue;
|
|
19043
|
+
const siteText = parts.slice(cursor + 1, index).map((part) => part.original).join(" ").trim();
|
|
19044
|
+
if (!siteText) continue;
|
|
19045
|
+
const resolved = resolveBodySitePhrase(siteText, options == null ? void 0 : options.siteCodeMap, {
|
|
19046
|
+
bodySiteContext: (_a28 = options == null ? void 0 : options.context) == null ? void 0 : _a28.bodySiteContext,
|
|
19047
|
+
allowTerminalModifierInheritance: true
|
|
19048
|
+
});
|
|
19049
|
+
if ((resolved == null ? void 0 : resolved.coding) || (resolved == null ? void 0 : resolved.definition)) return true;
|
|
19050
|
+
}
|
|
19051
|
+
return false;
|
|
19052
|
+
}
|
|
19012
19053
|
function actionTailIsRegimenModifier(parts, actionStart, index, definition, options) {
|
|
19013
19054
|
const token = key(parts[index]);
|
|
19014
19055
|
if (!token) return false;
|
|
@@ -19030,7 +19071,8 @@ function actionTailIsRegimenModifier(parts, actionStart, index, definition, opti
|
|
|
19030
19071
|
if (!eventTail.some((part) => Boolean(EVENT_TIMING_TOKENS[key(part)]))) return false;
|
|
19031
19072
|
}
|
|
19032
19073
|
if ((definition == null ? void 0 : definition.argumentParser) === "object-time") return false;
|
|
19033
|
-
|
|
19074
|
+
if (!actionHasLocalRelationBefore(parts, actionStart, index)) return true;
|
|
19075
|
+
return actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options);
|
|
19034
19076
|
}
|
|
19035
19077
|
function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
19036
19078
|
var _a28, _b4, _c3;
|
|
@@ -20179,6 +20221,19 @@ function instructionGraphRoundTripPrimaryAction(clause) {
|
|
|
20179
20221
|
return hasLocalRelation || hasRichArgument;
|
|
20180
20222
|
});
|
|
20181
20223
|
}
|
|
20224
|
+
function instructionGraphPrimarySiteRelation(clause) {
|
|
20225
|
+
var _a28;
|
|
20226
|
+
const graph = clause.instructionGraph;
|
|
20227
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
20228
|
+
if (!graph || !primary || !clause.site) return void 0;
|
|
20229
|
+
return (_a28 = graph.actions.filter(
|
|
20230
|
+
(action) => action.polarity !== "negate" /* Negate */ && action.relation !== void 0 && relationHasSemanticClass(action.relation, "locative") && action.span.start < primary.end && primary.start < action.span.end && actionMatchesCanonicalMethod(action, clause) && action.args.some(
|
|
20231
|
+
(arg) => arg.role === "site" /* Site */ && siteArgumentCoveredByClause(arg, clause)
|
|
20232
|
+
)
|
|
20233
|
+
).sort(
|
|
20234
|
+
(left, right) => left.span.start - right.span.start || left.span.end - right.span.end
|
|
20235
|
+
)[0]) == null ? void 0 : _a28.relation;
|
|
20236
|
+
}
|
|
20182
20237
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
20183
20238
|
var _a28;
|
|
20184
20239
|
const graph = clause.instructionGraph;
|
|
@@ -21120,7 +21175,9 @@ function formatSite(clause, grammar, directObject = false) {
|
|
|
21120
21175
|
const noun = (_p = perTargetNoun != null ? perTargetNoun : resolvedSite == null ? void 0 : resolvedSite.englishObjectText) != null ? _p : `the ${normalizedText}`;
|
|
21121
21176
|
if (directObject) return noun;
|
|
21122
21177
|
const preferredPreposition = resolvedSite == null ? void 0 : resolvedSite.preferredPreposition;
|
|
21123
|
-
|
|
21178
|
+
const primarySiteRelation = instructionGraphPrimarySiteRelation(clause);
|
|
21179
|
+
const sourcePreposition = relationHasSemanticClass(primarySiteRelation, "locative") ? localizeAdviceRelation(primarySiteRelation, "en") : void 0;
|
|
21180
|
+
let preposition = sourcePreposition != null ? sourcePreposition : grammar.sitePreposition;
|
|
21124
21181
|
if (!preposition || preposition === "to" && preferredPreposition && preferredPreposition !== "to") {
|
|
21125
21182
|
preposition = preferredPreposition;
|
|
21126
21183
|
}
|
|
@@ -33642,6 +33699,23 @@ function methodLexicalRule() {
|
|
|
33642
33699
|
];
|
|
33643
33700
|
});
|
|
33644
33701
|
}
|
|
33702
|
+
function routeTokenIsTemporalPrepositionBeforeTiming(context, start, span) {
|
|
33703
|
+
if (span !== 1) return false;
|
|
33704
|
+
const token = context.tokens[start];
|
|
33705
|
+
if (!token || !SITE_ANCHORS.has(normalizeTokenLower(token))) return false;
|
|
33706
|
+
let cursor = start + 1;
|
|
33707
|
+
while (cursor < context.limit) {
|
|
33708
|
+
const candidate = context.tokens[cursor];
|
|
33709
|
+
if (!candidate || context.state.consumed.has(candidate.index)) return false;
|
|
33710
|
+
const lower = normalizeTokenLower(candidate);
|
|
33711
|
+
if (SITE_FILLERS.has(lower)) {
|
|
33712
|
+
cursor += 1;
|
|
33713
|
+
continue;
|
|
33714
|
+
}
|
|
33715
|
+
return Boolean(EVENT_TIMING_TOKENS[lower]);
|
|
33716
|
+
}
|
|
33717
|
+
return false;
|
|
33718
|
+
}
|
|
33645
33719
|
function routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) {
|
|
33646
33720
|
var _a28, _b4, _c3;
|
|
33647
33721
|
if (span !== 1) return false;
|
|
@@ -33677,7 +33751,7 @@ function routeLexicalRule() {
|
|
|
33677
33751
|
continue;
|
|
33678
33752
|
}
|
|
33679
33753
|
if (span === 1 && isMedicationAdministrationMethod(phrase, context.options)) continue;
|
|
33680
|
-
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span)) {
|
|
33754
|
+
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) || routeTokenIsTemporalPrepositionBeforeTiming(context, start, span)) {
|
|
33681
33755
|
continue;
|
|
33682
33756
|
}
|
|
33683
33757
|
const routeCandidates = routePhraseCandidates(phrase);
|
package/dist/index.js
CHANGED
|
@@ -8150,10 +8150,20 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8150
8150
|
}
|
|
8151
8151
|
},
|
|
8152
8152
|
{
|
|
8153
|
-
names: ["finger"
|
|
8153
|
+
names: ["finger"],
|
|
8154
|
+
definition: {
|
|
8155
|
+
coding: { code: "7569003", display: "Finger structure" },
|
|
8156
|
+
text: "finger",
|
|
8157
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8158
|
+
routeHint: RouteCode["Topical route"]
|
|
8159
|
+
}
|
|
8160
|
+
},
|
|
8161
|
+
{
|
|
8162
|
+
names: ["fingers"],
|
|
8154
8163
|
definition: {
|
|
8155
8164
|
coding: { code: "7569003", display: "Finger structure" },
|
|
8156
8165
|
text: "fingers",
|
|
8166
|
+
i18n: { th: "\u0E19\u0E34\u0E49\u0E27\u0E21\u0E37\u0E2D" },
|
|
8157
8167
|
routeHint: RouteCode["Topical route"]
|
|
8158
8168
|
}
|
|
8159
8169
|
},
|
|
@@ -8519,6 +8529,22 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
|
|
|
8519
8529
|
routeHint: RouteCode["Topical route"]
|
|
8520
8530
|
}
|
|
8521
8531
|
},
|
|
8532
|
+
{
|
|
8533
|
+
names: ["wart", "\u0E2B\u0E39\u0E14"],
|
|
8534
|
+
definition: {
|
|
8535
|
+
text: "wart",
|
|
8536
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8537
|
+
routeHint: RouteCode["Topical route"]
|
|
8538
|
+
}
|
|
8539
|
+
},
|
|
8540
|
+
{
|
|
8541
|
+
names: ["warts"],
|
|
8542
|
+
definition: {
|
|
8543
|
+
text: "warts",
|
|
8544
|
+
i18n: { th: "\u0E2B\u0E39\u0E14" },
|
|
8545
|
+
routeHint: RouteCode["Topical route"]
|
|
8546
|
+
}
|
|
8547
|
+
},
|
|
8522
8548
|
{
|
|
8523
8549
|
names: ["spot", "spots", "acne spot", "acne spots", "\u0E08\u0E38\u0E14"],
|
|
8524
8550
|
definition: {
|
|
@@ -18859,6 +18885,21 @@ function actionHasLocalRelationBefore(parts, actionStart, index) {
|
|
|
18859
18885
|
}
|
|
18860
18886
|
return false;
|
|
18861
18887
|
}
|
|
18888
|
+
function actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options) {
|
|
18889
|
+
var _a28;
|
|
18890
|
+
for (let cursor = index - 1; cursor > actionStart; cursor -= 1) {
|
|
18891
|
+
const relation = resolveActionRelationSurface(key(parts[cursor]));
|
|
18892
|
+
if (!relation || !relationHasSemanticClass(relation, "locative")) continue;
|
|
18893
|
+
const siteText = parts.slice(cursor + 1, index).map((part) => part.original).join(" ").trim();
|
|
18894
|
+
if (!siteText) continue;
|
|
18895
|
+
const resolved = resolveBodySitePhrase(siteText, options == null ? void 0 : options.siteCodeMap, {
|
|
18896
|
+
bodySiteContext: (_a28 = options == null ? void 0 : options.context) == null ? void 0 : _a28.bodySiteContext,
|
|
18897
|
+
allowTerminalModifierInheritance: true
|
|
18898
|
+
});
|
|
18899
|
+
if ((resolved == null ? void 0 : resolved.coding) || (resolved == null ? void 0 : resolved.definition)) return true;
|
|
18900
|
+
}
|
|
18901
|
+
return false;
|
|
18902
|
+
}
|
|
18862
18903
|
function actionTailIsRegimenModifier(parts, actionStart, index, definition, options) {
|
|
18863
18904
|
const token = key(parts[index]);
|
|
18864
18905
|
if (!token) return false;
|
|
@@ -18880,7 +18921,8 @@ function actionTailIsRegimenModifier(parts, actionStart, index, definition, opti
|
|
|
18880
18921
|
if (!eventTail.some((part) => Boolean(EVENT_TIMING_TOKENS[key(part)]))) return false;
|
|
18881
18922
|
}
|
|
18882
18923
|
if ((definition == null ? void 0 : definition.argumentParser) === "object-time") return false;
|
|
18883
|
-
|
|
18924
|
+
if (!actionHasLocalRelationBefore(parts, actionStart, index)) return true;
|
|
18925
|
+
return actionHasResolvedLocativeSiteBefore(parts, actionStart, index, options);
|
|
18884
18926
|
}
|
|
18885
18927
|
function parseInstructionActions(sourceText, baseOffset = 0, options) {
|
|
18886
18928
|
var _a28, _b4, _c3;
|
|
@@ -20029,6 +20071,19 @@ function instructionGraphRoundTripPrimaryAction(clause) {
|
|
|
20029
20071
|
return hasLocalRelation || hasRichArgument;
|
|
20030
20072
|
});
|
|
20031
20073
|
}
|
|
20074
|
+
function instructionGraphPrimarySiteRelation(clause) {
|
|
20075
|
+
var _a28;
|
|
20076
|
+
const graph = clause.instructionGraph;
|
|
20077
|
+
const primary = graph == null ? void 0 : graph.primaryAdministrationSpan;
|
|
20078
|
+
if (!graph || !primary || !clause.site) return void 0;
|
|
20079
|
+
return (_a28 = graph.actions.filter(
|
|
20080
|
+
(action) => action.polarity !== "negate" /* Negate */ && action.relation !== void 0 && relationHasSemanticClass(action.relation, "locative") && action.span.start < primary.end && primary.start < action.span.end && actionMatchesCanonicalMethod(action, clause) && action.args.some(
|
|
20081
|
+
(arg) => arg.role === "site" /* Site */ && siteArgumentCoveredByClause(arg, clause)
|
|
20082
|
+
)
|
|
20083
|
+
).sort(
|
|
20084
|
+
(left, right) => left.span.start - right.span.start || left.span.end - right.span.end
|
|
20085
|
+
)[0]) == null ? void 0 : _a28.relation;
|
|
20086
|
+
}
|
|
20032
20087
|
function instructionGraphPrimaryAdministrationModality(clause) {
|
|
20033
20088
|
var _a28;
|
|
20034
20089
|
const graph = clause.instructionGraph;
|
|
@@ -20970,7 +21025,9 @@ function formatSite(clause, grammar, directObject = false) {
|
|
|
20970
21025
|
const noun = (_p = perTargetNoun != null ? perTargetNoun : resolvedSite == null ? void 0 : resolvedSite.englishObjectText) != null ? _p : `the ${normalizedText}`;
|
|
20971
21026
|
if (directObject) return noun;
|
|
20972
21027
|
const preferredPreposition = resolvedSite == null ? void 0 : resolvedSite.preferredPreposition;
|
|
20973
|
-
|
|
21028
|
+
const primarySiteRelation = instructionGraphPrimarySiteRelation(clause);
|
|
21029
|
+
const sourcePreposition = relationHasSemanticClass(primarySiteRelation, "locative") ? localizeAdviceRelation(primarySiteRelation, "en") : void 0;
|
|
21030
|
+
let preposition = sourcePreposition != null ? sourcePreposition : grammar.sitePreposition;
|
|
20974
21031
|
if (!preposition || preposition === "to" && preferredPreposition && preferredPreposition !== "to") {
|
|
20975
21032
|
preposition = preferredPreposition;
|
|
20976
21033
|
}
|
|
@@ -33492,6 +33549,23 @@ function methodLexicalRule() {
|
|
|
33492
33549
|
];
|
|
33493
33550
|
});
|
|
33494
33551
|
}
|
|
33552
|
+
function routeTokenIsTemporalPrepositionBeforeTiming(context, start, span) {
|
|
33553
|
+
if (span !== 1) return false;
|
|
33554
|
+
const token = context.tokens[start];
|
|
33555
|
+
if (!token || !SITE_ANCHORS.has(normalizeTokenLower(token))) return false;
|
|
33556
|
+
let cursor = start + 1;
|
|
33557
|
+
while (cursor < context.limit) {
|
|
33558
|
+
const candidate = context.tokens[cursor];
|
|
33559
|
+
if (!candidate || context.state.consumed.has(candidate.index)) return false;
|
|
33560
|
+
const lower = normalizeTokenLower(candidate);
|
|
33561
|
+
if (SITE_FILLERS.has(lower)) {
|
|
33562
|
+
cursor += 1;
|
|
33563
|
+
continue;
|
|
33564
|
+
}
|
|
33565
|
+
return Boolean(EVENT_TIMING_TOKENS[lower]);
|
|
33566
|
+
}
|
|
33567
|
+
return false;
|
|
33568
|
+
}
|
|
33495
33569
|
function routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) {
|
|
33496
33570
|
var _a28, _b4, _c3;
|
|
33497
33571
|
if (span !== 1) return false;
|
|
@@ -33527,7 +33601,7 @@ function routeLexicalRule() {
|
|
|
33527
33601
|
continue;
|
|
33528
33602
|
}
|
|
33529
33603
|
if (span === 1 && isMedicationAdministrationMethod(phrase, context.options)) continue;
|
|
33530
|
-
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span)) {
|
|
33604
|
+
if (routeTokenIsPartitiveSiteHead(context, start, span) || routeTokenIsSitePrepositionBeforeResolvableSite(context, start, span) || routeTokenIsTemporalPrepositionBeforeTiming(context, start, span)) {
|
|
33531
33605
|
continue;
|
|
33532
33606
|
}
|
|
33533
33607
|
const routeCandidates = routePhraseCandidates(phrase);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdviceFrame, AdviceModality, CanonicalInstructionGraph, CanonicalSigClause, ParseOptions } from "./types";
|
|
1
|
+
import { AdviceFrame, AdviceModality, AdviceRelation, CanonicalInstructionGraph, CanonicalSigClause, ParseOptions } from "./types";
|
|
2
2
|
export declare function parseInstructionActions(sourceText: string, baseOffset?: number, options?: ParseOptions): AdviceFrame[];
|
|
3
3
|
export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph): void;
|
|
4
4
|
export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions): CanonicalInstructionGraph | undefined;
|
|
@@ -8,6 +8,7 @@ export declare function instructionGraphTextParticipatesInRelation(graph: Canoni
|
|
|
8
8
|
export declare function instructionGraphSingleActionRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
|
|
9
9
|
export declare function instructionGraphRichPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
|
|
10
10
|
export declare function instructionGraphRoundTripPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
|
|
11
|
+
export declare function instructionGraphPrimarySiteRelation(clause: CanonicalSigClause): AdviceRelation | undefined;
|
|
11
12
|
export declare function instructionGraphPrimaryAdministrationModality(clause: CanonicalSigClause): AdviceModality | undefined;
|
|
12
13
|
export declare function instructionGraphHasNovelNonWarningContent(graph: CanonicalInstructionGraph, representedTexts: readonly string[]): boolean;
|
|
13
14
|
export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph, locale?: string, options?: {
|