ezmedicationinput 0.1.60 → 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 +68 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +67 -13
- 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;
|
|
@@ -36590,7 +36617,7 @@ function normalizeSegmentLexeme(item) {
|
|
|
36590
36617
|
var _a28;
|
|
36591
36618
|
return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
|
|
36592
36619
|
}
|
|
36593
|
-
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
|
|
36620
|
+
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
|
|
36594
36621
|
var _a28;
|
|
36595
36622
|
const connector = tokens[connectorIndex];
|
|
36596
36623
|
const first = tokens[connectorIndex + 1];
|
|
@@ -36609,7 +36636,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
|
|
|
36609
36636
|
const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
|
|
36610
36637
|
if (!prefixText) return false;
|
|
36611
36638
|
const prefix = parseClauseState(prefixText, options);
|
|
36612
|
-
if (!hasAdministrationHead(prefix))
|
|
36639
|
+
if (!hasAdministrationHead(prefix)) {
|
|
36640
|
+
if (!inheritedAdministrationHead) return false;
|
|
36641
|
+
if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
|
|
36642
|
+
}
|
|
36613
36643
|
if (connectorLower === "then") return true;
|
|
36614
36644
|
const prefixSchedule = prefix.primaryClause.schedule;
|
|
36615
36645
|
return Boolean(
|
|
@@ -36695,6 +36725,7 @@ function parseSigSegments(input, options) {
|
|
|
36695
36725
|
const proceduralActions = parseInstructionActions(input, 0, options);
|
|
36696
36726
|
const segments = [];
|
|
36697
36727
|
let start = 0;
|
|
36728
|
+
let inheritedAdministrationContinuation = false;
|
|
36698
36729
|
let parenDepth = 0;
|
|
36699
36730
|
let scannedOffset = 0;
|
|
36700
36731
|
const scanParens = (end) => {
|
|
@@ -36726,18 +36757,40 @@ function parseSigSegments(input, options) {
|
|
|
36726
36757
|
}
|
|
36727
36758
|
const nextToken = tokens[index + 1];
|
|
36728
36759
|
if (token.original === "," && nextToken) {
|
|
36729
|
-
|
|
36760
|
+
const scheduleContinuation = scheduleOnlyAdministrationContinuation(
|
|
36761
|
+
input,
|
|
36762
|
+
tokens,
|
|
36763
|
+
index + 1,
|
|
36764
|
+
start,
|
|
36765
|
+
options,
|
|
36766
|
+
inheritedAdministrationContinuation
|
|
36767
|
+
);
|
|
36768
|
+
const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index + 1, start, options);
|
|
36769
|
+
if (scheduleContinuation || doseContinuation) {
|
|
36730
36770
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36731
36771
|
start = nextToken.sourceEnd;
|
|
36772
|
+
inheritedAdministrationContinuation = true;
|
|
36732
36773
|
index += 1;
|
|
36733
36774
|
scannedOffset = nextToken.sourceEnd;
|
|
36734
36775
|
continue;
|
|
36735
36776
|
}
|
|
36736
|
-
} else
|
|
36737
|
-
|
|
36738
|
-
|
|
36739
|
-
|
|
36740
|
-
|
|
36777
|
+
} else {
|
|
36778
|
+
const scheduleContinuation = scheduleOnlyAdministrationContinuation(
|
|
36779
|
+
input,
|
|
36780
|
+
tokens,
|
|
36781
|
+
index,
|
|
36782
|
+
start,
|
|
36783
|
+
options,
|
|
36784
|
+
inheritedAdministrationContinuation
|
|
36785
|
+
);
|
|
36786
|
+
const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index, start, options);
|
|
36787
|
+
if (scheduleContinuation || doseContinuation) {
|
|
36788
|
+
pushSegment(segments, input, start, token.sourceStart);
|
|
36789
|
+
start = token.sourceEnd;
|
|
36790
|
+
inheritedAdministrationContinuation = true;
|
|
36791
|
+
scannedOffset = token.sourceEnd;
|
|
36792
|
+
continue;
|
|
36793
|
+
}
|
|
36741
36794
|
}
|
|
36742
36795
|
const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
|
|
36743
36796
|
if (!isBoundary) {
|
|
@@ -36746,6 +36799,7 @@ function parseSigSegments(input, options) {
|
|
|
36746
36799
|
}
|
|
36747
36800
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36748
36801
|
start = token.sourceEnd;
|
|
36802
|
+
inheritedAdministrationContinuation = false;
|
|
36749
36803
|
scannedOffset = token.sourceEnd;
|
|
36750
36804
|
}
|
|
36751
36805
|
pushSegment(segments, input, start, input.length);
|
|
@@ -41132,6 +41186,7 @@ function resolvePrimaryLintResult(results, input, options) {
|
|
|
41132
41186
|
resolveAdviceRelationSurface,
|
|
41133
41187
|
resolveMedicationInstructionAction,
|
|
41134
41188
|
resolveMedicationInstructionConcept,
|
|
41189
|
+
resolveMedicationInstructionSequenceAction,
|
|
41135
41190
|
resolveSigLocalization,
|
|
41136
41191
|
resolveSigTranslation,
|
|
41137
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;
|
|
@@ -36440,7 +36466,7 @@ function normalizeSegmentLexeme(item) {
|
|
|
36440
36466
|
var _a28;
|
|
36441
36467
|
return ((_a28 = item.canonical) != null ? _a28 : item.lower).replace(/^[.,;:]+|[.,;:]+$/g, "");
|
|
36442
36468
|
}
|
|
36443
|
-
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options) {
|
|
36469
|
+
function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, segmentStart, options, inheritedAdministrationHead = false) {
|
|
36444
36470
|
var _a28;
|
|
36445
36471
|
const connector = tokens[connectorIndex];
|
|
36446
36472
|
const first = tokens[connectorIndex + 1];
|
|
@@ -36459,7 +36485,10 @@ function scheduleOnlyAdministrationContinuation(input, tokens, connectorIndex, s
|
|
|
36459
36485
|
const prefixText = input.slice(segmentStart, connector.sourceStart).replace(/[,;]\s*$/u, "").trim();
|
|
36460
36486
|
if (!prefixText) return false;
|
|
36461
36487
|
const prefix = parseClauseState(prefixText, options);
|
|
36462
|
-
if (!hasAdministrationHead(prefix))
|
|
36488
|
+
if (!hasAdministrationHead(prefix)) {
|
|
36489
|
+
if (!inheritedAdministrationHead) return false;
|
|
36490
|
+
if (findUnparsedTokenGroups(prefix).length || !hasMeaningfulSchedule(prefix)) return false;
|
|
36491
|
+
}
|
|
36463
36492
|
if (connectorLower === "then") return true;
|
|
36464
36493
|
const prefixSchedule = prefix.primaryClause.schedule;
|
|
36465
36494
|
return Boolean(
|
|
@@ -36545,6 +36574,7 @@ function parseSigSegments(input, options) {
|
|
|
36545
36574
|
const proceduralActions = parseInstructionActions(input, 0, options);
|
|
36546
36575
|
const segments = [];
|
|
36547
36576
|
let start = 0;
|
|
36577
|
+
let inheritedAdministrationContinuation = false;
|
|
36548
36578
|
let parenDepth = 0;
|
|
36549
36579
|
let scannedOffset = 0;
|
|
36550
36580
|
const scanParens = (end) => {
|
|
@@ -36576,18 +36606,40 @@ function parseSigSegments(input, options) {
|
|
|
36576
36606
|
}
|
|
36577
36607
|
const nextToken = tokens[index + 1];
|
|
36578
36608
|
if (token.original === "," && nextToken) {
|
|
36579
|
-
|
|
36609
|
+
const scheduleContinuation = scheduleOnlyAdministrationContinuation(
|
|
36610
|
+
input,
|
|
36611
|
+
tokens,
|
|
36612
|
+
index + 1,
|
|
36613
|
+
start,
|
|
36614
|
+
options,
|
|
36615
|
+
inheritedAdministrationContinuation
|
|
36616
|
+
);
|
|
36617
|
+
const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index + 1, start, options);
|
|
36618
|
+
if (scheduleContinuation || doseContinuation) {
|
|
36580
36619
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36581
36620
|
start = nextToken.sourceEnd;
|
|
36621
|
+
inheritedAdministrationContinuation = true;
|
|
36582
36622
|
index += 1;
|
|
36583
36623
|
scannedOffset = nextToken.sourceEnd;
|
|
36584
36624
|
continue;
|
|
36585
36625
|
}
|
|
36586
|
-
} else
|
|
36587
|
-
|
|
36588
|
-
|
|
36589
|
-
|
|
36590
|
-
|
|
36626
|
+
} else {
|
|
36627
|
+
const scheduleContinuation = scheduleOnlyAdministrationContinuation(
|
|
36628
|
+
input,
|
|
36629
|
+
tokens,
|
|
36630
|
+
index,
|
|
36631
|
+
start,
|
|
36632
|
+
options,
|
|
36633
|
+
inheritedAdministrationContinuation
|
|
36634
|
+
);
|
|
36635
|
+
const doseContinuation = !scheduleContinuation && doseBearingAdministrationContinuation(input, tokens, index, start, options);
|
|
36636
|
+
if (scheduleContinuation || doseContinuation) {
|
|
36637
|
+
pushSegment(segments, input, start, token.sourceStart);
|
|
36638
|
+
start = token.sourceEnd;
|
|
36639
|
+
inheritedAdministrationContinuation = true;
|
|
36640
|
+
scannedOffset = token.sourceEnd;
|
|
36641
|
+
continue;
|
|
36642
|
+
}
|
|
36591
36643
|
}
|
|
36592
36644
|
const isBoundary = isBoundaryToken(token) || isCommaClauseBoundary(input, tokens, index, proceduralActions, options, start) || isSlashClauseBoundary(tokens, index);
|
|
36593
36645
|
if (!isBoundary) {
|
|
@@ -36596,6 +36648,7 @@ function parseSigSegments(input, options) {
|
|
|
36596
36648
|
}
|
|
36597
36649
|
pushSegment(segments, input, start, token.sourceStart);
|
|
36598
36650
|
start = token.sourceEnd;
|
|
36651
|
+
inheritedAdministrationContinuation = false;
|
|
36599
36652
|
scannedOffset = token.sourceEnd;
|
|
36600
36653
|
}
|
|
36601
36654
|
pushSegment(segments, input, start, input.length);
|
|
@@ -40981,6 +41034,7 @@ export {
|
|
|
40981
41034
|
resolveAdviceRelationSurface,
|
|
40982
41035
|
resolveMedicationInstructionAction,
|
|
40983
41036
|
resolveMedicationInstructionConcept,
|
|
41037
|
+
resolveMedicationInstructionSequenceAction,
|
|
40984
41038
|
resolveSigLocalization,
|
|
40985
41039
|
resolveSigTranslation,
|
|
40986
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.
|