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
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EZMED's clinical course normal form.
|
|
3
|
+
*
|
|
4
|
+
* Grammar owns CanonicalSigClause and CanonicalParallelRegimen; this module
|
|
5
|
+
* completes that canonical model with course-wide meaning used by execution
|
|
6
|
+
* and by BOTH interchange adapters. It does not extend a FHIR datatype and
|
|
7
|
+
* contains no extension URLs or version-specific sequence/retention markers.
|
|
8
|
+
*
|
|
9
|
+
* Unknown external fields stay in provenance and are never executed. The
|
|
10
|
+
* syntax clauses are read-only evidence, not a second editable dosage truth.
|
|
11
|
+
* A caller editing clinical fields creates the next authoritative course;
|
|
12
|
+
* adapters serialize those fields and preserve unrelated source metadata.
|
|
13
|
+
*/
|
|
14
|
+
import { convertQuantityValue } from "../utils/units";
|
|
15
|
+
import type { BodySiteSpatialRelation, CanonicalSigClause, CanonicalScheduleExpr, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalEventWindowExpr, MedicationCondition, NextDueDoseOptions, TotalUnitsOptions } from "../types";
|
|
16
|
+
export { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent } from "../types";
|
|
17
|
+
import type { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent, FhirDayOfWeek as Weekday } from "../types";
|
|
18
|
+
/** Shared clinical measurements are not a wire-format Quantity. Additional
|
|
19
|
+
* coding metadata is preserved for exact export, but execution uses only the
|
|
20
|
+
* explicitly known numeric value, unit and operator. */
|
|
21
|
+
export interface CanonicalMeasure {
|
|
22
|
+
value?: number;
|
|
23
|
+
unit?: string;
|
|
24
|
+
system?: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
comparator?: "<" | "<=" | ">=" | ">" | "~" | "ad";
|
|
27
|
+
id?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CanonicalRange {
|
|
30
|
+
low?: CanonicalMeasure;
|
|
31
|
+
high?: CanonicalMeasure;
|
|
32
|
+
}
|
|
33
|
+
export interface CanonicalRatio {
|
|
34
|
+
numerator?: CanonicalMeasure;
|
|
35
|
+
denominator?: CanonicalMeasure;
|
|
36
|
+
}
|
|
37
|
+
export interface CanonicalExpression {
|
|
38
|
+
name?: string;
|
|
39
|
+
expression?: string;
|
|
40
|
+
language?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
reference?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CanonicalConcept {
|
|
45
|
+
text?: string;
|
|
46
|
+
coding?: Array<{
|
|
47
|
+
system?: string;
|
|
48
|
+
code?: string;
|
|
49
|
+
display?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** An amount role needs clinical wording or coding; wire annotations alone
|
|
54
|
+
* do not turn an ordinary scalar dose into a role-bearing amount. */
|
|
55
|
+
export declare function hasAmountRole(role: CanonicalConcept | undefined): boolean;
|
|
56
|
+
/** One clinical quantity limit retains its scope, independent value choice,
|
|
57
|
+
* period and source identity. Unlike R5's three maximum fields, this list can
|
|
58
|
+
* represent several differently qualified or expression-based limits without
|
|
59
|
+
* demoting the extras into an active compatibility extension. */
|
|
60
|
+
export interface CanonicalDoseLimit {
|
|
61
|
+
scope: "dosage" | "period" | "administration" | "lifetime";
|
|
62
|
+
amount?: CanonicalMeasure;
|
|
63
|
+
count?: number;
|
|
64
|
+
expression?: CanonicalExpression;
|
|
65
|
+
period?: CanonicalMeasure;
|
|
66
|
+
text?: string;
|
|
67
|
+
/** Typed original wire limit; clinical execution uses the fields above. */
|
|
68
|
+
provenance?: import("../types").FhirR6DoseLimit | import("../types").FhirRatio;
|
|
69
|
+
}
|
|
70
|
+
/** Understood clinical safety policy, not a bag of arbitrary restrictions.
|
|
71
|
+
* Unrecognized FHIR annotations remain ONLY in external source provenance.
|
|
72
|
+
* Dose limits at step/course scope reuse the same typed limit shape. */
|
|
73
|
+
export interface CanonicalSafety {
|
|
74
|
+
ifExceeded?: string;
|
|
75
|
+
limits?: CanonicalDoseLimit[];
|
|
76
|
+
maximaDeclared?: boolean;
|
|
77
|
+
requiresReview?: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface CanonicalAmount {
|
|
80
|
+
quantity?: CanonicalMeasure;
|
|
81
|
+
range?: CanonicalRange;
|
|
82
|
+
expression?: CanonicalExpression;
|
|
83
|
+
rate?: CanonicalMeasure;
|
|
84
|
+
rateRange?: CanonicalRange;
|
|
85
|
+
rateRatio?: CanonicalRatio;
|
|
86
|
+
rateExpression?: CanonicalExpression;
|
|
87
|
+
role?: CanonicalConcept;
|
|
88
|
+
provenance?: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
/** Recurrence and course length are separate meanings. Optional fields retain
|
|
91
|
+
* partial structured input rather than guessing a missing rate or count. */
|
|
92
|
+
export interface CanonicalRecurrence {
|
|
93
|
+
count?: number;
|
|
94
|
+
countMax?: number;
|
|
95
|
+
sharedCount?: CanonicalScheduleExpr["sharedCount"];
|
|
96
|
+
frequency?: number;
|
|
97
|
+
frequencyMax?: number;
|
|
98
|
+
period?: number;
|
|
99
|
+
periodMax?: number;
|
|
100
|
+
periodUnit?: DurationUnit;
|
|
101
|
+
occurrenceDuration?: number;
|
|
102
|
+
occurrenceDurationMax?: number;
|
|
103
|
+
occurrenceDurationUnit?: DurationUnit;
|
|
104
|
+
occurrenceDurationComparator?: CanonicalMeasure["comparator"];
|
|
105
|
+
/** Explicit endpoint quantities retain their independent units/qualifiers. */
|
|
106
|
+
occurrenceDurationRange?: CanonicalRange;
|
|
107
|
+
courseLength?: CanonicalMeasure;
|
|
108
|
+
courseLengthRange?: CanonicalRange;
|
|
109
|
+
calendarWindow?: {
|
|
110
|
+
start?: string;
|
|
111
|
+
end?: string;
|
|
112
|
+
};
|
|
113
|
+
dayOfWeek?: Weekday[];
|
|
114
|
+
clocks?: string[];
|
|
115
|
+
anchors?: TimingEvent[];
|
|
116
|
+
offset?: number;
|
|
117
|
+
offsetMin?: number;
|
|
118
|
+
offsetMax?: number;
|
|
119
|
+
monthDays?: number[];
|
|
120
|
+
weekdayOrdinal?: number;
|
|
121
|
+
activityTiming?: CanonicalActivityTimingExpr[];
|
|
122
|
+
occurrenceCap?: CanonicalOccurrenceCapExpr;
|
|
123
|
+
clockWindow?: {
|
|
124
|
+
start: string;
|
|
125
|
+
end: string;
|
|
126
|
+
endInclusive: boolean;
|
|
127
|
+
};
|
|
128
|
+
eventWindow?: CanonicalEventWindowExpr;
|
|
129
|
+
startOffset?: CanonicalMeasure;
|
|
130
|
+
endOffset?: CanonicalMeasure;
|
|
131
|
+
provenance?: Record<string, unknown>;
|
|
132
|
+
}
|
|
133
|
+
export interface CanonicalTiming {
|
|
134
|
+
recurrence?: CanonicalRecurrence;
|
|
135
|
+
explicitEvents?: string[];
|
|
136
|
+
code?: CanonicalConcept;
|
|
137
|
+
provenance?: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
/** A boundary's anchor is interpreted once at import. A foreign/unknown event
|
|
140
|
+
* remains available for editing, never guessed to be treatment start. */
|
|
141
|
+
export interface CanonicalBoundary {
|
|
142
|
+
/** The previous-phase-next-day anchor denotes local midnight following
|
|
143
|
+
* the predecessor's final occupied day, derived from its exclusive end.
|
|
144
|
+
* previous-phase-end retains that exact exclusive end before a typed pause.
|
|
145
|
+
* treatment-day-start denotes midnight of the order's local calendar day,
|
|
146
|
+
* before applying its day displacement. treatment-start retains the clock.
|
|
147
|
+
* Other non-treatment anchors need an external resolver; never reinterpret
|
|
148
|
+
* them as treatment-relative dates. */
|
|
149
|
+
anchor: "treatment-start" | "treatment-day-start" | "previous-phase-next-day" | "previous-phase-end" | "coded-event" | "resource-reference" | "definition" | "path" | "unresolved";
|
|
150
|
+
contextCode?: CanonicalConcept;
|
|
151
|
+
contextReference?: CanonicalReference;
|
|
152
|
+
contextDefinition?: string;
|
|
153
|
+
contextPath?: string;
|
|
154
|
+
description?: string;
|
|
155
|
+
displacement?: CanonicalMeasure;
|
|
156
|
+
displacementRange?: CanonicalRange;
|
|
157
|
+
/** Uninterpreted external metadata, not an executable anchor. */
|
|
158
|
+
provenance?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
/** The two contextual boundaries share predecessor dependency ownership. */
|
|
161
|
+
export declare function isPreviousPhaseAnchor(anchor: CanonicalBoundary["anchor"] | undefined): anchor is "previous-phase-next-day" | "previous-phase-end";
|
|
162
|
+
export interface CanonicalChoice {
|
|
163
|
+
groupId: string;
|
|
164
|
+
branchId: string;
|
|
165
|
+
}
|
|
166
|
+
/** Known external resource identity semantics. Extra foreign Reference
|
|
167
|
+
* annotations are opaque source metadata, not additional clinical fields. */
|
|
168
|
+
export interface CanonicalReference {
|
|
169
|
+
reference?: string;
|
|
170
|
+
type?: string;
|
|
171
|
+
identifier?: {
|
|
172
|
+
system?: string;
|
|
173
|
+
value?: string;
|
|
174
|
+
use?: string;
|
|
175
|
+
type?: CanonicalConcept;
|
|
176
|
+
period?: {
|
|
177
|
+
start?: string;
|
|
178
|
+
end?: string;
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
display?: string;
|
|
182
|
+
id?: string;
|
|
183
|
+
}
|
|
184
|
+
export interface CanonicalAdministration {
|
|
185
|
+
kind: "administration";
|
|
186
|
+
schedule?: CanonicalTiming;
|
|
187
|
+
amounts?: CanonicalAmount[];
|
|
188
|
+
stageOrdinal?: number;
|
|
189
|
+
/** Typed parser member identity, independent of external dose sequence. */
|
|
190
|
+
sourceMember?: number;
|
|
191
|
+
/** Same-track phase dependencies by sourceMember identity. Presence marks
|
|
192
|
+
* participating nodes; an empty list retains a referenced root identity. */
|
|
193
|
+
phasePredecessors?: number[];
|
|
194
|
+
onsetDays?: number;
|
|
195
|
+
onsetReference?: "previous-phase-next-day" | "previous-phase-end" | "treatment-day-start";
|
|
196
|
+
asNeeded?: boolean;
|
|
197
|
+
targetCount?: number;
|
|
198
|
+
target?: CanonicalConcept;
|
|
199
|
+
siteReference?: CanonicalReference;
|
|
200
|
+
siteSpatialRelation?: BodySiteSpatialRelation;
|
|
201
|
+
route?: CanonicalConcept;
|
|
202
|
+
method?: CanonicalConcept;
|
|
203
|
+
text?: string;
|
|
204
|
+
patientInstruction?: string;
|
|
205
|
+
additionalInstructions?: CanonicalConcept[];
|
|
206
|
+
predicate?: MedicationCondition;
|
|
207
|
+
calendarPredicate?: MedicationCondition;
|
|
208
|
+
excludedDates?: string[];
|
|
209
|
+
excludedWeekdays?: Weekday[];
|
|
210
|
+
limits?: CanonicalDoseLimit[];
|
|
211
|
+
/** Understood safety policy; opaque source metadata lives in provenance. */
|
|
212
|
+
safety?: CanonicalSafety;
|
|
213
|
+
choice?: CanonicalChoice;
|
|
214
|
+
choiceIssue?: boolean;
|
|
215
|
+
phaseOrigin?: CanonicalMeasure;
|
|
216
|
+
/** A member phase whose event origin is not a concrete treatment offset. */
|
|
217
|
+
phaseStart?: CanonicalBoundary;
|
|
218
|
+
/** Exclusive same-track transition, independent of this member's duration. */
|
|
219
|
+
phaseEnd?: CanonicalBoundary;
|
|
220
|
+
phaseOriginIssue?: boolean;
|
|
221
|
+
delayMinutes?: number;
|
|
222
|
+
anchoredLength?: {
|
|
223
|
+
quantity?: CanonicalMeasure;
|
|
224
|
+
range?: CanonicalRange;
|
|
225
|
+
};
|
|
226
|
+
cycleDays?: CanonicalCycleDayConstraint;
|
|
227
|
+
contextIssue?: "conflicting-course-phase" | "missing-course-context";
|
|
228
|
+
syntax?: CanonicalSigClause;
|
|
229
|
+
provenance?: {
|
|
230
|
+
format: "r5" | "r6" | "syntax";
|
|
231
|
+
data: Record<string, unknown>;
|
|
232
|
+
/** False when preserved wording has no agreement proof for current clinical facts. */
|
|
233
|
+
sourceTextVerified?: boolean;
|
|
234
|
+
/** This exact component text had established source agreement; current clinical replay is separate. */
|
|
235
|
+
sourceTextAgreed?: boolean;
|
|
236
|
+
/** Original primary schedule clock ownership; independent graph clocks remain source facts. */
|
|
237
|
+
sourceHasStructuredClocks?: boolean;
|
|
238
|
+
/** Original primary schedule anchor ownership; independent graph events remain source facts. */
|
|
239
|
+
sourceHasStructuredEvents?: boolean;
|
|
240
|
+
/** Original structured primary site ownership; graph-only sites remain independent facts. */
|
|
241
|
+
sourceHasStructuredSite?: boolean;
|
|
242
|
+
/** Original foreign fields retained inside an imported R5 row. Only
|
|
243
|
+
* adapters inspect this source; execution reads the typed fields above. */
|
|
244
|
+
retained?: Partial<import("../types").FhirR6Dosage>;
|
|
245
|
+
};
|
|
246
|
+
missingContexts?: string[];
|
|
247
|
+
}
|
|
248
|
+
export interface CanonicalStage {
|
|
249
|
+
administrations: CanonicalAdministration[];
|
|
250
|
+
start?: CanonicalBoundary;
|
|
251
|
+
end?: CanonicalBoundary;
|
|
252
|
+
count?: number;
|
|
253
|
+
/** Authored stage repetition with a primitive companion but no known scalar. */
|
|
254
|
+
countUnresolved?: true;
|
|
255
|
+
safety?: CanonicalSafety;
|
|
256
|
+
provenance?: Record<string, unknown>;
|
|
257
|
+
}
|
|
258
|
+
export interface CanonicalCourse {
|
|
259
|
+
kind: "course";
|
|
260
|
+
stages: CanonicalStage[];
|
|
261
|
+
instruction?: string;
|
|
262
|
+
cycleInterval?: CanonicalMeasure;
|
|
263
|
+
/** Total complete-course cycles, including the first; independent of each stage's local count. */
|
|
264
|
+
cycleCount?: number;
|
|
265
|
+
/** An authored finite count has primitive metadata but no known scalar. */
|
|
266
|
+
cycleCountUnresolved?: true;
|
|
267
|
+
safety?: CanonicalSafety;
|
|
268
|
+
contextIssue?: "conflicting-course-phase" | "missing-course-context";
|
|
269
|
+
provenance?: {
|
|
270
|
+
format: "r5" | "r6" | "syntax";
|
|
271
|
+
data: Record<string, unknown>;
|
|
272
|
+
/** Source preservation is independent of authority to replay that wording. */
|
|
273
|
+
sourceTextVerified?: boolean;
|
|
274
|
+
/** The producer established coverage of this exact header, independently of clinical replay. */
|
|
275
|
+
sourceTextAgreed?: boolean;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
export type CanonicalScheduleInput = CanonicalCourse | CanonicalAdministration | readonly CanonicalAdministration[];
|
|
279
|
+
export type CanonicalSupplyOptions = Omit<TotalUnitsOptions, "dosage"> & {
|
|
280
|
+
dosage: CanonicalScheduleInput;
|
|
281
|
+
};
|
|
282
|
+
export type CanonicalExecutionOptions = NextDueDoseOptions;
|
|
283
|
+
export interface CanonicalRegimenDueTimes {
|
|
284
|
+
dosageIndex: number;
|
|
285
|
+
stageOrdinal: number;
|
|
286
|
+
phaseStart: string;
|
|
287
|
+
timestamps: string[];
|
|
288
|
+
}
|
|
289
|
+
/** These direct semantic accessors intentionally know nothing about FHIR
|
|
290
|
+
* extensions. Wire readers normalize at the boundary, once per input. */
|
|
291
|
+
export declare const measureOperator: (q: CanonicalMeasure | undefined) => "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
292
|
+
export declare const administrationCondition: (a: CanonicalAdministration) => MedicationCondition | undefined;
|
|
293
|
+
export declare const administrationCalendarCondition: (a: CanonicalAdministration) => MedicationCondition | undefined;
|
|
294
|
+
export declare const administrationExcludedDates: (a: CanonicalAdministration) => string[];
|
|
295
|
+
export declare const administrationExcludedWeekdays: (a: CanonicalAdministration) => Weekday[];
|
|
296
|
+
export declare const administrationChoice: (a: CanonicalAdministration) => CanonicalChoice | undefined;
|
|
297
|
+
export declare const courseContextIssue: (c: CanonicalCourse) => "conflicting-course-phase" | "missing-course-context" | undefined;
|
|
298
|
+
export declare const recurrenceOffset: (r: CanonicalRecurrence | undefined) => number | undefined;
|
|
299
|
+
export declare const recurrenceActivities: (r: CanonicalRecurrence | undefined) => CanonicalActivityTimingExpr[] | undefined;
|
|
300
|
+
export declare const administrationDelay: (a: CanonicalAdministration) => number | undefined;
|
|
301
|
+
export declare const anchoredDuration: (a: Pick<CanonicalAdministration, "anchoredLength">) => {
|
|
302
|
+
quantity?: CanonicalMeasure;
|
|
303
|
+
range?: CanonicalRange;
|
|
304
|
+
} | undefined;
|
|
305
|
+
export declare const recurrenceMonthDays: (r: CanonicalRecurrence | undefined) => number[] | undefined;
|
|
306
|
+
export declare const recurrenceCap: (r: CanonicalRecurrence | undefined) => CanonicalOccurrenceCapExpr | undefined;
|
|
307
|
+
export declare const administrationCycleDays: (a: CanonicalAdministration) => CanonicalCycleDayConstraint | undefined;
|
|
308
|
+
export declare const recurrenceClockWindow: (r: CanonicalRecurrence | undefined) => {
|
|
309
|
+
start: string;
|
|
310
|
+
end: string;
|
|
311
|
+
endInclusive: boolean;
|
|
312
|
+
} | undefined;
|
|
313
|
+
export declare const recurrenceEventWindow: (r: CanonicalRecurrence | undefined) => CanonicalEventWindowExpr | undefined;
|
|
314
|
+
/** Absolute-event ownership stays nominal; both execution fences follow
|
|
315
|
+
* the event's elapsed displacement. Relative recurrence keeps its own origin. */
|
|
316
|
+
export declare function absoluteEventCycleDisplacement(administration: CanonicalAdministration): number | undefined;
|
|
317
|
+
export declare function administrationHasDatedStart(a: CanonicalAdministration, resolvedStart?: Date | null): boolean;
|
|
318
|
+
/** Clock and weekday selection defer a calendar cut to the execution owner.
|
|
319
|
+
* A clinical guard or PRN use does not move an authored clock to midnight;
|
|
320
|
+
* clockless clinical conditions retain their existing admission. */
|
|
321
|
+
export declare function administrationHasDatedSelectedStart(a: CanonicalAdministration, resolvedStart?: Date | null): boolean;
|
|
322
|
+
/** The earliest successor date owns any calendar-only cutoff. Selected clocks
|
|
323
|
+
* or weekdays leave the exact cut to execution; an unselected date-only member
|
|
324
|
+
* on the same day opens first, at midnight. */
|
|
325
|
+
export declare function earliestCalendarOpening(administrations: readonly CanonicalAdministration[]): {
|
|
326
|
+
start: string;
|
|
327
|
+
deferred: boolean;
|
|
328
|
+
} | undefined;
|
|
329
|
+
/** Intersect usable scoped maxima in the administration's quantity unit.
|
|
330
|
+
* Incomplete or incomparable retained constraints do not erase another
|
|
331
|
+
* known maximum. `multiple` records constraints still requiring evaluation. */
|
|
332
|
+
export declare function numericAdministrationLimits(a: CanonicalAdministration, strength?: Parameters<typeof convertQuantityValue>[3]): {
|
|
333
|
+
administration?: CanonicalMeasure;
|
|
334
|
+
lifetime?: CanonicalMeasure;
|
|
335
|
+
multiple: boolean;
|
|
336
|
+
};
|
|
337
|
+
/** Choose the last fully numeric source constraint where the clinical API
|
|
338
|
+
* expects a single bound; other choices remain retained and explicitly
|
|
339
|
+
* unevaluated. Period constraints are consumed independently by the engine. */
|
|
340
|
+
export declare function singleNumericLimit(a: CanonicalAdministration, scope: "administration" | "lifetime"): CanonicalMeasure | undefined;
|
|
341
|
+
export declare function hasPeriodLimits(a: CanonicalAdministration): boolean;
|
|
342
|
+
/** Nonnegative treatment-relative positions keep calendar months distinct
|
|
343
|
+
* from civil days. Cross-unit order is known only when conservative calendar
|
|
344
|
+
* bounds do not overlap; these bounds never become an executable duration. */
|
|
345
|
+
export interface RegimenPosition {
|
|
346
|
+
unit: 'd' | 'mo';
|
|
347
|
+
value: number;
|
|
348
|
+
}
|
|
349
|
+
export declare function compareRegimenPositions(left: RegimenPosition, right: RegimenPosition): -1 | 0 | 1 | undefined;
|
|
350
|
+
/** Text and foreign Element metadata alone do not establish clinical facts
|
|
351
|
+
* that can replace an authored instruction with a generated preview. */
|
|
352
|
+
export declare function administrationHasAmountFacts(a: Pick<CanonicalAdministration, "amounts" | "additionalInstructions">, includeRates?: boolean): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Native clinical course realization. This module reads canonical facts
|
|
2
|
+
* and the existing grammar renderer, never FHIR rows or persistence markers.
|
|
3
|
+
* Display stays separate from executable interpretation: unknown expressions
|
|
4
|
+
* and boundaries remain visible without inventing values or event dates. */
|
|
5
|
+
import type { FormatBatchOptions, FormatOptions, MedicationCondition, FhirDayOfWeek, CanonicalSigClause } from "../types";
|
|
6
|
+
import type { CanonicalCourse, CanonicalAdministration, CanonicalRange, CanonicalExpression, CanonicalSafety } from "./course";
|
|
7
|
+
import { type SigLocalization, type CourseLanguage } from "../i18n";
|
|
8
|
+
/** Resolved once per invocation; recursive clinical composition reuses it. */
|
|
9
|
+
interface CourseFormatEnvironment {
|
|
10
|
+
localization?: SigLocalization;
|
|
11
|
+
words: CourseLanguage;
|
|
12
|
+
}
|
|
13
|
+
export declare function joinGeneratedClauses(clauses: readonly string[], separator?: string): string;
|
|
14
|
+
export declare function appendMedicationExcludedDatesText(text: string, dates: readonly string[], options?: FormatOptions, environment?: CourseFormatEnvironment): string;
|
|
15
|
+
/** The locale owns weekday vocabulary; clinical exclusion membership is
|
|
16
|
+
* walked once instead of repeatedly looking through prior array members. */
|
|
17
|
+
export declare function appendMedicationExcludedWeekdaysText(text: string, days: readonly FhirDayOfWeek[], options?: FormatOptions, environment?: CourseFormatEnvironment): string;
|
|
18
|
+
export declare function appendMedicationConditionText(text: string, condition: MedicationCondition, options?: FormatOptions, environment?: CourseFormatEnvironment): string;
|
|
19
|
+
/** Show an imported expression without evaluating it or inventing a dose.
|
|
20
|
+
* Referenced/named expressions are usable structured data too. */
|
|
21
|
+
export declare function unevaluatedExpressionText(expression: CanonicalExpression, kind: "dose" | "rate", words?: CourseLanguage): string;
|
|
22
|
+
/** Source-less native dose/rate ranges retain both independently authored
|
|
23
|
+
* endpoints and their unit/operators, never a guessed shared unit or value. */
|
|
24
|
+
export declare function rateRangePreview(range: CanonicalRange): string | undefined;
|
|
25
|
+
export declare function prefersSourceInstruction(course: CanonicalCourse): boolean;
|
|
26
|
+
/** Unconditional membership owns a shared allowance across every selectable path. */
|
|
27
|
+
export declare function formatCourseChoices<T>(members: readonly T[], render: (member: T, sharedCountAlreadyDisplayed?: boolean) => string, choiceOf: (member: T) => CanonicalAdministration["choice"], words: CourseLanguage, separator?: string, courseLabels?: ReadonlyMap<string, ReadonlyMap<string, string>>, sharedGroupOf?: (member: T) => string | undefined): string;
|
|
28
|
+
/** Transient renderer result for callers retaining independently authored text. */
|
|
29
|
+
interface AuthoredDirectionsState {
|
|
30
|
+
text: string;
|
|
31
|
+
rendered: boolean;
|
|
32
|
+
headerRendered?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function formatCanonicalAdministration(a: CanonicalAdministration, style?: "short" | "long", options?: FormatOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: AuthoredDirectionsState, stageSafety?: CanonicalSafety): string;
|
|
35
|
+
export declare function formatCanonicalCourse(oneOrCourse: CanonicalCourse, style?: "short" | "long", options?: FormatBatchOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: AuthoredDirectionsState): string;
|
|
36
|
+
export {};
|