ezmedicationinput 0.3.0-beta.1 → 0.3.1

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 (79) hide show
  1. package/README.md +155 -10
  2. package/dist/adapters/canonical-course.d.ts +7 -4
  3. package/dist/adapters/r5-course.d.ts +11 -2
  4. package/dist/advice-locale-adapter.d.ts +24 -0
  5. package/dist/advice.d.ts +39 -3
  6. package/dist/body-site-grammar.d.ts +21 -2
  7. package/dist/body-site-lookup.d.ts +6 -1
  8. package/dist/body-site-spatial.d.ts +7 -1
  9. package/dist/body-site-target.d.ts +35 -3
  10. package/dist/canonical/compile.d.ts +22 -3
  11. package/dist/canonical/course.d.ts +43 -7
  12. package/dist/canonical/dosage-agreement.d.ts +84 -0
  13. package/dist/canonical/format-course.d.ts +4 -2
  14. package/dist/clause-tail-grammar.d.ts +2 -0
  15. package/dist/combine-multilingual-dosages.d.ts +32 -0
  16. package/dist/date-interpretation.d.ts +36 -2
  17. package/dist/dosage-course.d.ts +26 -17
  18. package/dist/event-timing-expression.d.ts +26 -1
  19. package/dist/execution/engine.d.ts +2 -1
  20. package/dist/fhir-quantity-operator.d.ts +37 -1
  21. package/dist/fhir-translations.d.ts +14 -1
  22. package/dist/fhir.d.ts +25 -5
  23. package/dist/format.d.ts +23 -24
  24. package/dist/hpsg/constructions.d.ts +27 -5
  25. package/dist/hpsg/lexical-classes.d.ts +94 -33
  26. package/dist/hpsg/method-lexicon.d.ts +3 -0
  27. package/dist/hpsg/procedural-context.d.ts +51 -3
  28. package/dist/hpsg/projection.d.ts +7 -3
  29. package/dist/hpsg/quantity-lexicon.d.ts +51 -0
  30. package/dist/hpsg/rule-context.d.ts +101 -33
  31. package/dist/hpsg/rules/clinical-quantity-rules.d.ts +1 -1
  32. package/dist/hpsg/rules/condition-rules.d.ts +13 -2
  33. package/dist/hpsg/rules/core-rules.d.ts +5 -2
  34. package/dist/hpsg/rules/prn-rules.d.ts +10 -1
  35. package/dist/hpsg/rules/site-rules.d.ts +10 -1
  36. package/dist/hpsg/rules/timing-rules.d.ts +108 -24
  37. package/dist/hpsg/segmenter.d.ts +2 -2
  38. package/dist/hpsg/signature.d.ts +50 -5
  39. package/dist/hpsg/timing-lexicon.d.ts +18 -2
  40. package/dist/i18n.d.ts +8 -7
  41. package/dist/index.cjs +84275 -66589
  42. package/dist/index.d.ts +13 -3
  43. package/dist/index.js +84263 -66588
  44. package/dist/instruction-action-locale-adapter.d.ts +69 -5
  45. package/dist/instruction-action-parser.d.ts +48 -0
  46. package/dist/instruction-action-terminology.d.ts +22 -1
  47. package/dist/instruction-concept-terminology.d.ts +14 -1
  48. package/dist/instruction-graph-fhir.d.ts +4 -2
  49. package/dist/instruction-graph-ownership.d.ts +96 -0
  50. package/dist/instruction-graph.d.ts +19 -42
  51. package/dist/lexer/lex.d.ts +5 -1
  52. package/dist/lexer/locale.d.ts +14 -0
  53. package/dist/lexer/locales/en.d.ts +11 -0
  54. package/dist/lexer/surface.d.ts +3 -1
  55. package/dist/lexer/token-types.d.ts +6 -0
  56. package/dist/locale-detection.d.ts +4 -2
  57. package/dist/locales/clause/en.d.ts +14 -0
  58. package/dist/locales/course/en.d.ts +5 -0
  59. package/dist/localization.d.ts +6 -0
  60. package/dist/localized-timing.d.ts +1 -1
  61. package/dist/maps.d.ts +38 -12
  62. package/dist/medication-condition.d.ts +105 -11
  63. package/dist/parser-state.d.ts +10 -0
  64. package/dist/parser.d.ts +5 -3
  65. package/dist/prn.d.ts +15 -2
  66. package/dist/regimen/coordination-scope.d.ts +13 -1
  67. package/dist/regimen/grammar.d.ts +7 -1
  68. package/dist/regimen/parallel-course.d.ts +6 -2
  69. package/dist/regimen/planner.d.ts +2 -3
  70. package/dist/regimen/regimen.d.ts +2 -0
  71. package/dist/schedule.d.ts +5 -2
  72. package/dist/snomed.d.ts +3 -0
  73. package/dist/suggest-locale-adapter.d.ts +15 -0
  74. package/dist/symptom-terminology.d.ts +5 -1
  75. package/dist/timing-summary.d.ts +43 -10
  76. package/dist/types.d.ts +213 -16
  77. package/dist/unit-lexicon.d.ts +2 -6
  78. package/dist/utils/units.d.ts +3 -0
  79. package/package.json +1 -1
package/dist/fhir.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ParseOptions } from "./types";
2
2
  import type { HpsgClinicalQuantityFeature } from "./hpsg/signature";
3
3
  import { ParserState } from "./parser-state";
4
- import { CanonicalAdditionalInstructionExpr, CanonicalInstructionGraph, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalDoseRange, CanonicalSigClause, CanonicalScheduleExpr, EventTiming, FhirCodeableConcept, FhirR6CodeableConcept, FhirDosage, FhirExtension, FhirR6Extension, FhirR6Dosage, FhirR6Quantity, FhirRange, FhirR6Range, FhirTiming, FhirTimingRepeat, FhirR6TimingRepeat } from "./types";
4
+ import { CanonicalAdditionalInstructionExpr, CanonicalClinicalAdjuncts, CanonicalInstructionGraph, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalDoseRange, CanonicalDoseExpr, CanonicalSigClause, CanonicalScheduleExpr, EventTiming, FhirCodeableConcept, FhirR6CodeableConcept, FhirDosage, FhirExtension, FhirR6Extension, FhirR6Dosage, FhirR6Quantity, FhirRange, FhirR6Range, FhirTiming, FhirTimingRepeat, FhirR6TimingRepeat } from "./types";
5
5
  /** Known modifier: an independent cadence is restricted by unresolved cycle days. */
6
6
  export declare const CYCLE_DAY_ELIGIBILITY_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-cycle-day-eligibility";
7
7
  /** Read the recognized cycle constraint without interpreting narrative text.
@@ -13,14 +13,21 @@ export declare function getCycleDayConstraint(dosage: FhirDosage | FhirR6Dosage)
13
13
  */
14
14
  export declare function cycleDayConstraintExtension(constraint: CanonicalCycleDayConstraint, previous?: FhirExtension): FhirExtension;
15
15
  export declare const TIMING_FREQUENCY_MIN_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-frequency-min";
16
+ /** Divided administrations share the active treatment day of a civil-day interval. */
17
+ export declare const TIMING_FREQUENCY_WITHIN_DAY_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-frequency-within-day";
16
18
  /** Qualified per-administration duration, independent of a scalar rate denominator. */
17
19
  export declare const TIMING_ADMINISTRATION_DURATION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:timing-administration-duration";
18
20
  /** Decode one classified marker without flattening independent endpoints. */
19
- export declare function parseTimingAdministrationDuration(extension: FhirR6Extension | undefined, current?: Pick<FhirTimingRepeat, "duration" | "durationMax" | "durationUnit">): (Partial<NonNullable<HpsgClinicalQuantityFeature["administrationDuration"]>> & {
21
+ export declare function parseTimingAdministrationDuration(extension: FhirR6Extension | undefined, current?: Pick<FhirR6TimingRepeat, "duration" | "durationMax" | "durationUnit">): (Partial<NonNullable<HpsgClinicalQuantityFeature["administrationDuration"]>> & {
20
22
  range?: import("./canonical/course").CanonicalRange;
21
23
  }) | undefined;
22
24
  /** Modifier: each retained base-schedule opportunity occurs this many minutes later. */
23
25
  export declare const ADMINISTRATION_OFFSET_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-administration-offset";
26
+ /** Modifier: a selective condition cannot allocate the authored shared amount. */
27
+ export declare const CONDITION_ALLOCATION_UNRESOLVED_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-condition-allocation-unresolved";
28
+ /** Keep the selective site's allowance in its own modifier, never on the whole dose. */
29
+ export declare function buildConditionAllocationUnresolvedExtension(target?: CanonicalClinicalAdjuncts["conditionTarget"]): FhirExtension;
30
+ export declare function conditionAllocationTargetFromExtension(marker: FhirR6Extension): CanonicalClinicalAdjuncts["conditionTarget"];
24
31
  export declare function getAdministrationOffsetMinutes(dosage: FhirDosage | FhirR6Dosage): number | undefined;
25
32
  /** Modifier retaining a course duration alongside its absolute calendar bounds. */
26
33
  export declare const ANCHORED_COURSE_DURATION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-anchored-course-duration";
@@ -101,7 +108,14 @@ export declare const TIMING_OCCURRENCE_CAP_EXTENSION_URL = "urn:ezmedicationinpu
101
108
  export declare const TIMING_SHARED_COUNT_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-shared-count";
102
109
  export declare const TIMING_EVENT_CALENDAR_SOURCE_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-event-calendar-source";
103
110
  export declare const PRN_TRIGGER_PHASE_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-prn-trigger-phase";
111
+ /** Explicit counted per-target allocation; anatomical cardinality alone is not this fact. */
112
+ export declare const DOSAGE_DOSE_ALLOCATION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-dose-allocation";
113
+ export declare function getDosageDoseAllocation(dosage: {
114
+ modifierExtension?: FhirR6Extension[];
115
+ }): CanonicalDoseExpr["allocation"];
104
116
  export declare const BODY_SITE_RESTRICTION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-body-site-restriction";
117
+ /** An explicitly authored vehicle volume, independent of active dose or rate. */
118
+ export declare const INFUSION_CARRIER_VOLUME_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-infusion-carrier-volume";
105
119
  export declare const INFUSION_CARRIER_MATERIAL_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-infusion-carrier-material";
106
120
  /** Draft FHIR R5 extension definition, produced from the same typed child
107
121
  * contract as the live encoder. Carrier material is a descriptive vehicle
@@ -187,6 +201,10 @@ export declare function buildInfusionCarrierMaterialStructureDefinition(): {
187
201
  * changes dose/rate scheduling or converts a vehicle into the active drug.
188
202
  */
189
203
  export declare function infusionCarrierMaterialExtension(material: NonNullable<HpsgClinicalQuantityFeature["carrierMaterial"]>): FhirExtension;
204
+ /** Typed FHIR extraction: retain only supplied extension children, never
205
+ * guess a vehicle from original SIG text or volume/mass alone.
206
+ */
207
+ export declare function infusionCarrierMaterialFromFhir(dosage: FhirDosage): HpsgClinicalQuantityFeature["carrierMaterial"];
190
208
  /** Reconstitute dimensional R5 meaning only where the role and amount were
191
209
  * explicitly supplied. Other external rateRatio dosages remain untouched.
192
210
  */
@@ -226,8 +244,10 @@ export declare function extractCanonicalDoseRange(range: FhirRange): {
226
244
  * are read back from this interchange object. R5/R6 adapters own their own
227
245
  * quantity and timing choices around the same exact clinical code payload. */
228
246
  export declare function serializeCanonicalContext(clause: CanonicalSigClause, options?: FhirProjectionOptions): Pick<FhirDosage, "extension" | "route" | "site" | "method" | "additionalInstruction" | "asNeeded" | "asNeededFor" | "patientInstruction">;
229
- /** Core Timing offsets require a nonnegative integer and a qualified event anchor. */
230
- export declare function canUseCoreTimingOffset(when: readonly (string | null)[] | undefined, offset: number | undefined): boolean;
247
+ /** Core Timing offsets require a nonnegative integer and a supplied when
248
+ * element without a neutral meal code. An extension-only primitive is still
249
+ * a supplied element; its annotation does not invent an event identity. */
250
+ export declare function canUseCoreTimingOffset(when: readonly (string | null)[] | undefined, offset: number | undefined, suppliedWhenElement?: boolean): boolean;
231
251
  /** Shared wire Timing/source metadata serializer. This projects the already
232
252
  * scoped canonical schedule; it never parses or interprets external dosage.
233
253
  * R5 and current-R6 adapters independently choose their Quantity encodings. */
@@ -242,7 +262,7 @@ export declare function toFhir(state: ParserState): FhirDosage;
242
262
  /** Decode common coded source annotations for either FHIR version.
243
263
  * No dose, rate, Timing, course, or compatibility marker is interpreted here.
244
264
  * Native-course import supplies an R6 CodeableReference's concept explicitly. */
245
- export declare function deserializeCanonicalContext(dosage: Pick<FhirR6Dosage, "text" | "route" | "method" | "asNeeded" | "asNeededFor" | "additionalInstruction" | "patientInstruction" | "extension"> & {
265
+ export declare function deserializeCanonicalContext(dosage: Pick<FhirR6Dosage, "text" | "route" | "method" | "asNeeded" | "asNeededFor" | "additionalInstruction" | "patientInstruction" | "_patientInstruction" | "extension"> & {
246
266
  site?: FhirR6CodeableConcept;
247
267
  }, options?: ParseOptions): CanonicalSigClause;
248
268
  export declare function canonicalFromFhir(dosage: FhirDosage, options?: ParseOptions): CanonicalSigClause;
package/dist/format.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import type { CourseLanguage } from "./localization";
2
2
  import { ParserState } from "./parser-state";
3
- import { type SigLocalization, type SigLongContext, type SigDoseScope } from "./i18n";
3
+ import { resolveNativeClauseRendering, type SigLocalization, type SigLongContext } from "./i18n";
4
4
  import { type InstructionGraphPrimaryCondition } from "./instruction-graph";
5
- import { type AdviceFrame, type CanonicalAdditionalInstructionExpr, CanonicalDoseExpr, CanonicalScheduleExpr, CanonicalSigClause, EventTiming, FhirPeriodUnit, type MedicationCondition, type FhirDayOfWeek } from "./types";
5
+ import { type AdviceFrame, type CanonicalAdditionalInstructionExpr, CanonicalScheduleExpr, CanonicalSigClause, EventTiming, FhirPeriodUnit, type MedicationCondition, type FhirDayOfWeek } from "./types";
6
6
  import { type TimingSummaryOptions } from "./timing-summary";
7
- export declare const DAY_NAMES: Record<string, string>;
7
+ export declare function scheduleOf(clause: CanonicalSigClause): CanonicalScheduleExpr;
8
8
  /** A method can name a registered manner rather than an action head. */
9
9
  export declare function registeredMethodManner(method: CanonicalSigClause["method"], resolvedMethod?: SigLongContext["resolvedMethod"]): import("./types").AdditionalInstructionDefinition | undefined;
10
10
  export declare function alternateDayEvent(schedule: CanonicalScheduleExpr | undefined): EventTiming | undefined;
@@ -14,7 +14,7 @@ export declare function alternateDayEvent(schedule: CanonicalScheduleExpr | unde
14
14
  * @param schedule Typed timing to realize; source text is never inspected.
15
15
  */
16
16
  export declare function hasDailyRecurrenceAcrossClocks(schedule: CanonicalScheduleExpr | undefined): boolean;
17
- type FrequencyDisplayMode = "daily" | "daily-count" | "daily-range" | "daily-maximum" | "period" | "period-maximum" | "alternate-days" | "calendar-count" | "calendar-range" | "calendar-maximum" | "code" | "code-period" | "count" | "count-bounds";
17
+ type FrequencyDisplayMode = "daily" | "daily-count" | "daily-range" | "daily-maximum" | "period" | "period-maximum" | "alternate-days" | "treatment-day-count" | "calendar-count" | "calendar-range" | "calendar-maximum" | "code" | "code-period" | "count" | "count-bounds";
18
18
  interface FrequencyDisplay {
19
19
  mode: FrequencyDisplayMode;
20
20
  countPrefix: "none" | "count" | "range" | "maximum";
@@ -30,15 +30,12 @@ interface FrequencyDisplay {
30
30
  periodUnit: FhirPeriodUnit;
31
31
  };
32
32
  }
33
+ /** Select the independent cadence label; a selected event owns its own identity. */
34
+ export declare function timingPreviewCadenceCode(code: string, schedule: CanonicalScheduleExpr): string | undefined;
33
35
  /** Select clinical display meaning once; each locale retains its wording. */
34
36
  export declare function frequencyDisplay(schedule: CanonicalScheduleExpr | undefined, uppercaseTimingCode?: boolean): FrequencyDisplay | undefined;
35
37
  export declare function standaloneOccurrenceCount(schedule: CanonicalScheduleExpr | undefined): number | undefined;
36
- /** A typed scalar/range, or an already complete native rich amount, can be
37
- * labelled without selecting it as the administration's prescribed dose. */
38
- export declare function formatDoseEnglish(dose: CanonicalDoseExpr | string, style: "short" | "long", scope?: SigDoseScope): string | undefined;
39
- export declare function joinWithAnd(parts: string[]): string;
40
- /** Discrete doses distribute across paired targets; metric amounts are totals. */
41
- export declare function doseUnitUsesTargetScope(unit: string | undefined): boolean;
38
+ export { doseUnitUsesTargetScope } from "./body-site-target";
42
39
  /** Whether the recurrence supports describing selected days as occurring each month. */
43
40
  export declare function dayOfMonthUsesSingleMonth(schedule: CanonicalScheduleExpr | undefined): boolean;
44
41
  export declare function formatDurationShort(schedule: CanonicalScheduleExpr): string | undefined;
@@ -52,14 +49,18 @@ export interface DurationWording {
52
49
  readonly lower: string;
53
50
  administrationUnit(unit: FhirPeriodUnit, value: number | undefined, maximum: number | undefined, short: boolean, words: CourseLanguage): string;
54
51
  }
55
- export declare function describeDuration(schedule: CanonicalScheduleExpr | undefined, words: CourseLanguage, text?: DurationWording): string | undefined;
56
- export declare function describeAdministrationDuration(schedule: CanonicalScheduleExpr | undefined, short?: boolean, words?: CourseLanguage, text?: DurationWording, prefix?: string): string | undefined;
57
- /** Preserve free labels; recognized cadence prose yields to a typed recurrence. */
58
- export declare function independentTimingText(code: string | undefined, recurrence?: Pick<CanonicalScheduleExpr, "frequency" | "frequencyMax" | "period" | "periodMax" | "periodUnit">): string | undefined;
59
- export declare function timingCodeMatchesRecurrence(schedule: Pick<CanonicalScheduleExpr, "timingCode" | "frequency" | "frequencyMax" | "period" | "periodMax" | "periodUnit" | "when" | "timeOfDay">, code?: string | undefined): boolean;
52
+ export declare function describeDuration(schedule: CanonicalScheduleExpr | undefined, words: CourseLanguage, text: DurationWording): string | undefined;
53
+ export declare function describeAdministrationDuration(schedule: CanonicalScheduleExpr | undefined, short: boolean, words: CourseLanguage, text: DurationWording, prefix?: string): string | undefined;
54
+ type TimingPreviewRecurrence = Pick<CanonicalScheduleExpr, "frequency" | "frequencyMax" | "period" | "periodMax" | "periodUnit"> & {
55
+ when?: readonly (string | null)[];
56
+ timeOfDay?: readonly (string | null)[];
57
+ };
58
+ /** Preserve free labels and independently selected cadence beside a range. */
59
+ export declare function independentTimingText(code: string | undefined, recurrence?: TimingPreviewRecurrence): string | undefined;
60
+ export declare function timingCodeMatchesRecurrence(schedule: TimingPreviewRecurrence & Pick<CanonicalScheduleExpr, "timingCode">, code?: string | undefined): boolean;
60
61
  /** A code-only event supplies display meaning without changing authored timing. */
61
62
  export declare function timingEventPreviewSchedule(schedule: CanonicalScheduleExpr | undefined): CanonicalScheduleExpr | undefined;
62
- interface LongAdministrationTimingParts {
63
+ export interface LongAdministrationTimingParts {
63
64
  frequency?: string;
64
65
  event?: string;
65
66
  eventWindow?: string;
@@ -73,6 +74,7 @@ interface LongAdministrationTimingParts {
73
74
  administrationDuration?: string;
74
75
  duration?: string;
75
76
  occurrenceCap?: string;
77
+ administrationNote?: string;
76
78
  }
77
79
  interface RichAdministrationParts {
78
80
  route?: string;
@@ -84,12 +86,7 @@ interface RichAdministrationParts {
84
86
  coversSingleEvent: boolean;
85
87
  }
86
88
  /** Locale realizers supply words; their clinical timing order is shared. */
87
- export declare function describeClockWindow(schedule: CanonicalScheduleExpr | undefined, timing?: {
88
- sharedAdministration: (body: string, total?: string) => string;
89
- clockWindow: (start: string, end: string, inclusive: boolean) => string;
90
- offset: (minutes: number) => string;
91
- dayShift: (days: number) => string;
92
- }): string | undefined;
89
+ export declare function describeClockWindow(schedule: CanonicalScheduleExpr | undefined, timing: ReturnType<typeof resolveNativeClauseRendering>["timing"]): string | undefined;
93
90
  export declare function appendLongAdministrationTiming(parts: string[], timing: LongAdministrationTimingParts, richTiming?: RichAdministrationParts): void;
94
91
  export declare function richGraphAdministrationTail(clause: CanonicalSigClause, action: AdviceFrame, timing: LongAdministrationTimingParts, parts: RichAdministrationParts): string[];
95
92
  export declare function instructionGraphMatchesDose(clause: CanonicalSigClause): boolean;
@@ -106,11 +103,13 @@ export declare function composeNativePrimaryDirections(rendered: string, authore
106
103
  current?: string;
107
104
  }, clause?: CanonicalSigClause): string;
108
105
  export declare function isEmptyStomachInstruction(instruction: CanonicalAdditionalInstructionExpr): boolean;
106
+ /** One locale-owned allowance label for a selected shared administration group. */
107
+ export declare function formatSharedAdministration(body: string, shared: Pick<NonNullable<CanonicalScheduleExpr["sharedCount"]>, "count" | "countMax">, localization?: SigLocalization): string;
109
108
  export declare function formatNativeCanonicalClause(clause: CanonicalSigClause, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions, authoredPrimary?: string, deferredDirections?: {
110
109
  text?: string;
111
110
  current?: string;
112
- }, sharedCountAlreadyDisplayed?: boolean): string;
111
+ }, sharedCountAlreadyDisplayed?: boolean, administrationTimingNote?: string): string;
113
112
  export declare function formatCanonicalClause(clause: CanonicalSigClause, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions, nativeDefault?: (target: "short" | "long") => string): string;
114
113
  export declare function formatInternal(internal: ParserState, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions): string;
115
114
  export declare function stripTrailingZero(value: number): string;
116
- export {};
115
+ export { DAY_NAMES, formatDoseEnglish, joinWithAnd } from "./locales/clause/en";
@@ -1,3 +1,4 @@
1
+ import { type MedicationConditionLexicalFeatures } from "../medication-condition";
1
2
  import type { Token } from "../parser-state";
2
3
  import type { MedicationCondition, ParseOptions } from "../types";
3
4
  import { AdviceArgumentRole, AdviceRelation, type AdviceArgument, type AdviceFrame } from "../types";
@@ -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,6 +104,8 @@ 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
  }
@@ -103,6 +116,12 @@ export declare function guardHasMeasurement(value: MedicationCondition): boolean
103
116
  * @param scope Existing clinical scope sign (including otherwise-hold ownership).
104
117
  */
105
118
  export declare function scopeMedicationGuardSign(guard: ParsedMedicationGuard, scope: HpsgSign): HpsgSign;
119
+ /** The same predicate constituent is also the daughter of a procedural
120
+ * advice conditional. It need not license a medication administration guard. */
121
+ export declare function closedInstructionPredicate(source: string, tokens: Token[], start: number, end: number, lexicon: MedicationConditionLexicalFeatures, options?: ParseOptions): Pick<import("./signature").HpsgConditionFeature, "predicate" | "predicateTiming">;
122
+ /** An opaque consequent can select a closed predicate without exporting a
123
+ * medication guard or inventing a typed action inside that consequent. */
124
+ export declare function hasFrontedInstructionCondition(source: string, tokens: Token[], head: Token, end: number, lexicon: MedicationConditionLexicalFeatures): boolean;
106
125
  /** Single source of medication-guard meaning: lexical daughters compose via
107
126
  * HPSG predicate/coordination/head constructions, reused by planner and chart.
108
127
  * @param source Exact clinician text.
@@ -117,3 +136,6 @@ export declare function parseMedicationGuard(source: string, existingTokens?: To
117
136
  markerEnd: number;
118
137
  end?: number;
119
138
  }): ParsedMedicationGuard | undefined;
139
+ /** Continue through each selected guard and branch in the same typed grammar
140
+ * so every independent administration retains its own condition scope. */
141
+ export declare function parseMedicationGuards(source: string, tokens: Token[], options?: ParseOptions): ParsedMedicationGuard[];
@@ -1,5 +1,5 @@
1
1
  import { type LexToken } from "../lexer/token-types";
2
- import { AdviceForce, AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirDayOfWeek, FhirPeriodUnit, type FhirPrimitiveElement } from "../types";
2
+ import { AdviceForce, AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirPeriodUnit, type FhirPrimitiveElement } from "../types";
3
3
  export { ACTION_SEQUENCE_MARKERS } from "../relation-terminology";
4
4
  type MaximumPeriodPreposition = {
5
5
  unitDenominator?: boolean;
@@ -54,6 +54,7 @@ export declare const BODY_SITE_PARTITIVE_CONNECTORS: Set<string>;
54
54
  export declare const BODY_SITE_BARE_NOMINAL_PREFIXES: Set<string>;
55
55
  export declare const BODY_SITE_BARE_NOMINAL_PREFIX_I18N: Record<string, Record<string, string>>;
56
56
  export declare const BODY_SITE_ATTRIBUTIVE_MODIFIERS: Set<string>;
57
+ export declare const BODY_SITE_POSTPOSITIVE_MODIFIERS: Set<string>;
57
58
  export declare const BODY_SITE_ATTRIBUTIVE_MODIFIER_I18N: Record<string, Record<string, string>>;
58
59
  export declare const OTIC_SITE_WORDS: Set<string>;
59
60
  export declare const OPHTHALMIC_SITE_WORDS: Set<string>;
@@ -66,6 +67,7 @@ export declare function methodAuxiliaryVerbsForLocale(locale: string): ReadonlyS
66
67
  export declare const COORDINATED_NOUN_METHOD_VERBS: Set<string>;
67
68
  export declare const METHOD_NOUN_LEFT_CONTEXT: Map<string, Set<string>>;
68
69
  export declare const PRODUCT_EXTERNAL_MODIFIERS: Set<string>;
70
+ export declare const ROUTE_GOVERNORS: Set<string>;
69
71
  export declare const ROUTE_SITE_PREPOSITIONS: Set<string>;
70
72
  export declare const SITE_DISPLAY_FILLERS: Set<string>;
71
73
  export declare const SITE_MULTIPLICITY_WORDS: Set<string>;
@@ -104,12 +106,21 @@ export declare const IMPLICIT_SINGLE_DOSE_UNITS: Set<string>;
104
106
  export declare const PERCENT_BODY_AREA_UNITS: Map<string, string>;
105
107
  export declare const DOSE_FRACTION_WORDS: Map<string, number>;
106
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>;
107
114
  export declare const DOSE_ADDITIVE_QUANTITY_CONNECTORS: Set<string>;
108
115
  export declare const DOSE_FRACTION_ARTICLES: Set<string>;
109
116
  export declare const DOSE_NUMBER_WORDS: Map<string, number>;
110
117
  export declare const DOSE_UNIT_CONNECTORS: Set<string>;
111
118
  /** Calendar dayparts are not elapsed periods for rolling medication limits. */
112
- export declare const DAYPART_INTERVAL_TOKENS: Set<string>;
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
+ }>;
113
124
  export declare const MILLION_DOSE_MULTIPLIER_TOKENS: Set<string>;
114
125
  export declare const SCHEDULE_UNIT_SEPARATOR_TOKENS: Set<string>;
115
126
  export declare const COMPACT_LIST_SEPARATORS: Set<string>;
@@ -135,15 +146,30 @@ export declare const FREQUENCY_NUMBER_WORDS_DATA: Record<string, number>;
135
146
  /** Coded course-end events remain advisory until an actual bound is known. */
136
147
  export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
137
148
  kind: string;
149
+ nominals: string[];
138
150
  modifiers: string[];
139
151
  heads: string[];
140
152
  code: string;
141
153
  display: string;
142
154
  i18n: {
155
+ en: string;
143
156
  th: string;
144
157
  };
145
158
  subjects?: undefined;
146
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;
147
173
  } | {
148
174
  kind: string;
149
175
  subjects: string[];
@@ -152,7 +178,9 @@ export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
152
178
  display: string;
153
179
  i18n: {
154
180
  th: string;
181
+ en?: undefined;
155
182
  };
183
+ nominals?: undefined;
156
184
  modifiers?: undefined;
157
185
  heads?: undefined;
158
186
  } | {
@@ -163,11 +191,15 @@ export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
163
191
  display: string;
164
192
  i18n: {
165
193
  th: string;
194
+ en?: undefined;
166
195
  };
196
+ nominals?: undefined;
167
197
  modifiers?: undefined;
168
198
  heads?: undefined;
169
199
  })[];
200
+ export declare const OPEN_ENDED_COURSE_END_LEADS: Set<string>;
170
201
  /** Nominal quantifiers and event membership for typed medication-dose references. */
202
+ export declare const DOSE_TARGET_NOMINAL_MODIFIERS: Set<string>;
171
203
  export declare const DOSE_TARGET_SLOT_HEADS: Set<string>;
172
204
  export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "all" | "both">;
173
205
  /** Broad named dayparts can select a unique already stated clock, never invent one. */
@@ -175,22 +207,18 @@ export declare const DOSE_TARGET_DAYPART_CLOCK_RANGES: Map<EventTiming, {
175
207
  startHour: number;
176
208
  endHour: number;
177
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;
178
215
  /** Meridiem nominals select existing clock slots without asserting a meal time. */
179
216
  export declare const DOSE_TARGET_MERIDIEM_CLOCK_RANGES: Map<string, {
180
217
  startHour: number;
181
218
  endHour: number;
182
219
  }>;
183
220
  export declare const DOSE_TARGET_EVENT_MEMBERS: Map<EventTiming, readonly EventTiming[]>;
184
- export declare const CALENDAR_WEEKDAY_LEXEMES: {
185
- day: FhirDayOfWeek;
186
- patterns: RegExp[];
187
- }[];
188
- export declare const CALENDAR_WEEKDAY_GROUPS: {
189
- pattern: RegExp;
190
- days: FhirDayOfWeek[];
191
- }[];
192
- export declare const CALENDAR_DAY_LIST_CONNECTORS: RegExp;
193
- export declare const CALENDAR_EXCLUSION_CUE: RegExp;
221
+ export declare const CALENDAR_EXCLUSION_TOKENS: Set<string>;
194
222
  export declare const CALENDAR_EXCLUSION_DAY_HEADS: Set<string>;
195
223
  export declare const CALENDAR_UNIVERSAL_DAY_QUANTIFIERS: Set<string>;
196
224
  export declare const CALENDAR_COMPLEMENT_DAY_MODIFIERS: Set<string>;
@@ -209,13 +237,15 @@ export declare const ANTE_MERIDIEM_TOKENS: Set<string>;
209
237
  export declare const POST_MERIDIEM_TOKENS: Set<string>;
210
238
  export declare const MERIDIEM_TOKENS: Set<string>;
211
239
  export declare const LIST_SEPARATORS: Set<string>;
212
- /** Thai daypart daughters license their compact conjunction punctuation.
213
- * Numeric dose slots and non-Thai time ranges do not use this lexical sense.
214
- */
215
- 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;
216
244
  /** Existing rate-head surfaces retain their registered action valence. */
217
245
  export declare const CLINICAL_RATE_ADMINISTRATION_HEADS: Map<string, string>;
218
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>;
219
249
  /** Typed resultative adjustment leads; the following cadence owns the new phase. */
220
250
  export declare const PHASE_ADJUSTMENT_LEAD_SEQUENCES: string[][];
221
251
  export declare const PHASE_ADDITION_LEAD_SEQUENCES: string[][];
@@ -246,7 +276,17 @@ export declare const CALENDAR_MONTH_DAY_FRAMES: {
246
276
  listConnectors: string[];
247
277
  };
248
278
  export declare const RANGE_CONNECTORS: Set<string>;
279
+ export declare const RANGE_HEAD_CONNECTORS: Map<string, string>;
249
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;
250
290
  /** Complete compact interval token shared by grammar and timing preview.
251
291
  * Consumers retain the existing unit admission and cadence normalization. */
252
292
  export declare function compactIntervalParts(surface: string): {
@@ -269,12 +309,25 @@ export declare const EVENT_OFFSET_ARTICLES: Set<string>;
269
309
  export declare const INSTRUCTION_LEADING_SEPARATORS: Set<string>;
270
310
  export declare const INSTRUCTION_START_WORDS: Set<string>;
271
311
  export declare const POSITIVE_DIRECTIVE_MARKERS: Set<string>;
312
+ export declare const ACTION_DIRECTIVE_SUBJECTS: Set<string>;
272
313
  export declare const ACTION_DIRECTIVE_PREFIXES: {
273
314
  parts: readonly string[];
274
315
  polarity: AdvicePolarity | undefined;
275
316
  modality: AdviceModality | undefined;
276
317
  force: AdviceForce | undefined;
277
- complement: "contact-clause" | undefined;
318
+ requiresDirectiveBoundary: boolean;
319
+ requiresCoordination: boolean;
320
+ complement: "activity" | "contact-clause" | undefined;
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;
278
331
  }[];
279
332
  export declare const NEGATIVE_ACTION_DIRECTIVE_LEADS: Set<string>;
280
333
  export declare const ACTION_COORDINATION_CONNECTORS: Set<string>;
@@ -296,6 +349,7 @@ export declare const NEXT_DAY_START_LEADS: Set<string>;
296
349
  /** Typed derivation identity shared by lexical timing and phase composition. */
297
350
  export declare const NEXT_DAY_SCHEDULE_RULE = "hpsg.lex.schedule.nextDay";
298
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";
299
353
  export declare function isNextDayScheduleRule(rule: string): boolean;
300
354
  export declare const FIXED_CLOCK_DAYPART_QUALIFICATION_RULE = "hpsg.cx.schedule.fixed-clock-daypart-qualification";
301
355
  export declare const ACTION_COORDINATION_CONNECTOR_I18N: Record<string, Record<string, string>>;
@@ -354,25 +408,19 @@ export declare const HARD_SEGMENT_BOUNDARY_TOKENS: Set<string>;
354
408
  export declare const CLAUSE_LEAD_WORDS: Set<string>;
355
409
  export declare const LATERAL_MODIFIER_WORDS: Set<string>;
356
410
  /** Explicit temporal construction vocabulary; no medication or specialty-specific dispatch. */
357
- export declare const CYCLE_WORDS: {
358
- name: string;
359
- dayLead: string;
360
- dayPart: string;
361
- listSeparator: string;
362
- periodLead: string;
363
- periodUnit: string;
364
- startLead: string;
365
- repeatCount: string;
366
- };
367
411
  /** Declarative surface vocabulary for calendar-date relations for typed calendar constituents. */
368
412
  export declare const TEMPORAL_DATE_RELATION_SOURCES: {
369
- readonly startInclusive: string;
370
- readonly startExclusive: string;
371
- readonly endInclusive: string;
372
- readonly endExclusive: string;
413
+ startInclusive: string;
414
+ startExclusive: string;
415
+ endInclusive: string;
416
+ endExclusive: string;
373
417
  };
374
418
  export declare const TEMPORAL_RELATION_LEAD_WORDS: Set<string>;
375
- 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
+ }[];
376
424
  /** Resolve the duration-complement sense of a polysemous continuation head.
377
425
  * A physical attachment still requires its object and is not licensed by this
378
426
  * time-quantity valence. One source constituent is shared by action sense
@@ -388,7 +436,7 @@ export declare function courseContinuationDurationAt(tokens: readonly Pick<LexTo
388
436
  unit: FhirPeriodUnit;
389
437
  } | undefined;
390
438
  /** One range daughter shared by ordinary doses and dimensional quantities. */
391
- export declare function doseRangeNumberAt(tokens: readonly LexToken[], start: number, limit: number): {
439
+ export declare function doseRangeNumberAt(tokens: readonly LexToken[], start: number, limit: number, allowMillion?: boolean, wordValue?: (token: LexToken) => number | undefined): {
392
440
  range: {
393
441
  low: number;
394
442
  high: number;
@@ -437,6 +485,11 @@ export declare function fractionalDoseNumberAt(tokens: readonly LexToken[], star
437
485
  /** One bounded quantity-prefix lexeme shared by scalar and dimensional
438
486
  * rules. It identifies source tokens; it does not assign a unit or dose.
439
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;
440
493
  export declare function doseComparatorNumberAt(tokens: readonly LexToken[], start: number, limit: number, lower: string, allowMillion?: boolean): {
441
494
  comparator: "<" | "<=" | ">" | ">=" | "~";
442
495
  value: number;
@@ -448,3 +501,11 @@ export declare function parseClockToken<T extends LexToken>(token: T | undefined
448
501
  value: string;
449
502
  tokens: T[];
450
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,72 @@
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
11
  * HPSG lexical constructions and graph finalization. Keeping this cache in
6
12
  * the HPSG context avoids independently parsing the same action program.
7
13
  */
8
- export declare function getProceduralFrames(context: Pick<HpsgClauseContext, "state" | "options">): 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
+ /** A later conditional head begins its own instruction. Repeated heads
37
+ * joined inside a Boolean predicate retain their shared predicate owner. */
38
+ export declare function isIndependentAdviceConditionLead(context: HpsgClauseContext, index: number, predicateEnd: number): boolean;
39
+ /** An independent typed maximum closes the same conditional source scope
40
+ * as a hard clause boundary. Incomplete and predicate-owned counts do not. */
41
+ export declare function hasConditionalAdviceBoundary(context: HpsgClauseContext, start: number, end: number, predicateEnd?: number, prnStart?: number): boolean;
11
42
  /** Compose the consecutive action daughters selected by one fronted condition. */
12
- export declare function proceduralInstructionProgram(context: HpsgClauseContext, firstTargetIndex: number, frames: AdviceFrame[]): AdviceFrame[];
43
+ export declare function proceduralInstructionProgram(context: HpsgClauseContext, firstTargetIndex: number, frames: AdviceFrame[], end?: number, countedProgram?: boolean): AdviceFrame[];
44
+ /** A written dose outside an already selected action can supply an omitted
45
+ * administration head. The quantity rule remains its semantic owner. */
46
+ export declare function unownedDoseLexicalEnd(context: Pick<HpsgClauseContext, "tokens" | "options"> & {
47
+ limit?: number;
48
+ }, frames: readonly AdviceFrame[], start: number, limit?: number): number | undefined;
49
+ /** A measured procedure's independently selected cadence licenses exact
50
+ * elapsed coverage. Without that proof, retain ordinary primary selection.
51
+ * Methods with registered administration runtime keep their timing owner. */
52
+ export declare function localAdministrationDurationSpan(frame: AdviceFrame, definition: ReturnType<typeof frameActionDefinition>, program: InstructionActionProgram): import("../types").TextRange | undefined;
13
53
  /** Return the conditional's existing action owner, if it is advice rather
14
54
  * than a newly quantified administration. */
55
+ export declare function conditionalAdviceProgramAt(context: HpsgClauseContext, index: number): AdviceFrame[] | undefined;
56
+ export declare function hasSelectedProcedurePrn(context: HpsgClauseContext, index: number): boolean;
15
57
  export declare function conditionalAdviceOwnerAt(context: HpsgClauseContext, index: number): AdviceFrame | undefined;
58
+ /** Range of an explicitly selected counted-advice antecedent. */
59
+ export declare function countedAdviceAntecedentAt(context: HpsgClauseContext, index: number): number | undefined;
16
60
  /** Whether this existing action daughter is governed as conditional advice. */
17
61
  export declare function isConditionalAdviceFrame(context: HpsgClauseContext, frame: AdviceFrame): boolean;
62
+ /** A complete Activity can be local to a prepared use. A leading
63
+ * Immediate can also close that use before its adjacent measured daughter. */
64
+ export declare function preparedUseOwnsActivity(context: HpsgClauseContext, start: number, end: number, measured?: boolean): boolean;
18
65
  /** Resolve attachment for an already recognized temporal activity nominal.
19
66
  * A fronted adjunct lies outside its following procedure's own action span. */
20
67
  export declare function followingProcedureOwnsTemporalAdjunct(context: HpsgClauseContext, start: number, end: number): boolean;
21
68
  export type HpsgAttachmentClass = "administration" | "procedure";
22
- export declare function sourceRangeAttachmentClass(context: HpsgClauseContext, start: number, end: number): HpsgAttachmentClass;
69
+ export declare function sourceRangeAttachmentClass(context: HpsgClauseContext, start: number, end: number, selectedNominal?: boolean, selectedPhaseOnset?: boolean, selectedSchedule?: boolean): HpsgAttachmentClass;
23
70
  /** A temporal linker between two complete action events is not an opaque condition. */
24
71
  export declare function actionEventRelationAt(context: HpsgClauseContext, index: number): import("../types").AdviceRelation | undefined;
72
+ export {};