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,17 +1,27 @@
1
- import { AdviceArgument, AdviceFrame, MedicationInstructionActionDefinition, MedicationInstructionActionRealizer } from "./types";
1
+ import type { BodySiteFeatureStructure } from "./body-site-grammar";
2
+ import { type BodySiteRestriction, AdviceArgument, AdviceFrame, AdviceModality, EventTiming, AdviceRelation, MedicationInstructionActionDefinition, MedicationInstructionActionRealizer } from "./types";
2
3
  export interface InstructionActionRealizationInput {
3
4
  frame: AdviceFrame;
4
5
  locale: string;
5
6
  label: string;
7
+ modalityText?: string;
6
8
  amount?: string;
7
9
  theme?: string;
10
+ /** Nominal selected by the shared action valence, independent of its lexical role. */
11
+ selectedObject?: AdviceArgument;
8
12
  container?: string;
9
13
  destination?: string;
10
14
  site?: string;
11
15
  substance?: string;
12
16
  result?: string;
13
17
  activity?: string;
18
+ selectedActivity?: AdviceArgument;
14
19
  time?: string;
20
+ /** Selected Time's explicit or licensed inherited relation. */
21
+ timeRelation?: AdviceRelation;
22
+ /** Optional output evidence requested by action composition. Set only
23
+ * at the branch that actually includes the selected Time in its wording. */
24
+ timeWasRendered?: boolean;
15
25
  duration?: string;
16
26
  material?: string;
17
27
  manner?: string;
@@ -20,22 +30,99 @@ export interface InstructionActionRealizationInput {
20
30
  translateArgumentConcept: (arg: AdviceArgument) => string;
21
31
  translateQuantity: (quantity: NonNullable<AdviceArgument["quantity"]>) => string;
22
32
  }
33
+ export interface BodySiteRestrictionRealizationInput {
34
+ restriction: BodySiteRestriction;
35
+ relation: string;
36
+ predicateTranslation?: string;
37
+ conditionTranslation?: string;
38
+ symptomTranslation?: string;
39
+ }
40
+ type InstructionObjectDeterminer = "definite" | "indefinite" | "addressee";
23
41
  export interface InstructionActionLocaleAdapter {
24
42
  locale: string;
25
43
  selectLexicalRealization?(input: InstructionActionRealizationInput): InstructionActionRealizationInput;
44
+ /** Select a registered noun under a local determiner. A lexical action
45
+ * compound can already contain the noun at the end of its matched head. */
46
+ qualifiedObjectNominal?(source: string, actionHead: string): {
47
+ head: string;
48
+ determiner: InstructionObjectDeterminer;
49
+ incorporatedHeadLength?: number;
50
+ } | undefined;
51
+ realizeObjectDeterminer?(head: string, determiner: InstructionObjectDeterminer): string;
52
+ /** License a direction qualifier as a separate complement of the action. */
53
+ directionQualifier?(source: string): "bare" | "attributed" | undefined;
26
54
  render(realizer: MedicationInstructionActionRealizer, input: InstructionActionRealizationInput): string | undefined;
27
- renderNegated(input: InstructionActionRealizationInput): string;
28
- applyPositiveModality(text: string, frame: AdviceFrame): string;
55
+ renderNegated(input: InstructionActionRealizationInput, completeAction?: string): string;
56
+ applyPositiveModality(text: string, frame: AdviceFrame, modalityText?: string): string;
29
57
  parseConditionPersistence(body: string): {
30
58
  body: string;
31
59
  persists: boolean;
32
60
  };
33
61
  renderConditionBody(base: string, conditionForm: string | undefined, persists: boolean): string;
34
62
  joinConditionLead(lead: string, body: string): string;
35
- conditionalContinuation(text: string, imperative: boolean): string;
36
- postposedCondition(text: string): string;
63
+ conditionalContinuation(text: string, imperative: boolean, precedingText?: string): string;
64
+ postposedCondition(text: string, precedingText?: string): string;
37
65
  sequenceSeparator(): string;
38
66
  continuationText(text: string, understood: boolean): string;
67
+ withAuthoredDirections?(current: string, source: string): string;
68
+ /** Return undefined to retain an explicit relation for an unrecognized Time. */
69
+ directTime?(time: string, selected?: AdviceArgument, relation?: AdviceRelation, locale?: string): string | undefined;
70
+ /** Wording for a typed meal qualification beside an authored clock. */
71
+ mealInstruction?(events: readonly EventTiming[], defaultText: string): string | undefined;
72
+ /** Language-owned completeness decision for an opaque nominal complement.
73
+ * The graph retains responsibility for polarity, modality and source scope. */
74
+ prefersAuthoredAction?(frame: AdviceFrame, locale: string, translateArgument: (argument: AdviceArgument, locale: string) => string): boolean;
75
+ fallbackConceptDisplay?(display: string): string;
76
+ removeAmountLinker?(text: string): string;
77
+ hasContrastiveNominal?(text: string): boolean;
78
+ composeAttributiveSite?(head: string, qualifiers: readonly string[], source: string): string;
79
+ /** Realize registered nominal modifiers outside a translated anatomical head. */
80
+ bodySiteNominalModifiers?(head: string, modifiers: readonly string[]): string;
81
+ /** Registered wording for an already recognized anatomy; this does not admit input aliases. */
82
+ bodySiteTranslation?(text: string, code?: string): string | undefined;
83
+ bodySiteRestriction?(input: BodySiteRestrictionRealizationInput): string | undefined;
84
+ bodySiteObject?(features: BodySiteFeatureStructure): string;
85
+ bodySiteDisplay?(features: BodySiteFeatureStructure): string;
86
+ bodySiteLaterality?(text: string, laterality: "left" | "right" | "both"): string;
87
+ bodySiteSpatialText?(relation: string, target: string, kind: "locative" | "modifier"): string;
39
88
  }
40
89
  export declare function registerInstructionActionLocaleAdapter(adapter: InstructionActionLocaleAdapter): void;
90
+ export declare function instructionActionLocaleAdapterRevision(): number;
91
+ export declare function registeredInstructionActionLocaleAdapters(): IterableIterator<InstructionActionLocaleAdapter>;
41
92
  export declare function getInstructionActionLocaleAdapter(locale: string): InstructionActionLocaleAdapter;
93
+ export declare function instructionActionDefinitionForRealization(frame: AdviceFrame): MedicationInstructionActionDefinition | undefined;
94
+ /** The selected valence determines which daughter owns the frame relation. */
95
+ export declare function instructionFrameRelationOwnsTemporalArgument(frame: AdviceFrame, arg: AdviceArgument): boolean;
96
+ /** Resolve Site attachment before locale realization or Time consumption. */
97
+ export declare function instructionFrameSiteRelation(frame: AdviceFrame, site?: AdviceArgument): AdviceRelation | undefined;
98
+ export declare function instructionSiteRelation(input: InstructionActionRealizationInput, site?: AdviceArgument): string | undefined;
99
+ /** The selected material owns its attachment independently of other complements. */
100
+ export declare function instructionFrameMaterialRelation(frame: AdviceFrame, material?: AdviceArgument): AdviceRelation;
101
+ export declare const EN_POSITIVE_MODALITY_PREFIX: Partial<Record<AdviceModality, string>>;
102
+ /** Internal selection metadata; public locale inputs and callbacks stay unchanged. */
103
+ type SelectedTimeInput = Pick<InstructionActionRealizationInput, "locale" | "time" | "timeRelation" | "timeWasRendered"> & {
104
+ selectedTime?: AdviceArgument;
105
+ frame?: AdviceFrame;
106
+ };
107
+ /** Consume the selected typed Time once; locale adapters own direct wording. */
108
+ export declare function realizeTimeArgument(c: SelectedTimeInput): string | undefined;
109
+ /** A Duration keeps its own governor in every registered action valence.
110
+ * A supplied elapsed prefix retains the valence's existing For wording;
111
+ * other explicit governors always use their registered duration wording. */
112
+ export declare function realizeDurationArgument(input: Pick<InstructionActionRealizationInput, "frame" | "locale" | "duration">, elapsedPrefix?: string): string | undefined;
113
+ export declare function quantityOnlyInstructionArgument(arg: AdviceArgument | undefined): boolean;
114
+ /** A typed measured nominal without its own noun label retains the opaque
115
+ * argument separately; its source text cannot override the current quantity. */
116
+ export declare function instructionArgumentNeedsAuthoredDirections(arg: AdviceArgument, locale: string): boolean;
117
+ /** Realize an already selected weekday Time through the existing locale labels. */
118
+ export declare function localizedWeekdayArgument(value: string, locale: string | undefined, weekdayName?: (day: string) => string): string | undefined;
119
+ /** These lexical valences use shared composition for a selected relative
120
+ * activity. Providers may retain their own realization of that constituent. */
121
+ export declare function hasRelativeActivityRealization(realizer: MedicationInstructionActionRealizer, input: InstructionActionRealizationInput): boolean;
122
+ /** Shared stock wording; registered advice/action callbacks keep their own output. */
123
+ export declare function thaiNegatedModalityPrefix(frame: AdviceFrame): string;
124
+ export declare const TH_POSITIVE_MODALITY_PREFIX: Partial<Record<AdviceModality, string>>;
125
+ export declare function selectThaiApplyLabel(actionCode: string | undefined, label: string, unit?: string, args?: readonly AdviceArgument[]): string | undefined;
126
+ /** Reuse the registered nominal classes for both site and action realization. */
127
+ export declare function applyBodySiteNominalModifiersThai(translatedBase: string, modifierWords: readonly string[] | undefined): string;
128
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { CanonicalSourceSpan } from "./types";
2
+ import { lexInput } from "./lexer/lex";
3
+ import { AdviceArgument, AdviceFrame, MedicationInstructionActionDefinition, ParseOptions, TextRange } from "./types";
4
+ export type ActionDefinition = MedicationInstructionActionDefinition;
5
+ type Lexeme = ReturnType<typeof lexInput>[number];
6
+ export declare const SNOMED_SYSTEM = "http://snomed.info/sct";
7
+ export declare function key(part: Lexeme | undefined): string;
8
+ interface ActionMatch {
9
+ definition: ActionDefinition;
10
+ length: number;
11
+ separableParticleIndex?: number;
12
+ }
13
+ /** A declared nonfinite form inside a fronted condition supplies an
14
+ * activity to the predicate. A written consequent boundary or explicit
15
+ * directive still licenses the following administration or procedure. */
16
+ export declare function isInstructionConditionActivity(parts: Lexeme[], index: number, definition: ActionDefinition, surface: string): boolean;
17
+ export declare function actionMatchAt(parts: Lexeme[], index: number, options?: ParseOptions, includeGovernedProcedure?: boolean, directivePrefixEnd?: number, productComplement?: boolean): ActionMatch | undefined;
18
+ export declare function codingFromSite(text: string, options?: ParseOptions): AdviceArgument | undefined;
19
+ export declare function trimSemanticText(value: string): string;
20
+ export declare function parseQuantityArgument(parts: Lexeme[], start: number, endExclusive: number, input: string, offset: number, options?: ParseOptions, numberEndExclusive?: number): AdviceArgument | undefined;
21
+ type MeasuredTemporalReference = TextRange & {
22
+ timing?: TextRange;
23
+ };
24
+ type InterleavedCadence = TextRange & {
25
+ meal?: TextRange;
26
+ measuredReference?: MeasuredTemporalReference;
27
+ };
28
+ /** A bounded predicate can describe inability to perform a registered
29
+ * administration. Reuse the same modal/action valence as directive selection. */
30
+ export declare function isNegativeAdministrationAbility(parts: Lexeme[], options?: ParseOptions): boolean;
31
+ /** Preserve the lexical daughter while the conditional owner selects whether
32
+ * its modal predicate belongs to an antecedent or an independent directive. */
33
+ export declare function actionFrameHasEmbeddedModal(parts: Lexeme[], frame: AdviceFrame, options?: ParseOptions): boolean;
34
+ /** Internal selected action/source result; public action parsing still returns frames. */
35
+ export interface InstructionActionProgram {
36
+ frames: AdviceFrame[];
37
+ opaqueSpans?: CanonicalSourceSpan[];
38
+ interleavedCadences?: Map<AdviceFrame, InterleavedCadence>;
39
+ }
40
+ export declare function parseInstructionActionProgram(sourceText: string, baseOffset?: number, options?: ParseOptions, parts?: import("./lexer/token-types").LexToken[]): InstructionActionProgram;
41
+ export declare function parseInstructionActions(sourceText: string, baseOffset?: number, options?: ParseOptions): AdviceFrame[];
42
+ export declare function definitionCanRepresentPrimaryAdministration(definition: ActionDefinition | undefined): boolean;
43
+ export {};
@@ -1,5 +1,20 @@
1
- import { AdviceArgument, FhirCoding, MedicationInstructionActionDefinition, ParseOptions } from "./types";
1
+ import { AdviceArgument, AdviceFrame, CanonicalMethodExpr, FhirCoding, FhirPeriodUnit, FhirR6Coding, MedicationInstructionActionDefinition, ParseOptions } from "./types";
2
2
  export declare const MEDICATION_INSTRUCTION_ACTION_SYSTEM: string;
3
+ /** A registered Repeat operation on an administration head licenses an
4
+ * additional use when the grammar supplies a compatible antecedent. */
5
+ export declare function isRepeatedAdministrationAction(definition: MedicationInstructionActionDefinition | undefined): boolean;
6
+ /** Lexical candidate capability only. The selected HPSG target/argument must
7
+ * still prove medication withholding; a physical object or ordinary drinking
8
+ * warning cannot become a clinical guard from this preliminary head test. */
9
+ export declare function isMedicationWithholdingHeadCandidate(definition: MedicationInstructionActionDefinition | undefined, negated: boolean): boolean;
10
+ /** The selected nominal owns the medication/physical distinction. Unknown
11
+ * qualifiers still require the condition grammar's source proof; a complete
12
+ * physical noun cannot become a dose merely because its name is also a unit. */
13
+ export declare function medicationInstructionActionTypedWithholdingTarget(definition: MedicationInstructionActionDefinition, args: readonly AdviceArgument[], prohibitedAdministration?: boolean): boolean | undefined;
14
+ /** Refine an output-owned selected frame only after its medication target is
15
+ * proved. Stock HOLD has a physical default; custom definitions keep their
16
+ * supplied meaning and wording. Conditional ellipsis is proved by HPSG. */
17
+ export declare function refineMedicationInstructionWithholdingSense(frame: AdviceFrame, definition: MedicationInstructionActionDefinition | undefined): void;
3
18
  export interface MedicationInstructionActionCodeSystem {
4
19
  resourceType: "CodeSystem";
5
20
  url: string;
@@ -23,6 +38,8 @@ export interface MedicationInstructionActionCodeSystem {
23
38
  */
24
39
  export declare function medicationInstructionActionSpanLimit(lead: string, options?: ParseOptions): number;
25
40
  export declare function normalizeActionSurface(value: string): string;
41
+ /** These declared aliases denote an activity without licensing its imperative. */
42
+ export declare function isMedicationInstructionActivityOnlyAlias(definition: MedicationInstructionActionDefinition, surface: string): boolean;
26
43
  /** Preserve coded constituents separately from equivalent whole-action codings. */
27
44
  export declare function cloneMedicationInstructionActionSemanticComponents(components: MedicationInstructionActionDefinition["semanticComponents"]): MedicationInstructionActionDefinition["semanticComponents"];
28
45
  export declare function cloneMedicationInstructionActionRealizerConfig(config: MedicationInstructionActionDefinition["realizerConfig"]): MedicationInstructionActionDefinition["realizerConfig"];
@@ -36,12 +53,36 @@ export declare function medicationInstructionActionContextualCodings(definition:
36
53
  /** Combine only constituents justified by this action's actual typed arguments.
37
54
  * Do not place fragment/finding/qualifier codes in whole-predicate Codings. */
38
55
  export declare function medicationInstructionActionSemanticComponentsForArgs(definition: MedicationInstructionActionDefinition, args: readonly AdviceArgument[]): MedicationInstructionActionDefinition["semanticComponents"];
56
+ /** The selected action owns occurrence duration; a unit restriction never grants a new introducer. */
57
+ export declare function licensesAdministrationDuration(definition: MedicationInstructionActionDefinition | undefined, introducer: string, unit?: FhirPeriodUnit): boolean;
39
58
  export declare function resolveMedicationInstructionSequenceAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
40
59
  export declare function resolveMedicationInstructionSeparableAction(lead: string, particle: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
41
60
  export declare function medicationInstructionActionIsSafetyScopeTarget(surface: string, options?: ParseOptions): boolean;
42
- export declare function resolveMedicationInstructionAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
43
- export declare function getMedicationInstructionAction(code: string): MedicationInstructionActionDefinition | undefined;
61
+ export declare function resolveMedicationInstructionAction(surface: string, options?: ParseOptions, includeCode?: boolean): MedicationInstructionActionDefinition | undefined;
62
+ /** The package lookup accepts saved codes as well as registered surfaces.
63
+ * Internal lexical callers retain the surface-only default above. */
64
+ export declare function resolveMedicationInstructionActionWithCodeFallback(surface: string, options?: ParseOptions, includeCode?: boolean): MedicationInstructionActionDefinition | undefined;
65
+ /** Resolve a declared administration method by exact code identity. Known
66
+ * codings own the verb even when an external edit leaves stale display text.
67
+ * Unknown identities return undefined for the caller's existing text fallback. */
68
+ export declare function resolveMedicationInstructionActionByMethod(coding: FhirR6Coding | undefined, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
69
+ /** A translated coding can precede the known method in a CodeableConcept.
70
+ * Select its recognized identity in one pass and retain the first code as
71
+ * the fallback for wholly unfamiliar concepts. A display-only Coding remains
72
+ * a text fallback when no identity is supplied. The source array is untouched. */
73
+ export declare function selectMedicationInstructionMethodCoding<TCoding extends FhirR6Coding>(codings: readonly TCoding[] | undefined, options?: ParseOptions): TCoding | undefined;
74
+ /** An exact registered method label is compatible only with its supplied identity. */
75
+ export declare function matchesMedicationInstructionMethodDisplay(definition: MedicationInstructionActionDefinition, coding: FhirR6Coding | undefined, text: string): boolean;
76
+ /** Keep compatible authored verbs (Drink and Swallow share a method), while
77
+ * a recognized edited code replaces an incompatible retained verb. */
78
+ export declare function resolveMedicationInstructionActionForMethod(method: (Omit<CanonicalMethodExpr, "coding"> & {
79
+ coding?: FhirR6Coding;
80
+ }) | undefined, options?: ParseOptions, includeQualifiedHead?: boolean): MedicationInstructionActionDefinition | undefined;
81
+ export declare function getMedicationInstructionAction(code: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
44
82
  export declare function listMedicationInstructionActions(): MedicationInstructionActionDefinition[];
83
+ /** A CodeSystem snapshot is a public value, not mutable global schema.
84
+ * Build it with one definition walk and one language-key walk per published
85
+ * action; avoid filter→map and map→filter pipelines on every public call. */
45
86
  export declare function buildMedicationInstructionActionCodeSystem(): MedicationInstructionActionCodeSystem;
46
87
  export declare function medicationInstructionActionCoding(definition: MedicationInstructionActionDefinition): FhirCoding;
47
88
  export declare function medicationInstructionActionCodings(definition: MedicationInstructionActionDefinition): FhirCoding[];
@@ -1,5 +1,9 @@
1
- import { FhirCoding, MedicationInstructionConceptDefinition, ParseOptions } from "./types";
1
+ import { AdviceArgument, FhirCoding, MedicationInstructionConceptDefinition, ParseOptions } from "./types";
2
2
  export declare const MEDICATION_INSTRUCTION_CONCEPT_SYSTEM: string;
3
+ export declare function isAuthoredMeasuredTime(argument: AdviceArgument): boolean;
4
+ /** Both resolved and unresolved relative instruction times remain review-only. */
5
+ export declare function isFirstAdministrationReference(argument: AdviceArgument): boolean;
6
+ export declare function isMedicationDosageFormConcept(conceptId: string | undefined): boolean;
3
7
  export interface MedicationInstructionConceptCodeSystem {
4
8
  resourceType: "CodeSystem";
5
9
  url: string;
@@ -19,8 +23,23 @@ export interface MedicationInstructionConceptCodeSystem {
19
23
  }>;
20
24
  }
21
25
  export declare function normalizeConceptSurface(value: string): string;
26
+ /** Bound complete nominal arbitration by the same registered surfaces as exact lookup. */
27
+ export declare function medicationInstructionConceptSpanLimit(anchor: string, options?: ParseOptions, edge?: "start" | "end"): number;
28
+ export declare function cloneMedicationInstructionConceptComponents(components: MedicationInstructionConceptDefinition["components"]): MedicationInstructionConceptDefinition["components"];
29
+ /** Dictionary definitions are immutable by caller contract. Repeated
30
+ * lexical resolution must not recursively clone the same vocabulary tree.
31
+ * Explicit frame construction still copies only the fields it later edits. */
22
32
  export declare function resolveMedicationInstructionConcept(surface: string, options?: ParseOptions): MedicationInstructionConceptDefinition | undefined;
23
33
  export declare function getMedicationInstructionConcept(code: string, system?: string): MedicationInstructionConceptDefinition | undefined;
24
34
  export declare function listMedicationInstructionConcepts(): MedicationInstructionConceptDefinition[];
35
+ /** The public CodeSystem is freshly returned, but its published concepts
36
+ * require only one source-definition walk and one designation walk each.
37
+ * This avoids filter->map and map->filter intermediary arrays per call. */
25
38
  export declare function buildMedicationInstructionConceptCodeSystem(): MedicationInstructionConceptCodeSystem;
26
39
  export declare function medicationInstructionConceptCodings(definition: MedicationInstructionConceptDefinition): FhirCoding[];
40
+ /** Keep a selected qualifier while translating only registered whole-concept labels. */
41
+ export declare function localizedInstructionConceptText(value: {
42
+ text?: string;
43
+ coding?: FhirCoding;
44
+ i18n?: Record<string, string>;
45
+ }, locale: string): string | undefined;
@@ -1,4 +1,12 @@
1
- import { CanonicalInstructionGraph, FhirExtension } from "./types";
1
+ import { AdviceFrame, CanonicalInstructionCoverage, CanonicalInstructionGraph, FhirExtension } from "./types";
2
2
  export declare const MEDICATION_INSTRUCTION_GRAPH_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-instruction-graph";
3
+ export declare function buildActionExtension(frame: AdviceFrame): FhirExtension;
4
+ export declare function buildInstructionCoverageExtension(coverage: CanonicalInstructionCoverage): FhirExtension;
3
5
  export declare function buildInstructionGraphExtension(graph: CanonicalInstructionGraph | undefined): FhirExtension | undefined;
4
- export declare function parseInstructionGraphExtension(extensions: FhirExtension[] | undefined): CanonicalInstructionGraph | undefined;
6
+ /** One traversal per known graph/action/argument node. Repeated children retain
7
+ * order, first scalar fields retain ownership, and unknown metadata remains
8
+ * outside interpreted clinical meaning. No indexed heap copies or cached
9
+ * input identities are needed to read the same mutable external input again.
10
+ * Infer the complete input array so a union of R5/R6 arrays retains its own
11
+ * element types until the existing URL discriminator selects this graph. */
12
+ export declare function parseInstructionGraphExtension<T extends readonly Pick<FhirExtension, "url">[]>(extensions: T | undefined): CanonicalInstructionGraph | undefined;
@@ -0,0 +1,96 @@
1
+ import { AdviceArgument, AdviceFrame, AdviceModality, AdviceRelation, CanonicalDoseExpr, CanonicalInstructionGraph, CanonicalSigClause, CanonicalAdditionalInstructionExpr, CanonicalSourceSpan, EventTiming, ParseOptions, TextRange } from "./types";
2
+ import { type ActionDefinition } from "./instruction-action-parser";
3
+ export declare function frameActionDefinition(frame: AdviceFrame, options?: ParseOptions): ActionDefinition | undefined;
4
+ export declare function sameArgumentQuantity(left: AdviceArgument, right: AdviceArgument): boolean;
5
+ /** The selected nominal and Amount describe the same measured occurrence. */
6
+ export declare function argumentContainsAmountOccurrence(argument: AdviceArgument, amount: AdviceArgument): boolean;
7
+ /** One source-contained measured companion can also supply a standalone Amount. */
8
+ export declare function amountSharesMeasuredAccompaniment(frame: AdviceFrame, amount: AdviceArgument): boolean;
9
+ export declare function sourceBackedTimeExtension(existing: AdviceFrame, candidate: AdviceFrame): boolean;
10
+ export declare function defaultActionArguments(frame: AdviceFrame): {
11
+ objectArg: AdviceArgument | undefined;
12
+ additionalObjects: AdviceArgument[] | undefined;
13
+ relationTargetArg: AdviceArgument | undefined;
14
+ amountArg: AdviceArgument | undefined;
15
+ additionalAccompaniments: AdviceArgument[] | undefined;
16
+ frameRelationOwner: AdviceArgument | undefined;
17
+ };
18
+ /** An explicitly governed nominal owns its frame relation independently of a Time. */
19
+ export declare function inheritedFrameTimeRelation(frame: AdviceFrame, selected?: ReturnType<typeof defaultActionArguments>): AdviceRelation | undefined;
20
+ export declare function normalizedInstructionSurface(value: string): string;
21
+ export declare function sameAdviceArgumentMeaning(left: AdviceArgument, right: AdviceArgument): boolean;
22
+ /** Typed warning equivalence retains complete qualifiers and the established negative-force tolerance. */
23
+ export declare function sameTypedWarning(left: AdviceFrame, right: AdviceFrame): boolean;
24
+ /** The selected occurrence may gain presentation/coding facts during graph
25
+ * composition. Absent facts permit enrichment; supplied conflicting facts do not. */
26
+ export declare function selectedAdviceFrameMatchesGraph(selected: AdviceFrame, actual: AdviceFrame): boolean;
27
+ /** Locate an authored fragment; this is correspondence, not action identity. */
28
+ export declare function instructionSourceRange(graph: Pick<CanonicalInstructionGraph, "sourceText">, text: string | undefined, source?: string): TextRange | undefined;
29
+ /** Selected instruction evidence covers exactly its complete typed frames. */
30
+ export declare function instructionHasCompleteFrameEvidence(instruction: CanonicalAdditionalInstructionExpr): boolean;
31
+ /** Exact source-backed discourse connector that introduces the first action
32
+ * after the canonical administration. This lets realization preserve contrast
33
+ * without pretending that it is the temporal THEN relation. */
34
+ export declare function instructionGraphPostAdministrationDiscourseConnector(graph: CanonicalInstructionGraph): CanonicalSourceSpan | undefined;
35
+ export declare function codingEquivalent(left: {
36
+ system?: string;
37
+ code?: string;
38
+ } | undefined, right: {
39
+ system?: string;
40
+ code?: string;
41
+ } | undefined): boolean;
42
+ export declare function quantityCoveredByDose(arg: AdviceArgument, dose: CanonicalDoseExpr | undefined): boolean;
43
+ export declare function actionMatchesCanonicalMethod(frame: AdviceFrame, clause: Pick<CanonicalSigClause, "method">, options?: Pick<ParseOptions, "instructionActionMap">): boolean;
44
+ export declare function argumentEventTiming(arg: AdviceArgument): EventTiming | undefined;
45
+ /** Counted or qualified sites use the canonical site's complete dose scope. */
46
+ export declare function canonicalSiteOwnsPrimaryPhrase(clause: CanonicalSigClause): boolean;
47
+ /** Apply the selected primary's live schedule/site in one display-only pass.
48
+ * A source graph clock is independent unless the wire source established
49
+ * structured clock ownership. Source arguments and other actions stay intact. */
50
+ export declare function frameWithCanonicalPrimaryContext(frame: AdviceFrame, clause: CanonicalSigClause): AdviceFrame;
51
+ /**
52
+ * A rich administration frame and its canonical HPSG schedule can refer to
53
+ * the same meal event using different typed relations: CM + before = ACM.
54
+ * Both localizers share this compositional check instead of reparsing the
55
+ * displayed text independently.
56
+ */
57
+ export declare function timeArgumentCoversSingleScheduledEvent(frame: AdviceFrame, arg: AdviceArgument, clause: CanonicalSigClause): boolean;
58
+ export declare function primaryActionCoveredByCanonicalClause(frame: AdviceFrame, actions: readonly AdviceFrame[], clause: CanonicalSigClause, selectedOwner?: AdviceFrame | null, sourceFrame?: AdviceFrame): boolean;
59
+ /** The normalized and source-preserving primary selectors must honor the
60
+ * same current dose, while leaving superseded graph/source data untouched. */
61
+ export declare function primaryAmountConflicts(amount: AdviceArgument | undefined, dose: CanonicalDoseExpr | undefined, removed?: boolean): boolean;
62
+ /** Realize the current Amount without rewriting its saved graph.
63
+ * Its source label may also be embedded in a larger Object ('1 tablet of
64
+ * amoxicillin'); remove only the owned amount, keeping the drug name and the
65
+ * action's independent material/target. Numeric edits and forced localized
66
+ * display use the same typed ownership. */
67
+ export declare function frameWithReconciledAmount(frame: AdviceFrame, sourceAmount: AdviceArgument, currentDose: CanonicalDoseExpr | undefined, replaceAtOwner?: boolean): AdviceFrame;
68
+ type PrimaryInstructionOwnership = NonNullable<CanonicalInstructionGraph["primaryOwnership"]>;
69
+ /** Resolve the selected source head and Amount once while HPSG/action facts
70
+ * and the original vocabulary are available. Older saved graphs reuse this
71
+ * conservative inference; an explicit binding never depends on edited values. */
72
+ export declare function inferPrimaryOwnership(graph: CanonicalInstructionGraph, clause: Pick<CanonicalSigClause, "dose" | "method" | "sourceProjectionVerified">, options?: Pick<ParseOptions, "instructionActionMap">): PrimaryInstructionOwnership;
73
+ export declare function primaryInstructionOwnership(graph: CanonicalInstructionGraph, clause: Pick<CanonicalSigClause, "dose" | "method" | "sourceProjectionVerified">, options?: Pick<ParseOptions, "instructionActionMap">): PrimaryInstructionOwnership;
74
+ export declare function primaryDoseAmountOwner(graph: CanonicalInstructionGraph, clause: Pick<CanonicalSigClause, "dose" | "method" | "sourceProjectionVerified">, options?: Pick<ParseOptions, "instructionActionMap">): {
75
+ action: AdviceFrame;
76
+ argument: AdviceArgument;
77
+ } | undefined;
78
+ /** A sole typed preparation owns the amount before a later administration.
79
+ * Ordinary primary-only graphs return before the ownership walk. */
80
+ export declare function instructionGraphPreparationOwnsDose(clause: CanonicalSigClause, options?: Pick<ParseOptions, "instructionActionMap">): boolean;
81
+ /** Whole-source replay and action realization have the same amount owner.
82
+ * Unrelated later-stage Amounts are not evidence the canonical dose changed. */
83
+ export declare function instructionGraphSourceConflictsWithDose(clause: CanonicalSigClause, options?: Pick<ParseOptions, "instructionActionMap">): boolean;
84
+ export declare function instructionGraphRichPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
85
+ export declare function instructionGraphRoundTripPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
86
+ export declare function instructionGraphPrimarySiteRelation(clause: CanonicalSigClause): AdviceRelation | undefined;
87
+ export declare function instructionGraphPrimaryAdministrationModality(clause: CanonicalSigClause): AdviceModality | undefined;
88
+ /** The selected primary span owns overlapping positive action semantics. */
89
+ export declare function instructionGraphPrimaryOverlap(graph: CanonicalInstructionGraph, frame: AdviceFrame): boolean;
90
+ /** Presentation classification only; action licensing and scope use their own typed facts. */
91
+ export declare function isInstructionGraphDisplayWarning(frame: AdviceFrame): boolean;
92
+ export declare function sourceTextCoversFrameMeaning(frame: AdviceFrame): boolean;
93
+ /** A named region is not an injection depth. Only a rendered anatomical
94
+ * compartment under an injection's INTO attachment can convey that route. */
95
+ export declare function injectionSiteConveysRoute(clause: CanonicalSigClause, compartmentCode: string): boolean;
96
+ export {};
@@ -1,56 +1,74 @@
1
- import { AdviceFrame, AdviceModality, AdviceRelation, CanonicalInstructionGraph, CanonicalSigClause, CanonicalAdditionalInstructionExpr, CanonicalSourceSpan, FhirCoding, ParseOptions, TextRange } from "./types";
2
- export declare function parseInstructionActions(sourceText: string, baseOffset?: number, options?: ParseOptions): AdviceFrame[];
3
- export declare function isSupplementalHydrationInstruction(frame: AdviceFrame): boolean;
4
- export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph): void;
5
- export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions, semanticOwnershipRanges?: readonly TextRange[]): CanonicalInstructionGraph | undefined;
6
- export declare function realizeInstructionAction(frame: AdviceFrame, locale?: string): string;
7
- export declare function instructionGraphRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
8
- export declare function instructionGraphTextParticipatesInRelation(graph: CanonicalInstructionGraph, text: string): boolean;
9
- export declare function instructionGraphSingleActionRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
10
- /**
11
- * Non-coded advice is redundant only when the grammar already owns every
12
- * negative predicate in the same source interval. Free text alone cannot
13
- * justify deleting a distinct clinical prohibition.
14
- */
15
- export declare function instructionGraphCoversTypedWarnings(graph: CanonicalInstructionGraph, frames: readonly AdviceFrame[] | undefined): boolean;
16
- /** A coded qualifier already entailed by the displayed action graph needs no
17
- * second patient-visible sentence, but keeps its exact FHIR coding. */
18
- export declare function instructionGraphEntailsAdviceCoding(graph: CanonicalInstructionGraph, coding: FhirCoding | undefined): boolean;
19
- /**
20
- * Give a complete source-preserved free-text instruction ownership of the
21
- * graph actions whose exact source ranges it contains. This prevents duplicate
22
- * rendering without reinterpreting the instruction or dropping its remaining
23
- * unparsed clinical content.
24
- */
25
- export declare function instructionGraphSourceOwnedByAdvice(graph: CanonicalInstructionGraph, instruction: CanonicalAdditionalInstructionExpr): string[];
26
- /**
27
- * A source-backed additional fragment is fully represented when every
28
- * lexical constituent belongs to a composed action or its licensed
29
- * coordination connector. A partial match cannot delete unresolved advice.
30
- */
31
- export declare function instructionGraphFullyOwnsAdvice(graph: CanonicalInstructionGraph, instruction: CanonicalAdditionalInstructionExpr): boolean;
32
- /** Exact source-backed discourse connector that introduces the first action
33
- * after the canonical administration. This lets realization preserve contrast
34
- * without pretending that it is the temporal THEN relation. */
35
- export declare function instructionGraphPostAdministrationDiscourseConnector(graph: CanonicalInstructionGraph): CanonicalSourceSpan | undefined;
36
- /** Use complete realized negative actions to recognize otherwise untyped FHIR text. */
37
- export declare function instructionGraphRealizesWarningText(graph: CanonicalInstructionGraph, text: string): boolean;
38
- /**
39
- * A rich administration frame and its canonical HPSG schedule can refer to
40
- * the same meal event using different typed relations: CM + before = ACM.
41
- * Both localizers share this compositional check instead of reparsing the
42
- * displayed text independently.
43
- */
44
- export declare function instructionGraphActionCoversSingleScheduledEvent(frame: AdviceFrame, clause: CanonicalSigClause): boolean;
45
- export declare function instructionGraphRichPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
46
- export declare function instructionGraphRoundTripPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
47
- export declare function instructionGraphPrimarySiteRelation(clause: CanonicalSigClause): AdviceRelation | undefined;
48
- export declare function instructionGraphPrimaryAdministrationModality(clause: CanonicalSigClause): AdviceModality | undefined;
49
- export declare function instructionGraphHasNovelNonWarningContent(graph: CanonicalInstructionGraph, representedTexts: readonly string[]): boolean;
1
+ import { AdviceFrame, AdviceRelation, CanonicalInstructionCoverage, CanonicalInstructionGraph, CanonicalInstructionRelation, CanonicalSigClause, CanonicalAdditionalInstructionExpr, CanonicalSourceSpan, FhirCodeableConcept, ParseOptions, TextRange } from "./types";
2
+ export { actionMatchAt, parseQuantityArgument, actionFrameHasEmbeddedModal, parseInstructionActions } from "./instruction-action-parser";
3
+ export { frameActionDefinition, sameTypedWarning, instructionSourceRange, instructionHasCompleteFrameEvidence, instructionGraphPostAdministrationDiscourseConnector, canonicalSiteOwnsPrimaryPhrase, instructionGraphPreparationOwnsDose, instructionGraphSourceConflictsWithDose, instructionGraphRichPrimaryAction, instructionGraphRoundTripPrimaryAction, instructionGraphPrimarySiteRelation, instructionGraphPrimaryAdministrationModality, instructionGraphPrimaryOverlap, isInstructionGraphDisplayWarning } from "./instruction-graph-ownership";
4
+ /** An undosed administration frame can supply counsel about an existing dose.
5
+ * Its typed manner/accompaniment stays distinct from a new dose or clock. */
6
+ export declare function isMedicationAdministrationAdvice(frame: AdviceFrame, options?: ParseOptions): boolean;
7
+ export declare function isSupplementalHydrationInstruction(frame: AdviceFrame, allowMeasured?: boolean): boolean;
8
+ export declare function relationFromSourceText(text: string): AdviceRelation | undefined;
9
+ export declare function buildInstructionCoverage(actions: AdviceFrame[], relations: CanonicalInstructionRelation[], opaqueSpans: CanonicalSourceSpan[]): CanonicalInstructionCoverage;
10
+ export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph, selectedOpaqueSpans?: readonly CanonicalSourceSpan[], selectedGapSpans?: readonly TextRange[]): void;
11
+ export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions, semanticOwnershipRanges?: readonly TextRange[], proceduralFrames?: readonly AdviceFrame[], proceduralOpaqueSpans?: readonly CanonicalSourceSpan[]): CanonicalInstructionGraph | undefined;
12
+ /** Select complete administration techniques from the already-composed clause
13
+ * and action program. Interchange only projects these selected codings. */
14
+ export declare function instructionGraphAdministrationTechnique(clause: CanonicalSigClause): {
15
+ route?: FhirCodeableConcept;
16
+ method?: FhirCodeableConcept;
17
+ } | undefined;
18
+ /** Realize one selected action with its existing external graph scope, when supplied. */
19
+ export declare function realizeInstructionAction(frame: AdviceFrame, locale?: string, graph?: CanonicalInstructionGraph, useAdviceWording?: boolean): string;
20
+ /** A rich source action can carry its own Manner/Time but no Amount because a
21
+ * preceding preparatory verb supplied the original quantity. When the
22
+ * clinician edits the canonical dose, never let that amountless rich action
23
+ * replace the numeric administration text without the CURRENT dose.
24
+ * This is a display-only frame copy, not an edit of source graph/provenance. */
25
+ export declare function realizeRichPrimaryWithCanonicalDose(frame: AdviceFrame, clause: CanonicalSigClause, locale: string, options?: Pick<ParseOptions, "instructionActionMap" | "realizationMode">, coverage?: {
26
+ singleScheduledEvent: boolean;
27
+ }): string;
28
+ /** A graph condition whose primary action is rendered by the clause formatter. */
29
+ export interface InstructionGraphPrimaryCondition {
30
+ text: string;
31
+ position: "pre" | "post";
32
+ start: number;
33
+ imperative: boolean;
34
+ /** Present only when this condition retains untranslated source wording. */
35
+ sourceLocale?: string;
36
+ }
37
+ /** Attach only conditions owned by that primary, before independent graph
38
+ * actions/advice are composed. Ordinary clauses do not allocate this report. */
39
+ export declare function attachInstructionGraphPrimaryConditions(text: string, conditions: InstructionGraphPrimaryCondition[] | undefined, locale: string, guardedPrimary?: boolean): string;
40
+ /** Associate selected advice with current typed action occurrences; no display coverage is inferred. */
41
+ export declare function instructionGraphAdviceAssociation(graph: {
42
+ actions: readonly AdviceFrame[];
43
+ relations?: CanonicalInstructionGraph["relations"];
44
+ }, instruction: CanonicalAdditionalInstructionExpr, includeRepresentation?: boolean): {
45
+ actionIndices: number[];
46
+ representedActionIndices: number[];
47
+ codingProved: boolean;
48
+ };
49
+ /** Generate only new row labels; complete selected groups retain their own
50
+ * localization instead of competing with a partial single-action label. */
51
+ export declare function generateInstructionAdviceTranslations(clause: CanonicalSigClause): Map<CanonicalAdditionalInstructionExpr, Record<string, string>>;
52
+ interface ClauseInstructionRealization {
53
+ pre?: string;
54
+ post?: string;
55
+ whole?: string;
56
+ patient?: string;
57
+ preFlowsIntoAdministration?: boolean;
58
+ postFlowsFromAdministration?: boolean;
59
+ }
60
+ /** Internal clause preview uses the same selected node walk as the public graph
61
+ * realizer. No receipt or source ownership is stored on the clinical values. */
62
+ export declare function realizeClauseInstructions(clause: CanonicalSigClause, locale: string, options: Parameters<typeof realizeInstructionGraph>[2], render: (instruction: CanonicalAdditionalInstructionExpr) => string | undefined, alreadyRendered?: readonly CanonicalAdditionalInstructionExpr[], presentGraphAction?: (text: string) => string | undefined): ClauseInstructionRealization;
50
63
  export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph, locale?: string, options?: {
51
64
  includeWarnings?: boolean;
52
65
  onlyWarnings?: boolean;
53
66
  omitCanonicalAdministration?: CanonicalSigClause;
67
+ /** The selected primary action already realized with its full arguments.
68
+ * Identity remains valid even when imported source wording is absent. */
69
+ omitRenderedAction?: AdviceFrame;
70
+ /** Report conditions attached to the covered primary during this walk. */
71
+ primaryConditions?: InstructionGraphPrimaryCondition[];
54
72
  /** Prefer each understood action's exact source wording when source and target locales match. */
55
73
  preferSourceText?: boolean;
56
74
  /** Source phrases already rendered through another semantic channel. */
@@ -59,4 +77,5 @@ export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph
59
77
  position?: "all" | "pre" | "post";
60
78
  /** Prefer deliberately unambiguous lexical labels when generating parse-safe text. */
61
79
  roundtripSafe?: boolean;
80
+ instructionActionMap?: ParseOptions["instructionActionMap"];
62
81
  }): string | undefined;
package/dist/ir.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ParserState } from "./parser-state";
2
2
  import { CanonicalSigClause } from "./types";
3
- export declare function canonicalClauseHasAdministrationSemantics(clause: CanonicalSigClause): boolean;
3
+ export declare function canonicalClauseHasAdministrationSemantics(clause: CanonicalSigClause, includeConstraints?: boolean): boolean;
4
4
  export declare function buildCanonicalSigClauses(internal: ParserState): CanonicalSigClause[];
5
5
  /**
6
6
  * Convert one segment's relative canonical source ranges into full-SIG ranges.
@@ -1,2 +1,6 @@
1
+ import type { ParseOptions } from "../types";
1
2
  import { LexToken } from "./token-types";
2
- export declare function lexInput(input: string): LexToken[];
3
+ /** Lexical unit punctuation only; the calling constituent licenses continuation. */
4
+ export declare function dottedDoseUnitAt(tokens: readonly LexToken[], index: number): string | undefined;
5
+ /** Detected source language takes precedence; the selected locale fills undetected input. */
6
+ export declare function lexInput(input: string, options?: ParseOptions): LexToken[];
@@ -1,3 +1,4 @@
1
+ import { type MedicationDateLexicon, type MedicationDateLexicalFeatures } from "../date-interpretation";
1
2
  import { LexToken } from "./token-types";
2
3
  export interface MedicationLocaleLexeme {
3
4
  surface: string;
@@ -6,9 +7,22 @@ export interface MedicationLocaleLexeme {
6
7
  export interface MedicationLexerLocalePack {
7
8
  locale: string;
8
9
  apply(tokens: readonly LexToken[], input: string): LexToken[];
10
+ /** Provider-owned canonical token completion retained by vocabulary replacements. */
11
+ completeTokens?(tokens: readonly LexToken[], input: string): LexToken[];
9
12
  listLexemes?(): MedicationLocaleLexeme[];
13
+ /** Canonical support heads that can join an adjacent medication method. */
14
+ joinedMethodAuxiliaries?: readonly string[];
15
+ /** Word boundaries require this pack before advice can select lexical heads. */
16
+ requiresWordSegmentation?: boolean;
17
+ defaultCalendars?: string[];
18
+ /** Declarative lexical slots for the existing structural date grammar.
19
+ * Omitting both date fields retains prior capabilities; explicit undefined clears them. */
20
+ dateLexicon?: MedicationDateLexicon;
21
+ /** Prepared once by registration, never compiled on a parse path. */
22
+ dateLexicalFeatures?: MedicationDateLexicalFeatures;
10
23
  }
11
24
  export declare function registerMedicationLexerLocalePack(pack: MedicationLexerLocalePack): void;
25
+ export declare function getJoinedMedicationMethodLocales(lead: string): ReadonlySet<string> | undefined;
12
26
  export declare function medicationLexerLocalePackRevision(): number;
13
27
  export declare function getMedicationLexerLocalePack(locale: string): MedicationLexerLocalePack | undefined;
14
28
  export declare function applyLocaleLexicon(tokens: readonly LexToken[], input: string, locale?: string): LexToken[];
@@ -0,0 +1,11 @@
1
+ import { type LexToken } from "../token-types";
2
+ /** English compact meridiem spellings contribute an explicit canonical clock.
3
+ * Numeric validation and conversion remain in the shared clock grammar. */
4
+ export declare function englishCompactClockLexeme(value: string): string | undefined;
5
+ /** Match one registered phrase at the current provider cursor. Selected
6
+ * canonical members retain precedence; the merged token keeps the full source. */
7
+ export declare function englishRelationPhraseAt(tokens: readonly LexToken[], cursor: number, input: string): {
8
+ token: LexToken;
9
+ length: number;
10
+ } | undefined;
11
+ export declare function applyEnglishLocaleLexicon(tokens: readonly LexToken[], input: string): LexToken[];
@@ -8,7 +8,7 @@ export interface MedicationSurfaceSegmenter {
8
8
  segment(input: string): Iterable<MedicationSurfaceSegment>;
9
9
  }
10
10
  export declare function registerMedicationSurfaceSegmenter(segmenter: MedicationSurfaceSegmenter): void;
11
- export declare function listMedicationSurfaceSegmenters(): MedicationSurfaceSegmenter[];
11
+ export declare function listMedicationSurfaceSegmenters(): Readonly<MedicationSurfaceSegmenter>[];
12
12
  export declare function registerIntlMedicationSurfaceSegmenter(locale: string, script: RegExp): void;
13
13
  export declare function splitMedicationScriptRuns(value: string): Array<{
14
14
  text: string;