ezmedicationinput 0.1.67 → 0.3.0-beta.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.
- package/README.md +222 -28
- package/dist/adapters/canonical-course.d.ts +128 -0
- package/dist/adapters/r5-course.d.ts +24 -0
- package/dist/advice.d.ts +52 -1
- package/dist/body-site-grammar.d.ts +34 -1
- package/dist/body-site-lookup.d.ts +3 -0
- package/dist/body-site-spatial.d.ts +6 -2
- package/dist/body-site-target.d.ts +9 -3
- package/dist/canonical/compile.d.ts +79 -0
- package/dist/canonical/course.d.ts +352 -0
- package/dist/canonical/format-course.d.ts +36 -0
- package/dist/date-interpretation.d.ts +2 -0
- package/dist/dosage-course.d.ts +453 -0
- package/dist/execution/calendar.d.ts +107 -0
- package/dist/execution/engine.d.ts +11 -0
- package/dist/fhir-quantity-operator.d.ts +53 -0
- package/dist/fhir-translations.d.ts +5 -6
- package/dist/fhir.d.ts +233 -13
- package/dist/format.d.ts +113 -3
- package/dist/hpsg/constructions.d.ts +113 -0
- package/dist/hpsg/defaults.d.ts +2 -0
- package/dist/hpsg/lexical-classes.d.ts +282 -2
- package/dist/hpsg/procedural-context.d.ts +18 -4
- package/dist/hpsg/projection.d.ts +38 -3
- package/dist/hpsg/rule-context.d.ts +117 -7
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +18 -0
- package/dist/hpsg/rules/condition-rules.d.ts +14 -0
- package/dist/hpsg/rules/core-rules.d.ts +32 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +11 -1
- package/dist/hpsg/rules/prn-rules.d.ts +3 -1
- package/dist/hpsg/rules/timing-rules.d.ts +138 -8
- package/dist/hpsg/signature.d.ts +353 -5
- package/dist/hpsg/type-system.d.ts +16 -1
- package/dist/hpsg/unification.d.ts +4 -1
- package/dist/i18n.d.ts +39 -1
- package/dist/index.cjs +65539 -30893
- package/dist/index.d.ts +35 -7
- package/dist/index.js +65505 -30892
- package/dist/instruction-action-locale-adapter.d.ts +32 -3
- package/dist/instruction-action-terminology.d.ts +38 -3
- package/dist/instruction-concept-terminology.d.ts +8 -1
- package/dist/instruction-graph-fhir.d.ts +9 -3
- package/dist/instruction-graph.d.ts +85 -7
- package/dist/ir.d.ts +13 -2
- package/dist/lexer/surface-segmenter.d.ts +1 -1
- package/dist/lexer/surface.d.ts +1 -0
- package/dist/locale-detection.d.ts +3 -0
- package/dist/locales/course/en.d.ts +15 -0
- package/dist/locales/course/th.d.ts +12 -0
- package/dist/localization.d.ts +73 -0
- package/dist/maps.d.ts +24 -1
- package/dist/medication-condition.d.ts +42 -0
- package/dist/parser-state.d.ts +6 -2
- package/dist/parser.d.ts +5 -2
- package/dist/regimen/coordination-scope.d.ts +53 -0
- package/dist/regimen/grammar.d.ts +79 -0
- package/dist/regimen/parallel-course.d.ts +52 -0
- package/dist/regimen/planner.d.ts +19 -0
- package/dist/regimen/regimen.d.ts +70 -0
- package/dist/relation-terminology.d.ts +1 -0
- package/dist/schedule.d.ts +12 -5
- package/dist/stable-structure.d.ts +23 -1
- package/dist/timing-summary.d.ts +82 -1
- package/dist/types.d.ts +899 -40
- package/dist/unit-lexicon.d.ts +7 -0
- package/dist/utils/strength.d.ts +16 -0
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/units.d.ts +19 -0
- package/package.json +3 -2
|
@@ -1,10 +1,42 @@
|
|
|
1
|
+
import { Token } from "../../parser-state";
|
|
2
|
+
import { type ParseOptions } from "../../types";
|
|
1
3
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
4
|
import { HpsgLexicalRule } from "../signature";
|
|
5
|
+
/** Bounded lexical recognition shared by chart and boundary candidacy.
|
|
6
|
+
* @param tokens Source tokens with the existing locale normalization.
|
|
7
|
+
* @param start Candidate head index; never searches arbitrary later text.
|
|
8
|
+
* @param limit Exclusive end of the current constituent.
|
|
9
|
+
*/
|
|
10
|
+
export declare function phaseAdjustmentAt(tokens: readonly Token[], start: number, limit?: number): {
|
|
11
|
+
kind: "replace-target";
|
|
12
|
+
end: number;
|
|
13
|
+
targetStart: number;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "replace" | "add";
|
|
16
|
+
end: number;
|
|
17
|
+
targetStart?: undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
/** A typed ADD/REPLACE operator composes with ordinary dose/time daughters. */
|
|
20
|
+
export declare function phaseAdjustmentLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
3
21
|
export declare function directiveMarkerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
22
|
export declare function methodLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
23
|
export declare function routeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
6
24
|
export declare function fillerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
25
|
export declare function productLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
26
|
+
/**
|
|
27
|
+
* Return the end of a bounded, explicit scalar-dose head for regimen boundary
|
|
28
|
+
* candidacy. This uses the same HPSG quantity lexemes as `doseLexicalRule`;
|
|
29
|
+
* it does not assign a dose or authorize a split. The boundary grammar still
|
|
30
|
+
* has to parse complete typed daughters before accepting the candidate.
|
|
31
|
+
*
|
|
32
|
+
* Keeping the optional fraction article inside this constituent is important:
|
|
33
|
+
* in `half a tablet`, `a` is a determiner of the unit, not a second one-tablet
|
|
34
|
+
* dose head.
|
|
35
|
+
*/
|
|
36
|
+
export declare function explicitDoseLexicalEnd(tokens: readonly Token[], start: number, options?: ParseOptions, limit?: number): number | undefined;
|
|
37
|
+
/** A written unit or the existing medication context can complete a numeric
|
|
38
|
+
* dose daughter. This is boundary admission; the dose rule still owns its value. */
|
|
39
|
+
export declare function contextualDoseLexicalEnd(tokens: Token[], start: number, options?: ParseOptions, limit?: number): number | undefined;
|
|
8
40
|
export declare function perTargetCountDoseRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
9
41
|
export declare function doseLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
10
42
|
export declare function connectorLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import { AdviceFrame } from "../../types";
|
|
1
2
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
-
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
import { HpsgLexicalRule, type HpsgSign } from "../signature";
|
|
4
|
+
export declare function isProceduralInstructionFrame(context: HpsgClauseContext, frame: AdviceFrame): boolean;
|
|
3
5
|
export declare function proceduralActionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
6
|
export declare function workflowLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
|
+
/** Compose ON/ONLY ON/EXCEPT with a registered activity and DAY noun.
|
|
8
|
+
* The activity identifies the day domain, not a scheduled procedure occurrence.
|
|
9
|
+
* Membership remains a caller-evaluated condition; no dates are guessed.
|
|
10
|
+
* @param context Shared source, lexical registry and procedural ownership.
|
|
11
|
+
* @param start Beginning of a declared day-adjunct frame.
|
|
12
|
+
* @param withholdingComplement Licensed by a typed withholding head selecting this adjunct.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registeredActivityDayAt(context: HpsgClauseContext, start: number, withholdingComplement?: true): HpsgSign | undefined;
|
|
5
15
|
export declare function instructionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Token } from "../../parser-state";
|
|
2
2
|
import { HpsgClauseContext } from "../rule-context";
|
|
3
|
-
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
import { HpsgLexicalRule, HpsgSign } from "../signature";
|
|
4
4
|
export declare function startsMaximumCountLead(context: HpsgClauseContext, start: number): boolean;
|
|
5
5
|
export declare function symptomAdjustmentLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
6
6
|
export declare function matchContextualPrnReasonLead(context: HpsgClauseContext, start: number): {
|
|
@@ -11,4 +11,6 @@ export declare function matchContextualPrnReasonLead(context: HpsgClauseContext,
|
|
|
11
11
|
export declare function tokenBelongsToContextualPrnReasonLead(context: HpsgClauseContext, tokenIndex: number): boolean;
|
|
12
12
|
export declare function hasSymptomOnsetPrnAt(context: HpsgClauseContext, start: number): boolean;
|
|
13
13
|
export declare function symptomOnsetPrnRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
14
|
+
/** Share a PRN daughter requested before chart admission by scope ownership. */
|
|
15
|
+
export declare function prnAt(context: HpsgClauseContext, start: number): HpsgSign[];
|
|
14
16
|
export declare function prnLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,8 +1,54 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Token } from "../../parser-state";
|
|
2
|
+
import { type AdviceFrame, type CanonicalCalendarEventExpr, type FhirQuantity, type ParseOptions } from "../../types";
|
|
3
|
+
import { HpsgClauseContext, maximumCountLeadAt, maximumDosePerPeriodAt, maximumDosePeriodAt } from "../rule-context";
|
|
4
|
+
import { HpsgLexicalRule, HpsgSign } from "../signature";
|
|
5
|
+
/** Bounded lexical constituent for a fronted following treatment course.
|
|
6
|
+
* The planner reuses its source extent; duration semantics remain owned by
|
|
7
|
+
* the ordinary duration lexical rule.
|
|
8
|
+
* @param tokens Source lexical tokens.
|
|
9
|
+
* @param start Candidate duration-lead index.
|
|
10
|
+
*/
|
|
11
|
+
export declare function followingCourseDurationHeaderAt(tokens: readonly Token[], start: number): {
|
|
12
|
+
valueIndex: number;
|
|
13
|
+
tokenEnd: number;
|
|
14
|
+
implicitSingle?: boolean;
|
|
15
|
+
} | undefined;
|
|
16
|
+
export interface OrdinalWeekStageHeader {
|
|
17
|
+
tokenStart: number;
|
|
18
|
+
tokenEnd: number;
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
ordinal: number;
|
|
22
|
+
openEnded: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Recognize a bounded ordinal-week regimen header as a typed lexical shape.
|
|
26
|
+
* The caller decides whether several headers form a treatment sequence; this
|
|
27
|
+
* matcher does not split text or infer a regimen from a lone occurrence.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ordinalWeekStageHeaderAt(tokens: readonly Token[], start: number): OrdinalWeekStageHeader | undefined;
|
|
30
|
+
export declare function ordinalWeekStageHeaders(tokens: readonly Token[]): OrdinalWeekStageHeader[];
|
|
31
|
+
/** A regimen-stage construction requires at least Week 1 + Week 2. */
|
|
32
|
+
export declare function ordinalWeekStageSequence(tokens: readonly Token[]): OrdinalWeekStageHeader[];
|
|
3
33
|
export declare function multiplicativeDoseFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
34
|
export declare function compactIntervalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
35
|
export declare function separatedIntervalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
36
|
+
/** One complete occurrence maximum is shared by the schedule chart and guard scope. */
|
|
37
|
+
export declare function maximumOccurrenceAt(context: Parameters<typeof maximumCountLeadAt>[0], start: number, lead?: {
|
|
38
|
+
tokens: Token[];
|
|
39
|
+
headStart: number;
|
|
40
|
+
} | undefined): {
|
|
41
|
+
tokens: Token[];
|
|
42
|
+
headStart: number;
|
|
43
|
+
count: number;
|
|
44
|
+
implicitOccurrence: boolean;
|
|
45
|
+
period?: NonNullable<ReturnType<typeof maximumDosePeriodAt>>;
|
|
46
|
+
} | undefined;
|
|
47
|
+
/** A comparative maximum needs a complete preceding predicate and its own
|
|
48
|
+
* complete daughter. A conjunction alone cannot detach a count prefix from
|
|
49
|
+
* an opaque Boolean predicate. Explicit separators/maximum heads retain their
|
|
50
|
+
* independent instruction license. */
|
|
51
|
+
export declare function isIndependentMaximum(context: Parameters<typeof maximumCountLeadAt>[0], start: number, maximum: NonNullable<ReturnType<typeof maximumOccurrenceAt> | ReturnType<typeof maximumDosePerPeriodAt>>, completePredicate?: boolean): boolean;
|
|
6
52
|
export declare function separatedFrequencyRangeRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
53
|
/**
|
|
8
54
|
* A distributive cadence followed directly by a discrete unit licenses an
|
|
@@ -23,12 +69,6 @@ export declare function alternateEventCadenceRule(): HpsgLexicalRule<HpsgClauseC
|
|
|
23
69
|
export declare function calendarDateListRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
24
70
|
export declare function timingLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
25
71
|
export declare function quantityFirstActivityTimingRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
26
|
-
/**
|
|
27
|
-
* Quantity-first event offsets are the ordinary English inverse of
|
|
28
|
-
* relation-first forms: `30 min before breakfast`, `half an hour after food`.
|
|
29
|
-
* They project to the same canonical event-offset feature as `before meals
|
|
30
|
-
* 30 minutes`, so ordering is grammar rather than a separate semantic model.
|
|
31
|
-
*/
|
|
32
72
|
export declare function quantityFirstEventOffsetRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
33
73
|
/**
|
|
34
74
|
* Relative event offsets are timing semantics, not treatment duration.
|
|
@@ -36,7 +76,97 @@ export declare function quantityFirstEventOffsetRule(): HpsgLexicalRule<HpsgClau
|
|
|
36
76
|
*/
|
|
37
77
|
export declare function eventOffsetRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
38
78
|
export declare function eventTimingPhraseRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
79
|
+
/** A calendar-month day range is a recurrence selector, never a dose range.
|
|
80
|
+
* Both the headed day noun and its explicit monthly complement must be present,
|
|
81
|
+
* so ordinary “1–14 tablets”, duration ranges and menstrual cycle offsets
|
|
82
|
+
* cannot satisfy this constituent.
|
|
83
|
+
* @returns A lexical rule yielding typed calendar-day membership.
|
|
84
|
+
*/
|
|
85
|
+
export declare function monthlyDayOfMonthLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
39
86
|
export declare function dayRangeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
87
|
+
/**
|
|
88
|
+
* A maximum medication quantity is a typed schedule adjunct, not another
|
|
89
|
+
* administration dose. The full lexical sign owns its source span so a
|
|
90
|
+
* trailing cap cannot be reparsed from Dosage.text after FHIR projection.
|
|
91
|
+
*/
|
|
92
|
+
export declare function maximumDosePerPeriodRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
93
|
+
/** Does a source lead license a new treatment-relative phase onset? No
|
|
94
|
+
* arbitrary numeric quantity or isolated "in/from" qualifies.
|
|
95
|
+
*/
|
|
96
|
+
export declare function treatmentRelativePeriodStartAt(tokens: readonly Token[], start: number): {
|
|
97
|
+
tokenEnd: number;
|
|
98
|
+
offsetDays: number;
|
|
99
|
+
} | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* A duration noun phrase contributes a quantity and a time dimension. Its
|
|
102
|
+
* governing construction decides whether it is an active course, a rest
|
|
103
|
+
* interval, or a local procedural duration; the lexical daughter does not.
|
|
104
|
+
* @param tokens Existing normalized source tokens, never retokenized text.
|
|
105
|
+
* @param start First token of the duration daughter.
|
|
106
|
+
* @param limit Exclusive end of the containing constituent.
|
|
107
|
+
*/
|
|
108
|
+
export declare function durationNominalAt(tokens: readonly Token[], start: number, limit?: number): HpsgSign | undefined;
|
|
40
109
|
export declare function countAndDurationRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
41
110
|
export declare function timeOfDayRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
42
111
|
export declare function isScheduleLead(context: HpsgClauseContext, index: number): boolean;
|
|
112
|
+
export declare function openEndedScheduleRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
113
|
+
/** A licensed active/rest/repeat phrase, with both duration daughters retained. */
|
|
114
|
+
export interface HpsgRecurringCourseConstituent {
|
|
115
|
+
sign: HpsgSign;
|
|
116
|
+
onDuration: FhirQuantity;
|
|
117
|
+
offDuration: FhirQuantity;
|
|
118
|
+
repeatCycle: FhirQuantity;
|
|
119
|
+
repeatCount?: number;
|
|
120
|
+
}
|
|
121
|
+
/** Cheap lexical activation only; the course construction must still compose. */
|
|
122
|
+
export declare function hasRecurringCourseCue(tokens: readonly Token[], options?: ParseOptions): boolean;
|
|
123
|
+
/** A registered withholding head selects one complete finite duration NP.
|
|
124
|
+
* Objects such as breath, conditional tails, and negative directives cannot
|
|
125
|
+
* satisfy this medication-pause valence. Both daughters remain in the chart. */
|
|
126
|
+
export declare function finiteTreatmentPauseAt(context: HpsgClauseContext, frame: AdviceFrame, start: number): {
|
|
127
|
+
actionEnd: number;
|
|
128
|
+
duration: HpsgSign;
|
|
129
|
+
pause: {
|
|
130
|
+
durationDays: number;
|
|
131
|
+
range: {
|
|
132
|
+
start: number;
|
|
133
|
+
end: number;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
} | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* Compose duration + stopped-duration + repetition as one headed course
|
|
139
|
+
* phrase. Ordinary duration morphology, registered action meaning and shared
|
|
140
|
+
* discourse markers are the only language authorities; no whole-SIG regex.
|
|
141
|
+
* @param input Unchanged source for lexical action aliases and provenance.
|
|
142
|
+
* @param tokens Existing normalized source tokens.
|
|
143
|
+
* @param start Candidate active-duration daughter.
|
|
144
|
+
* @param options Caller terminology, including registered action synonyms.
|
|
145
|
+
*/
|
|
146
|
+
export declare function recurringCourseAt(input: string, tokens: readonly Token[], start: number, options?: ParseOptions): HpsgRecurringCourseConstituent | undefined;
|
|
147
|
+
/** Share the same selected cycle constituents with segmentation and the chart. */
|
|
148
|
+
export declare function recurringCourseConstituents(input: string, tokens: readonly Token[], options?: ParseOptions): HpsgRecurringCourseConstituent[];
|
|
149
|
+
export interface CycleSchedule {
|
|
150
|
+
start: number;
|
|
151
|
+
end: number;
|
|
152
|
+
sourceText: string;
|
|
153
|
+
days: number[];
|
|
154
|
+
cycles: number;
|
|
155
|
+
periodDays?: number;
|
|
156
|
+
anchor?: string;
|
|
157
|
+
events: CanonicalCalendarEventExpr[];
|
|
158
|
+
error?: string;
|
|
159
|
+
kind?: 'calendar-days' | 'recurring-on-off';
|
|
160
|
+
onDuration?: FhirQuantity;
|
|
161
|
+
offDuration?: FhirQuantity;
|
|
162
|
+
repeatCycle?: FhirQuantity;
|
|
163
|
+
repeatCount?: number;
|
|
164
|
+
unbounded?: boolean;
|
|
165
|
+
/** Selected HPSG phrase reused by chart ownership and schedule projection. */
|
|
166
|
+
sign?: HpsgSign;
|
|
167
|
+
}
|
|
168
|
+
/** Recognize finite anchored cycle/day-offset expressions; never guess an absent anchor or cycle length. */
|
|
169
|
+
export declare function recognizeCycles(input: string, options?: ParseOptions, sourceTokens?: readonly Token[]): CycleSchedule[];
|
|
170
|
+
/** Finite cycles emit exact events; recurring active/rest cycles emit their
|
|
171
|
+
* typed active duration and whole-course repeat interval on the same sign. */
|
|
172
|
+
export declare function cycleScheduleRule(): HpsgLexicalRule<HpsgClauseContext>;
|