ezmedicationinput 0.1.61 → 0.1.62
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 +33 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -5
- package/dist/instruction-action-terminology.d.ts +1 -0
- package/dist/types.d.ts +9 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -179,6 +179,7 @@ __export(index_exports, {
|
|
|
179
179
|
resolveAdviceRelationSurface: () => resolveAdviceRelationSurface,
|
|
180
180
|
resolveMedicationInstructionAction: () => resolveMedicationInstructionAction,
|
|
181
181
|
resolveMedicationInstructionConcept: () => resolveMedicationInstructionConcept,
|
|
182
|
+
resolveMedicationInstructionSequenceAction: () => resolveMedicationInstructionSequenceAction,
|
|
182
183
|
resolveSigLocalization: () => resolveSigLocalization,
|
|
183
184
|
resolveSigTranslation: () => resolveSigTranslation,
|
|
184
185
|
resolveSymptomDefinition: () => resolveSymptomDefinition,
|
|
@@ -10817,6 +10818,9 @@ var instruction_action_terminology_default = {
|
|
|
10817
10818
|
"\u0E2B\u0E22\u0E38\u0E14",
|
|
10818
10819
|
"\u0E2B\u0E22\u0E38\u0E14\u0E43\u0E0A\u0E49"
|
|
10819
10820
|
],
|
|
10821
|
+
sequenceAliases: [
|
|
10822
|
+
"off"
|
|
10823
|
+
],
|
|
10820
10824
|
procedural: true,
|
|
10821
10825
|
safetyScopeTarget: true,
|
|
10822
10826
|
argumentParser: "duration-activity",
|
|
@@ -12401,6 +12405,7 @@ function cloneDefinition2(definition) {
|
|
|
12401
12405
|
i18n: definition.i18n ? __spreadValues({}, definition.i18n) : void 0,
|
|
12402
12406
|
roundtripI18n: definition.roundtripI18n ? __spreadValues({}, definition.roundtripI18n) : void 0,
|
|
12403
12407
|
aliases: definition.aliases ? [...definition.aliases] : void 0,
|
|
12408
|
+
sequenceAliases: definition.sequenceAliases ? [...definition.sequenceAliases] : void 0,
|
|
12404
12409
|
localeAliases: cloneLocaleAliases(definition.localeAliases),
|
|
12405
12410
|
separableAliases: (_a28 = definition.separableAliases) == null ? void 0 : _a28.map((alias) => __spreadValues({}, alias)),
|
|
12406
12411
|
procedural: definition.procedural,
|
|
@@ -12438,6 +12443,7 @@ function normalizeDefinition(sourceDefinition) {
|
|
|
12438
12443
|
i18n: sourceDefinition.i18n ? __spreadValues({}, sourceDefinition.i18n) : void 0,
|
|
12439
12444
|
roundtripI18n: sourceDefinition.roundtripI18n ? __spreadValues({}, sourceDefinition.roundtripI18n) : void 0,
|
|
12440
12445
|
aliases: sourceDefinition.aliases ? [...sourceDefinition.aliases] : void 0,
|
|
12446
|
+
sequenceAliases: sourceDefinition.sequenceAliases ? [...sourceDefinition.sequenceAliases] : void 0,
|
|
12441
12447
|
localeAliases: cloneLocaleAliases(sourceDefinition.localeAliases),
|
|
12442
12448
|
separableAliases: (_a28 = sourceDefinition.separableAliases) == null ? void 0 : _a28.map((alias) => __spreadValues({}, alias)),
|
|
12443
12449
|
procedural: sourceDefinition.procedural,
|
|
@@ -12476,6 +12482,7 @@ function normalizeCustomDefinition(surface, input) {
|
|
|
12476
12482
|
i18n: input.i18n ? __spreadValues({}, input.i18n) : void 0,
|
|
12477
12483
|
roundtripI18n: input.roundtripI18n ? __spreadValues({}, input.roundtripI18n) : void 0,
|
|
12478
12484
|
aliases: Array.from(/* @__PURE__ */ new Set([surface, ...(_d2 = input.aliases) != null ? _d2 : []])),
|
|
12485
|
+
sequenceAliases: input.sequenceAliases ? [...input.sequenceAliases] : void 0,
|
|
12479
12486
|
localeAliases: cloneLocaleAliases(input.localeAliases),
|
|
12480
12487
|
separableAliases: (_e2 = input.separableAliases) == null ? void 0 : _e2.map((alias) => __spreadValues({}, alias)),
|
|
12481
12488
|
procedural: (_f2 = input.procedural) != null ? _f2 : true,
|
|
@@ -12523,6 +12530,25 @@ function customDefinitionForSurface(surface, options) {
|
|
|
12523
12530
|
}
|
|
12524
12531
|
return void 0;
|
|
12525
12532
|
}
|
|
12533
|
+
function resolveMedicationInstructionSequenceAction(surface, options) {
|
|
12534
|
+
var _a28, _b4;
|
|
12535
|
+
const target = normalizeActionSurface(surface);
|
|
12536
|
+
const map = options == null ? void 0 : options.instructionActionMap;
|
|
12537
|
+
if (map) {
|
|
12538
|
+
for (const configuredSurface of Object.keys(map)) {
|
|
12539
|
+
const input = map[configuredSurface];
|
|
12540
|
+
if (((_a28 = input.sequenceAliases) != null ? _a28 : []).some((alias) => normalizeActionSurface(alias) === target)) {
|
|
12541
|
+
return normalizeCustomDefinition(configuredSurface, input);
|
|
12542
|
+
}
|
|
12543
|
+
}
|
|
12544
|
+
}
|
|
12545
|
+
for (const definition of DEFAULT_ACTIONS) {
|
|
12546
|
+
if (((_b4 = definition.sequenceAliases) != null ? _b4 : []).some((alias) => normalizeActionSurface(alias) === target)) {
|
|
12547
|
+
return cloneDefinition2(definition);
|
|
12548
|
+
}
|
|
12549
|
+
}
|
|
12550
|
+
return void 0;
|
|
12551
|
+
}
|
|
12526
12552
|
function resolveMedicationInstructionSeparableAction(lead, particle, options) {
|
|
12527
12553
|
var _a28, _b4;
|
|
12528
12554
|
const normalizedLead = normalizeActionSurface(lead);
|
|
@@ -17918,7 +17944,7 @@ function actionCandidateIsPerPeriodGrammar(parts, index) {
|
|
|
17918
17944
|
);
|
|
17919
17945
|
}
|
|
17920
17946
|
function actionMatchAt(parts, index, options) {
|
|
17921
|
-
var _a28;
|
|
17947
|
+
var _a28, _b4;
|
|
17922
17948
|
const current = parts[index];
|
|
17923
17949
|
const next = parts[index + 1];
|
|
17924
17950
|
if (actionCandidateIsPerPeriodGrammar(parts, index)) return void 0;
|
|
@@ -17930,10 +17956,10 @@ function actionMatchAt(parts, index, options) {
|
|
|
17930
17956
|
const maxSpan = Math.min(4, parts.length - index);
|
|
17931
17957
|
for (let length = maxSpan; length >= 1; length -= 1) {
|
|
17932
17958
|
for (const candidate of actionPhraseCandidates(parts, index, length)) {
|
|
17933
|
-
const definition = resolveMedicationInstructionAction(candidate, options);
|
|
17959
|
+
const definition = previous && ACTION_SEQUENCE_MARKERS.has(key(previous)) ? (_a28 = resolveMedicationInstructionSequenceAction(candidate, options)) != null ? _a28 : resolveMedicationInstructionAction(candidate, options) : resolveMedicationInstructionAction(candidate, options);
|
|
17934
17960
|
if (definition) {
|
|
17935
17961
|
const first = parts[index];
|
|
17936
|
-
const actionLocale = first ? (
|
|
17962
|
+
const actionLocale = first ? (_b4 = baseLanguageTag(options == null ? void 0 : options.locale)) != null ? _b4 : inferMedicationLocale(first.original, "en") : "en";
|
|
17937
17963
|
if (first && methodAuxiliaryVerbsForLocale(actionLocale).has(definition.code)) {
|
|
17938
17964
|
const next2 = parts[index + length];
|
|
17939
17965
|
const nextDefinition = next2 ? resolveMedicationInstructionAction(key(next2), options) : void 0;
|
|
@@ -34884,7 +34910,8 @@ function replaceWhen(state, values) {
|
|
|
34884
34910
|
}
|
|
34885
34911
|
function applySmartMealExpansion(state, options) {
|
|
34886
34912
|
const effectiveOptions = options != null ? options : {};
|
|
34887
|
-
|
|
34913
|
+
const mealExpansion = options == null ? void 0 : options.smartMealExpansion;
|
|
34914
|
+
if (!mealExpansion || !smartMealExpansionAllowed(state, options)) {
|
|
34888
34915
|
replaceWhen(
|
|
34889
34916
|
state,
|
|
34890
34917
|
sortWhenCodes(
|
|
@@ -34908,7 +34935,7 @@ function applySmartMealExpansion(state, options) {
|
|
|
34908
34935
|
...expanded
|
|
34909
34936
|
];
|
|
34910
34937
|
}
|
|
34911
|
-
} else if (!when.length && dailyCadence) {
|
|
34938
|
+
} else if (!when.length && dailyCadence && mealExpansion !== "explicit") {
|
|
34912
34939
|
const expanded = expandRelationByFrequency(relationForContext(options), state.frequency, options);
|
|
34913
34940
|
if (expanded) {
|
|
34914
34941
|
when = expanded;
|
|
@@ -41159,6 +41186,7 @@ function resolvePrimaryLintResult(results, input, options) {
|
|
|
41159
41186
|
resolveAdviceRelationSurface,
|
|
41160
41187
|
resolveMedicationInstructionAction,
|
|
41161
41188
|
resolveMedicationInstructionConcept,
|
|
41189
|
+
resolveMedicationInstructionSequenceAction,
|
|
41162
41190
|
resolveSigLocalization,
|
|
41163
41191
|
resolveSigTranslation,
|
|
41164
41192
|
resolveSymptomDefinition,
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { listMedicationSurfaceSegmenters, registerIntlMedicationSurfaceSegmenter
|
|
|
14
14
|
export type { MedicationSurfaceSegment, MedicationSurfaceSegmenter } from "./lexer/surface-segmenter";
|
|
15
15
|
export { getSuggestLocaleAdapter, registerSuggestLocaleAdapter } from "./suggest-locale-adapter";
|
|
16
16
|
export type { SuggestLocaleAdapter, SuggestLocaleLexemeResolver, SuggestLocaleUnitRoutePair } from "./suggest-locale-adapter";
|
|
17
|
-
export { MEDICATION_INSTRUCTION_ACTION_SYSTEM, buildMedicationInstructionActionCodeSystem, getMedicationInstructionAction, listMedicationInstructionActions, resolveMedicationInstructionAction } from "./instruction-action-terminology";
|
|
17
|
+
export { MEDICATION_INSTRUCTION_ACTION_SYSTEM, buildMedicationInstructionActionCodeSystem, getMedicationInstructionAction, listMedicationInstructionActions, resolveMedicationInstructionAction, resolveMedicationInstructionSequenceAction } from "./instruction-action-terminology";
|
|
18
18
|
export type { MedicationInstructionActionCodeSystem } from "./instruction-action-terminology";
|
|
19
19
|
export { MEDICATION_INSTRUCTION_CONCEPT_SYSTEM, buildMedicationInstructionConceptCodeSystem, getMedicationInstructionConcept, listMedicationInstructionConcepts, resolveMedicationInstructionConcept } from "./instruction-concept-terminology";
|
|
20
20
|
export type { MedicationInstructionConceptCodeSystem } from "./instruction-concept-terminology";
|
package/dist/index.js
CHANGED
|
@@ -10667,6 +10667,9 @@ var instruction_action_terminology_default = {
|
|
|
10667
10667
|
"\u0E2B\u0E22\u0E38\u0E14",
|
|
10668
10668
|
"\u0E2B\u0E22\u0E38\u0E14\u0E43\u0E0A\u0E49"
|
|
10669
10669
|
],
|
|
10670
|
+
sequenceAliases: [
|
|
10671
|
+
"off"
|
|
10672
|
+
],
|
|
10670
10673
|
procedural: true,
|
|
10671
10674
|
safetyScopeTarget: true,
|
|
10672
10675
|
argumentParser: "duration-activity",
|
|
@@ -12251,6 +12254,7 @@ function cloneDefinition2(definition) {
|
|
|
12251
12254
|
i18n: definition.i18n ? __spreadValues({}, definition.i18n) : void 0,
|
|
12252
12255
|
roundtripI18n: definition.roundtripI18n ? __spreadValues({}, definition.roundtripI18n) : void 0,
|
|
12253
12256
|
aliases: definition.aliases ? [...definition.aliases] : void 0,
|
|
12257
|
+
sequenceAliases: definition.sequenceAliases ? [...definition.sequenceAliases] : void 0,
|
|
12254
12258
|
localeAliases: cloneLocaleAliases(definition.localeAliases),
|
|
12255
12259
|
separableAliases: (_a28 = definition.separableAliases) == null ? void 0 : _a28.map((alias) => __spreadValues({}, alias)),
|
|
12256
12260
|
procedural: definition.procedural,
|
|
@@ -12288,6 +12292,7 @@ function normalizeDefinition(sourceDefinition) {
|
|
|
12288
12292
|
i18n: sourceDefinition.i18n ? __spreadValues({}, sourceDefinition.i18n) : void 0,
|
|
12289
12293
|
roundtripI18n: sourceDefinition.roundtripI18n ? __spreadValues({}, sourceDefinition.roundtripI18n) : void 0,
|
|
12290
12294
|
aliases: sourceDefinition.aliases ? [...sourceDefinition.aliases] : void 0,
|
|
12295
|
+
sequenceAliases: sourceDefinition.sequenceAliases ? [...sourceDefinition.sequenceAliases] : void 0,
|
|
12291
12296
|
localeAliases: cloneLocaleAliases(sourceDefinition.localeAliases),
|
|
12292
12297
|
separableAliases: (_a28 = sourceDefinition.separableAliases) == null ? void 0 : _a28.map((alias) => __spreadValues({}, alias)),
|
|
12293
12298
|
procedural: sourceDefinition.procedural,
|
|
@@ -12326,6 +12331,7 @@ function normalizeCustomDefinition(surface, input) {
|
|
|
12326
12331
|
i18n: input.i18n ? __spreadValues({}, input.i18n) : void 0,
|
|
12327
12332
|
roundtripI18n: input.roundtripI18n ? __spreadValues({}, input.roundtripI18n) : void 0,
|
|
12328
12333
|
aliases: Array.from(/* @__PURE__ */ new Set([surface, ...(_d2 = input.aliases) != null ? _d2 : []])),
|
|
12334
|
+
sequenceAliases: input.sequenceAliases ? [...input.sequenceAliases] : void 0,
|
|
12329
12335
|
localeAliases: cloneLocaleAliases(input.localeAliases),
|
|
12330
12336
|
separableAliases: (_e2 = input.separableAliases) == null ? void 0 : _e2.map((alias) => __spreadValues({}, alias)),
|
|
12331
12337
|
procedural: (_f2 = input.procedural) != null ? _f2 : true,
|
|
@@ -12373,6 +12379,25 @@ function customDefinitionForSurface(surface, options) {
|
|
|
12373
12379
|
}
|
|
12374
12380
|
return void 0;
|
|
12375
12381
|
}
|
|
12382
|
+
function resolveMedicationInstructionSequenceAction(surface, options) {
|
|
12383
|
+
var _a28, _b4;
|
|
12384
|
+
const target = normalizeActionSurface(surface);
|
|
12385
|
+
const map = options == null ? void 0 : options.instructionActionMap;
|
|
12386
|
+
if (map) {
|
|
12387
|
+
for (const configuredSurface of Object.keys(map)) {
|
|
12388
|
+
const input = map[configuredSurface];
|
|
12389
|
+
if (((_a28 = input.sequenceAliases) != null ? _a28 : []).some((alias) => normalizeActionSurface(alias) === target)) {
|
|
12390
|
+
return normalizeCustomDefinition(configuredSurface, input);
|
|
12391
|
+
}
|
|
12392
|
+
}
|
|
12393
|
+
}
|
|
12394
|
+
for (const definition of DEFAULT_ACTIONS) {
|
|
12395
|
+
if (((_b4 = definition.sequenceAliases) != null ? _b4 : []).some((alias) => normalizeActionSurface(alias) === target)) {
|
|
12396
|
+
return cloneDefinition2(definition);
|
|
12397
|
+
}
|
|
12398
|
+
}
|
|
12399
|
+
return void 0;
|
|
12400
|
+
}
|
|
12376
12401
|
function resolveMedicationInstructionSeparableAction(lead, particle, options) {
|
|
12377
12402
|
var _a28, _b4;
|
|
12378
12403
|
const normalizedLead = normalizeActionSurface(lead);
|
|
@@ -17768,7 +17793,7 @@ function actionCandidateIsPerPeriodGrammar(parts, index) {
|
|
|
17768
17793
|
);
|
|
17769
17794
|
}
|
|
17770
17795
|
function actionMatchAt(parts, index, options) {
|
|
17771
|
-
var _a28;
|
|
17796
|
+
var _a28, _b4;
|
|
17772
17797
|
const current = parts[index];
|
|
17773
17798
|
const next = parts[index + 1];
|
|
17774
17799
|
if (actionCandidateIsPerPeriodGrammar(parts, index)) return void 0;
|
|
@@ -17780,10 +17805,10 @@ function actionMatchAt(parts, index, options) {
|
|
|
17780
17805
|
const maxSpan = Math.min(4, parts.length - index);
|
|
17781
17806
|
for (let length = maxSpan; length >= 1; length -= 1) {
|
|
17782
17807
|
for (const candidate of actionPhraseCandidates(parts, index, length)) {
|
|
17783
|
-
const definition = resolveMedicationInstructionAction(candidate, options);
|
|
17808
|
+
const definition = previous && ACTION_SEQUENCE_MARKERS.has(key(previous)) ? (_a28 = resolveMedicationInstructionSequenceAction(candidate, options)) != null ? _a28 : resolveMedicationInstructionAction(candidate, options) : resolveMedicationInstructionAction(candidate, options);
|
|
17784
17809
|
if (definition) {
|
|
17785
17810
|
const first = parts[index];
|
|
17786
|
-
const actionLocale = first ? (
|
|
17811
|
+
const actionLocale = first ? (_b4 = baseLanguageTag(options == null ? void 0 : options.locale)) != null ? _b4 : inferMedicationLocale(first.original, "en") : "en";
|
|
17787
17812
|
if (first && methodAuxiliaryVerbsForLocale(actionLocale).has(definition.code)) {
|
|
17788
17813
|
const next2 = parts[index + length];
|
|
17789
17814
|
const nextDefinition = next2 ? resolveMedicationInstructionAction(key(next2), options) : void 0;
|
|
@@ -34734,7 +34759,8 @@ function replaceWhen(state, values) {
|
|
|
34734
34759
|
}
|
|
34735
34760
|
function applySmartMealExpansion(state, options) {
|
|
34736
34761
|
const effectiveOptions = options != null ? options : {};
|
|
34737
|
-
|
|
34762
|
+
const mealExpansion = options == null ? void 0 : options.smartMealExpansion;
|
|
34763
|
+
if (!mealExpansion || !smartMealExpansionAllowed(state, options)) {
|
|
34738
34764
|
replaceWhen(
|
|
34739
34765
|
state,
|
|
34740
34766
|
sortWhenCodes(
|
|
@@ -34758,7 +34784,7 @@ function applySmartMealExpansion(state, options) {
|
|
|
34758
34784
|
...expanded
|
|
34759
34785
|
];
|
|
34760
34786
|
}
|
|
34761
|
-
} else if (!when.length && dailyCadence) {
|
|
34787
|
+
} else if (!when.length && dailyCadence && mealExpansion !== "explicit") {
|
|
34762
34788
|
const expanded = expandRelationByFrequency(relationForContext(options), state.frequency, options);
|
|
34763
34789
|
if (expanded) {
|
|
34764
34790
|
when = expanded;
|
|
@@ -41008,6 +41034,7 @@ export {
|
|
|
41008
41034
|
resolveAdviceRelationSurface,
|
|
41009
41035
|
resolveMedicationInstructionAction,
|
|
41010
41036
|
resolveMedicationInstructionConcept,
|
|
41037
|
+
resolveMedicationInstructionSequenceAction,
|
|
41011
41038
|
resolveSigLocalization,
|
|
41012
41039
|
resolveSigTranslation,
|
|
41013
41040
|
resolveSymptomDefinition,
|
|
@@ -21,6 +21,7 @@ export interface MedicationInstructionActionCodeSystem {
|
|
|
21
21
|
export declare function normalizeActionSurface(value: string): string;
|
|
22
22
|
export declare function cloneMedicationInstructionActionRealizerConfig(config: MedicationInstructionActionDefinition["realizerConfig"]): MedicationInstructionActionDefinition["realizerConfig"];
|
|
23
23
|
export declare function medicationInstructionActionLocaleRealizerConfig(config: MedicationInstructionActionDefinition["realizerConfig"], locale: string): import("./types").MedicationInstructionActionLocaleRealizerConfig | undefined;
|
|
24
|
+
export declare function resolveMedicationInstructionSequenceAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
|
|
24
25
|
export declare function resolveMedicationInstructionSeparableAction(lead: string, particle: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
|
|
25
26
|
export declare function medicationInstructionActionIsSafetyScopeTarget(surface: string, options?: ParseOptions): boolean;
|
|
26
27
|
export declare function resolveMedicationInstructionAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -722,6 +722,8 @@ export interface MedicationInstructionActionDefinition {
|
|
|
722
722
|
roundtripI18n?: Record<string, string>;
|
|
723
723
|
/** Surface forms that should resolve to this action. */
|
|
724
724
|
aliases?: string[];
|
|
725
|
+
/** Surface forms licensed only when immediately sequence-scoped (e.g. `then off`). */
|
|
726
|
+
sequenceAliases?: string[];
|
|
725
727
|
/** Locale-specific parser lexemes. Display translation belongs in `i18n`; parsing aliases are explicit. */
|
|
726
728
|
localeAliases?: Record<string, string[]>;
|
|
727
729
|
/** Discontinuous surface forms such as Thai `เอา X ออก` (remove X). */
|
|
@@ -879,13 +881,14 @@ export interface ParseOptions extends FormatOptions {
|
|
|
879
881
|
*/
|
|
880
882
|
assumeSingleDiscreteDose?: boolean;
|
|
881
883
|
/**
|
|
882
|
-
* Enables inferring with-meal timings
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
* `context.mealRelation` when
|
|
884
|
+
* Enables inferring with-meal timings. `true` and `"cadence"` preserve the
|
|
885
|
+
* legacy behavior: explicit meal abbreviations (AC/PC/C) and cadence-only
|
|
886
|
+
* instructions may expand into breakfast/lunch/dinner/(bedtime). `"explicit"`
|
|
887
|
+
* expands only explicit generic meal timing and never invents meal anchors
|
|
888
|
+
* from cadence alone. Works with `context.mealRelation` when cadence expansion
|
|
889
|
+
* is enabled.
|
|
887
890
|
*/
|
|
888
|
-
smartMealExpansion?: boolean;
|
|
891
|
+
smartMealExpansion?: boolean | "explicit" | "cadence";
|
|
889
892
|
/**
|
|
890
893
|
* Optional route/dosage-form policy overrides for smart meal expansion.
|
|
891
894
|
* When omitted, the parser uses its built-in default heuristic.
|