ezmedicationinput 0.2.0 → 0.3.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.
Files changed (86) hide show
  1. package/README.md +216 -18
  2. package/dist/adapters/canonical-course.d.ts +131 -0
  3. package/dist/adapters/r5-course.d.ts +27 -0
  4. package/dist/advice-locale-adapter.d.ts +24 -0
  5. package/dist/advice.d.ts +73 -6
  6. package/dist/body-site-grammar.d.ts +21 -2
  7. package/dist/body-site-lookup.d.ts +8 -0
  8. package/dist/body-site-spatial.d.ts +12 -2
  9. package/dist/body-site-target.d.ts +38 -3
  10. package/dist/canonical/compile.d.ts +98 -0
  11. package/dist/canonical/course.d.ts +388 -0
  12. package/dist/canonical/format-course.d.ts +38 -0
  13. package/dist/clause-tail-grammar.d.ts +2 -0
  14. package/dist/date-interpretation.d.ts +36 -2
  15. package/dist/dosage-course.d.ts +304 -30
  16. package/dist/event-timing-expression.d.ts +26 -1
  17. package/dist/execution/calendar.d.ts +107 -0
  18. package/dist/execution/engine.d.ts +11 -0
  19. package/dist/fhir-quantity-operator.d.ts +89 -0
  20. package/dist/fhir-translations.d.ts +5 -6
  21. package/dist/fhir.d.ts +119 -14
  22. package/dist/format.d.ts +106 -5
  23. package/dist/hpsg/constructions.d.ts +35 -8
  24. package/dist/hpsg/defaults.d.ts +2 -0
  25. package/dist/hpsg/lexical-classes.d.ts +196 -24
  26. package/dist/hpsg/method-lexicon.d.ts +3 -0
  27. package/dist/hpsg/procedural-context.d.ts +48 -5
  28. package/dist/hpsg/projection.d.ts +32 -1
  29. package/dist/hpsg/quantity-lexicon.d.ts +51 -0
  30. package/dist/hpsg/rule-context.d.ts +172 -7
  31. package/dist/hpsg/rules/clinical-quantity-rules.d.ts +16 -7
  32. package/dist/hpsg/rules/condition-rules.d.ts +13 -3
  33. package/dist/hpsg/rules/core-rules.d.ts +8 -2
  34. package/dist/hpsg/rules/instruction-rules.d.ts +2 -0
  35. package/dist/hpsg/rules/prn-rules.d.ts +12 -1
  36. package/dist/hpsg/rules/site-rules.d.ts +10 -1
  37. package/dist/hpsg/rules/timing-rules.d.ts +116 -22
  38. package/dist/hpsg/segmenter.d.ts +2 -2
  39. package/dist/hpsg/signature.d.ts +54 -7
  40. package/dist/hpsg/timing-lexicon.d.ts +18 -2
  41. package/dist/hpsg/unification.d.ts +3 -1
  42. package/dist/i18n.d.ts +37 -1
  43. package/dist/index.cjs +83231 -52284
  44. package/dist/index.d.ts +26 -9
  45. package/dist/index.js +83222 -52284
  46. package/dist/instruction-action-locale-adapter.d.ts +92 -5
  47. package/dist/instruction-action-parser.d.ts +43 -0
  48. package/dist/instruction-action-terminology.d.ts +44 -3
  49. package/dist/instruction-concept-terminology.d.ts +20 -1
  50. package/dist/instruction-graph-fhir.d.ts +10 -2
  51. package/dist/instruction-graph-ownership.d.ts +96 -0
  52. package/dist/instruction-graph.d.ts +68 -49
  53. package/dist/ir.d.ts +1 -1
  54. package/dist/lexer/lex.d.ts +5 -1
  55. package/dist/lexer/locale.d.ts +14 -0
  56. package/dist/lexer/locales/en.d.ts +11 -0
  57. package/dist/lexer/surface-segmenter.d.ts +1 -1
  58. package/dist/lexer/surface.d.ts +4 -1
  59. package/dist/lexer/token-types.d.ts +6 -0
  60. package/dist/locale-detection.d.ts +5 -0
  61. package/dist/locales/clause/en.d.ts +14 -0
  62. package/dist/locales/course/en.d.ts +20 -0
  63. package/dist/locales/course/th.d.ts +12 -0
  64. package/dist/localization.d.ts +76 -0
  65. package/dist/localized-timing.d.ts +1 -1
  66. package/dist/maps.d.ts +44 -10
  67. package/dist/medication-condition.d.ts +72 -11
  68. package/dist/parser-state.d.ts +12 -2
  69. package/dist/parser.d.ts +5 -3
  70. package/dist/prn.d.ts +13 -2
  71. package/dist/regimen/coordination-scope.d.ts +13 -1
  72. package/dist/regimen/grammar.d.ts +18 -1
  73. package/dist/regimen/parallel-course.d.ts +13 -42
  74. package/dist/regimen/planner.d.ts +2 -3
  75. package/dist/regimen/regimen.d.ts +8 -2
  76. package/dist/relation-terminology.d.ts +1 -0
  77. package/dist/schedule.d.ts +14 -10
  78. package/dist/snomed.d.ts +3 -0
  79. package/dist/suggest-locale-adapter.d.ts +15 -0
  80. package/dist/symptom-terminology.d.ts +5 -1
  81. package/dist/timing-summary.d.ts +114 -1
  82. package/dist/types.d.ts +627 -61
  83. package/dist/unit-lexicon.d.ts +4 -1
  84. package/dist/utils/text.d.ts +3 -0
  85. package/dist/utils/units.d.ts +22 -0
  86. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
+ import { type MedicationConditionLexicalFeatures } from "../medication-condition";
1
2
  import type { Token } from "../parser-state";
2
- import type { MedicationCondition } from "../types";
3
- import { AdviceArgumentRole, type AdviceArgument, type AdviceFrame } from "../types";
3
+ import type { MedicationCondition, ParseOptions } from "../types";
4
+ import { AdviceArgumentRole, AdviceRelation, type AdviceArgument, type AdviceFrame } from "../types";
4
5
  import type { HpsgConstruction, HpsgSign, HpsgType } from "./signature";
5
6
  import type { BoundaryRelation, CoordinationScopeFacts, RegimenSemanticSelection } from "./signature";
6
7
  export interface HpsgConstructionSelection {
@@ -64,12 +65,18 @@ export declare function selectHpsgCalendarClockEllipsisConstruction(facts: HpsgC
64
65
  timeOfDay: string[];
65
66
  }) | undefined;
66
67
  /**
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.
68
+ * A selected shared-polarity link joins the immediately preceding negative
69
+ * daughter. Explicit directives and positive administrations start new groups.
70
+ * Consumers must use the original selected frame order, not a filtered subset.
71
71
  */
72
- export declare function composeCoordinatedActionDirective(left: AdviceFrame, right: AdviceFrame, coordination: "conjunction" | "disjunction" | "unknown", explicitRightDirective: boolean): readonly [AdviceFrame, AdviceFrame];
72
+ export declare function sharedNegativeActionGroupStart(frames: readonly AdviceFrame[], endIndex?: number): number | undefined;
73
+ /**
74
+ * The existing typed coordination owns one directive's polarity and modality.
75
+ * A trailing temporal qualification applies to every daughter of that selected
76
+ * group. Explicit local temporal scope remains local; material
77
+ * and Amount arguments never become shared temporal qualifications.
78
+ */
79
+ export declare function composeCoordinatedActionDirective(frames: AdviceFrame[], right: AdviceFrame, coordination: "conjunction" | "disjunction" | "unknown", explicitRightDirective: boolean): AdviceFrame;
73
80
  /** A contact clause licenses a preposed physical theme, as in a directive
74
81
  * preventing a bottle tip from touching the eye. A nominal and contact head
75
82
  * are required; the causative marker cannot turn an ordinary GIVE into this
@@ -83,6 +90,10 @@ export interface ParsedMedicationGuard {
83
90
  start: number;
84
91
  markerEnd: number;
85
92
  end: number;
93
+ /** Administration head already selected by the guard's consequent construction. */
94
+ administrationStart?: number;
95
+ /** Selected registered withholding consequent; it does not administer a choice dose. */
96
+ withholdingConsequent?: true;
86
97
  text: string;
87
98
  otherwiseHold: boolean;
88
99
  otherwise?: {
@@ -93,19 +104,35 @@ export interface ParsedMedicationGuard {
93
104
  start: number;
94
105
  end: number;
95
106
  };
107
+ /** Selected positive alternative dose, with an explicit or omitted administration head. */
108
+ alternativeDoseStart?: number;
96
109
  /** Authoritative typed derivation reused by the main clause chart. */
97
110
  sign: HpsgSign;
98
111
  }
112
+ export declare function guardHasMeasurement(value: MedicationCondition): boolean;
99
113
  /** Attach already typed procedural withholding/target scope to the same guard
100
114
  * derivation. This retains the predicate daughters in the clause feature graph.
101
115
  * @param guard Selected conditional head/predicate analysis.
102
116
  * @param scope Existing clinical scope sign (including otherwise-hold ownership).
103
117
  */
104
118
  export declare function scopeMedicationGuardSign(guard: ParsedMedicationGuard, scope: HpsgSign): HpsgSign;
119
+ /** An opaque consequent can select a closed predicate without exporting a
120
+ * medication guard or inventing a typed action inside that consequent. */
121
+ export declare function hasFrontedInstructionCondition(source: string, tokens: Token[], head: Token, end: number, lexicon: MedicationConditionLexicalFeatures): boolean;
105
122
  /** Single source of medication-guard meaning: lexical daughters compose via
106
123
  * HPSG predicate/coordination/head constructions, reused by planner and chart.
107
124
  * @param source Exact clinician text.
108
125
  * @param existingTokens Already-lexed tokens when the caller has a source context.
109
126
  * @param withholdingConsequent License supplied only by a typed medication-withholding action daughter.
127
+ * @param options Registered action vocabulary used by the enclosing clause.
128
+ * @param scope An already selected conditional relation and optional closed predicate span.
110
129
  */
111
- export declare function parseMedicationGuard(source: string, existingTokens?: Token[], withholdingConsequent?: true): ParsedMedicationGuard | undefined;
130
+ export declare function parseMedicationGuard(source: string, existingTokens?: Token[], withholdingConsequent?: true, options?: ParseOptions, scope?: {
131
+ relation: AdviceRelation;
132
+ start: number;
133
+ markerEnd: number;
134
+ end?: number;
135
+ }): ParsedMedicationGuard | undefined;
136
+ /** Continue through each selected guard and branch in the same typed grammar
137
+ * so every independent administration retains its own condition scope. */
138
+ export declare function parseMedicationGuards(source: string, tokens: Token[], options?: ParseOptions): ParsedMedicationGuard[];
@@ -3,6 +3,8 @@ import { ParseOptions, RouteCode } from "../types";
3
3
  export interface HpsgDefaultConstraintDeps {
4
4
  setRoute: (state: ParserState, code: RouteCode, text?: string) => void;
5
5
  }
6
+ /** Resolve the duration under the selected local or inherited administration head. */
7
+ export declare function applyAdministrationDurationSemantics(state: ParserState, options?: ParseOptions, inheritedMethod?: boolean): void;
6
8
  export declare function applyHpsgDefaultConstraints(state: ParserState, tokens: readonly {
7
9
  lower: string;
8
10
  canonical?: string;
@@ -1,6 +1,10 @@
1
1
  import { type LexToken } from "../lexer/token-types";
2
- import { AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirPeriodUnit } from "../types";
2
+ import { AdviceForce, AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirPeriodUnit, type FhirPrimitiveElement } from "../types";
3
3
  export { ACTION_SEQUENCE_MARKERS } from "../relation-terminology";
4
+ type MaximumPeriodPreposition = {
5
+ unitDenominator?: boolean;
6
+ rolling?: boolean;
7
+ };
4
8
  type MealRelation = "before" | "after" | "with";
5
9
  type MealTimingByRelation = Map<MealRelation, Map<EventTiming, EventTiming>>;
6
10
  type BodySiteFeatureKind = "nominal" | "partitive" | "locative";
@@ -50,6 +54,7 @@ export declare const BODY_SITE_PARTITIVE_CONNECTORS: Set<string>;
50
54
  export declare const BODY_SITE_BARE_NOMINAL_PREFIXES: Set<string>;
51
55
  export declare const BODY_SITE_BARE_NOMINAL_PREFIX_I18N: Record<string, Record<string, string>>;
52
56
  export declare const BODY_SITE_ATTRIBUTIVE_MODIFIERS: Set<string>;
57
+ export declare const BODY_SITE_POSTPOSITIVE_MODIFIERS: Set<string>;
53
58
  export declare const BODY_SITE_ATTRIBUTIVE_MODIFIER_I18N: Record<string, Record<string, string>>;
54
59
  export declare const OTIC_SITE_WORDS: Set<string>;
55
60
  export declare const OPHTHALMIC_SITE_WORDS: Set<string>;
@@ -62,6 +67,7 @@ export declare function methodAuxiliaryVerbsForLocale(locale: string): ReadonlyS
62
67
  export declare const COORDINATED_NOUN_METHOD_VERBS: Set<string>;
63
68
  export declare const METHOD_NOUN_LEFT_CONTEXT: Map<string, Set<string>>;
64
69
  export declare const PRODUCT_EXTERNAL_MODIFIERS: Set<string>;
70
+ export declare const ROUTE_GOVERNORS: Set<string>;
65
71
  export declare const ROUTE_SITE_PREPOSITIONS: Set<string>;
66
72
  export declare const SITE_DISPLAY_FILLERS: Set<string>;
67
73
  export declare const SITE_MULTIPLICITY_WORDS: Set<string>;
@@ -87,7 +93,10 @@ export declare const PRN_DEFAULT_SITE_CONNECTOR: string;
87
93
  export declare const PRN_COMPACT_REASON_SEPARATORS: Set<string>;
88
94
  export declare const SITE_ROUTE_HINTS_ALLOWED_IN_GRAMMAR: Set<import("../types").SNOMEDCTRouteCodes>;
89
95
  export declare const PRODUCT_METHOD_REALIZATIONS: Record<string, Partial<Record<string, Record<string, string>>>>;
90
- export declare function productMethodRealizations(verb: string, product: string): Record<string, string> | undefined;
96
+ export declare function productMethodRealization(verb: string, product: string): {
97
+ text: string;
98
+ textElement?: FhirPrimitiveElement;
99
+ } | undefined;
91
100
  export declare const PRODUCT_FORM_MODIFIERS: Set<string>;
92
101
  export declare const PRODUCT_SOURCE_PREPOSITIONS: Set<string>;
93
102
  export declare const COMPOUND_DOSE_UNITS: CompoundDoseUnit[];
@@ -97,10 +106,21 @@ export declare const IMPLICIT_SINGLE_DOSE_UNITS: Set<string>;
97
106
  export declare const PERCENT_BODY_AREA_UNITS: Map<string, string>;
98
107
  export declare const DOSE_FRACTION_WORDS: Map<string, number>;
99
108
  export declare const DOSE_FRACTION_DENOMINATOR_WORDS: Map<string, number>;
109
+ export declare const DOSE_DIVISION_HEADS: Set<string>;
110
+ export declare const DOSE_DIVISION_CONNECTORS: Set<string>;
111
+ export declare const DOSE_DIVISION_MODIFIERS: Set<string>;
112
+ export declare const DOSE_DIVISION_PARTICIPLES: Set<string>;
113
+ export declare const DOSE_DIVISION_NOUNS: Set<string>;
100
114
  export declare const DOSE_ADDITIVE_QUANTITY_CONNECTORS: Set<string>;
101
115
  export declare const DOSE_FRACTION_ARTICLES: Set<string>;
102
116
  export declare const DOSE_NUMBER_WORDS: Map<string, number>;
103
117
  export declare const DOSE_UNIT_CONNECTORS: Set<string>;
118
+ /** Calendar dayparts are not elapsed periods for rolling medication limits. */
119
+ export declare const DAYPART_INTERVAL_TOKENS: Map<string, EventTiming>;
120
+ /** Elapsed runtime introducers for the existing infusion construction. */
121
+ export declare const INFUSION_DURATION_LEADS: Map<string, {
122
+ unheaded?: boolean;
123
+ }>;
104
124
  export declare const MILLION_DOSE_MULTIPLIER_TOKENS: Set<string>;
105
125
  export declare const SCHEDULE_UNIT_SEPARATOR_TOKENS: Set<string>;
106
126
  export declare const COMPACT_LIST_SEPARATORS: Set<string>;
@@ -111,9 +131,10 @@ export declare const COUNT_CONNECTOR_WORDS_DATA: Set<string>;
111
131
  export declare const SUPPLEMENTAL_DOSE_MODIFIERS: Set<string>;
112
132
  export declare const MAXIMUM_COUNT_LEAD_TOKENS: Set<string>;
113
133
  export declare const MAXIMUM_COUNT_LEAD_SEQUENCES: string[][];
134
+ export declare const MAXIMUM_COUNT_LEAD_FIRST_TOKENS: Set<string>;
114
135
  export declare const OCCURRENCE_COUNT_WORDS: Set<string>;
115
136
  export declare const OCCURRENCE_COUNT_MODIFIERS: Set<string>;
116
- export declare const MAXIMUM_PERIOD_PREPOSITIONS: Set<string>;
137
+ export declare const MAXIMUM_PERIOD_PREPOSITIONS: Map<string, MaximumPeriodPreposition>;
117
138
  export declare const MAXIMUM_PERIOD_MODIFIERS: Set<string>;
118
139
  export declare const OCCURRENCE_CAP_PERIOD_PHRASES: {
119
140
  parts: string[];
@@ -125,15 +146,30 @@ export declare const FREQUENCY_NUMBER_WORDS_DATA: Record<string, number>;
125
146
  /** Coded course-end events remain advisory until an actual bound is known. */
126
147
  export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
127
148
  kind: string;
149
+ nominals: string[];
128
150
  modifiers: string[];
129
151
  heads: string[];
130
152
  code: string;
131
153
  display: string;
132
154
  i18n: {
155
+ en: string;
133
156
  th: string;
134
157
  };
135
158
  subjects?: undefined;
136
159
  predicates?: undefined;
160
+ } | {
161
+ kind: string;
162
+ heads: string[];
163
+ display: string;
164
+ i18n: {
165
+ en: string;
166
+ th: string;
167
+ };
168
+ nominals?: undefined;
169
+ modifiers?: undefined;
170
+ code?: undefined;
171
+ subjects?: undefined;
172
+ predicates?: undefined;
137
173
  } | {
138
174
  kind: string;
139
175
  subjects: string[];
@@ -142,7 +178,9 @@ export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
142
178
  display: string;
143
179
  i18n: {
144
180
  th: string;
181
+ en?: undefined;
145
182
  };
183
+ nominals?: undefined;
146
184
  modifiers?: undefined;
147
185
  heads?: undefined;
148
186
  } | {
@@ -153,24 +191,35 @@ export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
153
191
  display: string;
154
192
  i18n: {
155
193
  th: string;
194
+ en?: undefined;
156
195
  };
196
+ nominals?: undefined;
157
197
  modifiers?: undefined;
158
198
  heads?: undefined;
159
199
  })[];
200
+ export declare const OPEN_ENDED_COURSE_END_LEADS: Set<string>;
160
201
  /** Nominal quantifiers and event membership for typed medication-dose references. */
202
+ export declare const DOSE_TARGET_NOMINAL_MODIFIERS: Set<string>;
161
203
  export declare const DOSE_TARGET_SLOT_HEADS: Set<string>;
162
- export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "both" | "all">;
204
+ export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "all" | "both">;
163
205
  /** Broad named dayparts can select a unique already stated clock, never invent one. */
164
206
  export declare const DOSE_TARGET_DAYPART_CLOCK_RANGES: Map<EventTiming, {
165
207
  startHour: number;
166
208
  endHour: number;
167
209
  }>;
210
+ /** Select an existing clock within a named daypart, including one crossing midnight. */
211
+ export declare function clockHourInRange(hour: number, range: {
212
+ startHour: number;
213
+ endHour: number;
214
+ }): boolean;
168
215
  /** Meridiem nominals select existing clock slots without asserting a meal time. */
169
216
  export declare const DOSE_TARGET_MERIDIEM_CLOCK_RANGES: Map<string, {
170
217
  startHour: number;
171
218
  endHour: number;
172
219
  }>;
173
220
  export declare const DOSE_TARGET_EVENT_MEMBERS: Map<EventTiming, readonly EventTiming[]>;
221
+ export declare const CALENDAR_EXCLUSION_TOKENS: Set<string>;
222
+ export declare const CALENDAR_EXCLUSION_DAY_HEADS: Set<string>;
174
223
  export declare const CALENDAR_UNIVERSAL_DAY_QUANTIFIERS: Set<string>;
175
224
  export declare const CALENDAR_COMPLEMENT_DAY_MODIFIERS: Set<string>;
176
225
  export declare const CALENDAR_COMPLEMENT_DETERMINERS: Set<string>;
@@ -188,11 +237,15 @@ export declare const ANTE_MERIDIEM_TOKENS: Set<string>;
188
237
  export declare const POST_MERIDIEM_TOKENS: Set<string>;
189
238
  export declare const MERIDIEM_TOKENS: Set<string>;
190
239
  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;
240
+ /** Full clock lists share the existing spaced and compact list separators. */
241
+ export declare function isClockListSeparator(value: string): boolean;
242
+ /** Both typed event daughters must carry their provider's punctuation license. */
243
+ export declare function isCompactDaypartListSeparator(separator: LexToken | undefined, left: LexToken | undefined, right: LexToken | undefined): boolean;
244
+ /** Existing rate-head surfaces retain their registered action valence. */
245
+ export declare const CLINICAL_RATE_ADMINISTRATION_HEADS: Map<string, string>;
195
246
  export declare const MEDICATION_OBJECT_FILLERS: Set<string>;
247
+ export declare const MEDICATION_OBJECT_MODIFIERS: Set<string>;
248
+ export declare const COURSE_CONTINUATION_MODIFIERS: Set<string>;
196
249
  /** Typed resultative adjustment leads; the following cadence owns the new phase. */
197
250
  export declare const PHASE_ADJUSTMENT_LEAD_SEQUENCES: string[][];
198
251
  export declare const PHASE_ADDITION_LEAD_SEQUENCES: string[][];
@@ -201,9 +254,16 @@ export declare const TIMING_ANAPHORA_PHRASES: string[][];
201
254
  export declare const CLOCK_LEAD_TOKENS: Set<string>;
202
255
  export declare const EVENT_PREPOSITIONS: Set<string>;
203
256
  export declare const EVENT_ARTICLE_TOKENS: Set<string>;
257
+ export declare const INSTRUCTION_NOMINAL_ARTICLES: Set<string>;
204
258
  export declare const FIXED_EVENT_PHRASES: Map<string, EventTiming>;
205
259
  export declare const MEAL_RELATION_BY_TOKEN: Map<string, MealRelation>;
206
260
  export declare const MEAL_TIMING_BY_RELATION: MealTimingByRelation;
261
+ /** Realize the existing meal lexicon's instruction wording and translations.
262
+ * Typed qualification and offset scope remain with the HPSG construction. */
263
+ export declare function mealInstructionWording(events: readonly EventTiming[], sourceText: string): {
264
+ text: string;
265
+ i18n?: Record<string, string>;
266
+ };
207
267
  export declare const SLEEP_EVENT_ALIASES: Set<string>;
208
268
  export declare const WAKE_EVENT_ALIASES: Set<string>;
209
269
  export declare const FOOD_EVENT_ALIASES: Set<string>;
@@ -216,7 +276,24 @@ export declare const CALENDAR_MONTH_DAY_FRAMES: {
216
276
  listConnectors: string[];
217
277
  };
218
278
  export declare const RANGE_CONNECTORS: Set<string>;
279
+ export declare const RANGE_HEAD_CONNECTORS: Map<string, string>;
219
280
  export declare const DURATION_LEAD_TOKENS: ReadonlySet<string>;
281
+ /** Temporal quantity governors bound their own nominal, independently of course admission. */
282
+ export declare const DURATION_ARGUMENT_LEAD_TOKENS: ReadonlySet<string>;
283
+ /** Compact count-per-period notation, distinct from a compound dose unit.
284
+ * Canonical lexer aliases and the schedule rule use this same lexical fact. */
285
+ export declare function compactFrequencyParts(surface: string): {
286
+ frequency: number;
287
+ frequencyMax?: number;
288
+ unitSurface: string;
289
+ } | undefined;
290
+ /** Complete compact interval token shared by grammar and timing preview.
291
+ * Consumers retain the existing unit admission and cadence normalization. */
292
+ export declare function compactIntervalParts(surface: string): {
293
+ period: number;
294
+ periodMax?: number;
295
+ unitSurface: string;
296
+ } | undefined;
220
297
  /** Shared source-lexical reading of an unspaced headed duration NP.
221
298
  * HPSG schedule and procedural action grammar consume the same daughter.
222
299
  * No semantic meaning is assigned until each consumer licenses the unit. */
@@ -232,22 +309,49 @@ export declare const EVENT_OFFSET_ARTICLES: Set<string>;
232
309
  export declare const INSTRUCTION_LEADING_SEPARATORS: Set<string>;
233
310
  export declare const INSTRUCTION_START_WORDS: Set<string>;
234
311
  export declare const POSITIVE_DIRECTIVE_MARKERS: Set<string>;
312
+ export declare const ACTION_DIRECTIVE_SUBJECTS: Set<string>;
235
313
  export declare const ACTION_DIRECTIVE_PREFIXES: {
236
314
  parts: readonly string[];
237
315
  polarity: AdvicePolarity | undefined;
238
316
  modality: AdviceModality | undefined;
239
- complement: "contact-clause" | undefined;
317
+ force: AdviceForce | undefined;
318
+ requiresDirectiveBoundary: boolean;
319
+ requiresCoordination: boolean;
320
+ complement: "activity" | "contact-clause" | undefined;
240
321
  }[];
322
+ /** Additional negative prefixes are licensed only after an existing coordination connector. */
323
+ export declare const ACTION_COORDINATED_DIRECTIVE_PREFIXES: {
324
+ parts: readonly string[];
325
+ polarity: AdvicePolarity | undefined;
326
+ modality: AdviceModality | undefined;
327
+ force: AdviceForce | undefined;
328
+ requiresDirectiveBoundary: boolean;
329
+ requiresCoordination: boolean;
330
+ complement: "activity" | "contact-clause" | undefined;
331
+ }[];
332
+ export declare const NEGATIVE_ACTION_DIRECTIVE_LEADS: Set<string>;
241
333
  export declare const ACTION_COORDINATION_CONNECTORS: Set<string>;
242
334
  /** Closed-class contrast that connects two instructions, not a new action. */
243
335
  export declare const ACTION_DISCOURSE_CONNECTORS: Set<string>;
244
336
  /** Compositional phrasal sequencers; single-token THEN remains the relation lexicon's authority. */
337
+ export declare const TRAILING_PHASE_RELATION_ADVERBS: Set<string>;
245
338
  export declare const REGIMEN_SEQUENCE_CONNECTOR_PHRASES: readonly (readonly string[])[];
246
339
  export declare function sequenceConnectorEnd(tokens: readonly LexToken[], start: number): number | undefined;
247
340
  /** Count nouns select whole treatment cycles rather than doses or days. */
248
341
  export declare const CYCLE_COUNT_HEADS: Set<string>;
249
342
  /** Cheap source-lexical gate for typed treatment-relative phase onsets. */
250
343
  export declare const TREATMENT_PERIOD_START_LEADS: Set<string>;
344
+ export declare const RELATIVE_TIME_END_LEADS: Set<string>;
345
+ export declare const NEXT_DAY_MODIFIERS: Set<string>;
346
+ export declare const NEXT_DAY_HEADS: Set<string>;
347
+ export declare const NEXT_DAY_PREPOSITIONS: Set<string>;
348
+ export declare const NEXT_DAY_START_LEADS: Set<string>;
349
+ /** Typed derivation identity shared by lexical timing and phase composition. */
350
+ export declare const NEXT_DAY_SCHEDULE_RULE = "hpsg.lex.schedule.nextDay";
351
+ export declare const NEXT_DAY_ONSET_RULE = "hpsg.lex.schedule.nextDay.onset";
352
+ export declare const PAIRED_REPEATED_DURATION_RULE = "hpsg.lex.schedule.duration.pairedRepeated";
353
+ export declare function isNextDayScheduleRule(rule: string): boolean;
354
+ export declare const FIXED_CLOCK_DAYPART_QUALIFICATION_RULE = "hpsg.cx.schedule.fixed-clock-daypart-qualification";
251
355
  export declare const ACTION_COORDINATION_CONNECTOR_I18N: Record<string, Record<string, string>>;
252
356
  export declare function coordinationConnectorKind(surface: string): "conjunction" | "disjunction" | "unknown";
253
357
  export declare const ACTION_SEQUENCE_RELATION_TOKENS: ReadonlySet<string>;
@@ -304,25 +408,19 @@ export declare const HARD_SEGMENT_BOUNDARY_TOKENS: Set<string>;
304
408
  export declare const CLAUSE_LEAD_WORDS: Set<string>;
305
409
  export declare const LATERAL_MODIFIER_WORDS: Set<string>;
306
410
  /** 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
411
  /** Declarative surface vocabulary for calendar-date relations for typed calendar constituents. */
318
412
  export declare const TEMPORAL_DATE_RELATION_SOURCES: {
319
- readonly startInclusive: string;
320
- readonly startExclusive: string;
321
- readonly endInclusive: string;
322
- readonly endExclusive: string;
413
+ startInclusive: string;
414
+ startExclusive: string;
415
+ endInclusive: string;
416
+ endExclusive: string;
323
417
  };
324
418
  export declare const TEMPORAL_RELATION_LEAD_WORDS: Set<string>;
325
- export declare const OPEN_ENDED_WORDS: Set<string>;
419
+ export declare const OPEN_ENDED_MARKERS: readonly {
420
+ parts: readonly string[];
421
+ requiresStartRelation?: boolean;
422
+ excludedPredecessors?: readonly string[];
423
+ }[];
326
424
  /** Resolve the duration-complement sense of a polysemous continuation head.
327
425
  * A physical attachment still requires its object and is not licensed by this
328
426
  * time-quantity valence. One source constituent is shared by action sense
@@ -337,3 +435,77 @@ export declare function courseContinuationDurationAt(tokens: readonly Pick<LexTo
337
435
  value: number;
338
436
  unit: FhirPeriodUnit;
339
437
  } | undefined;
438
+ /** One range daughter shared by ordinary doses and dimensional quantities. */
439
+ export declare function doseRangeNumberAt(tokens: readonly LexToken[], start: number, limit: number, allowMillion?: boolean, wordValue?: (token: LexToken) => number | undefined): {
440
+ range: {
441
+ low: number;
442
+ high: number;
443
+ };
444
+ numericIndex: number;
445
+ } | undefined;
446
+ /** Authored comparative dose NPs. Only complete number+medication-unit
447
+ * constituents are licensed; "about 3 weeks" stays temporal, and no
448
+ * second text-level dose parser runs after HPSG.
449
+ */
450
+ type DoseComparator = "<" | "<=" | ">" | ">=" | "~";
451
+ export declare const DOSE_COMPARATOR_PREFIXES: Map<string, {
452
+ words: readonly string[];
453
+ comparator: DoseComparator;
454
+ }[]>;
455
+ export declare const DOSE_COMPARATOR_SYMBOLS: Record<string, DoseComparator>;
456
+ /** Shared WHOLE + connector + optional article + fraction head. The
457
+ * caller still owns its medication unit; this cannot swallow two independently
458
+ * unit-bearing coordinated doses. Returns the last number token it owns. */
459
+ export declare function additiveDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, whole: number, allowMillion?: boolean): {
460
+ value: number;
461
+ numericIndex: number;
462
+ } | undefined;
463
+ /** A million is a numeric multiplier, never a medication unit.
464
+ * Shared by exact/comparative scalar and dimensional quantities. Source
465
+ * position advances past a separately spelled multiplier only when present. */
466
+ export declare function millionDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, value: number): {
467
+ value: number;
468
+ numericIndex: number;
469
+ } | undefined;
470
+ /** Numeric source token with an attached unit, e.g. 0.1mcg/kg.
471
+ * A prefix comparator is optional and remains owned by its outer lexeme.
472
+ * This is a bounded token form, never a second whole-SIG parser. */
473
+ export declare function attachedNumberUnitAt(lower: string): {
474
+ value: number;
475
+ rawUnit: string;
476
+ } | undefined;
477
+ /** A compact million suffix shares the attached-numeral decimal shape.
478
+ * The leading decimal point is numeric evidence, never punctuation. */
479
+ export declare function compactMillionDoseNumber(lower: string): number | undefined;
480
+ /** A denominator word belongs to the numeric head before its unit connector. */
481
+ export declare function fractionalDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, value: number, allowMillion?: boolean): {
482
+ value: number;
483
+ numericIndex: number;
484
+ } | undefined;
485
+ /** One bounded quantity-prefix lexeme shared by scalar and dimensional
486
+ * rules. It identifies source tokens; it does not assign a unit or dose.
487
+ * Duration daughters disable medication scaling so m remains their unit. */
488
+ /** Select the registered comparison prefix before its complete numeric daughter. */
489
+ export declare function doseComparatorPrefixAt(tokens: readonly LexToken[], start: number, limit: number, lower: string): {
490
+ comparator: "<" | "<=" | ">" | ">=" | "~";
491
+ numericIndex: number;
492
+ } | undefined;
493
+ export declare function doseComparatorNumberAt(tokens: readonly LexToken[], start: number, limit: number, lower: string, allowMillion?: boolean): {
494
+ comparator: "<" | "<=" | ">" | ">=" | "~";
495
+ value: number;
496
+ numericIndex: number;
497
+ rawUnit?: string;
498
+ } | undefined;
499
+ export declare function normalizeTokenLower(token: LexToken): string;
500
+ export declare function parseClockToken<T extends LexToken>(token: T | undefined, meridiemToken?: T | undefined): {
501
+ value: string;
502
+ tokens: T[];
503
+ } | undefined;
504
+ /** The existing clock grammar together with its registered unit suffix. */
505
+ export declare function parseClockAt<T extends LexToken>(tokens: readonly T[], start: number, limit?: number, consumed?: ReadonlySet<number>): {
506
+ value: string;
507
+ tokens: T[];
508
+ } | undefined;
509
+ export declare const BODY_SITE_SPATIAL_HEADS: Set<string>;
510
+ export declare const BODY_SITE_PARTITIVE_HEAD_LEMMAS: Readonly<Record<string, string>>;
511
+ export declare const BODY_SITE_ATTRIBUTIVE_LATERALITY: Map<string, string>;
@@ -1,4 +1,5 @@
1
1
  import { FhirCoding, MedicationInstructionActionDefinition, ParseOptions, RouteCode } from "../types";
2
+ import { type LexToken } from "../lexer/token-types";
2
3
  export type MethodAction = string;
3
4
  declare function cloneMethodCoding(coding: FhirCoding | undefined): FhirCoding | undefined;
4
5
  /**
@@ -10,6 +11,8 @@ export declare const METHOD_CODING_BY_ACTION: Record<string, FhirCoding>;
10
11
  export declare const METHOD_ACTIONS_WITHOUT_IMPLICIT_ROUTE: Set<string>;
11
12
  export declare const METHOD_ROUTE_OVERRIDE_BY_VERB: Partial<Record<string, RouteCode>>;
12
13
  export declare function resolveMedicationAdministrationMethod(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
14
+ /** A licensed support head and method retain one complete source constituent. */
15
+ export declare function resolveCompoundMedicationMethod(lead: LexToken, following: LexToken | undefined, options?: ParseOptions, productComplement?: boolean): MedicationInstructionActionDefinition | undefined;
13
16
  export declare function isMedicationAdministrationMethod(surface: string, options?: ParseOptions): boolean;
14
17
  export declare function medicationAdministrationMethodCoding(surface: string, options?: ParseOptions): FhirCoding | undefined;
15
18
  export { cloneMethodCoding };
@@ -1,24 +1,67 @@
1
+ import { type InstructionActionProgram } from "../instruction-action-parser";
2
+ import { frameActionDefinition } from "../instruction-graph";
1
3
  import { type AdviceFrame } from "../types";
2
4
  import { type HpsgClauseContext } from "./rule-context";
5
+ type OpaqueSpans = NonNullable<InstructionActionProgram["opaqueSpans"]>;
6
+ type ProceduralProgram = InstructionActionProgram & {
7
+ frontedConditionSpans?: OpaqueSpans;
8
+ };
3
9
  /**
4
10
  * Parse procedural semantics once per ParserState and share the result across
5
- * HPSG lexical constructions. Keeping this cache at the HPSG context layer
6
- * avoids each rule family independently running the instruction parser.
11
+ * HPSG lexical constructions and graph finalization. Keeping this cache in
12
+ * the HPSG context avoids independently parsing the same action program.
7
13
  */
8
- export declare function getProceduralFrames(context: HpsgClauseContext): AdviceFrame[];
14
+ export declare function getProceduralActionProgram(context: Pick<HpsgClauseContext, "state" | "options" | "rawTokens">, plannedProgram?: InstructionActionProgram): ProceduralProgram;
15
+ /** Before chart admission, a complete typed PRN nominal can own source that
16
+ * generic action fallback left opaque. The remaining fronted conditions retain
17
+ * their full spans and the existing subset cache. */
18
+ export declare function resolveOpaquePrnNominals(context: HpsgClauseContext): ProceduralProgram;
19
+ export declare function getProceduralFrames(context: Pick<HpsgClauseContext, "state" | "options" | "rawTokens">): AdviceFrame[];
20
+ /** An explicitly sequenced undosed administration can select a measured
21
+ * preparation. Its material quantities and independently named use stay local. */
22
+ export declare function selectedPreparationAmount(context: Pick<HpsgClauseContext, "tokens" | "options">, frame: AdviceFrame, program: InstructionActionProgram): AdviceFrame["args"][number] | undefined;
23
+ type PreparedUseContext = HpsgClauseContext | Pick<HpsgClauseContext, "tokens" | "options">;
24
+ /** A selected undosed use consumes the previously measured preparation.
25
+ * Its Immediate is local when an independent recurrence, Time or PRN already
26
+ * licenses use; without those, the authored Immediate is executable. */
27
+ export declare function isPreparedMedicationUse(context: PreparedUseContext, frame: AdviceFrame, program: InstructionActionProgram): boolean;
28
+ /** Exact nominal source ownership. A medication noun in some other argument
29
+ * (e.g. an AFTER-taking activity) does not make the held object a drug dose. */
30
+ export declare function actionArgumentSpan(input: string, frame: AdviceFrame, argument: AdviceFrame["args"][number]): {
31
+ start: number;
32
+ end: number;
33
+ } | undefined;
9
34
  /** Existing action-sequence relation shared by condition closure and lexical ownership. */
10
35
  export declare function instructionActionsAreSequenced(context: HpsgClauseContext, startSource: number, endSource: number): boolean;
36
+ /** An independent typed maximum closes the same conditional source scope
37
+ * as a hard clause boundary. Incomplete and predicate-owned counts do not. */
38
+ export declare function hasConditionalAdviceBoundary(context: HpsgClauseContext, start: number, end: number, predicateEnd?: number, prnStart?: number): boolean;
11
39
  /** Compose the consecutive action daughters selected by one fronted condition. */
12
- export declare function proceduralInstructionProgram(context: HpsgClauseContext, firstTargetIndex: number, frames: AdviceFrame[]): AdviceFrame[];
40
+ export declare function proceduralInstructionProgram(context: HpsgClauseContext, firstTargetIndex: number, frames: AdviceFrame[], end?: number): AdviceFrame[];
41
+ /** A written dose outside an already selected action can supply an omitted
42
+ * administration head. The quantity rule remains its semantic owner. */
43
+ export declare function unownedDoseLexicalEnd(context: Pick<HpsgClauseContext, "tokens" | "options"> & {
44
+ limit?: number;
45
+ }, frames: readonly AdviceFrame[], start: number, limit?: number): number | undefined;
46
+ /** A measured procedure's independently selected cadence licenses exact
47
+ * elapsed coverage. Without that proof, retain ordinary primary selection.
48
+ * Methods with registered administration runtime keep their timing owner. */
49
+ export declare function localAdministrationDurationSpan(frame: AdviceFrame, definition: ReturnType<typeof frameActionDefinition>, program: InstructionActionProgram): import("../types").TextRange | undefined;
13
50
  /** Return the conditional's existing action owner, if it is advice rather
14
51
  * than a newly quantified administration. */
52
+ export declare function conditionalAdviceProgramAt(context: HpsgClauseContext, index: number): AdviceFrame[] | undefined;
53
+ export declare function hasSelectedProcedurePrn(context: HpsgClauseContext, index: number): boolean;
15
54
  export declare function conditionalAdviceOwnerAt(context: HpsgClauseContext, index: number): AdviceFrame | undefined;
16
55
  /** Whether this existing action daughter is governed as conditional advice. */
17
56
  export declare function isConditionalAdviceFrame(context: HpsgClauseContext, frame: AdviceFrame): boolean;
57
+ /** A complete Activity can be local to a prepared use. A leading
58
+ * Immediate can also close that use before its adjacent measured daughter. */
59
+ export declare function preparedUseOwnsActivity(context: HpsgClauseContext, start: number, end: number, measured?: boolean): boolean;
18
60
  /** Resolve attachment for an already recognized temporal activity nominal.
19
61
  * A fronted adjunct lies outside its following procedure's own action span. */
20
62
  export declare function followingProcedureOwnsTemporalAdjunct(context: HpsgClauseContext, start: number, end: number): boolean;
21
63
  export type HpsgAttachmentClass = "administration" | "procedure";
22
- export declare function sourceRangeAttachmentClass(context: HpsgClauseContext, start: number, end: number): HpsgAttachmentClass;
64
+ export declare function sourceRangeAttachmentClass(context: HpsgClauseContext, start: number, end: number, selectedNominal?: boolean, selectedPhaseOnset?: boolean, selectedSchedule?: boolean): HpsgAttachmentClass;
23
65
  /** A temporal linker between two complete action events is not an opaque condition. */
24
66
  export declare function actionEventRelationAt(context: HpsgClauseContext, index: number): import("../types").AdviceRelation | undefined;
67
+ export {};
@@ -1,6 +1,6 @@
1
1
  import { ParserState, Token } from "../parser-state";
2
2
  import { EventTiming, FhirDayOfWeek, RouteCode, type CanonicalSigClause, type CanonicalSiteExpr, type CanonicalLexicalCategory, type CanonicalScheduleSemanticField } from "../types";
3
- import { HpsgSign } from "./signature";
3
+ import { HpsgScheduleFeature, HpsgSign } from "./signature";
4
4
  export interface HpsgProjectionDeps {
5
5
  addDayOfWeekList: (state: ParserState, days: FhirDayOfWeek[]) => void;
6
6
  addWhen: (target: EventTiming[], whenCode: EventTiming) => void;
@@ -9,12 +9,43 @@ export interface HpsgProjectionDeps {
9
9
  refreshMethodSurface: (state: ParserState) => void;
10
10
  setRoute: (state: ParserState, code: RouteCode, text?: string) => void;
11
11
  }
12
+ export declare function cloneSiteRestrictions(restrictions: NonNullable<HpsgSign["synsem"]["valence"]["site"]>["restrictions"]): {
13
+ range: {
14
+ start: number;
15
+ end: number;
16
+ } | undefined;
17
+ markerRange: {
18
+ start: number;
19
+ end: number;
20
+ } | undefined;
21
+ predicate: {
22
+ range: {
23
+ start: number;
24
+ end: number;
25
+ } | undefined;
26
+ text: string;
27
+ lemma?: string;
28
+ form: import("../types").BodySiteRestrictionPredicateForm;
29
+ focusText?: string;
30
+ };
31
+ relation: "where";
32
+ sourceText: string;
33
+ }[] | undefined;
34
+ export declare function hasRecurringSchedule(schedule: HpsgScheduleFeature | undefined, positionsRepeat?: boolean): boolean;
35
+ /** A single dated clock locates an elapsed administration, including its
36
+ * authored start date; it does not supply a repeat cadence. Independent
37
+ * cadence, course bounds and additional slots retain recurring ownership. */
38
+ export declare function hasRecurringAdministrationSchedule(schedule: HpsgScheduleFeature | undefined, positionsRepeat?: boolean): boolean;
12
39
  export declare function projectHpsgSignToState(sign: HpsgSign, state: ParserState, tokens: Token[], deps: HpsgProjectionDeps): void;
40
+ /** The selected member of a retained source conjunction, without inferring a
41
+ * new target from coding, text, or a later rendering. */
42
+ export declare function selectedAdministrationTargetIndex(clause: CanonicalSigClause): number | undefined;
13
43
  /**
14
44
  * Return the FHIR projection alternatives licensed by the typed HPSG site
15
45
  * coordination. A disjunction is deliberately one retained canonical clause;
16
46
  * it is never converted into simultaneous administrations.
17
47
  */
48
+ export declare function unexpandedAdministrationTargets(clauses: readonly CanonicalSigClause[]): readonly CanonicalSiteExpr[] | undefined;
18
49
  export declare function administrationTargetProjections(clauses: readonly CanonicalSigClause[]): Array<CanonicalSiteExpr | undefined>;
19
50
  /** Pure pre-FHIR projection from one typed conjunction to one singular site. */
20
51
  export declare function projectAdministrationTargetClauses(clauses: readonly CanonicalSigClause[], target: CanonicalSiteExpr | undefined): CanonicalSigClause[];