ezmedicationinput 0.3.0 → 0.3.2-beta.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 (42) hide show
  1. package/README.md +138 -0
  2. package/dist/adapters/r5-course.d.ts +6 -0
  3. package/dist/body-site-grammar.d.ts +6 -2
  4. package/dist/body-site-target.d.ts +4 -1
  5. package/dist/canonical/course.d.ts +4 -1
  6. package/dist/canonical/dosage-agreement.d.ts +84 -0
  7. package/dist/canonical/format-course.d.ts +8 -1
  8. package/dist/combine-multilingual-dosages.d.ts +32 -0
  9. package/dist/event-timing-expression.d.ts +3 -1
  10. package/dist/execution/engine.d.ts +2 -1
  11. package/dist/fhir-translations.d.ts +13 -0
  12. package/dist/fhir.d.ts +1 -1
  13. package/dist/format.d.ts +4 -1
  14. package/dist/hpsg/constructions.d.ts +3 -0
  15. package/dist/hpsg/lexical-classes.d.ts +6 -0
  16. package/dist/hpsg/procedural-context.d.ts +11 -6
  17. package/dist/hpsg/projection.d.ts +2 -2
  18. package/dist/hpsg/rule-context.d.ts +9 -4
  19. package/dist/hpsg/rules/core-rules.d.ts +5 -3
  20. package/dist/hpsg/rules/prn-rules.d.ts +2 -1
  21. package/dist/hpsg/rules/timing-rules.d.ts +35 -25
  22. package/dist/hpsg/signature.d.ts +31 -1
  23. package/dist/hpsg/timing-lexicon.d.ts +5 -0
  24. package/dist/i18n.d.ts +3 -0
  25. package/dist/index.cjs +49230 -43847
  26. package/dist/index.d.ts +6 -1
  27. package/dist/index.js +49218 -43846
  28. package/dist/instruction-action-locale-adapter.d.ts +21 -3
  29. package/dist/instruction-action-parser.d.ts +16 -1
  30. package/dist/instruction-action-terminology.d.ts +7 -0
  31. package/dist/instruction-concept-terminology.d.ts +1 -0
  32. package/dist/instruction-graph-ownership.d.ts +9 -2
  33. package/dist/instruction-graph.d.ts +15 -4
  34. package/dist/locale-realization.d.ts +2 -0
  35. package/dist/locales/course/en.d.ts +10 -5
  36. package/dist/localization.d.ts +8 -1
  37. package/dist/medication-condition.d.ts +36 -1
  38. package/dist/prn.d.ts +2 -0
  39. package/dist/schedule.d.ts +5 -2
  40. package/dist/timing-summary.d.ts +3 -2
  41. package/dist/types.d.ts +104 -4
  42. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import type { BodySiteFeatureStructure } from "./body-site-grammar";
2
- import { type BodySiteRestriction, AdviceArgument, AdviceFrame, AdviceModality, EventTiming, AdviceRelation, MedicationInstructionActionDefinition, MedicationInstructionActionRealizer } from "./types";
2
+ import { type CourseLanguage } from "./localization";
3
+ import { type BodySiteRestriction, AdviceArgument, AdviceFrame, AdviceModality, EventTiming, AdviceRelation, MedicationInstructionActionDefinition, type MedicationCondition, type CanonicalAdditionalInstructionExpr, MedicationInstructionActionRealizer } from "./types";
3
4
  export interface InstructionActionRealizationInput {
4
5
  frame: AdviceFrame;
5
6
  locale: string;
@@ -59,10 +60,18 @@ export interface InstructionActionLocaleAdapter {
59
60
  persists: boolean;
60
61
  };
61
62
  renderConditionBody(base: string, conditionForm: string | undefined, persists: boolean): string;
63
+ renderConditionMeasurement?(condition: Extract<MedicationCondition, {
64
+ kind: "measurement";
65
+ }>): string;
66
+ parseConditionWorsening?(body: string): string | undefined;
67
+ renderConditionWorsening?(body: string): string;
68
+ renderCountedAdviceSituation?(condition: AdviceArgument): string | undefined;
69
+ joinConditionOperands?(operator: "all" | "any" | "not", operands: string[]): string;
62
70
  joinConditionLead(lead: string, body: string): string;
63
71
  conditionalContinuation(text: string, imperative: boolean, precedingText?: string): string;
64
72
  postposedCondition(text: string, precedingText?: string): string;
65
- sequenceSeparator(): string;
73
+ sequenceSeparator(sharedGuard?: boolean): string;
74
+ coordinatedAdviceSeparator?(moreSiblings?: boolean): string;
66
75
  continuationText(text: string, understood: boolean): string;
67
76
  withAuthoredDirections?(current: string, source: string): string;
68
77
  /** Return undefined to retain an explicit relation for an unrecognized Time. */
@@ -86,6 +95,14 @@ export interface InstructionActionLocaleAdapter {
86
95
  bodySiteLaterality?(text: string, laterality: "left" | "right" | "both"): string;
87
96
  bodySiteSpatialText?(relation: string, target: string, kind: "locative" | "modifier"): string;
88
97
  }
98
+ /** A typed measurement supplies its live operator, value and unit. The
99
+ * language provider owns only the registered observation name. */
100
+ export declare function realizeMedicationMeasurement(condition: Extract<MedicationCondition, {
101
+ kind: "measurement";
102
+ }>, words: Pick<CourseLanguage, "measurementName">): string;
103
+ /** A registered Time qualifier joins the administration's existing timing
104
+ * phrase. Unknown authored instructions retain their separate source row. */
105
+ export declare function localizedTemporalInstruction(instruction: CanonicalAdditionalInstructionExpr, locale: string): string | undefined;
89
106
  export declare function registerInstructionActionLocaleAdapter(adapter: InstructionActionLocaleAdapter): void;
90
107
  export declare function instructionActionLocaleAdapterRevision(): number;
91
108
  export declare function registeredInstructionActionLocaleAdapters(): IterableIterator<InstructionActionLocaleAdapter>;
@@ -109,7 +126,7 @@ export declare function realizeTimeArgument(c: SelectedTimeInput): string | unde
109
126
  /** A Duration keeps its own governor in every registered action valence.
110
127
  * A supplied elapsed prefix retains the valence's existing For wording;
111
128
  * other explicit governors always use their registered duration wording. */
112
- export declare function realizeDurationArgument(input: Pick<InstructionActionRealizationInput, "frame" | "locale" | "duration">, elapsedPrefix?: string): string | undefined;
129
+ export declare function realizeDurationArgument(input: Pick<InstructionActionRealizationInput, "frame" | "locale" | "duration" | "realizerConfig">, elapsedPrefix?: string): string | undefined;
113
130
  export declare function quantityOnlyInstructionArgument(arg: AdviceArgument | undefined): boolean;
114
131
  /** A typed measured nominal without its own noun label retains the opaque
115
132
  * argument separately; its source text cannot override the current quantity. */
@@ -124,5 +141,6 @@ export declare function thaiNegatedModalityPrefix(frame: AdviceFrame): string;
124
141
  export declare const TH_POSITIVE_MODALITY_PREFIX: Partial<Record<AdviceModality, string>>;
125
142
  export declare function selectThaiApplyLabel(actionCode: string | undefined, label: string, unit?: string, args?: readonly AdviceArgument[]): string | undefined;
126
143
  /** Reuse the registered nominal classes for both site and action realization. */
144
+ export declare function applyBodySiteNominalModifiersEnglish(text: string, modifiers: readonly string[]): string;
127
145
  export declare function applyBodySiteNominalModifiersThai(translatedBase: string, modifierWords: readonly string[] | undefined): string;
128
146
  export {};
@@ -14,12 +14,25 @@ interface ActionMatch {
14
14
  * activity to the predicate. A written consequent boundary or explicit
15
15
  * directive still licenses the following administration or procedure. */
16
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;
17
+ export declare function actionMatchAt(parts: Lexeme[], index: number, options?: ParseOptions, includeGovernedProcedure?: boolean, directivePrefixEnd?: number, productComplement?: boolean, includeSeparable?: boolean, endExclusive?: number): ActionMatch | undefined;
18
18
  export declare function codingFromSite(text: string, options?: ParseOptions): AdviceArgument | undefined;
19
19
  export declare function trimSemanticText(value: string): string;
20
+ /** A temporal governor can select a complete registered Activity nominal
21
+ * without introducing an executable clock or an opaque connector Time. */
22
+ export declare function knownTemporalActivity(parts: Lexeme[], start: number, end: number, input: string, options?: ParseOptions, measuredOnly?: boolean): AdviceArgument | undefined;
20
23
  export declare function parseQuantityArgument(parts: Lexeme[], start: number, endExclusive: number, input: string, offset: number, options?: ParseOptions, numberEndExclusive?: number): AdviceArgument | undefined;
21
24
  type MeasuredTemporalReference = TextRange & {
22
25
  timing?: TextRange;
26
+ clockTiming?: {
27
+ arguments: AdviceArgument[];
28
+ startIndex: number;
29
+ endIndex: number;
30
+ sourceEnd: number;
31
+ };
32
+ continuation?: {
33
+ span: TextRange;
34
+ lemma: string;
35
+ };
23
36
  };
24
37
  type InterleavedCadence = TextRange & {
25
38
  meal?: TextRange;
@@ -28,6 +41,8 @@ type InterleavedCadence = TextRange & {
28
41
  /** A bounded predicate can describe inability to perform a registered
29
42
  * administration. Reuse the same modal/action valence as directive selection. */
30
43
  export declare function isNegativeAdministrationAbility(parts: Lexeme[], options?: ParseOptions): boolean;
44
+ /** An overt, licensed directive prefix can close a fronted advice condition. */
45
+ export declare function actionFrameHasExplicitDirective(parts: Lexeme[], frame: AdviceFrame, options?: ParseOptions): boolean;
31
46
  /** Preserve the lexical daughter while the conditional owner selects whether
32
47
  * its modal predicate belongs to an antecedent or an independent directive. */
33
48
  export declare function actionFrameHasEmbeddedModal(parts: Lexeme[], frame: AdviceFrame, options?: ParseOptions): boolean;
@@ -55,7 +55,14 @@ export declare function medicationInstructionActionContextualCodings(definition:
55
55
  export declare function medicationInstructionActionSemanticComponentsForArgs(definition: MedicationInstructionActionDefinition, args: readonly AdviceArgument[]): MedicationInstructionActionDefinition["semanticComponents"];
56
56
  /** The selected action owns occurrence duration; a unit restriction never grants a new introducer. */
57
57
  export declare function licensesAdministrationDuration(definition: MedicationInstructionActionDefinition | undefined, introducer: string, unit?: FhirPeriodUnit): boolean;
58
+ /** Resolve configured candidates in one map traversal. Sequence-only aliases
59
+ * retain priority over ordinary forms, including the stock sequence fallback. */
60
+ export declare function resolveMedicationInstructionActionCandidates(surfaces: readonly string[], map: NonNullable<ParseOptions["instructionActionMap"]>, includeSequence?: boolean): {
61
+ surface: string;
62
+ definition: MedicationInstructionActionDefinition;
63
+ } | undefined;
58
64
  export declare function resolveMedicationInstructionSequenceAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
65
+ export declare function hasMedicationInstructionSeparableActionLead(surface: string, options?: ParseOptions): boolean;
59
66
  export declare function resolveMedicationInstructionSeparableAction(lead: string, particle: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
60
67
  export declare function medicationInstructionActionIsSafetyScopeTarget(surface: string, options?: ParseOptions): boolean;
61
68
  export declare function resolveMedicationInstructionAction(surface: string, options?: ParseOptions, includeCode?: boolean): MedicationInstructionActionDefinition | undefined;
@@ -30,6 +30,7 @@ export declare function cloneMedicationInstructionConceptComponents(components:
30
30
  * lexical resolution must not recursively clone the same vocabulary tree.
31
31
  * Explicit frame construction still copies only the fields it later edits. */
32
32
  export declare function resolveMedicationInstructionConcept(surface: string, options?: ParseOptions): MedicationInstructionConceptDefinition | undefined;
33
+ export declare function argumentFromConceptDefinition(definition: MedicationInstructionConceptDefinition, sourceText: string): AdviceArgument;
33
34
  export declare function getMedicationInstructionConcept(code: string, system?: string): MedicationInstructionConceptDefinition | undefined;
34
35
  export declare function listMedicationInstructionConcepts(): MedicationInstructionConceptDefinition[];
35
36
  /** The public CodeSystem is freshly returned, but its published concepts
@@ -41,6 +41,12 @@ export declare function codingEquivalent(left: {
41
41
  } | undefined): boolean;
42
42
  export declare function quantityCoveredByDose(arg: AdviceArgument, dose: CanonicalDoseExpr | undefined): boolean;
43
43
  export declare function actionMatchesCanonicalMethod(frame: AdviceFrame, clause: Pick<CanonicalSigClause, "method">, options?: Pick<ParseOptions, "instructionActionMap">): boolean;
44
+ /**
45
+ * Native HPSG owners can fully represent a broad primary nominal before the
46
+ * instruction graph is serialized. Its unowned or independently coded content
47
+ * remains on the action; no source recognition occurs during wire formatting.
48
+ */
49
+ export declare function primaryNominalCoveredBySelectedSource(arg: AdviceArgument, frame: AdviceFrame, clause: CanonicalSigClause): boolean;
44
50
  export declare function argumentEventTiming(arg: AdviceArgument): EventTiming | undefined;
45
51
  /** Counted or qualified sites use the canonical site's complete dose scope. */
46
52
  export declare function canonicalSiteOwnsPrimaryPhrase(clause: CanonicalSigClause): boolean;
@@ -71,10 +77,11 @@ type PrimaryInstructionOwnership = NonNullable<CanonicalInstructionGraph["primar
71
77
  * conservative inference; an explicit binding never depends on edited values. */
72
78
  export declare function inferPrimaryOwnership(graph: CanonicalInstructionGraph, clause: Pick<CanonicalSigClause, "dose" | "method" | "sourceProjectionVerified">, options?: Pick<ParseOptions, "instructionActionMap">): PrimaryInstructionOwnership;
73
79
  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">): {
80
+ export interface PrimaryDoseAmountOwner {
75
81
  action: AdviceFrame;
76
82
  argument: AdviceArgument;
77
- } | undefined;
83
+ }
84
+ export declare function primaryDoseAmountOwner(graph: CanonicalInstructionGraph, clause: Pick<CanonicalSigClause, "dose" | "method" | "sourceProjectionVerified">, options?: Pick<ParseOptions, "instructionActionMap">): PrimaryDoseAmountOwner | undefined;
78
85
  /** A sole typed preparation owns the amount before a later administration.
79
86
  * Ordinary primary-only graphs return before the ownership walk. */
80
87
  export declare function instructionGraphPreparationOwnsDose(clause: CanonicalSigClause, options?: Pick<ParseOptions, "instructionActionMap">): boolean;
@@ -1,4 +1,6 @@
1
1
  import { AdviceFrame, AdviceRelation, CanonicalInstructionCoverage, CanonicalInstructionGraph, CanonicalInstructionRelation, CanonicalSigClause, CanonicalAdditionalInstructionExpr, CanonicalSourceSpan, FhirCodeableConcept, ParseOptions, TextRange } from "./types";
2
+ import { type InstructionActionProgram } from "./instruction-action-parser";
3
+ import { type PrimaryDoseAmountOwner } from "./instruction-graph-ownership";
2
4
  export { actionMatchAt, parseQuantityArgument, actionFrameHasEmbeddedModal, parseInstructionActions } from "./instruction-action-parser";
3
5
  export { frameActionDefinition, sameTypedWarning, instructionSourceRange, instructionHasCompleteFrameEvidence, instructionGraphPostAdministrationDiscourseConnector, canonicalSiteOwnsPrimaryPhrase, instructionGraphPreparationOwnsDose, instructionGraphSourceConflictsWithDose, instructionGraphRichPrimaryAction, instructionGraphRoundTripPrimaryAction, instructionGraphPrimarySiteRelation, instructionGraphPrimaryAdministrationModality, instructionGraphPrimaryOverlap, isInstructionGraphDisplayWarning } from "./instruction-graph-ownership";
4
6
  /** An undosed administration frame can supply counsel about an existing dose.
@@ -6,9 +8,13 @@ export { frameActionDefinition, sameTypedWarning, instructionSourceRange, instru
6
8
  export declare function isMedicationAdministrationAdvice(frame: AdviceFrame, options?: ParseOptions): boolean;
7
9
  export declare function isSupplementalHydrationInstruction(frame: AdviceFrame, allowMeasured?: boolean): boolean;
8
10
  export declare function relationFromSourceText(text: string): AdviceRelation | undefined;
11
+ interface EmbeddedProcedureReference {
12
+ procedure: AdviceFrame;
13
+ reference: AdviceFrame;
14
+ }
9
15
  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;
16
+ export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph, selectedOpaqueSpans?: readonly CanonicalSourceSpan[], selectedGapSpans?: readonly TextRange[], procedureReference?: EmbeddedProcedureReference): void;
17
+ export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions, semanticOwnershipRanges?: readonly TextRange[], proceduralProgram?: InstructionActionProgram): CanonicalInstructionGraph | undefined;
12
18
  /** Select complete administration techniques from the already-composed clause
13
19
  * and action program. Interchange only projects these selected codings. */
14
20
  export declare function instructionGraphAdministrationTechnique(clause: CanonicalSigClause): {
@@ -24,7 +30,7 @@ export declare function realizeInstructionAction(frame: AdviceFrame, locale?: st
24
30
  * This is a display-only frame copy, not an edit of source graph/provenance. */
25
31
  export declare function realizeRichPrimaryWithCanonicalDose(frame: AdviceFrame, clause: CanonicalSigClause, locale: string, options?: Pick<ParseOptions, "instructionActionMap" | "realizationMode">, coverage?: {
26
32
  singleScheduledEvent: boolean;
27
- }): string;
33
+ }, amountOwner?: PrimaryDoseAmountOwner | null | undefined, trailingPreparations?: string[]): string;
28
34
  /** A graph condition whose primary action is rendered by the clause formatter. */
29
35
  export interface InstructionGraphPrimaryCondition {
30
36
  text: string;
@@ -55,11 +61,16 @@ interface ClauseInstructionRealization {
55
61
  whole?: string;
56
62
  patient?: string;
57
63
  preFlowsIntoAdministration?: boolean;
64
+ preAdministrationSeparator?: string;
58
65
  postFlowsFromAdministration?: boolean;
66
+ postAdministrationSeparator?: string;
59
67
  }
60
68
  /** Internal clause preview uses the same selected node walk as the public graph
61
69
  * 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;
70
+ export declare function realizeClauseInstructions(clause: CanonicalSigClause, locale: string, options: NonNullable<Parameters<typeof realizeInstructionGraph>[2]> & {
71
+ /** Null records a completed lookup with no owner. */
72
+ amountOwner?: PrimaryDoseAmountOwner | null;
73
+ }, render: (instruction: CanonicalAdditionalInstructionExpr) => string | undefined, alreadyRendered?: readonly CanonicalAdditionalInstructionExpr[], presentGraphAction?: (text: string) => string | undefined): ClauseInstructionRealization;
63
74
  export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph, locale?: string, options?: {
64
75
  includeWarnings?: boolean;
65
76
  onlyWarnings?: boolean;
@@ -8,6 +8,8 @@ export interface LocaleRealizationProfile {
8
8
  }
9
9
  export declare function localeRealizationProfile(locale: string | undefined): LocaleRealizationProfile;
10
10
  export declare function joinLocalizedTokens(locale: string | undefined, parts: Array<string | undefined>): string;
11
+ /** Labels for an already selected complete medication dose-slot nominal. */
12
+ export declare function medicationDoseSlotNominalLabels(event: string): Readonly<Record<string, string>> | undefined;
11
13
  export declare function localizedTimeArgument(value: string, locale: string | undefined): string | undefined;
12
14
  export declare function localizedRecordValue(record: Record<string, string> | undefined, locale: string | undefined): string | undefined;
13
15
  export declare function renderLocaleTemplate(template: string, values: Record<string, string | undefined>): string;
@@ -11,10 +11,15 @@ export declare const ENGLISH_CLAUSE_TIMING: {
11
11
  offset: (minutes: number) => string;
12
12
  dayShift: (days: number) => string;
13
13
  };
14
- /** English route labels retain their existing lexical specificity in every locale. */
15
- export declare function routeCodeFromDisplayText(text: string | undefined, includeOtic: boolean): RouteCode | undefined;
16
- /** Retain authored route detail while leaving recognized route grammar in its owner. */
17
- export declare function retainedRouteDisplayText(text: string | undefined, code?: RouteCode): {
14
+ export interface RetainedRouteDisplay {
18
15
  text: string;
19
16
  kind: "technique" | "qualified" | "authored";
20
- } | undefined;
17
+ }
18
+ type RouteDisplayMatch = {
19
+ code?: RouteCode;
20
+ } & (RetainedRouteDisplay | {
21
+ kind?: undefined;
22
+ });
23
+ /** Classify a display label once for both route grammar and authored wording. */
24
+ export declare function matchRouteDisplay(text: string | undefined, suppliedCode: RouteCode | undefined, includeOtic: boolean): RouteDisplayMatch | undefined;
25
+ export {};
@@ -29,6 +29,8 @@ export interface CourseLanguage {
29
29
  readonly exceptWeekdays: string;
30
30
  readonly choicePrefix: string;
31
31
  readonly stageSeparator: string;
32
+ /** Contextual sequence wording; authored/custom text is never inflected. */
33
+ sequentialPhase?(text: string, style: "short" | "long", generatedPrimary: boolean): string;
32
34
  readonly doseLabel: string;
33
35
  amountRoleLabel(kind: "dose" | "rate" | "rateRange", role: "ordered" | "calculated" | undefined, sourceRole: string): string;
34
36
  applicationSites(count: number): string;
@@ -48,14 +50,19 @@ export interface CourseLanguage {
48
50
  readonly maxAdministrationLabel: string;
49
51
  readonly maxLifetimeLabel: string;
50
52
  readonly maxPeriodLabel: string;
53
+ /** Compose the localized limit and period in the language pack's word order. */
54
+ limitPeriod?(value: string, period: string, style: "short" | "long"): string;
51
55
  readonly maxDosageLabel: string;
52
56
  readonly courseLimitsLabel: string;
53
57
  readonly stageLimitsLabel: string;
54
58
  ifLimitExceeded(action: string): string;
55
59
  eventWindow(start: string, end: string): string;
56
60
  unresolvedCycleTiming(days: string, periodDays?: number, cycles?: number, anchor?: string): string;
61
+ namedCycleTiming?(cycle: string, days: string, startDay?: number, maxTreatmentDays?: number): string;
62
+ cycleDayOneDefinition?(event: string): string;
57
63
  weekdayName(day: string): string;
58
64
  measurementName(name: string): string;
65
+ conditionFindingName?(fallback: string, translations?: Readonly<Record<string, string>>, label?: string): string;
59
66
  joinList(items: readonly string[]): string;
60
67
  timeUnit(unit: string, value: number | undefined): string | undefined;
61
68
  expression(kind: "dose" | "rate", detail: string | undefined): string;
@@ -80,5 +87,5 @@ export interface CourseLanguage {
80
87
  phaseCount(count: number): string;
81
88
  unresolvedPhaseCount: string;
82
89
  repeatCount(count: number): string;
83
- repeatCycle(interval: string, exact: boolean, count?: number): string;
90
+ repeatCycle(interval: string, exact: boolean, count?: number, pause?: string): string;
84
91
  }
@@ -2,12 +2,23 @@ import { MedicationCondition, type FhirDayOfWeek } from "./types";
2
2
  import type { HpsgGuardFeature } from "./hpsg/signature";
3
3
  export { parseMedicationGuard } from "./hpsg/constructions";
4
4
  export type { ParsedMedicationGuard } from "./hpsg/constructions";
5
+ export interface CountedAdviceSituation {
6
+ end: number;
7
+ conceptId: string;
8
+ count: number;
9
+ unit: "tab" | "dose";
10
+ comparator?: ">=";
11
+ consecutive?: true;
12
+ }
5
13
  export interface MedicationConditionLexicalFeatures {
14
+ countedAdviceSituation?(source: string): CountedAdviceSituation | undefined;
6
15
  operators: ReadonlyArray<{
7
16
  operation: "ge" | "le" | "gt" | "lt";
8
17
  pattern: RegExp;
9
18
  }>;
10
19
  stateLeads: readonly RegExp[];
20
+ /** Additional morphology only for a completely resolved registered finding. */
21
+ registeredStateLeads?: readonly RegExp[];
11
22
  /** A predicate-initial qualifier that selects a registered nonfinite activity. */
12
23
  activityConcernLead?: RegExp;
13
24
  /** A predicate-final qualifier that selects an administration activity. */
@@ -31,10 +42,25 @@ export interface MedicationConditionLexicalFeatures {
31
42
  sourceCue: RegExp;
32
43
  calendar: {
33
44
  cycle: {
45
+ /** Whole-source admission for day, named-cycle and maximum constituents. */
34
46
  cue: RegExp;
35
47
  frame: string;
36
48
  startLead: RegExp;
37
49
  repeatCount: RegExp;
50
+ dayPart?: string;
51
+ identifyNamedCycle?(surface: string): {
52
+ conceptId: string;
53
+ startsOnDay?: boolean;
54
+ } | undefined;
55
+ treatmentMaximum?: {
56
+ cue: RegExp;
57
+ frame: string;
58
+ };
59
+ dayOneDefinitions?: readonly {
60
+ frame: string;
61
+ cycleConceptId: string;
62
+ eventConceptId: string;
63
+ }[];
38
64
  };
39
65
  cue: RegExp;
40
66
  /** Registration-derived views for whole-source search and token-origin admission. */
@@ -53,6 +79,7 @@ export interface MedicationConditionLexicalFeatures {
53
79
  dayHeads: ReadonlySet<string>;
54
80
  };
55
81
  guardLead: RegExp;
82
+ intervalEligibilityLead?: RegExp;
56
83
  numericGuard: RegExp;
57
84
  contextDayGuard: RegExp;
58
85
  contextDayNominal: RegExp;
@@ -68,16 +95,24 @@ export interface MedicationConditionLexicalFeatures {
68
95
  /** Existing advice providers supply lexical features; HPSG still owns the tree. */
69
96
  export declare function medicationConditionLexicalFeatures(locale?: string): MedicationConditionLexicalFeatures;
70
97
  /** Remove registered state leads without interpreting the remaining predicate. */
71
- export declare function normalizeMedicationConditionStateText(value: string, lexicon: MedicationConditionLexicalFeatures): string;
98
+ export declare function normalizeMedicationConditionStateText(value: string, lexicon: MedicationConditionLexicalFeatures, registeredFinding?: boolean): string;
72
99
  export interface MedicationGuardLeadLexeme {
73
100
  start: number;
74
101
  end: number;
75
102
  marker: "if" | "only-if" | "unless";
76
103
  circumstantial?: true;
104
+ intervalEligibility?: true;
77
105
  }
78
106
  /** Recognize a conditional marker's spelling, leaving its predicate licensing
79
107
  * and scope to the HPSG guard-head construction. */
80
108
  export declare function medicationGuardLeadLexeme(source: string, licensedConsequent?: boolean, lexicon?: MedicationConditionLexicalFeatures): MedicationGuardLeadLexeme | undefined;
109
+ /** The cycle schedule and adjacent guards use the same provider-owned cap span. */
110
+ export declare function namedCycleTreatmentMaxima(source: string, cycle: MedicationConditionLexicalFeatures["calendar"]["cycle"], start?: number, end?: number): IterableIterator<{
111
+ start: number;
112
+ end: number;
113
+ days: number;
114
+ conceptId: string;
115
+ }>;
81
116
  /** Lexical boundary spellings shared with the typed guard phrase. No result
82
117
  * from these recognizers is itself a medication condition or administration. */
83
118
  /** Recognize one predicate atom. Incomplete comparisons remain unsatisfied
package/dist/prn.d.ts CHANGED
@@ -3,6 +3,8 @@ import { type ResolvedBodySitePhrase } from "./body-site-grammar";
3
3
  export declare function getCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined): string | undefined;
4
4
  export declare function joinCanonicalPrnReasonTexts(reasons: CanonicalPrnReasonExpr[] | undefined, conjunction?: string): string | undefined;
5
5
  export declare function getPreferredCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined, reasons: CanonicalPrnReasonExpr[] | undefined, conjunction?: string): string | undefined;
6
+ /** Match the complete registered symptom, allowing only its existing predicative state lead. */
7
+ export declare function resolveWholePrnSymptom(text: string | undefined): SymptomDefinition | undefined;
6
8
  export declare function getPrnReasonTextFallbackI18n(reason: CanonicalPrnReasonExpr): Record<string, string> | undefined;
7
9
  export declare function getLocalizedCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined, reasons: CanonicalPrnReasonExpr[] | undefined, locale: string, conjunction?: string, realizeReason?: (reason: CanonicalPrnReasonExpr, localizedText: string | undefined) => string | undefined): string | undefined;
8
10
  export interface LocatedPrnWording {
@@ -6,9 +6,12 @@
6
6
  * implemented in execution/engine, which has no import/export dependency.
7
7
  * Canonical callers bypass interchange completely.
8
8
  */
9
- import type { FhirDosage, FhirR6DosageInstructionInput, ParseBatchResult, NextDueDoseOptions, TotalUnitsOptions, TotalUnitsResult } from "./types";
9
+ import type { FhirDosage, FhirR6DosageInstructionInput, ParseBatchResult, DueDose, NextDueDoseOptions, TotalUnitsOptions, TotalUnitsResult } from "./types";
10
10
  import type { CanonicalScheduleInput, CanonicalSupplyOptions } from "./canonical/course";
11
11
  import { MedicationQuantityCalculationError } from "./execution/engine";
12
12
  export { MedicationQuantityCalculationError };
13
- export declare function nextDueDoses(input: FhirDosage | readonly FhirDosage[] | FhirR6DosageInstructionInput | ParseBatchResult | CanonicalScheduleInput, options: NextDueDoseOptions): string[];
13
+ type ScheduleInput = FhirDosage | readonly FhirDosage[] | FhirR6DosageInstructionInput | ParseBatchResult | CanonicalScheduleInput;
14
+ export declare function nextDueDoses(input: ScheduleInput, options: NextDueDoseOptions): string[];
15
+ /** Schedule the same opportunities with the selected administration and known source facts. */
16
+ export declare function nextDueDosesDetailed(input: ScheduleInput, options: NextDueDoseOptions): DueDose[];
14
17
  export declare function calculateTotalUnits(options: TotalUnitsOptions | CanonicalSupplyOptions): TotalUnitsResult;
@@ -1,4 +1,4 @@
1
- import type { CanonicalScheduleExpr } from "./types";
1
+ import type { CanonicalScheduleExpr, FormatOptions } from "./types";
2
2
  import { EventTiming, FhirDayOfWeek, FhirPeriodUnit, type ParseOptions } from "./types";
3
3
  /** Resolve authored event-relative offsets without changing their stored sign. */
4
4
  export declare function signedTimingEventOffset(code: string, offset: number): number;
@@ -105,7 +105,7 @@ export declare function intervalTimingPreviewDescriptor(code: string): {
105
105
  periodMax?: number;
106
106
  periodUnit: FhirPeriodUnit;
107
107
  } | undefined;
108
- export interface TimingSummaryOptions {
108
+ export interface TimingSummaryOptions extends Pick<ParseOptions, "locale" | "i18n"> {
109
109
  /** Scoped vocabulary in the original parse/format request. Do not build
110
110
  * any second registry or retain it on the canonical clinical course. */
111
111
  instructionActionMap?: ParseOptions["instructionActionMap"];
@@ -113,6 +113,7 @@ export interface TimingSummaryOptions {
113
113
  groupMealTimingsByRelation?: boolean;
114
114
  includeTimesPerDaySummary?: boolean;
115
115
  sitePlacement?: "natural" | "trailing";
116
+ pairedSiteWording?: FormatOptions["pairedSiteWording"];
116
117
  }
117
118
  export type MealRelation = "before" | "after" | "with";
118
119
  export type MealName = "breakfast" | "lunch" | "dinner";