ezmedicationinput 0.1.66 → 0.2.0
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/README.md +25 -22
- package/dist/advice.d.ts +20 -0
- package/dist/body-site-grammar.d.ts +34 -1
- package/dist/date-interpretation.d.ts +2 -0
- package/dist/dosage-course.d.ts +188 -0
- package/dist/fhir.d.ts +144 -9
- package/dist/format.d.ts +9 -1
- package/dist/hpsg/constructions.d.ts +105 -0
- package/dist/hpsg/lexical-classes.d.ts +170 -1
- package/dist/hpsg/procedural-context.d.ts +15 -1
- package/dist/hpsg/projection.d.ts +10 -2
- package/dist/hpsg/rule-context.d.ts +13 -0
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +9 -0
- package/dist/hpsg/rules/condition-rules.d.ts +15 -0
- package/dist/hpsg/rules/core-rules.d.ts +29 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +9 -1
- package/dist/hpsg/rules/timing-rules.d.ts +121 -7
- package/dist/hpsg/signature.d.ts +342 -4
- package/dist/hpsg/type-system.d.ts +16 -1
- package/dist/hpsg/unification.d.ts +1 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/index.cjs +48961 -31422
- package/dist/index.d.ts +21 -5
- package/dist/index.js +48936 -31421
- package/dist/instruction-action-locale-adapter.d.ts +1 -0
- package/dist/instruction-action-terminology.d.ts +16 -1
- package/dist/instruction-concept-terminology.d.ts +1 -1
- package/dist/instruction-graph-fhir.d.ts +1 -1
- package/dist/instruction-graph.d.ts +38 -2
- package/dist/ir.d.ts +12 -1
- package/dist/maps.d.ts +15 -0
- package/dist/medication-condition.d.ts +42 -0
- package/dist/parser-state.d.ts +5 -1
- package/dist/parser.d.ts +5 -2
- package/dist/regimen/coordination-scope.d.ts +53 -0
- package/dist/regimen/grammar.d.ts +68 -0
- package/dist/regimen/parallel-course.d.ts +85 -0
- package/dist/regimen/planner.d.ts +19 -0
- package/dist/regimen/regimen.d.ts +66 -0
- package/dist/schedule.d.ts +9 -6
- package/dist/stable-structure.d.ts +23 -1
- package/dist/types.d.ts +433 -28
- package/dist/utils/strength.d.ts +16 -0
- package/package.json +11 -3
|
@@ -1,6 +1,111 @@
|
|
|
1
|
+
import type { Token } from "../parser-state";
|
|
2
|
+
import type { MedicationCondition } from "../types";
|
|
3
|
+
import { AdviceArgumentRole, type AdviceArgument, type AdviceFrame } from "../types";
|
|
1
4
|
import type { HpsgConstruction, HpsgSign, HpsgType } from "./signature";
|
|
5
|
+
import type { BoundaryRelation, CoordinationScopeFacts, RegimenSemanticSelection } from "./signature";
|
|
2
6
|
export interface HpsgConstructionSelection {
|
|
3
7
|
motherType: HpsgType;
|
|
4
8
|
construction: HpsgConstruction;
|
|
5
9
|
}
|
|
10
|
+
export interface HpsgCoordinationScopeSelection extends HpsgConstructionSelection {
|
|
11
|
+
semantic: RegimenSemanticSelection;
|
|
12
|
+
}
|
|
13
|
+
/** Typed daughter facts for one administration with coordinated timing anchors. */
|
|
14
|
+
export interface HpsgTimingAnchorCoordinationFacts {
|
|
15
|
+
relation?: BoundaryRelation;
|
|
16
|
+
sameSourceExpansion: boolean;
|
|
17
|
+
adjacent: boolean;
|
|
18
|
+
leftComplete: boolean;
|
|
19
|
+
rightComplete: boolean;
|
|
20
|
+
sameAdministration: boolean;
|
|
21
|
+
compatibleMethod: boolean;
|
|
22
|
+
leftHasMethod: boolean;
|
|
23
|
+
rightHasMethod: boolean;
|
|
24
|
+
leftAnchorOnly: boolean;
|
|
25
|
+
rightAnchorOnly: boolean;
|
|
26
|
+
sameScheduleContext: boolean;
|
|
27
|
+
addsAnchor: boolean;
|
|
28
|
+
/** The left event is already the first equal-dose occurrence of the right interval. */
|
|
29
|
+
originOfRightInterval?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface HpsgTimingAnchorCoordinationSelection extends HpsgConstructionSelection {
|
|
32
|
+
id: "hpsg.cx.regimen.coordinated-timing-anchors" | "hpsg.cx.regimen.interval-origin";
|
|
33
|
+
scheduleComposition: "union-anchors" | "right-interval";
|
|
34
|
+
}
|
|
6
35
|
export declare function selectHpsgConstruction(left: HpsgSign, right: HpsgSign): HpsgConstructionSelection | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Select a construction over two already chart-parsed administration clauses.
|
|
38
|
+
* This is the cross-clause counterpart of `selectHpsgConstruction`: the chart
|
|
39
|
+
* daughters retain their own dose/site values while the licensed adjunct
|
|
40
|
+
* daughter scopes over the coordinated phrase. An alternative has no head:
|
|
41
|
+
* neither daughter is privileged as the executable administration.
|
|
42
|
+
*/
|
|
43
|
+
export declare function selectHpsgCoordinationScopeConstruction(facts: CoordinationScopeFacts): HpsgCoordinationScopeSelection | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* License two complete administration daughters as one dosage with coordinated
|
|
46
|
+
* timing anchors. Sequence and alternative relations remain separate phases;
|
|
47
|
+
* a meal-dash expansion is already one source construction and needs no
|
|
48
|
+
* surface connector relation.
|
|
49
|
+
*/
|
|
50
|
+
export declare function selectHpsgTimingAnchorCoordinationConstruction(facts: HpsgTimingAnchorCoordinationFacts): HpsgTimingAnchorCoordinationSelection | undefined;
|
|
51
|
+
/** Source-typed calendar alternatives can omit a shared clock and head. */
|
|
52
|
+
export interface HpsgCalendarClockEllipsisFacts {
|
|
53
|
+
relation: BoundaryRelation;
|
|
54
|
+
adjacent: boolean;
|
|
55
|
+
calendarAlternatives: boolean;
|
|
56
|
+
compatibleAdministration: boolean;
|
|
57
|
+
omittedHead: boolean;
|
|
58
|
+
omittedClock: boolean;
|
|
59
|
+
/** Every antecedent contributes its clock; absence or disagreement blocks binding. */
|
|
60
|
+
donorClocks: readonly (string | undefined)[];
|
|
61
|
+
}
|
|
62
|
+
export declare function selectHpsgCalendarClockEllipsisConstruction(facts: HpsgCalendarClockEllipsisFacts): (HpsgConstructionSelection & {
|
|
63
|
+
id: string;
|
|
64
|
+
timeOfDay: string[];
|
|
65
|
+
}) | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* A shared directive scopes over coordinated action daughters. An explicit
|
|
68
|
+
* directive on the right starts its own scope; sequencing is not coordination.
|
|
69
|
+
* A trailing duration is an adjunct of the coordinated prohibition, not a
|
|
70
|
+
* medication-course bound. This construction consumes typed action meaning.
|
|
71
|
+
*/
|
|
72
|
+
export declare function composeCoordinatedActionDirective(left: AdviceFrame, right: AdviceFrame, coordination: "conjunction" | "disjunction" | "unknown", explicitRightDirective: boolean): readonly [AdviceFrame, AdviceFrame];
|
|
73
|
+
/** A contact clause licenses a preposed physical theme, as in a directive
|
|
74
|
+
* preventing a bottle tip from touching the eye. A nominal and contact head
|
|
75
|
+
* are required; the causative marker cannot turn an ordinary GIVE into this
|
|
76
|
+
* construction or spread negation to an unrelated following action.
|
|
77
|
+
*/
|
|
78
|
+
export declare function licensesPreposedContactTheme(role: AdviceArgumentRole, semanticClass?: string): boolean;
|
|
79
|
+
/** Compose the two contact participants under their existing directive scope. */
|
|
80
|
+
export declare function composePreposedContactTheme(frame: AdviceFrame, theme: AdviceArgument): AdviceFrame;
|
|
81
|
+
export interface ParsedMedicationGuard {
|
|
82
|
+
condition: MedicationCondition;
|
|
83
|
+
start: number;
|
|
84
|
+
markerEnd: number;
|
|
85
|
+
end: number;
|
|
86
|
+
text: string;
|
|
87
|
+
otherwiseHold: boolean;
|
|
88
|
+
otherwise?: {
|
|
89
|
+
start: number;
|
|
90
|
+
end: number;
|
|
91
|
+
};
|
|
92
|
+
alternative?: {
|
|
93
|
+
start: number;
|
|
94
|
+
end: number;
|
|
95
|
+
};
|
|
96
|
+
/** Authoritative typed derivation reused by the main clause chart. */
|
|
97
|
+
sign: HpsgSign;
|
|
98
|
+
}
|
|
99
|
+
/** Attach already typed procedural withholding/target scope to the same guard
|
|
100
|
+
* derivation. This retains the predicate daughters in the clause feature graph.
|
|
101
|
+
* @param guard Selected conditional head/predicate analysis.
|
|
102
|
+
* @param scope Existing clinical scope sign (including otherwise-hold ownership).
|
|
103
|
+
*/
|
|
104
|
+
export declare function scopeMedicationGuardSign(guard: ParsedMedicationGuard, scope: HpsgSign): HpsgSign;
|
|
105
|
+
/** Single source of medication-guard meaning: lexical daughters compose via
|
|
106
|
+
* HPSG predicate/coordination/head constructions, reused by planner and chart.
|
|
107
|
+
* @param source Exact clinician text.
|
|
108
|
+
* @param existingTokens Already-lexed tokens when the caller has a source context.
|
|
109
|
+
* @param withholdingConsequent License supplied only by a typed medication-withholding action daughter.
|
|
110
|
+
*/
|
|
111
|
+
export declare function parseMedicationGuard(source: string, existingTokens?: Token[], withholdingConsequent?: true): ParsedMedicationGuard | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type LexToken } from "../lexer/token-types";
|
|
2
|
+
import { AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirPeriodUnit } from "../types";
|
|
2
3
|
export { ACTION_SEQUENCE_MARKERS } from "../relation-terminology";
|
|
3
4
|
type MealRelation = "before" | "after" | "with";
|
|
4
5
|
type MealTimingByRelation = Map<MealRelation, Map<EventTiming, EventTiming>>;
|
|
@@ -8,6 +9,19 @@ type ContextualPrnReasonLead = {
|
|
|
8
9
|
canonical: string;
|
|
9
10
|
requiresKnownReason?: boolean;
|
|
10
11
|
};
|
|
12
|
+
export type SiteRelativeMarkerLexeme = {
|
|
13
|
+
surface: string;
|
|
14
|
+
relation: "where";
|
|
15
|
+
};
|
|
16
|
+
export type SiteRestrictionPredicateIntroducer = {
|
|
17
|
+
parts: string[];
|
|
18
|
+
form: "existential";
|
|
19
|
+
};
|
|
20
|
+
export type SiteRestrictionPredicateLexeme = {
|
|
21
|
+
lemma: string;
|
|
22
|
+
form: "state";
|
|
23
|
+
i18n?: Record<string, string>;
|
|
24
|
+
};
|
|
11
25
|
type CompoundDoseUnit = {
|
|
12
26
|
head: string;
|
|
13
27
|
tails: string[];
|
|
@@ -23,6 +37,11 @@ export type InstructionQuantityUnitLabel = {
|
|
|
23
37
|
}>;
|
|
24
38
|
};
|
|
25
39
|
export declare const SITE_ANCHORS: Set<string>;
|
|
40
|
+
/** Clause markers and standalone qualifiers share the relation registry. */
|
|
41
|
+
export declare const SITE_RELATIVE_MARKERS: Map<string, SiteRelativeMarkerLexeme>;
|
|
42
|
+
export declare const SITE_RESTRICTION_PREDICATE_INTRODUCERS: SiteRestrictionPredicateIntroducer[];
|
|
43
|
+
export declare const SITE_RESTRICTION_PREDICATES: Map<string, SiteRestrictionPredicateLexeme>;
|
|
44
|
+
export declare const SITE_RESTRICTION_PREDICATES_BY_LEMMA: Map<string, SiteRestrictionPredicateLexeme>;
|
|
26
45
|
export declare const SITE_SELF_DISPLAY_ANCHORS: Set<string>;
|
|
27
46
|
export declare const SITE_FILLERS: Set<string>;
|
|
28
47
|
export declare const BODY_SITE_PARTITIVE_HEADS: Set<string>;
|
|
@@ -70,11 +89,16 @@ export declare const SITE_ROUTE_HINTS_ALLOWED_IN_GRAMMAR: Set<import("../types")
|
|
|
70
89
|
export declare const PRODUCT_METHOD_REALIZATIONS: Record<string, Partial<Record<string, Record<string, string>>>>;
|
|
71
90
|
export declare function productMethodRealizations(verb: string, product: string): Record<string, string> | undefined;
|
|
72
91
|
export declare const PRODUCT_FORM_MODIFIERS: Set<string>;
|
|
92
|
+
export declare const PRODUCT_SOURCE_PREPOSITIONS: Set<string>;
|
|
73
93
|
export declare const COMPOUND_DOSE_UNITS: CompoundDoseUnit[];
|
|
94
|
+
export declare const QUALITATIVE_DOSE_MODIFIERS: Set<string>;
|
|
95
|
+
export declare const QUALITATIVE_DOSE_UNITS: Set<string>;
|
|
74
96
|
export declare const IMPLICIT_SINGLE_DOSE_UNITS: Set<string>;
|
|
75
97
|
export declare const PERCENT_BODY_AREA_UNITS: Map<string, string>;
|
|
76
98
|
export declare const DOSE_FRACTION_WORDS: Map<string, number>;
|
|
77
99
|
export declare const DOSE_FRACTION_DENOMINATOR_WORDS: Map<string, number>;
|
|
100
|
+
export declare const DOSE_ADDITIVE_QUANTITY_CONNECTORS: Set<string>;
|
|
101
|
+
export declare const DOSE_FRACTION_ARTICLES: Set<string>;
|
|
78
102
|
export declare const DOSE_NUMBER_WORDS: Map<string, number>;
|
|
79
103
|
export declare const DOSE_UNIT_CONNECTORS: Set<string>;
|
|
80
104
|
export declare const MILLION_DOSE_MULTIPLIER_TOKENS: Set<string>;
|
|
@@ -83,9 +107,14 @@ export declare const COMPACT_LIST_SEPARATORS: Set<string>;
|
|
|
83
107
|
export declare const EVERY_INTERVAL_TOKENS_DATA: Set<string>;
|
|
84
108
|
export declare const COUNT_MARKER_TOKENS_DATA: Set<string>;
|
|
85
109
|
export declare const COUNT_CONNECTOR_WORDS_DATA: Set<string>;
|
|
110
|
+
/** Restrictive supplemental-quantity modifiers shared by dose and action NPs. */
|
|
111
|
+
export declare const SUPPLEMENTAL_DOSE_MODIFIERS: Set<string>;
|
|
86
112
|
export declare const MAXIMUM_COUNT_LEAD_TOKENS: Set<string>;
|
|
87
113
|
export declare const MAXIMUM_COUNT_LEAD_SEQUENCES: string[][];
|
|
88
114
|
export declare const OCCURRENCE_COUNT_WORDS: Set<string>;
|
|
115
|
+
export declare const OCCURRENCE_COUNT_MODIFIERS: Set<string>;
|
|
116
|
+
export declare const MAXIMUM_PERIOD_PREPOSITIONS: Set<string>;
|
|
117
|
+
export declare const MAXIMUM_PERIOD_MODIFIERS: Set<string>;
|
|
89
118
|
export declare const OCCURRENCE_CAP_PERIOD_PHRASES: {
|
|
90
119
|
parts: string[];
|
|
91
120
|
period: number;
|
|
@@ -93,6 +122,58 @@ export declare const OCCURRENCE_CAP_PERIOD_PHRASES: {
|
|
|
93
122
|
}[];
|
|
94
123
|
export declare const FREQUENCY_SIMPLE_WORDS_DATA: Record<string, number>;
|
|
95
124
|
export declare const FREQUENCY_NUMBER_WORDS_DATA: Record<string, number>;
|
|
125
|
+
/** Coded course-end events remain advisory until an actual bound is known. */
|
|
126
|
+
export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
|
|
127
|
+
kind: string;
|
|
128
|
+
modifiers: string[];
|
|
129
|
+
heads: string[];
|
|
130
|
+
code: string;
|
|
131
|
+
display: string;
|
|
132
|
+
i18n: {
|
|
133
|
+
th: string;
|
|
134
|
+
};
|
|
135
|
+
subjects?: undefined;
|
|
136
|
+
predicates?: undefined;
|
|
137
|
+
} | {
|
|
138
|
+
kind: string;
|
|
139
|
+
subjects: string[];
|
|
140
|
+
predicates: string[];
|
|
141
|
+
code: string;
|
|
142
|
+
display: string;
|
|
143
|
+
i18n: {
|
|
144
|
+
th: string;
|
|
145
|
+
};
|
|
146
|
+
modifiers?: undefined;
|
|
147
|
+
heads?: undefined;
|
|
148
|
+
} | {
|
|
149
|
+
kind: string;
|
|
150
|
+
subjects: string[];
|
|
151
|
+
predicates: string[];
|
|
152
|
+
code: null;
|
|
153
|
+
display: string;
|
|
154
|
+
i18n: {
|
|
155
|
+
th: string;
|
|
156
|
+
};
|
|
157
|
+
modifiers?: undefined;
|
|
158
|
+
heads?: undefined;
|
|
159
|
+
})[];
|
|
160
|
+
/** Nominal quantifiers and event membership for typed medication-dose references. */
|
|
161
|
+
export declare const DOSE_TARGET_SLOT_HEADS: Set<string>;
|
|
162
|
+
export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "both" | "all">;
|
|
163
|
+
/** Broad named dayparts can select a unique already stated clock, never invent one. */
|
|
164
|
+
export declare const DOSE_TARGET_DAYPART_CLOCK_RANGES: Map<EventTiming, {
|
|
165
|
+
startHour: number;
|
|
166
|
+
endHour: number;
|
|
167
|
+
}>;
|
|
168
|
+
/** Meridiem nominals select existing clock slots without asserting a meal time. */
|
|
169
|
+
export declare const DOSE_TARGET_MERIDIEM_CLOCK_RANGES: Map<string, {
|
|
170
|
+
startHour: number;
|
|
171
|
+
endHour: number;
|
|
172
|
+
}>;
|
|
173
|
+
export declare const DOSE_TARGET_EVENT_MEMBERS: Map<EventTiming, readonly EventTiming[]>;
|
|
174
|
+
export declare const CALENDAR_UNIVERSAL_DAY_QUANTIFIERS: Set<string>;
|
|
175
|
+
export declare const CALENDAR_COMPLEMENT_DAY_MODIFIERS: Set<string>;
|
|
176
|
+
export declare const CALENDAR_COMPLEMENT_DETERMINERS: Set<string>;
|
|
96
177
|
export declare const FREQUENCY_TIMES_WORDS_DATA: Set<string>;
|
|
97
178
|
export declare const FREQUENCY_CONNECTOR_WORDS_DATA: Set<string>;
|
|
98
179
|
export declare const FREQUENCY_ALTERNATIVE_CONNECTORS: Set<string>;
|
|
@@ -101,11 +182,22 @@ export declare const FREQUENCY_ADVERB_UNITS_DATA: Map<string, string>;
|
|
|
101
182
|
export declare const INTERVAL_UNIT_TOKENS_DATA: Map<string, string>;
|
|
102
183
|
export declare const WORKFLOW_START_WORDS: Set<string>;
|
|
103
184
|
export declare const WORKFLOW_NOUNS: Set<string>;
|
|
185
|
+
/** Finite event-phase verbs that complete a workflow temporal noun phrase. */
|
|
186
|
+
export declare const WORKFLOW_EVENT_PHASE_VERBS: Set<string>;
|
|
104
187
|
export declare const ANTE_MERIDIEM_TOKENS: Set<string>;
|
|
105
188
|
export declare const POST_MERIDIEM_TOKENS: Set<string>;
|
|
106
189
|
export declare const MERIDIEM_TOKENS: Set<string>;
|
|
107
190
|
export declare const LIST_SEPARATORS: Set<string>;
|
|
191
|
+
/** Thai daypart daughters license their compact conjunction punctuation.
|
|
192
|
+
* Numeric dose slots and non-Thai time ranges do not use this lexical sense.
|
|
193
|
+
*/
|
|
194
|
+
export declare function isThaiDaypartListSeparator(separator: LexToken | undefined, left: LexToken | undefined, right: LexToken | undefined): boolean;
|
|
108
195
|
export declare const MEDICATION_OBJECT_FILLERS: Set<string>;
|
|
196
|
+
/** Typed resultative adjustment leads; the following cadence owns the new phase. */
|
|
197
|
+
export declare const PHASE_ADJUSTMENT_LEAD_SEQUENCES: string[][];
|
|
198
|
+
export declare const PHASE_ADDITION_LEAD_SEQUENCES: string[][];
|
|
199
|
+
/** Lexically marked reference to clock/event anchors of a preceding phase. */
|
|
200
|
+
export declare const TIMING_ANAPHORA_PHRASES: string[][];
|
|
109
201
|
export declare const CLOCK_LEAD_TOKENS: Set<string>;
|
|
110
202
|
export declare const EVENT_PREPOSITIONS: Set<string>;
|
|
111
203
|
export declare const EVENT_ARTICLE_TOKENS: Set<string>;
|
|
@@ -116,11 +208,26 @@ export declare const SLEEP_EVENT_ALIASES: Set<string>;
|
|
|
116
208
|
export declare const WAKE_EVENT_ALIASES: Set<string>;
|
|
117
209
|
export declare const FOOD_EVENT_ALIASES: Set<string>;
|
|
118
210
|
export declare const DAY_RANGE_CONNECTORS: Set<string>;
|
|
211
|
+
/** Typed calendar-month day nouns; prefix + numeric range + monthly daughter. */
|
|
212
|
+
export declare const CALENDAR_MONTH_DAY_FRAMES: {
|
|
213
|
+
prefixes: string[][];
|
|
214
|
+
suffixes: string[][];
|
|
215
|
+
rangeConnectors: string[];
|
|
216
|
+
listConnectors: string[];
|
|
217
|
+
};
|
|
119
218
|
export declare const RANGE_CONNECTORS: Set<string>;
|
|
120
219
|
export declare const DURATION_LEAD_TOKENS: ReadonlySet<string>;
|
|
220
|
+
/** Shared source-lexical reading of an unspaced headed duration NP.
|
|
221
|
+
* HPSG schedule and procedural action grammar consume the same daughter.
|
|
222
|
+
* No semantic meaning is assigned until each consumer licenses the unit. */
|
|
223
|
+
export declare function compactDurationParts(surface: string): {
|
|
224
|
+
value: number;
|
|
225
|
+
unitSurface: string;
|
|
226
|
+
} | undefined;
|
|
121
227
|
export declare const EVENT_OFFSET_MINIMUM_LEAD_SEQUENCES: string[][];
|
|
122
228
|
export declare const EVENT_OFFSET_MAXIMUM_LEAD_SEQUENCES: string[][];
|
|
123
229
|
export declare const EVENT_OFFSET_FRACTIONS: Map<string, number>;
|
|
230
|
+
export declare const RELATIVE_INTERVAL_TRAILING_RELATIONS: Map<string, AdviceRelation>;
|
|
124
231
|
export declare const EVENT_OFFSET_ARTICLES: Set<string>;
|
|
125
232
|
export declare const INSTRUCTION_LEADING_SEPARATORS: Set<string>;
|
|
126
233
|
export declare const INSTRUCTION_START_WORDS: Set<string>;
|
|
@@ -129,10 +236,22 @@ export declare const ACTION_DIRECTIVE_PREFIXES: {
|
|
|
129
236
|
parts: readonly string[];
|
|
130
237
|
polarity: AdvicePolarity | undefined;
|
|
131
238
|
modality: AdviceModality | undefined;
|
|
239
|
+
complement: "contact-clause" | undefined;
|
|
132
240
|
}[];
|
|
133
241
|
export declare const ACTION_COORDINATION_CONNECTORS: Set<string>;
|
|
242
|
+
/** Closed-class contrast that connects two instructions, not a new action. */
|
|
243
|
+
export declare const ACTION_DISCOURSE_CONNECTORS: Set<string>;
|
|
244
|
+
/** Compositional phrasal sequencers; single-token THEN remains the relation lexicon's authority. */
|
|
245
|
+
export declare const REGIMEN_SEQUENCE_CONNECTOR_PHRASES: readonly (readonly string[])[];
|
|
246
|
+
export declare function sequenceConnectorEnd(tokens: readonly LexToken[], start: number): number | undefined;
|
|
247
|
+
/** Count nouns select whole treatment cycles rather than doses or days. */
|
|
248
|
+
export declare const CYCLE_COUNT_HEADS: Set<string>;
|
|
249
|
+
/** Cheap source-lexical gate for typed treatment-relative phase onsets. */
|
|
250
|
+
export declare const TREATMENT_PERIOD_START_LEADS: Set<string>;
|
|
134
251
|
export declare const ACTION_COORDINATION_CONNECTOR_I18N: Record<string, Record<string, string>>;
|
|
252
|
+
export declare function coordinationConnectorKind(surface: string): "conjunction" | "disjunction" | "unknown";
|
|
135
253
|
export declare const ACTION_SEQUENCE_RELATION_TOKENS: ReadonlySet<string>;
|
|
254
|
+
export declare const COURSE_DURATION_UNITS: Set<string>;
|
|
136
255
|
export declare const INSTRUCTION_DURATION_UNITS: Map<string, string>;
|
|
137
256
|
export declare const INSTRUCTION_DURATION_APPROXIMATION_LEADS: Set<string>;
|
|
138
257
|
export declare const INSTRUCTION_QUANTITY_UNIT_LABELS: Map<string, InstructionQuantityUnitLabel>;
|
|
@@ -144,6 +263,18 @@ export declare const ALTERNATE_EVENT_CADENCES: {
|
|
|
144
263
|
period: number;
|
|
145
264
|
periodUnit: string;
|
|
146
265
|
}[];
|
|
266
|
+
/** Day-membership adjuncts around registered activity nouns; never calendar inference. */
|
|
267
|
+
export declare const ACTIVITY_DAY_ADJUNCTS: {
|
|
268
|
+
negativeNounPrefixes: string[];
|
|
269
|
+
negativeNounTokens: string[];
|
|
270
|
+
dayRelativeTokens: string[];
|
|
271
|
+
dayTokens: string[];
|
|
272
|
+
frames: {
|
|
273
|
+
parts: string[];
|
|
274
|
+
dayFirst: boolean;
|
|
275
|
+
exclude: boolean;
|
|
276
|
+
}[];
|
|
277
|
+
};
|
|
147
278
|
export declare const ADMINISTRATION_WINDOW_INSTRUCTIONS: {
|
|
148
279
|
parts: string[];
|
|
149
280
|
text: string;
|
|
@@ -153,6 +284,10 @@ export declare const ADMINISTRATION_WINDOW_INSTRUCTIONS: {
|
|
|
153
284
|
} | undefined;
|
|
154
285
|
relation: "before" | "after" | undefined;
|
|
155
286
|
activity: string | undefined;
|
|
287
|
+
eventWindow: {
|
|
288
|
+
start: EventTiming;
|
|
289
|
+
end: EventTiming;
|
|
290
|
+
} | undefined;
|
|
156
291
|
}[];
|
|
157
292
|
export declare const SITE_TRAILING_INSTRUCTION_WORDS: Set<string>;
|
|
158
293
|
export declare const WORKFLOW_CONTINUATION_LICENSES: Set<string>;
|
|
@@ -168,3 +303,37 @@ export declare const OCULAR_ROUTE_CODES: Set<import("../types").SNOMEDCTRouteCod
|
|
|
168
303
|
export declare const HARD_SEGMENT_BOUNDARY_TOKENS: Set<string>;
|
|
169
304
|
export declare const CLAUSE_LEAD_WORDS: Set<string>;
|
|
170
305
|
export declare const LATERAL_MODIFIER_WORDS: Set<string>;
|
|
306
|
+
/** Explicit temporal construction vocabulary; no medication or specialty-specific dispatch. */
|
|
307
|
+
export declare const CYCLE_WORDS: {
|
|
308
|
+
name: string;
|
|
309
|
+
dayLead: string;
|
|
310
|
+
dayPart: string;
|
|
311
|
+
listSeparator: string;
|
|
312
|
+
periodLead: string;
|
|
313
|
+
periodUnit: string;
|
|
314
|
+
startLead: string;
|
|
315
|
+
repeatCount: string;
|
|
316
|
+
};
|
|
317
|
+
/** Declarative surface vocabulary for calendar-date relations for typed calendar constituents. */
|
|
318
|
+
export declare const TEMPORAL_DATE_RELATION_SOURCES: {
|
|
319
|
+
readonly startInclusive: string;
|
|
320
|
+
readonly startExclusive: string;
|
|
321
|
+
readonly endInclusive: string;
|
|
322
|
+
readonly endExclusive: string;
|
|
323
|
+
};
|
|
324
|
+
export declare const TEMPORAL_RELATION_LEAD_WORDS: Set<string>;
|
|
325
|
+
export declare const OPEN_ENDED_WORDS: Set<string>;
|
|
326
|
+
/** Resolve the duration-complement sense of a polysemous continuation head.
|
|
327
|
+
* A physical attachment still requires its object and is not licensed by this
|
|
328
|
+
* time-quantity valence. One source constituent is shared by action sense
|
|
329
|
+
* selection and the HPSG schedule lexicon, avoiding competing ownership.
|
|
330
|
+
* @param tokens Source-preserving normalized lexical tokens.
|
|
331
|
+
* @param start Candidate head; never searches later unrelated text.
|
|
332
|
+
* @param limit Exclusive constituent boundary.
|
|
333
|
+
* @returns Complete duration daughter, or undefined for an object/negated sense.
|
|
334
|
+
*/
|
|
335
|
+
export declare function courseContinuationDurationAt(tokens: readonly Pick<LexToken, "lower" | "canonical" | "kind" | "value">[], start: number, limit?: number): {
|
|
336
|
+
end: number;
|
|
337
|
+
value: number;
|
|
338
|
+
unit: FhirPeriodUnit;
|
|
339
|
+
} | undefined;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { type AdviceFrame } from "../types";
|
|
2
|
-
import type
|
|
2
|
+
import { type HpsgClauseContext } from "./rule-context";
|
|
3
3
|
/**
|
|
4
4
|
* Parse procedural semantics once per ParserState and share the result across
|
|
5
5
|
* HPSG lexical constructions. Keeping this cache at the HPSG context layer
|
|
6
6
|
* avoids each rule family independently running the instruction parser.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getProceduralFrames(context: HpsgClauseContext): AdviceFrame[];
|
|
9
|
+
/** Existing action-sequence relation shared by condition closure and lexical ownership. */
|
|
10
|
+
export declare function instructionActionsAreSequenced(context: HpsgClauseContext, startSource: number, endSource: number): boolean;
|
|
11
|
+
/** Compose the consecutive action daughters selected by one fronted condition. */
|
|
12
|
+
export declare function proceduralInstructionProgram(context: HpsgClauseContext, firstTargetIndex: number, frames: AdviceFrame[]): AdviceFrame[];
|
|
13
|
+
/** Return the conditional's existing action owner, if it is advice rather
|
|
14
|
+
* than a newly quantified administration. */
|
|
15
|
+
export declare function conditionalAdviceOwnerAt(context: HpsgClauseContext, index: number): AdviceFrame | undefined;
|
|
16
|
+
/** Whether this existing action daughter is governed as conditional advice. */
|
|
17
|
+
export declare function isConditionalAdviceFrame(context: HpsgClauseContext, frame: AdviceFrame): boolean;
|
|
18
|
+
/** Resolve attachment for an already recognized temporal activity nominal.
|
|
19
|
+
* A fronted adjunct lies outside its following procedure's own action span. */
|
|
20
|
+
export declare function followingProcedureOwnsTemporalAdjunct(context: HpsgClauseContext, start: number, end: number): boolean;
|
|
9
21
|
export type HpsgAttachmentClass = "administration" | "procedure";
|
|
10
22
|
export declare function sourceRangeAttachmentClass(context: HpsgClauseContext, start: number, end: number): HpsgAttachmentClass;
|
|
23
|
+
/** A temporal linker between two complete action events is not an opaque condition. */
|
|
24
|
+
export declare function actionEventRelationAt(context: HpsgClauseContext, index: number): import("../types").AdviceRelation | undefined;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { ParserState, Token } from "../parser-state";
|
|
2
|
-
import { EventTiming, FhirDayOfWeek, RouteCode } from "../types";
|
|
2
|
+
import { EventTiming, FhirDayOfWeek, RouteCode, type CanonicalSigClause, type CanonicalSiteExpr, type CanonicalLexicalCategory, type CanonicalScheduleSemanticField } from "../types";
|
|
3
3
|
import { HpsgSign } from "./signature";
|
|
4
4
|
export interface HpsgProjectionDeps {
|
|
5
5
|
addDayOfWeekList: (state: ParserState, days: FhirDayOfWeek[]) => void;
|
|
6
6
|
addWhen: (target: EventTiming[], whenCode: EventTiming) => void;
|
|
7
7
|
markToken: (state: ParserState, token: Token) => void;
|
|
8
|
-
recordEvidence: (state: ParserState, rule: string, startIndex: number, endIndex: number) => void;
|
|
8
|
+
recordEvidence: (state: ParserState, rule: string, startIndex: number, endIndex: number, scheduleFields?: CanonicalScheduleSemanticField[], lexicalCategory?: CanonicalLexicalCategory) => void;
|
|
9
9
|
refreshMethodSurface: (state: ParserState) => void;
|
|
10
10
|
setRoute: (state: ParserState, code: RouteCode, text?: string) => void;
|
|
11
11
|
}
|
|
12
12
|
export declare function projectHpsgSignToState(sign: HpsgSign, state: ParserState, tokens: Token[], deps: HpsgProjectionDeps): void;
|
|
13
|
+
/**
|
|
14
|
+
* Return the FHIR projection alternatives licensed by the typed HPSG site
|
|
15
|
+
* coordination. A disjunction is deliberately one retained canonical clause;
|
|
16
|
+
* it is never converted into simultaneous administrations.
|
|
17
|
+
*/
|
|
18
|
+
export declare function administrationTargetProjections(clauses: readonly CanonicalSigClause[]): Array<CanonicalSiteExpr | undefined>;
|
|
19
|
+
/** Pure pre-FHIR projection from one typed conjunction to one singular site. */
|
|
20
|
+
export declare function projectAdministrationTargetClauses(clauses: readonly CanonicalSigClause[], target: CanonicalSiteExpr | undefined): CanonicalSigClause[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Token, ParserState } from "../parser-state";
|
|
2
2
|
import { ParseOptions } from "../types";
|
|
3
3
|
import type { MedicationDateListMatch } from "../date-interpretation";
|
|
4
|
+
import { type ParsedMedicationGuard } from "./constructions";
|
|
4
5
|
import { HpsgLexicalRule } from "./signature";
|
|
5
6
|
import { HpsgProjectionDeps } from "./projection";
|
|
6
7
|
import { HpsgUnificationContext } from "./unification";
|
|
@@ -11,8 +12,20 @@ export interface HpsgClauseContext {
|
|
|
11
12
|
dateSpans: MedicationDateListMatch[];
|
|
12
13
|
limit: number;
|
|
13
14
|
deps: HpsgProjectionDeps & HpsgUnificationContext;
|
|
15
|
+
clinicalCache: {
|
|
16
|
+
medicationGuardScanned?: true;
|
|
17
|
+
medicationGuard?: ParsedMedicationGuard;
|
|
18
|
+
};
|
|
14
19
|
project?: boolean;
|
|
15
20
|
}
|
|
21
|
+
export declare function medicationGuardForContext(context: HpsgClauseContext): ParsedMedicationGuard | undefined;
|
|
22
|
+
/** A marker phrase owns each of its lexical tokens, including IF inside
|
|
23
|
+
* ONLY IF. Such a token cannot independently introduce a PRN phrase.
|
|
24
|
+
* @param context Shared cached typed guard producer.
|
|
25
|
+
* @param start Candidate lexical token index.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isMedicationGuardMarker(context: HpsgClauseContext, start: number): boolean;
|
|
28
|
+
export declare function startsMedicationGuard(context: HpsgClauseContext, start: number): boolean;
|
|
16
29
|
export declare function sourceRangeOverlapsContextDate(context: HpsgClauseContext, start: number, end: number): boolean;
|
|
17
30
|
export declare function normalizeTokenLower(token: Token): string;
|
|
18
31
|
export declare function isPunctuation(lower: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
+
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
/**
|
|
4
|
+
* Bounded lexical/construction contribution for safety-critical medication
|
|
5
|
+
* quantities. It never searches the full clause and only accepts explicit
|
|
6
|
+
* dimensional forms; unsupported weight suffixes remain typed unresolved
|
|
7
|
+
* evidence instead of an ordinary dose.
|
|
8
|
+
*/
|
|
9
|
+
export declare function clinicalQuantityLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { FhirDayOfWeek, ParseOptions } from "../../types";
|
|
2
|
+
import { MedicationDateListMatch } from "../../date-interpretation";
|
|
1
3
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
4
|
import { HpsgConditionFeature, HpsgLexicalRule } from "../signature";
|
|
5
|
+
export interface CalendarExclusion {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
excluded: FhirDayOfWeek[];
|
|
9
|
+
dates: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function containsCalendarExclusionCue(source: string): boolean;
|
|
12
|
+
/** Resolve the lexical payload for a typed calendar-exclusion sign. */
|
|
13
|
+
export declare function matchCalendarExclusion(source: string, options?: ParseOptions, knownDateSpans?: MedicationDateListMatch[], scopeEnd?: number, from?: number): CalendarExclusion | undefined;
|
|
14
|
+
/** Medication guards are lexical adjuncts, separate from procedural IF scope. */
|
|
15
|
+
export declare function medicationGuardLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
16
|
+
export declare function weekdayComplementReferenceLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
17
|
+
export declare function calendarExclusionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
3
18
|
export declare function conditionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
19
|
export declare function getConditionFeatures(context: HpsgClauseContext): HpsgConditionFeature[];
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
+
import { Token } from "../../parser-state";
|
|
2
|
+
import { type ParseOptions } from "../../types";
|
|
1
3
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
4
|
import { HpsgLexicalRule } from "../signature";
|
|
5
|
+
/** Bounded lexical recognition shared by chart and boundary candidacy.
|
|
6
|
+
* @param tokens Source tokens with the existing locale normalization.
|
|
7
|
+
* @param start Candidate head index; never searches arbitrary later text.
|
|
8
|
+
* @param limit Exclusive end of the current constituent.
|
|
9
|
+
*/
|
|
10
|
+
export declare function phaseAdjustmentAt(tokens: readonly Token[], start: number, limit?: number): {
|
|
11
|
+
kind: "replace-target";
|
|
12
|
+
end: number;
|
|
13
|
+
targetStart: number;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "replace" | "add";
|
|
16
|
+
end: number;
|
|
17
|
+
targetStart?: undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** A typed ADD/REPLACE operator composes with ordinary dose/time daughters. */
|
|
20
|
+
export declare function phaseAdjustmentLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
3
21
|
export declare function directiveMarkerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
22
|
export declare function methodLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
23
|
export declare function routeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
6
24
|
export declare function fillerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
25
|
export declare function productLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
26
|
+
/**
|
|
27
|
+
* Return the end of a bounded, explicit scalar-dose head for regimen boundary
|
|
28
|
+
* candidacy. This uses the same HPSG quantity lexemes as `doseLexicalRule`;
|
|
29
|
+
* it does not assign a dose or authorize a split. The boundary grammar still
|
|
30
|
+
* has to parse complete typed daughters before accepting the candidate.
|
|
31
|
+
*
|
|
32
|
+
* Keeping the optional fraction article inside this constituent is important:
|
|
33
|
+
* in `half a tablet`, `a` is a determiner of the unit, not a second one-tablet
|
|
34
|
+
* dose head.
|
|
35
|
+
*/
|
|
36
|
+
export declare function explicitDoseLexicalEnd(tokens: readonly Token[], start: number, options?: ParseOptions, limit?: number): number | undefined;
|
|
8
37
|
export declare function perTargetCountDoseRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
9
38
|
export declare function doseLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
10
39
|
export declare function connectorLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
-
import { HpsgLexicalRule } from "../signature";
|
|
2
|
+
import { HpsgLexicalRule, type HpsgSign } from "../signature";
|
|
3
3
|
export declare function proceduralActionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
4
|
export declare function workflowLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
|
+
/** Compose ON/ONLY ON/EXCEPT with a registered activity and DAY noun.
|
|
6
|
+
* The activity identifies the day domain, not a scheduled procedure occurrence.
|
|
7
|
+
* Membership remains a caller-evaluated condition; no dates are guessed.
|
|
8
|
+
* @param context Shared source, lexical registry and procedural ownership.
|
|
9
|
+
* @param start Beginning of a declared day-adjunct frame.
|
|
10
|
+
* @param withholdingComplement Licensed by a typed withholding head selecting this adjunct.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registeredActivityDayAt(context: HpsgClauseContext, start: number, withholdingComplement?: true): HpsgSign | undefined;
|
|
5
13
|
export declare function instructionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|