ezmedicationinput 0.2.0 → 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 +201 -10
- package/dist/adapters/canonical-course.d.ts +128 -0
- package/dist/adapters/r5-course.d.ts +24 -0
- package/dist/advice.d.ts +36 -5
- 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/dosage-course.d.ts +294 -29
- 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 +99 -14
- package/dist/format.d.ts +105 -3
- package/dist/hpsg/constructions.d.ts +11 -3
- package/dist/hpsg/defaults.d.ts +2 -0
- package/dist/hpsg/lexical-classes.d.ts +115 -4
- package/dist/hpsg/procedural-context.d.ts +3 -3
- package/dist/hpsg/projection.d.ts +28 -1
- package/dist/hpsg/rule-context.d.ts +104 -7
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +16 -7
- package/dist/hpsg/rules/condition-rules.d.ts +0 -1
- package/dist/hpsg/rules/core-rules.d.ts +3 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +2 -0
- package/dist/hpsg/rules/prn-rules.d.ts +3 -1
- package/dist/hpsg/rules/timing-rules.d.ts +17 -1
- package/dist/hpsg/signature.d.ts +13 -3
- package/dist/hpsg/unification.d.ts +3 -1
- package/dist/i18n.d.ts +37 -1
- package/dist/index.cjs +63500 -46393
- package/dist/index.d.ts +21 -9
- package/dist/index.js +63491 -46393
- package/dist/instruction-action-locale-adapter.d.ts +31 -3
- package/dist/instruction-action-terminology.d.ts +23 -3
- package/dist/instruction-concept-terminology.d.ts +7 -0
- package/dist/instruction-graph-fhir.d.ts +8 -2
- package/dist/instruction-graph.d.ts +80 -38
- package/dist/ir.d.ts +1 -1
- 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 +10 -2
- package/dist/medication-condition.d.ts +1 -1
- package/dist/parser-state.d.ts +2 -2
- package/dist/regimen/grammar.d.ts +11 -0
- package/dist/regimen/parallel-course.d.ts +8 -41
- package/dist/regimen/regimen.d.ts +6 -2
- package/dist/relation-terminology.d.ts +1 -0
- package/dist/schedule.d.ts +14 -10
- package/dist/timing-summary.d.ts +82 -1
- package/dist/types.d.ts +510 -56
- package/dist/unit-lexicon.d.ts +7 -0
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/units.d.ts +19 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Token, ParserState } from "../parser-state";
|
|
2
|
-
import { ParseOptions } from "../types";
|
|
2
|
+
import { EventTiming, FhirPeriodUnit, ParseOptions } from "../types";
|
|
3
3
|
import type { MedicationDateListMatch } from "../date-interpretation";
|
|
4
4
|
import { type ParsedMedicationGuard } from "./constructions";
|
|
5
|
-
|
|
5
|
+
export { normalizeTokenLower, parseClockToken } from "./lexical-classes";
|
|
6
|
+
import { HpsgLexicalRule, HpsgSign } from "./signature";
|
|
6
7
|
import { HpsgProjectionDeps } from "./projection";
|
|
7
8
|
import { HpsgUnificationContext } from "./unification";
|
|
8
9
|
export interface HpsgClauseContext {
|
|
@@ -13,8 +14,18 @@ export interface HpsgClauseContext {
|
|
|
13
14
|
limit: number;
|
|
14
15
|
deps: HpsgProjectionDeps & HpsgUnificationContext;
|
|
15
16
|
clinicalCache: {
|
|
17
|
+
/** Existing lexical matches requested early by instruction body lookahead. */
|
|
18
|
+
quantityLookahead?: Map<number, HpsgSign[]>;
|
|
19
|
+
/** PRN daughters requested early by conditional target ownership. */
|
|
20
|
+
prnLookahead?: Map<number, HpsgSign[]>;
|
|
16
21
|
medicationGuardScanned?: true;
|
|
17
22
|
medicationGuard?: ParsedMedicationGuard;
|
|
23
|
+
/** Tokens owned by a complete dimensional quantity or cumulative limit.
|
|
24
|
+
* Numeric, site and advice fallbacks must not detach its daughters. */
|
|
25
|
+
quantityTokenIndices?: Set<number>;
|
|
26
|
+
/** A recognized per-time expression still owns its numeral when no rate
|
|
27
|
+
* head licenses it. Scalar-dose fallback must not detach that numeral. */
|
|
28
|
+
unlicensedRateTokenIndices?: Set<number>;
|
|
18
29
|
};
|
|
19
30
|
project?: boolean;
|
|
20
31
|
}
|
|
@@ -27,16 +38,13 @@ export declare function medicationGuardForContext(context: HpsgClauseContext): P
|
|
|
27
38
|
export declare function isMedicationGuardMarker(context: HpsgClauseContext, start: number): boolean;
|
|
28
39
|
export declare function startsMedicationGuard(context: HpsgClauseContext, start: number): boolean;
|
|
29
40
|
export declare function sourceRangeOverlapsContextDate(context: HpsgClauseContext, start: number, end: number): boolean;
|
|
30
|
-
export declare function normalizeTokenLower(token: Token): string;
|
|
31
41
|
export declare function isPunctuation(lower: string): boolean;
|
|
42
|
+
/** The selected action lexicon licenses its elapsed-duration complement. */
|
|
43
|
+
export declare function precedingMethodOwnsAdministrationDuration(context: HpsgClauseContext, start: number, relation: string): boolean;
|
|
32
44
|
export declare function isClockLikeLower(lower: string): boolean;
|
|
33
45
|
export declare function isAmPmLower(lower: string): boolean;
|
|
34
46
|
export declare function isAnteMeridiemLower(lower: string): boolean;
|
|
35
47
|
export declare function isPostMeridiemLower(lower: string): boolean;
|
|
36
|
-
export declare function parseClockToken(token: Token | undefined, meridiemToken?: Token | undefined): {
|
|
37
|
-
value: string;
|
|
38
|
-
tokens: Token[];
|
|
39
|
-
} | undefined;
|
|
40
48
|
export declare function tokensAvailable(context: HpsgClauseContext, start: number, span: number): Token[] | undefined;
|
|
41
49
|
export declare function rangeFromTokens(tokens: Token[]): {
|
|
42
50
|
start: number;
|
|
@@ -46,3 +54,92 @@ export declare function splitByLexicalSeparators(text: string, separators: Reado
|
|
|
46
54
|
export declare function hasLexicalSeparator(text: string, separators: ReadonlySet<string>): boolean;
|
|
47
55
|
export declare function joinTokenText(tokens: Token[]): string;
|
|
48
56
|
export declare function lexicalRule(id: string, match: HpsgLexicalRule<HpsgClauseContext>["match"]): HpsgLexicalRule<HpsgClauseContext>;
|
|
57
|
+
interface QuantityLexicalContext {
|
|
58
|
+
tokens: Token[];
|
|
59
|
+
options?: ParseOptions;
|
|
60
|
+
limit?: number;
|
|
61
|
+
state?: Pick<ParserState, "consumed">;
|
|
62
|
+
clinicalCache?: HpsgClauseContext["clinicalCache"];
|
|
63
|
+
}
|
|
64
|
+
export declare function quantityTokenAvailable(context: QuantityLexicalContext, index: number): boolean;
|
|
65
|
+
export declare function doseNumberValue(token: Token | undefined): number | undefined;
|
|
66
|
+
/** Shared numeric-word inventory: clinical quantities and ordinary timing
|
|
67
|
+
* interpret the same lexical number daughters, without string special cases. */
|
|
68
|
+
export declare function clinicalDurationNumber(token: Token | undefined): number | undefined;
|
|
69
|
+
/** One elapsed-duration daughter shared by infusion amounts and dose-limit periods. */
|
|
70
|
+
export declare function clinicalDurationAt(context: QuantityLexicalContext, start: number): {
|
|
71
|
+
value: number;
|
|
72
|
+
unit: FhirPeriodUnit.Minute | FhirPeriodUnit.Hour | FhirPeriodUnit.Day | FhirPeriodUnit.Week | FhirPeriodUnit.Month;
|
|
73
|
+
unitSurface: string;
|
|
74
|
+
comparator: "<" | "<=" | ">=" | ">" | "~" | undefined;
|
|
75
|
+
end: number;
|
|
76
|
+
} | undefined;
|
|
77
|
+
/** One plain numeric daughter shared by active amounts, carrier volumes and limits. */
|
|
78
|
+
export declare function plainClinicalNumberAt(context: QuantityLexicalContext, start: number, initial?: number): {
|
|
79
|
+
value: number;
|
|
80
|
+
numericIndex: number;
|
|
81
|
+
mixed: boolean;
|
|
82
|
+
fractional: boolean;
|
|
83
|
+
} | undefined;
|
|
84
|
+
/** The optional article or partitive belongs to the following medication unit. */
|
|
85
|
+
export declare function doseUnitIndexAfter(context: QuantityLexicalContext, start: number): number | undefined;
|
|
86
|
+
export declare function directDoseUnitAfter(context: QuantityLexicalContext, start: number): {
|
|
87
|
+
unit: string;
|
|
88
|
+
end: number;
|
|
89
|
+
} | undefined;
|
|
90
|
+
/** The same lexical medication amount owns administration heads and dose caps. */
|
|
91
|
+
export declare function medicationAmountAt(context: QuantityLexicalContext, index: number): boolean;
|
|
92
|
+
export declare function hasPrecedingMedicationAmount(context: QuantityLexicalContext, before: number): boolean;
|
|
93
|
+
/** A maximum head owns its leading separators and coordinated attachment. */
|
|
94
|
+
export declare function maximumCountLeadAt(context: QuantityLexicalContext, start: number, firstLower?: string): {
|
|
95
|
+
tokens: Token[];
|
|
96
|
+
headStart: number;
|
|
97
|
+
} | undefined;
|
|
98
|
+
export declare function occurrenceCapPeriodAt(context: QuantityLexicalContext, start: number): {
|
|
99
|
+
tokens: Token[];
|
|
100
|
+
period: number;
|
|
101
|
+
periodUnit: FhirPeriodUnit;
|
|
102
|
+
} | undefined;
|
|
103
|
+
type MaximumDosePeriod = ({
|
|
104
|
+
tokens: Token[];
|
|
105
|
+
period: number;
|
|
106
|
+
periodUnit: FhirPeriodUnit;
|
|
107
|
+
} | {
|
|
108
|
+
tokens: Token[];
|
|
109
|
+
daypart: true;
|
|
110
|
+
}) & {
|
|
111
|
+
unitDenominator?: boolean;
|
|
112
|
+
rolling?: true;
|
|
113
|
+
};
|
|
114
|
+
/** The existing compact maximum denominator is shared by quantity and count nouns. */
|
|
115
|
+
export declare function compactMaximumPeriodAt(context: QuantityLexicalContext, unitIndex: number, unitSurface: string): {
|
|
116
|
+
unitSurface: string;
|
|
117
|
+
period: MaximumDosePeriod;
|
|
118
|
+
} | undefined;
|
|
119
|
+
export declare function maximumDosePeriodAt(context: QuantityLexicalContext, start: number): MaximumDosePeriod | undefined;
|
|
120
|
+
/** Shared lexical constituent: a dose limit owns both its amount and period. */
|
|
121
|
+
export declare function maximumDosePerPeriodAt(context: QuantityLexicalContext, start: number, maximumHead?: {
|
|
122
|
+
tokens: Token[];
|
|
123
|
+
headStart: number;
|
|
124
|
+
} | undefined): {
|
|
125
|
+
tokens: Token[];
|
|
126
|
+
amount: number;
|
|
127
|
+
unit: string;
|
|
128
|
+
period: MaximumDosePeriod;
|
|
129
|
+
headStart: number;
|
|
130
|
+
comparative: boolean;
|
|
131
|
+
} | undefined;
|
|
132
|
+
/** Numeric and locale-licensed named clocks share one end complement owner. */
|
|
133
|
+
export declare function courseEndClockAt(tokens: readonly Token[], start: number, limit?: number): {
|
|
134
|
+
tokens: Token[];
|
|
135
|
+
value?: string;
|
|
136
|
+
event?: EventTiming;
|
|
137
|
+
} | undefined;
|
|
138
|
+
/** A daypart inside UNTIL + NEXT is an end complement, not a recurring event. */
|
|
139
|
+
export declare function isEndBoundDaypartAt(tokens: readonly Token[], head: number): boolean;
|
|
140
|
+
/** Bounded NEXT + day/daypart nominal, with an optional locale article. */
|
|
141
|
+
export declare function nextDayOnsetAt(tokens: readonly Token[], start: number, limit: number): {
|
|
142
|
+
headIndex: number;
|
|
143
|
+
tokenEnd: number;
|
|
144
|
+
explicitStart: boolean;
|
|
145
|
+
} | undefined;
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
import { FhirPeriodUnit } from "../../types";
|
|
1
2
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
-
import { HpsgLexicalRule } from "../signature";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { HpsgDimensionalQuantityTerm, HpsgLexicalRule, HpsgSign } from "../signature";
|
|
4
|
+
export declare function volumeOrMassTerm(value: number, raw: string): HpsgDimensionalQuantityTerm | undefined;
|
|
5
|
+
export declare function clinicalRatePeriodUnit(raw: string): FhirPeriodUnit.Hour | FhirPeriodUnit.Minute | undefined;
|
|
6
|
+
/** Shared lexical rate-head ownership, including a local route or AT marker. */
|
|
7
|
+
export declare function clinicalRateHeadAt(context: HpsgClauseContext, phraseStart: number, end: number, allowPrecedingDose?: boolean, period?: number): {
|
|
8
|
+
licensed: boolean;
|
|
9
|
+
rateSpecific: boolean;
|
|
10
|
+
marker: number | undefined;
|
|
11
|
+
};
|
|
12
|
+
/** Bounded dimensional quantity construction; unresolved weight amounts
|
|
13
|
+
* remain typed rates instead of fabricated scalar administrations. */
|
|
14
|
+
/** Instruction lookahead asks the same typed quantity owner before absorbing
|
|
15
|
+
* a later body token. Each start is matched once in this chart context; the
|
|
16
|
+
* normal lexical enumeration then reuses the sign, without a pre-scan. */
|
|
17
|
+
export declare function clinicalQuantityAt(context: HpsgClauseContext, start: number): HpsgSign[];
|
|
9
18
|
export declare function clinicalQuantityLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -11,7 +11,6 @@ export interface CalendarExclusion {
|
|
|
11
11
|
export declare function containsCalendarExclusionCue(source: string): boolean;
|
|
12
12
|
/** Resolve the lexical payload for a typed calendar-exclusion sign. */
|
|
13
13
|
export declare function matchCalendarExclusion(source: string, options?: ParseOptions, knownDateSpans?: MedicationDateListMatch[], scopeEnd?: number, from?: number): CalendarExclusion | undefined;
|
|
14
|
-
/** Medication guards are lexical adjuncts, separate from procedural IF scope. */
|
|
15
14
|
export declare function medicationGuardLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
16
15
|
export declare function weekdayComplementReferenceLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
17
16
|
export declare function calendarExclusionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -34,6 +34,9 @@ export declare function productLexicalRule(): HpsgLexicalRule<HpsgClauseContext>
|
|
|
34
34
|
* dose head.
|
|
35
35
|
*/
|
|
36
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;
|
|
37
40
|
export declare function perTargetCountDoseRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
38
41
|
export declare function doseLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
39
42
|
export declare function connectorLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { AdviceFrame } from "../../types";
|
|
1
2
|
import { HpsgClauseContext } from "../rule-context";
|
|
2
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>;
|
|
5
7
|
/** Compose ON/ONLY ON/EXCEPT with a registered activity and DAY noun.
|
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
import { Token } from "../../parser-state";
|
|
2
2
|
import { type AdviceFrame, type CanonicalCalendarEventExpr, type FhirQuantity, type ParseOptions } from "../../types";
|
|
3
|
-
import { HpsgClauseContext } from "../rule-context";
|
|
3
|
+
import { HpsgClauseContext, maximumCountLeadAt, maximumDosePerPeriodAt, maximumDosePeriodAt } from "../rule-context";
|
|
4
4
|
import { HpsgLexicalRule, HpsgSign } from "../signature";
|
|
5
5
|
/** Bounded lexical constituent for a fronted following treatment course.
|
|
6
6
|
* The planner reuses its source extent; duration semantics remain owned by
|
|
@@ -33,6 +33,22 @@ export declare function ordinalWeekStageSequence(tokens: readonly Token[]): Ordi
|
|
|
33
33
|
export declare function multiplicativeDoseFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
34
34
|
export declare function compactIntervalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
35
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;
|
|
36
52
|
export declare function separatedFrequencyRangeRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
37
53
|
/**
|
|
38
54
|
* A distributive cadence followed directly by a discrete unit licenses an
|
package/dist/hpsg/signature.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface HpsgEvidence {
|
|
|
11
11
|
lexicalCategory?: CanonicalLexicalCategory;
|
|
12
12
|
tokenIndices: number[];
|
|
13
13
|
/** Lexical evidence that a schedule field is an inferred, construction-local default. */
|
|
14
|
-
scheduleDefault?: "daily-frequency";
|
|
14
|
+
scheduleDefault?: "daily-frequency" | "weekday-recurrence";
|
|
15
15
|
/** Exact typed schedule fields contributed by this lexical evidence. */
|
|
16
16
|
scheduleFields?: CanonicalScheduleSemanticField[];
|
|
17
17
|
}
|
|
@@ -92,6 +92,8 @@ export interface HpsgConditionFeature {
|
|
|
92
92
|
sourceEnd: number;
|
|
93
93
|
targetStart: number;
|
|
94
94
|
targetEnd: number;
|
|
95
|
+
/** Independently selected targets of one coordinated withholding program. */
|
|
96
|
+
targetRanges?: TextRange[];
|
|
95
97
|
safety: boolean;
|
|
96
98
|
frames: AdviceFrame[];
|
|
97
99
|
}
|
|
@@ -158,6 +160,7 @@ export interface HpsgDoseFeature {
|
|
|
158
160
|
value?: number;
|
|
159
161
|
range?: CanonicalDoseRange;
|
|
160
162
|
unit?: string;
|
|
163
|
+
comparator?: FhirQuantity["comparator"] | "~";
|
|
161
164
|
/**
|
|
162
165
|
* Dimensionally typed clinical quantity contributed by the grammar. This
|
|
163
166
|
* remains distinct from `value`/`unit`: an infusion rate must never be
|
|
@@ -172,6 +175,8 @@ export type HpsgClinicalQuantityDimension = "mass" | "volume" | "biologic-activi
|
|
|
172
175
|
export interface HpsgCodedQuantityTerm {
|
|
173
176
|
value: number;
|
|
174
177
|
unit: string;
|
|
178
|
+
/** Qualifier on this amount only; active drug and carrier can differ. */
|
|
179
|
+
comparator?: FhirQuantity["comparator"] | "~";
|
|
175
180
|
system?: string;
|
|
176
181
|
code?: string;
|
|
177
182
|
}
|
|
@@ -181,7 +186,9 @@ export interface HpsgDimensionalQuantityTerm extends HpsgCodedQuantityTerm {
|
|
|
181
186
|
export interface HpsgClinicalQuantityFeature {
|
|
182
187
|
representation: "dose" | "rate-quantity" | "dose-with-rate-ratio";
|
|
183
188
|
status: "resolved" | "incomplete" | "unsupported";
|
|
184
|
-
numerator: HpsgDimensionalQuantityTerm
|
|
189
|
+
numerator: HpsgDimensionalQuantityTerm | (Omit<HpsgDimensionalQuantityTerm, "value"> & {
|
|
190
|
+
range: CanonicalDoseRange;
|
|
191
|
+
});
|
|
185
192
|
denominators: HpsgDimensionalQuantityTerm[];
|
|
186
193
|
/** Per-administration value after an explicit daily total is divided. */
|
|
187
194
|
projectedDose?: HpsgCodedQuantityTerm;
|
|
@@ -198,6 +205,7 @@ export interface HpsgClinicalQuantityFeature {
|
|
|
198
205
|
administrationDuration?: {
|
|
199
206
|
value: number;
|
|
200
207
|
unit: FhirPeriodUnit;
|
|
208
|
+
comparator?: FhirQuantity["comparator"] | "~";
|
|
201
209
|
};
|
|
202
210
|
requiresPatientWeight?: true;
|
|
203
211
|
reviewReason?: "incomplete-weight-based-dose" | "unsupported-weight-based-rate";
|
|
@@ -228,8 +236,10 @@ export interface HpsgScheduleFeature {
|
|
|
228
236
|
/** Weekday occurrence in each month; -1 denotes the last occurrence. */
|
|
229
237
|
weekdayOrdinal?: -1 | 1 | 2 | 3 | 4 | 5;
|
|
230
238
|
timingReference?: "previous" | "previous-weekday-complement";
|
|
231
|
-
/** Source-relative phase onset
|
|
239
|
+
/** Source-relative phase onset; the reference distinguishes civil days. */
|
|
232
240
|
treatmentStartOffsetDays?: number;
|
|
241
|
+
/** Local civil-day origin or completion of the preceding phase. */
|
|
242
|
+
phaseStartReference?: "treatment-day-start" | "previous-phase-next-day" | "previous-phase-end";
|
|
233
243
|
attachmentClass?: "administration" | "procedure";
|
|
234
244
|
/** Exact source owned by this schedule construction, retained for generic attachment arbitration. */
|
|
235
245
|
sourceRanges?: TextRange[];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { HpsgSign, HpsgSynsem } from "./signature";
|
|
1
|
+
import { HpsgSign, HpsgInstructionFeature, HpsgSynsem } from "./signature";
|
|
2
2
|
import { RouteCode } from "../types";
|
|
3
3
|
export interface HpsgUnificationContext {
|
|
4
4
|
normalizeSiteText(text: string): string;
|
|
5
5
|
isCompatibleRouteRefinement(current: RouteCode | undefined, next: RouteCode): boolean;
|
|
6
6
|
sourceText?(start: number, end: number): string;
|
|
7
7
|
}
|
|
8
|
+
/** Keep separately selected occurrences while retaining unframed instruction deduplication. */
|
|
9
|
+
export declare function sameInstructionSourceOccurrence(left: HpsgInstructionFeature, right: HpsgInstructionFeature): boolean;
|
|
8
10
|
export declare function unifySynsem(left: HpsgSynsem, right: HpsgSynsem, context: HpsgUnificationContext): HpsgSynsem | undefined;
|
|
9
11
|
export declare function combineSigns(left: HpsgSign, right: HpsgSign, context: HpsgUnificationContext, rule: string): HpsgSign | undefined;
|
package/dist/i18n.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CourseLanguage } from "./localization";
|
|
2
|
+
import { ENGLISH_CLAUSE_TIMING } from "./locales/course/en";
|
|
3
|
+
export type { CourseLanguage } from "./localization";
|
|
4
|
+
import { BodySiteDefinition, CanonicalDoseExpr, CanonicalSigClause, type MedicationInstructionActionDefinition, type MedicationCondition } from "./types";
|
|
5
|
+
import { type TimingSummaryOptions } from "./timing-summary";
|
|
6
|
+
/** Compose the existing typed guard with its selected administration text. */
|
|
7
|
+
export declare function appendClinicalConditionText(text: string, condition: MedicationCondition, words: CourseLanguage): string;
|
|
2
8
|
export interface SigFormatContext {
|
|
3
9
|
readonly style: "short" | "long";
|
|
4
10
|
readonly clause: CanonicalSigClause;
|
|
5
11
|
readonly defaultText: string;
|
|
12
|
+
readonly course?: CourseLanguage;
|
|
6
13
|
readonly groupMealTimingsByRelation: boolean;
|
|
7
14
|
readonly includeTimesPerDaySummary: boolean;
|
|
8
15
|
readonly realizationMode: "normalized" | "roundtrip";
|
|
9
16
|
readonly sitePlacement: "natural" | "trailing";
|
|
17
|
+
readonly instructionActionMap?: TimingSummaryOptions["instructionActionMap"];
|
|
18
|
+
readonly resolvedMethod?: MedicationInstructionActionDefinition;
|
|
10
19
|
formatDefault(style: "short" | "long"): string;
|
|
11
20
|
}
|
|
12
21
|
export interface SigShortContext extends SigFormatContext {
|
|
@@ -15,18 +24,40 @@ export interface SigShortContext extends SigFormatContext {
|
|
|
15
24
|
export interface SigLongContext extends SigFormatContext {
|
|
16
25
|
readonly style: "long";
|
|
17
26
|
}
|
|
27
|
+
/** Dose amount scope is independent of whether the compact clause has one
|
|
28
|
+
* scalar dose. Native multi/role-bearing amounts retain this target scope. */
|
|
29
|
+
export interface SigDoseScope {
|
|
30
|
+
targetCount: number;
|
|
31
|
+
site?: BodySiteDefinition;
|
|
32
|
+
}
|
|
18
33
|
export interface SigLocalization {
|
|
19
34
|
readonly locale: string;
|
|
35
|
+
/** Optional language-pack facet for whole-course text. Clinical facts stay
|
|
36
|
+
* in canonical code; adding a language never edits the course algorithm. */
|
|
37
|
+
readonly course?: CourseLanguage;
|
|
38
|
+
formatDose?(dose: CanonicalDoseExpr | string, style: "short" | "long", scope?: SigDoseScope): string | undefined;
|
|
20
39
|
formatShort?(context: SigShortContext): string;
|
|
40
|
+
/** Overrides the complete clause; the callback owns its returned wording.
|
|
41
|
+
* Context and default renderings still describe the full clause. */
|
|
21
42
|
formatLong?(context: SigLongContext): string;
|
|
22
43
|
}
|
|
23
44
|
export interface SigLocalizationConfig extends Partial<Omit<SigLocalization, "locale">> {
|
|
24
45
|
locale?: string;
|
|
25
46
|
inherit?: string;
|
|
26
47
|
}
|
|
48
|
+
interface NativeClauseRendering {
|
|
49
|
+
long?: typeof formatLongThai;
|
|
50
|
+
short?: typeof formatShortThai;
|
|
51
|
+
timing: typeof ENGLISH_CLAUSE_TIMING;
|
|
52
|
+
}
|
|
27
53
|
export declare function registerSigLocalization(localization: SigLocalization): void;
|
|
28
54
|
export declare function getRegisteredSigLocalizations(): SigLocalization[];
|
|
55
|
+
export declare function resolveNativeClauseRendering(localization?: SigLocalization): NativeClauseRendering;
|
|
29
56
|
export declare function resolveSigLocalization(locale?: string, config?: SigLocalizationConfig): SigLocalization | undefined;
|
|
57
|
+
export declare function hasClauseFormatOverride(localization: SigLocalization | undefined, style: "short" | "long"): boolean;
|
|
58
|
+
/** Resolve the course facet once at a public formatting boundary. Reuse the
|
|
59
|
+
* existing registry and inheritance contract; no new pack registry or parser. */
|
|
60
|
+
export declare function resolveCourseLanguage(locale?: string, config?: SigLocalizationConfig, resolved?: SigLocalization): CourseLanguage;
|
|
30
61
|
export type SigTranslation = SigLocalization;
|
|
31
62
|
export type SigTranslationConfig = SigLocalizationConfig;
|
|
32
63
|
export declare const registerSigTranslation: typeof registerSigLocalization;
|
|
@@ -35,3 +66,8 @@ export declare function resolveSigTranslation(locale?: string, config?: SigTrans
|
|
|
35
66
|
export declare const DAY_NAMES_THAI: Record<string, string>;
|
|
36
67
|
export declare const THAI_SITE_TRANSLATIONS: Record<string, string>;
|
|
37
68
|
export declare function joinWithAndThai(parts: string[]): string;
|
|
69
|
+
declare function formatShortThai(clause: CanonicalSigClause, words?: CourseLanguage, resolvedMethod?: MedicationInstructionActionDefinition): string;
|
|
70
|
+
declare function formatLongThai(clause: CanonicalSigClause, options?: TimingSummaryOptions, words?: CourseLanguage, resolvedMethod?: MedicationInstructionActionDefinition, authoredPrimary?: string, deferredDirections?: {
|
|
71
|
+
text?: string;
|
|
72
|
+
current?: string;
|
|
73
|
+
}): string;
|