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
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { FhirDayOfWeek, FhirDosage, FhirExtension, FhirR6Extension, FhirQuantity, FhirR6Dosage, FhirR6DosageCondition, FhirR6DosageInstruction, FhirR6DosageStep, FhirR6DosageInstructionInput, FhirR6DosageSafety, FhirR6TimingRepeat, MedicationCondition, EzDosage, EzCourseMetadata, EzCourseStep } from "./types";
|
|
2
|
+
/** R5 and R6 tim-8 requires the lower-count Element beside countMax, not a numeric
|
|
3
|
+
* minimum. Preserve authored companions; an absent minimum remains unknown. */
|
|
4
|
+
export declare function withTimingCountMinimum<T extends Pick<FhirR6TimingRepeat, "count" | "countMax" | "_count">>(repeat: T): T;
|
|
5
|
+
/** R5 and R6 tim-7 requires a lower-duration Element, without inventing a numeric bound. */
|
|
6
|
+
export declare function withTimingDurationMinimum<T extends Pick<FhirR6TimingRepeat, "duration" | "durationMax" | "_duration">>(repeat: T): T;
|
|
7
|
+
/** R5 and R6 tim-6 requires a lower-period Element, without inventing a numeric cadence. */
|
|
8
|
+
export declare function withTimingPeriodMinimum<T extends Pick<FhirR6TimingRepeat, "period" | "periodMax" | "_period">>(repeat: T): T;
|
|
9
|
+
/** Modifier extensions: ignoring either can change whether a dose may be given. */
|
|
10
|
+
export declare const DOSAGE_CONDITION_R5_URL = "urn:ezmedicationinput:StructureDefinition:medication-conditional-dose";
|
|
11
|
+
/** Separate R6 DosageCondition-level extension: the R5 Dosage modifier has
|
|
12
|
+
* a different context and nested child contract, so it cannot be reused. */
|
|
13
|
+
export declare const DOSAGE_CONDITION_R6_LOGIC_URL = "urn:ezmedicationinput:StructureDefinition:medication-r6-condition-logic";
|
|
14
|
+
export declare const DOSAGE_EXCLUDED_DATES_R5_URL = "urn:ezmedicationinput:StructureDefinition:medication-excluded-calendar-dates";
|
|
15
|
+
export declare const DOSAGE_DETAILS_R5_URL = "urn:ezmedicationinput:StructureDefinition:medication-r6-course-details";
|
|
16
|
+
/** Keeps an expression-only R5 backbone element valid without inventing a dose. */
|
|
17
|
+
export declare const R5_EXPRESSION_SLOT_SOURCE_URL = "urn:ezmedicationinput:StructureDefinition:r5-expression-slot-source";
|
|
18
|
+
/** Non-modifier metadata: preserves the author's entire literal instruction
|
|
19
|
+
* without forcing ordinary R5 consumers to implement R6 safety semantics. */
|
|
20
|
+
export declare const DOSAGE_RENDERED_INSTRUCTION_R5_URL = "urn:ezmedicationinput:StructureDefinition:medication-rendered-instruction";
|
|
21
|
+
export declare const DOSAGE_EXCLUDED_WEEKDAYS_R5_URL = "urn:ezmedicationinput:StructureDefinition:medication-excluded-weekdays";
|
|
22
|
+
/** Non-modifier provenance emitted when an editable R5 projection and its
|
|
23
|
+
* retained R6 source cannot be merged one-to-one. */
|
|
24
|
+
export declare const DOSAGE_RECONCILIATION_WARNING_URL = "urn:ezmedicationinput:StructureDefinition:medication-course-reconciliation-warning";
|
|
25
|
+
export { DOSAGE_RECONCILIATION_SOURCE_URL } from "./fhir-quantity-operator";
|
|
26
|
+
export declare const DOSAGE_RETAINED_R5_SEQUENCE_URL = "urn:ezmedicationinput:StructureDefinition:medication-retained-r5-sequence";
|
|
27
|
+
/** R6 doseAndRate is Element. Preserve any older R5-local metadata in the
|
|
28
|
+
* Element.extension slot without emitting illegal modifierExtension keys. */
|
|
29
|
+
export declare const R5_RATE_MODIFIERS_R6_URL = "urn:ezmedicationinput:StructureDefinition:r5-dose-and-rate-modifier-extensions";
|
|
30
|
+
/** The finite repetition count belongs to the complete treatment course.
|
|
31
|
+
* R6 step.count repeats one step; neither R5 nor R6 has a core course-count
|
|
32
|
+
* slot, so both boundary adapters share this narrow modifier extension. */
|
|
33
|
+
export declare const COURSE_CYCLE_COUNT_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-course-cycle-count";
|
|
34
|
+
type CourseCountField = Pick<FhirExtension, "url" | "valueInteger"> & {
|
|
35
|
+
_valueInteger?: unknown;
|
|
36
|
+
};
|
|
37
|
+
type CourseCountOwner = {
|
|
38
|
+
modifierExtension?: readonly CourseCountField[];
|
|
39
|
+
};
|
|
40
|
+
/** Null retains an authored primitive whose finite count is not known. */
|
|
41
|
+
export declare function getCourseCycleCount(owner: CourseCountOwner): number | null | undefined;
|
|
42
|
+
/** Write the current typed count while preserving unrelated modifiers and
|
|
43
|
+
* metadata on an existing recognized count annotation. Output owns writes. */
|
|
44
|
+
export declare function setCourseCycleCount(owner: {
|
|
45
|
+
modifierExtension?: FhirExtension[];
|
|
46
|
+
}, count: number | undefined): FhirExtension[] | undefined;
|
|
47
|
+
export declare function setCourseCycleCount(owner: {
|
|
48
|
+
modifierExtension?: FhirR6Extension[];
|
|
49
|
+
}, count: number | undefined): FhirR6Extension[] | undefined;
|
|
50
|
+
type ModifierWrapperOwner = {
|
|
51
|
+
extension?: FhirR6Extension[];
|
|
52
|
+
modifierExtension?: FhirR6Extension[];
|
|
53
|
+
};
|
|
54
|
+
/** Project the editable modifier owner on an already-owned output fragment.
|
|
55
|
+
* Step and doseAndRate share this Element boundary, including wrapper metadata. */
|
|
56
|
+
export declare function projectR6ModifierWrapper(output: ModifierWrapperOwner, url: string): void;
|
|
57
|
+
export declare function projectR5ModifierWrapper(output: ModifierWrapperOwner, url: string): void;
|
|
58
|
+
export declare function r6StepMetadata(step: Partial<EzCourseStep>): Omit<FhirR6DosageStep, "component">;
|
|
59
|
+
export declare function r5StepMetadata(step: Omit<FhirR6DosageStep, "component">): Omit<EzCourseStep, "sequence">;
|
|
60
|
+
/** Treatment-relative phase origin for an independent parallel component. */
|
|
61
|
+
export declare const PARALLEL_COMPONENT_PHASE_ORIGIN_URL = "urn:ezmedicationinput:StructureDefinition:medication-parallel-component-phase-origin";
|
|
62
|
+
/** Local must-understand profile for exclusive administration choices.
|
|
63
|
+
* Equal R5 sequences and R6 step components alone represent concurrency,
|
|
64
|
+
* so grammar-proven alternatives need explicit membership in both formats.
|
|
65
|
+
*/
|
|
66
|
+
export declare const DOSAGE_ALTERNATIVE_CHOICE_URL = "urn:ezmedicationinput:StructureDefinition:medication-alternative-choice";
|
|
67
|
+
/** Group identity is course-local; a branch may contain multiple dosages. */
|
|
68
|
+
export interface DosageAlternativeChoice {
|
|
69
|
+
groupId: string;
|
|
70
|
+
branchId: string;
|
|
71
|
+
selectionBehavior: "exactly-one";
|
|
72
|
+
}
|
|
73
|
+
/** Read typed membership without interpreting clinical text or changing source.
|
|
74
|
+
* @param dosage An R5 or R6 dosage carrying the same modifier-extension shape.
|
|
75
|
+
* @returns Recognized membership, or undefined while unfamiliar data stays attached.
|
|
76
|
+
*/
|
|
77
|
+
export declare function getDosageAlternativeChoice(dosage: Pick<FhirR6Dosage, "modifierExtension">): DosageAlternativeChoice | undefined;
|
|
78
|
+
/** Assign membership already established by the typed regimen graph.
|
|
79
|
+
* This does not choose a branch, deduce a group from wording, or add conditions.
|
|
80
|
+
* @param dosage The editable R5 or R6 component to update.
|
|
81
|
+
* @param choice Proven membership; undefined explicitly clears this modifier.
|
|
82
|
+
*/
|
|
83
|
+
export declare function setDosageAlternativeChoice(dosage: Pick<FhirR6Dosage, "modifierExtension" | "extension">, choice: DosageAlternativeChoice | undefined): void;
|
|
84
|
+
/** Machine-readable declaration of the local alternative-choice modifier.
|
|
85
|
+
* It is generated beside its only codec, avoiding a second copied schema or
|
|
86
|
+
* an undocumented native FHIR field. Callers can publish/validate the returned
|
|
87
|
+
* StructureDefinition independently of the parser's permissive read path.
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildDosageAlternativeChoiceStructureDefinition(): {
|
|
90
|
+
resourceType: "StructureDefinition";
|
|
91
|
+
id: string;
|
|
92
|
+
url: string;
|
|
93
|
+
name: string;
|
|
94
|
+
title: string;
|
|
95
|
+
status: "draft";
|
|
96
|
+
description: string;
|
|
97
|
+
kind: "complex-type";
|
|
98
|
+
abstract: boolean;
|
|
99
|
+
type: string;
|
|
100
|
+
baseDefinition: string;
|
|
101
|
+
derivation: "constraint";
|
|
102
|
+
context: {
|
|
103
|
+
type: "element";
|
|
104
|
+
expression: string;
|
|
105
|
+
}[];
|
|
106
|
+
differential: {
|
|
107
|
+
element: ({
|
|
108
|
+
id: string;
|
|
109
|
+
path: string;
|
|
110
|
+
sliceName: string;
|
|
111
|
+
min: number;
|
|
112
|
+
max: string;
|
|
113
|
+
type: {
|
|
114
|
+
code: string;
|
|
115
|
+
}[];
|
|
116
|
+
fixedUri?: undefined;
|
|
117
|
+
} | {
|
|
118
|
+
id: string;
|
|
119
|
+
path: string;
|
|
120
|
+
max: string;
|
|
121
|
+
sliceName?: undefined;
|
|
122
|
+
min?: undefined;
|
|
123
|
+
type?: undefined;
|
|
124
|
+
fixedUri?: undefined;
|
|
125
|
+
} | {
|
|
126
|
+
id: string;
|
|
127
|
+
path: string;
|
|
128
|
+
fixedUri: string;
|
|
129
|
+
sliceName?: undefined;
|
|
130
|
+
min?: undefined;
|
|
131
|
+
max?: undefined;
|
|
132
|
+
type?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
fixedCode?: string | undefined;
|
|
135
|
+
id: string;
|
|
136
|
+
path: string;
|
|
137
|
+
min: number;
|
|
138
|
+
max: string;
|
|
139
|
+
type: {
|
|
140
|
+
code: "string" | "code";
|
|
141
|
+
}[];
|
|
142
|
+
sliceName?: undefined;
|
|
143
|
+
fixedUri?: undefined;
|
|
144
|
+
} | {
|
|
145
|
+
id: string;
|
|
146
|
+
path: string;
|
|
147
|
+
isModifier: boolean;
|
|
148
|
+
isModifierReason: string;
|
|
149
|
+
slicing?: undefined;
|
|
150
|
+
} | {
|
|
151
|
+
id: string;
|
|
152
|
+
path: string;
|
|
153
|
+
slicing: {
|
|
154
|
+
discriminator: {
|
|
155
|
+
type: string;
|
|
156
|
+
path: string;
|
|
157
|
+
}[];
|
|
158
|
+
ordered: boolean;
|
|
159
|
+
rules: string;
|
|
160
|
+
};
|
|
161
|
+
isModifier?: undefined;
|
|
162
|
+
isModifierReason?: undefined;
|
|
163
|
+
})[];
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/** Generated copies may be consumed only when their typed predicate agrees. */
|
|
167
|
+
export declare function exactConditionBridgePredicate(extension: FhirExtension): MedicationCondition | undefined;
|
|
168
|
+
export declare function isExactConditionBridge(extension: FhirExtension): boolean;
|
|
169
|
+
export declare function assertUnderstoodDosageModifiers(_dosage: FhirDosage | EzDosage): void;
|
|
170
|
+
declare function parseDosageCondition(dosage: Pick<FhirR6Dosage, "modifierExtension"> & {
|
|
171
|
+
condition?: FhirR6DosageCondition[];
|
|
172
|
+
}): MedicationCondition | undefined;
|
|
173
|
+
export declare function getDosageCondition(dosage: Pick<FhirR6Dosage, "modifierExtension"> & {
|
|
174
|
+
condition?: FhirR6DosageCondition[];
|
|
175
|
+
}): MedicationCondition | undefined;
|
|
176
|
+
/** A whole-day evaluation is licensed only for the same live predicate that
|
|
177
|
+
* the source grammar identified as calendar membership. An edited native
|
|
178
|
+
* condition or a mixed measurement/day predicate cannot inherit that claim.
|
|
179
|
+
* @param dosage Native or R5 dosage with optional source-owned day-domain metadata.
|
|
180
|
+
*/
|
|
181
|
+
export declare function getDosageCalendarDayCondition(dosage: FhirDosage | EzDosage | FhirR6Dosage): MedicationCondition | undefined;
|
|
182
|
+
/** Encode the clinical predicate and its independently supplied day-domain type.
|
|
183
|
+
* @param dosage Editable target dosage; other modifiers remain untouched.
|
|
184
|
+
* @param condition Live clinical predicate, or undefined to clear it.
|
|
185
|
+
* @param calendarDayCondition Source-certified whole-day predicate, never inferred from prose.
|
|
186
|
+
*/
|
|
187
|
+
export declare function setDosageCondition(dosage: FhirDosage, condition: MedicationCondition | undefined, calendarDayCondition?: MedicationCondition): void;
|
|
188
|
+
export declare function getDosageExcludedDates(dosage: FhirDosage | EzDosage | FhirR6Dosage): string[];
|
|
189
|
+
export declare function setDosageExcludedDates(dosage: FhirDosage, dates: string[]): void;
|
|
190
|
+
export declare function getDosageExcludedWeekdays(dosage: FhirDosage | FhirR6Dosage): FhirDayOfWeek[];
|
|
191
|
+
export declare function setDosageExcludedWeekdays(dosage: FhirDosage, days: FhirDayOfWeek[]): void;
|
|
192
|
+
export declare function conditionToR6(condition: MedicationCondition): FhirR6DosageCondition;
|
|
193
|
+
declare function toR6Safety(dosage: FhirDosage, includePartialPeriods?: boolean): FhirR6DosageSafety | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Apply edits made through R5 maximum-dose fields without discarding safety
|
|
196
|
+
* semantics that R5 cannot carry. Existing backbone metadata stays attached
|
|
197
|
+
* to the corresponding representable scope; expression/integer limits and
|
|
198
|
+
* the safety-level exceeded action remain byte-for-byte authoritative.
|
|
199
|
+
*/
|
|
200
|
+
export declare function reconcileR5SafetyEdits(retained: FhirR6DosageSafety, projected: FhirR6DosageSafety | undefined, baseline?: string, dose?: FhirQuantity): FhirR6DosageSafety | undefined;
|
|
201
|
+
/**
|
|
202
|
+
* Reconcile the two editable views of safety against the row's saved source.
|
|
203
|
+
* Explicit safety edits win. An unchanged lifted safety copy must not hide a
|
|
204
|
+
* changed/deleted R5 maximum; field-local merging retains R6-only limits and
|
|
205
|
+
* authored safety metadata. This runs only for rows with retained safety.
|
|
206
|
+
*/
|
|
207
|
+
export declare function reconcileR5SafetySnapshot(row: EzDosage, retained: FhirR6DosageSafety, baseline: string | undefined): FhirR6DosageSafety | undefined;
|
|
208
|
+
export declare function reconcileLiftedR5Safety(row: EzDosage): FhirR6DosageSafety | undefined;
|
|
209
|
+
/** Lift real R6 concepts once into the familiar flat R5 dosage shape. */
|
|
210
|
+
export declare function toEzDosages(dosages: readonly (FhirDosage | EzDosage)[]): EzDosage[];
|
|
211
|
+
export declare function isRenderedInstructionMarker(extension: FhirExtension): boolean;
|
|
212
|
+
export declare function hasUnrecognizedEditMetadata(marker: FhirExtension): boolean;
|
|
213
|
+
/** Project one R6 component without building course-storage metadata. Used by
|
|
214
|
+
* both strict exports and read-only rendering; source objects are not mutated.
|
|
215
|
+
* @param dosage Native R6 component.
|
|
216
|
+
* @param sequence Ordered global course step for its R5 projection.
|
|
217
|
+
*/
|
|
218
|
+
export declare function fromR6Dosage(dosage: FhirR6Dosage, sequence: number): FhirDosage;
|
|
219
|
+
/** A text-only course's latest full marker may already embed previous
|
|
220
|
+
* reconciliation sources. Keep those sources in their existing flat list,
|
|
221
|
+
* and preserve only the immediate preceding course snapshot as a new item.
|
|
222
|
+
* This strips solely the nested source-history wrapper at the known course
|
|
223
|
+
* top level; it retains unknown fields, safety, warnings and other extensions. */
|
|
224
|
+
export declare function sourceWithoutNestedHistory(marker: FhirExtension): FhirExtension;
|
|
225
|
+
/** Preserve unmatched step metadata in its original typed extension structure.
|
|
226
|
+
* @param step Source step that could not be matched to a live dosage.
|
|
227
|
+
*/
|
|
228
|
+
export declare function retainedCourseStepSource(step: NonNullable<EzCourseMetadata["step"]>[number]): FhirExtension;
|
|
229
|
+
/** Compare live projections without sorted copies or serialization. Validator
|
|
230
|
+
* additions are tolerated only on Coding metadata, never on clinical fields.
|
|
231
|
+
* @param original Original typed projection.
|
|
232
|
+
* @param current Current editable projection.
|
|
233
|
+
* @param context Metadata context for Coding-system/version additions.
|
|
234
|
+
*/
|
|
235
|
+
export declare function equivalentProjection(original: unknown, current: unknown, context?: "general" | "coding-list" | "coding-item"): boolean;
|
|
236
|
+
/**
|
|
237
|
+
* Inspect the live R5 projection independently of the embedded R6 snapshot.
|
|
238
|
+
* Modifier metadata is deliberately excluded from the comparison: it can
|
|
239
|
+
* describe a course but must never replace subsequently edited dosage values.
|
|
240
|
+
*/
|
|
241
|
+
export declare function liveDosageProjection(dosage: FhirDosage | EzDosage, includeText?: boolean): object;
|
|
242
|
+
export declare function compactProjectionFingerprint(value: unknown): string;
|
|
243
|
+
/** Matching keys narrow candidates; exact equivalence is checked before
|
|
244
|
+
* claiming identity. Added Coding.system/version annotations do not force
|
|
245
|
+
* every edited row to rescan every original row. Existing baseline hashes
|
|
246
|
+
* remain byte-for-byte unchanged. */
|
|
247
|
+
export declare function matchingProjectionFingerprint(value: unknown): string;
|
|
248
|
+
/** Hash the current editable clinical view without allocating a stripped
|
|
249
|
+
* dosage tree on every call. Retained edit baselines themselves are excluded;
|
|
250
|
+
* active local row fields and all unrelated source annotations remain hashed.
|
|
251
|
+
* The exact token order is identical to compactProjectionFingerprint so
|
|
252
|
+
* existing persisted edit identities require no migration. */
|
|
253
|
+
export declare function dosageProjectionFingerprint(dosage: FhirDosage | EzDosage | FhirR6Dosage): string;
|
|
254
|
+
/** New agreement excludes narrative annotations; legacy untagged hashes keep
|
|
255
|
+
* their exact saved algorithm. An old hash alone cannot recover prior metadata. */
|
|
256
|
+
export declare function dosageClinicalProjectionFingerprint(dosage: FhirDosage | EzDosage | FhirR6Dosage): string;
|
|
257
|
+
export declare function matchesDosageProjectionFingerprint(dosage: FhirDosage | EzDosage | FhirR6Dosage, expected: string | undefined): boolean;
|
|
258
|
+
/** Source text can be retained without claiming it agrees with current
|
|
259
|
+
* external clinical fields. The compact annotation is local to every row. */
|
|
260
|
+
export declare function getDosageSourceTextFingerprint(dosage: Pick<FhirR6Dosage, "extension">): string | undefined;
|
|
261
|
+
/** The original clinical baseline stays bound to its original narrative across saves. */
|
|
262
|
+
export declare function getDosageSourceProjectionFingerprint(dosage: Pick<FhirR6Dosage, "extension">): string | undefined;
|
|
263
|
+
/** An unchanged source may receive its equivalent target-version baseline.
|
|
264
|
+
* Changed clinical fields retain the old hash so saving cannot certify stale text. */
|
|
265
|
+
export declare function retainedSourceProjectionFingerprint(dosage: FhirDosage | EzDosage | FhirR6Dosage): string | undefined;
|
|
266
|
+
/** Wording coverage and permission to replay clinical text are distinct.
|
|
267
|
+
* A declared coverage bit follows its exact source; legacy agreement keeps
|
|
268
|
+
* its existing requirement for a saved clinical projection. */
|
|
269
|
+
export declare function dosageHasAgreedSourceText(dosage: FhirDosage | EzDosage | FhirR6Dosage): boolean;
|
|
270
|
+
export declare function getDosageSourceTextAgreement(dosage: Pick<FhirR6Dosage, "extension" | "text">, acceptTextEdits?: boolean): boolean | undefined;
|
|
271
|
+
/** Source ownership of an immutable parser row. These flags identify the
|
|
272
|
+
* original HPSG projection; no clinical values are copied or watched. */
|
|
273
|
+
export interface FreshDoseSource {
|
|
274
|
+
defaulted: boolean;
|
|
275
|
+
clocks: boolean;
|
|
276
|
+
events: boolean;
|
|
277
|
+
site: boolean;
|
|
278
|
+
}
|
|
279
|
+
export declare function markFreshDoseSource(dosage: FhirDosage, defaulted: boolean, sourceTextAgreed?: boolean, sourceTextCovered?: boolean): void;
|
|
280
|
+
export declare function getFreshDoseSource(dosage: FhirDosage): FreshDoseSource | undefined;
|
|
281
|
+
export interface DosageSourceOwnership {
|
|
282
|
+
clocks?: boolean;
|
|
283
|
+
events?: boolean;
|
|
284
|
+
site?: boolean;
|
|
285
|
+
}
|
|
286
|
+
export declare function sourceOwnership(marker: FhirR6Extension): DosageSourceOwnership | undefined;
|
|
287
|
+
/** Saved primary-field ownership. Missing evidence never licenses removal
|
|
288
|
+
* of independent clocks, event anchors, or sites supplied only by the graph. */
|
|
289
|
+
export declare function getDosageSourceOwnership(dosage: Pick<FhirR6Dosage, "extension">): DosageSourceOwnership | undefined;
|
|
290
|
+
/** Known agreement remains owned even when its source Element has annotations. */
|
|
291
|
+
export declare function isSourceAgreementMarker(marker: FhirExtension): boolean;
|
|
292
|
+
export declare function isCompactSourceAgreementMarker(marker: FhirExtension | FhirR6Extension): boolean;
|
|
293
|
+
/** Verify each immutable submitted dosage's source clinical authority once.
|
|
294
|
+
* Missing provenance is unknown, not a mismatch. Fresh submissions always
|
|
295
|
+
* compare their current fields with the retained projection fingerprint. */
|
|
296
|
+
export declare function dosageMatchesSavedProjection(dosage: FhirDosage | EzDosage | FhirR6Dosage): boolean | undefined;
|
|
297
|
+
export declare function dosageTextFingerprint(dosage: FhirDosage | EzDosage | FhirR6Dosage): string;
|
|
298
|
+
/**
|
|
299
|
+
* Attach source/display provenance using repeated, structured row extensions.
|
|
300
|
+
* Both primary parser output and strict R5 export use this same representation.
|
|
301
|
+
* @param dosages Independently editable rows being returned to the caller.
|
|
302
|
+
* @param instruction The author's unmodified instruction, when supplied.
|
|
303
|
+
* @param sourceAgreement Whether the producer established that wording agrees with the clinical fields.
|
|
304
|
+
*/
|
|
305
|
+
export interface DosageSourceTextBaseline {
|
|
306
|
+
sourceAgreement: boolean;
|
|
307
|
+
sourceTextAgreed?: boolean;
|
|
308
|
+
projectionFingerprint?: string;
|
|
309
|
+
textFingerprint?: string;
|
|
310
|
+
sourceHasStructuredClocks?: boolean;
|
|
311
|
+
sourceHasStructuredEvents?: boolean;
|
|
312
|
+
sourceHasStructuredSite?: boolean;
|
|
313
|
+
}
|
|
314
|
+
export declare function withDosageEditProvenance<T extends FhirDosage | EzDosage>(dosages: readonly T[], instruction: string | undefined, sourceAgreement?: boolean, rowSources?: readonly (DosageSourceTextBaseline | undefined)[], headerCovered?: boolean): T[];
|
|
315
|
+
/** R6 imports follow the *current* DosageInstruction contract, not historical
|
|
316
|
+
* drafts. This runs only at the R6 import boundary, never on ordinary SIG
|
|
317
|
+
* parsing or R5 editing hot paths. Typed extensions and unknown value[x]
|
|
318
|
+
* payloads remain intact instead of being interpreted as clinical language. */
|
|
319
|
+
/** Compatibility name for the requested R6 export: R5 -> native -> R6.
|
|
320
|
+
* The native importer owns all row/phase reconciliation. */
|
|
321
|
+
export declare function toDosageDetails(rows: readonly (FhirDosage | EzDosage)[], instruction?: string, metadata?: EzCourseMetadata, options?: {
|
|
322
|
+
resolvedPhaseSequences?: readonly number[];
|
|
323
|
+
}): FhirR6DosageInstruction;
|
|
324
|
+
export declare function assertCurrentR6DosageInstruction(value: FhirR6DosageInstructionInput): string[];
|
|
325
|
+
/** A supplied R6 instruction is an input source, not an intermediate.
|
|
326
|
+
* Normalize it once and serialize requested R5 views directly. */
|
|
327
|
+
export declare function projectEditableR5Course(details: FhirR6DosageInstructionInput, strictPreview?: boolean): {
|
|
328
|
+
dosages: EzDosage[];
|
|
329
|
+
course: EzCourseMetadata;
|
|
330
|
+
strictDosages?: FhirDosage[];
|
|
331
|
+
};
|
|
332
|
+
/** Import the complete native R6 course into the established editable R5
|
|
333
|
+
* interchange contract. New internal course paths do not use this function. */
|
|
334
|
+
export declare function fromDosageDetails(details: FhirR6DosageInstructionInput): {
|
|
335
|
+
dosages: EzDosage[];
|
|
336
|
+
course: EzCourseMetadata;
|
|
337
|
+
};
|
|
338
|
+
/** Requested R5 export: either input version is imported into native
|
|
339
|
+
* clinical facts, then written directly to R5. Neither external format is an
|
|
340
|
+
* intermediate representation for the other. */
|
|
341
|
+
export declare function toFhirR5Dosages(input: FhirR6DosageInstructionInput | readonly (FhirDosage | EzDosage)[], metadata?: EzCourseMetadata): FhirDosage[];
|
|
342
|
+
/** R5-only fields whose original R6 spelling or metadata needs a local delta. */
|
|
343
|
+
export interface ComponentDeltaBaseline {
|
|
344
|
+
condition?: string;
|
|
345
|
+
safety?: string;
|
|
346
|
+
site?: string;
|
|
347
|
+
doseAndRate?: Array<{
|
|
348
|
+
dose?: string;
|
|
349
|
+
rate?: string;
|
|
350
|
+
doseExpression?: string;
|
|
351
|
+
rateExpression?: string;
|
|
352
|
+
expressionSlot?: boolean;
|
|
353
|
+
}>;
|
|
354
|
+
timing?: string;
|
|
355
|
+
}
|
|
356
|
+
/** Each marker belongs to its live row, never to another component's snapshot. */
|
|
357
|
+
export interface CompactCourseRow {
|
|
358
|
+
rowIndex: number;
|
|
359
|
+
sequence: number;
|
|
360
|
+
stepCount: number;
|
|
361
|
+
/** Current saved-row contract: step.count repeats only that step. */
|
|
362
|
+
countScope?: "step";
|
|
363
|
+
step?: Omit<FhirR6DosageStep, "component">;
|
|
364
|
+
component?: Partial<FhirR6Dosage>;
|
|
365
|
+
/** R6 offsets are typed extension children, never R5 Extension.valueTiming. */
|
|
366
|
+
timingOffsets?: Pick<FhirR6TimingRepeat, "startOffset" | "endOffset">;
|
|
367
|
+
baseline?: ComponentDeltaBaseline;
|
|
368
|
+
context?: string;
|
|
369
|
+
contextRequired?: boolean;
|
|
370
|
+
course?: Omit<FhirR6DosageInstruction, "step" | "renderedInstruction">;
|
|
371
|
+
emptyStep?: EzCourseStep[];
|
|
372
|
+
missingContext?: string[];
|
|
373
|
+
}
|
|
374
|
+
/** Period-local offsets are measured within the cadence period. A frequency
|
|
375
|
+
* edit does not change that window while the R6 frequency > 1 constraint holds. */
|
|
376
|
+
export declare function offsetCadenceFingerprint(timing: FhirDosage["timing"] | FhirR6Dosage["timing"]): string;
|
|
377
|
+
export declare function matchesOffsetCadence(timing: FhirDosage["timing"] | FhirR6Dosage["timing"], baseline: string | undefined): boolean;
|
|
378
|
+
/** Encode local phase metadata and unrepresentable component fields.
|
|
379
|
+
* Course-wide metadata has one owner, referenced by all participating rows.
|
|
380
|
+
* All rows are newly created by the caller; no source course is mutated.
|
|
381
|
+
* @param dosages Fresh flattened output rows in step/component order.
|
|
382
|
+
* @param details Typed source course, used only to calculate missing metadata.
|
|
383
|
+
*/
|
|
384
|
+
export declare function attachCourseDetailsExtensions(dosages: (FhirDosage | EzDosage)[], details: FhirR6DosageInstruction): void;
|
|
385
|
+
/** These are R5 extension codecs, not version converters. A native writer
|
|
386
|
+
* supplies only final retained fields which cannot live in an R5 Dosage row.
|
|
387
|
+
* The old extension names remain stable so existing persisted edits reopen. */
|
|
388
|
+
export declare function attachR5RetainedRow(row: FhirDosage | EzDosage, retained: CompactCourseRow): void;
|
|
389
|
+
/** Qualifiers in SimpleQuantity cannot be ignored as exact numeric doses.
|
|
390
|
+
* The clause writer calls this only after finding a typed qualifier, using the
|
|
391
|
+
* same modifier and edit baseline as the direct native R5 writer. */
|
|
392
|
+
export declare function attachQualifiedR5AmountDetails(row: FhirDosage): void;
|
|
393
|
+
/** A course with no administration has a source carrier, not a fabricated
|
|
394
|
+
* dosage. Encode the header and empty-stage metadata directly into its R5
|
|
395
|
+
* extension; do not allocate an intermediate external course. */
|
|
396
|
+
export declare function createR5EmptyCourseCarrier(fields: Omit<FhirR6DosageInstruction, "step" | "renderedInstruction">, steps: Omit<FhirR6DosageStep, "component">[], instruction?: string): FhirDosage;
|
|
397
|
+
/** Comparison views used only by the retained-row codec. These project small
|
|
398
|
+
* individual fields, never a whole R6 dosage/course to serve as R5 input. */
|
|
399
|
+
export declare const r5ConditionBaseline: typeof parseDosageCondition;
|
|
400
|
+
export declare const r5SafetyBaseline: typeof toR6Safety;
|
|
401
|
+
/** Decode only retained R5 profile fields, not a synthetic external course. */
|
|
402
|
+
export declare function decodeR5RetainedFields(marker: FhirR6Extension): Partial<CompactCourseRow>;
|
|
403
|
+
export declare function encodeR5RetainedFields(value: Partial<CompactCourseRow>): FhirExtension[];
|
|
404
|
+
/** Detect the row-local contract without decoding ordinary R5 inputs.
|
|
405
|
+
* @param dosage Live row carrying optional course metadata.
|
|
406
|
+
*/
|
|
407
|
+
export declare function compactCourseMarker(dosage: FhirDosage | EzDosage): FhirExtension | undefined;
|
|
408
|
+
/** Preserve a superseded local delta without nesting its course owner again.
|
|
409
|
+
* @param marker The row's original structured extension.
|
|
410
|
+
*/
|
|
411
|
+
export declare function localReconciliationSource(marker: FhirExtension): FhirExtension;
|
|
412
|
+
/** Align R6-only dose/rate choices with surviving R5 entries by their
|
|
413
|
+
* native Element.id or unique clinical type. Position is meaningful only if
|
|
414
|
+
* the list cardinality is unchanged; without identity, deleting one of two
|
|
415
|
+
* indistinguishable projected entries cannot prove which was removed.
|
|
416
|
+
*
|
|
417
|
+
* Only called for a course row that actually carries R6-only choices.
|
|
418
|
+
* @returns Live index -> retained source index; unmatched sources stay inert.
|
|
419
|
+
*/
|
|
420
|
+
export declare function retainedDoseRateMatches(source: readonly NonNullable<FhirR6Dosage["doseAndRate"]>[number][], live: readonly NonNullable<FhirR6Dosage["doseAndRate"]>[number][], baselines?: ComponentDeltaBaseline["doseAndRate"]): Map<number, number>;
|
|
421
|
+
/** Phase fields whose disagreement can change administration or supply.
|
|
422
|
+
* IDs and non-modifier annotations remain editable without blocking execution.
|
|
423
|
+
* @param step Local phase metadata without dosage components.
|
|
424
|
+
*/
|
|
425
|
+
export declare function executablePhaseMetadata(step: NonNullable<CompactCourseRow["step"]>): {
|
|
426
|
+
start: import("./types").FhirR6RelativeTime | undefined;
|
|
427
|
+
end: import("./types").FhirR6RelativeTime | undefined;
|
|
428
|
+
count: number | undefined;
|
|
429
|
+
safety: FhirR6DosageSafety | undefined;
|
|
430
|
+
};
|
|
431
|
+
/** Identify unavailable or contradictory context before numeric execution.
|
|
432
|
+
* Parsing, formatting and editing continue to preserve all surviving data.
|
|
433
|
+
* @param course Reconstructed course with typed context markers on its components.
|
|
434
|
+
*/
|
|
435
|
+
export declare function getCourseContextIssue(course: FhirR6DosageInstruction): "missing-course-context" | "conflicting-course-phase" | undefined;
|
|
436
|
+
export declare function encodeR6SourceMetadata(url: string, value: object, kind: "drafts" | "safety" | "step"): FhirExtension;
|
|
437
|
+
export declare function decodeR6SourceMetadata(marker: FhirR6Extension, kind: "drafts" | "safety" | "step"): Record<string, unknown> | undefined;
|
|
438
|
+
/** Preserve an unfamiliar field as explicit typed extension content, never an
|
|
439
|
+
* opaque JSON string. Known FHIR fields use the named datatype schemas above;
|
|
440
|
+
* this escape hatch only retains future/unrecognized native fields verbatim.
|
|
441
|
+
* @param url The enclosing field name.
|
|
442
|
+
* @param value The actual source value; no clinical interpretation is inferred.
|
|
443
|
+
*/
|
|
444
|
+
export declare function retainField(url: string, value: unknown): FhirExtension;
|
|
445
|
+
/** Read retained fields without evaluating them or reparsing serialized text.
|
|
446
|
+
* @param node One preserved field extension.
|
|
447
|
+
*/
|
|
448
|
+
export declare function readRetainedField(node: FhirR6Extension): unknown;
|
|
449
|
+
/** Recover a course from a structured extension, leaving malformed originals
|
|
450
|
+
* with the caller for preservation. No string payload is interpreted here.
|
|
451
|
+
* @param node The dosageDetails extension child.
|
|
452
|
+
*/
|
|
453
|
+
export declare function decodeCourseDetails(node: FhirExtension): FhirR6DosageInstruction | undefined;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Civil-clock primitives shared by clinical occurrence and supply execution.
|
|
2
|
+
* Calendar stepping preserves the prescribed wall clock across DST and month
|
|
3
|
+
* boundaries. No medication, FHIR, parser, or persistence type lives here. */
|
|
4
|
+
export declare const SECONDS_PER_MINUTE = 60;
|
|
5
|
+
/** Caches expensive Intl.DateTimeFormat objects per time zone. */
|
|
6
|
+
export declare const dateTimeFormatCache: Map<string, Intl.DateTimeFormat>;
|
|
7
|
+
/** Separate cache for weekday formatting to avoid rebuilding formatters. */
|
|
8
|
+
export declare const weekdayFormatCache: Map<string, Intl.DateTimeFormat>;
|
|
9
|
+
export interface TimeParts {
|
|
10
|
+
year: number;
|
|
11
|
+
month: number;
|
|
12
|
+
day: number;
|
|
13
|
+
hour: number;
|
|
14
|
+
minute: number;
|
|
15
|
+
second: number;
|
|
16
|
+
}
|
|
17
|
+
export interface DateTimeFormatPart {
|
|
18
|
+
type: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}
|
|
21
|
+
export interface IntlDateTimeFormatOptionsExtended extends Intl.DateTimeFormatOptions {
|
|
22
|
+
calendar?: string;
|
|
23
|
+
numberingSystem?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface DateTimeFormatWithParts {
|
|
26
|
+
formatToParts?: (date?: number | Date) => DateTimeFormatPart[];
|
|
27
|
+
}
|
|
28
|
+
/** Simple zero-padding helper for numeric components. */
|
|
29
|
+
export declare function pad(value: number, length?: number): string;
|
|
30
|
+
export declare function formatToParts(formatter: Intl.DateTimeFormat, date: Date): DateTimeFormatPart[];
|
|
31
|
+
/**
|
|
32
|
+
* Normalizes HH:mm or HH:mm:ss clocks into a consistent HH:mm:ss string.
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeClock(clock: string): string;
|
|
35
|
+
/** Retrieves (and caches) an Intl formatter for calendar components. */
|
|
36
|
+
export declare function getDateTimeFormat(timeZone: string): Intl.DateTimeFormat;
|
|
37
|
+
/** Retrieves (and caches) a formatter for weekday lookups. */
|
|
38
|
+
export declare function getWeekdayFormat(timeZone: string): Intl.DateTimeFormat;
|
|
39
|
+
/**
|
|
40
|
+
* Extracts calendar components for a Date interpreted within the supplied time
|
|
41
|
+
* zone.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getTimeParts(date: Date, timeZone: string): TimeParts;
|
|
44
|
+
/** Calculates the time-zone offset in minutes for a given instant. */
|
|
45
|
+
export declare function getOffset(date: Date, timeZone: string): number;
|
|
46
|
+
/** Locate the offset transition within one civil day. Calendar arithmetic
|
|
47
|
+
* can then split at the real discontinuity instead of assuming local wall
|
|
48
|
+
* clocks are monotone across a DST fold. Ordinary days need two lookups. */
|
|
49
|
+
export declare function calendarOffsetTransition(start: Date, end: Date, timeZone: string): number | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Renders an ISO-8601 string that reflects the provided time zone instead of
|
|
52
|
+
* defaulting to UTC.
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatZonedIso(date: Date, timeZone: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Builds a Date representing a local wall-clock time in the target time zone.
|
|
57
|
+
*/
|
|
58
|
+
export declare function makeZonedDate(timeZone: string, year: number, month: number, day: number, hour: number, minute: number, second: number): Date | null;
|
|
59
|
+
/** Calendar boundaries use the iCalendar DATE-TIME convention for a
|
|
60
|
+
* nonexistent wall clock: apply the pre-gap offset and advance through the
|
|
61
|
+
* gap. Do not use this for prescribed dose events; a missing explicit
|
|
62
|
+
* timeOfDay still has no exact administration instant. */
|
|
63
|
+
export declare function calendarBoundaryDate(timeZone: string, year: number, month: number, day: number, hour: number, minute: number, second: number): Date | null;
|
|
64
|
+
export interface ClockParts {
|
|
65
|
+
hour: number;
|
|
66
|
+
minute: number;
|
|
67
|
+
second: number;
|
|
68
|
+
milliseconds: number;
|
|
69
|
+
}
|
|
70
|
+
/** Decode a clock once for reuse by the existing civil-date constructor. */
|
|
71
|
+
export declare function parseClockParts(clock: string): ClockParts;
|
|
72
|
+
/** Convenience wrapper around makeZonedDate for day-level math. */
|
|
73
|
+
export declare function makeZonedDateFromDay(base: Date, timeZone: string, clock: string | ClockParts): Date | null;
|
|
74
|
+
/** Returns a Date pinned to the start of the local day. */
|
|
75
|
+
export declare function startOfLocalDay(date: Date, timeZone: string): Date;
|
|
76
|
+
/** Adds a number of calendar days while remaining aligned to the time zone. */
|
|
77
|
+
export declare function addLocalDays(date: Date, days: number, timeZone: string): Date;
|
|
78
|
+
/** Advance a *calendar* dose cycle by local days while keeping its
|
|
79
|
+
* prescribed wall clock. Unlike an elapsed q24h interval, a course cycle
|
|
80
|
+
* cannot lose an hour at daylight-saving transitions. */
|
|
81
|
+
export declare function addCalendarDaysAtClock(instant: Date, days: number, timeZone: string, clock: Pick<TimeParts, "hour" | "minute" | "second">): Date | null;
|
|
82
|
+
/** A calendar cycle keeps its original wall clock even after one boundary
|
|
83
|
+
* falls into a DST gap. The next boundary resumes the prescribed hour. */
|
|
84
|
+
export declare function calendarDayStepper(anchor: Date, days: number, timeZone: string, originalClock?: Pick<TimeParts, "hour" | "minute" | "second">): (instant: Date) => Date | null;
|
|
85
|
+
/** Computes the local weekday token (mon..sun). */
|
|
86
|
+
export declare function getLocalWeekday(date: Date, timeZone: string): string;
|
|
87
|
+
export declare function getLocalDayNumber(date: Date, timeZone: string): number;
|
|
88
|
+
export declare function getLocalMonthIndex(date: Date, timeZone: string): number;
|
|
89
|
+
/** Parses arbitrary string/Date inputs into a valid Date instance. */
|
|
90
|
+
export declare function coerceDate(value: Date | string, label: string): Date;
|
|
91
|
+
/**
|
|
92
|
+
* Adds calendar months while respecting varying month lengths and DST.
|
|
93
|
+
*
|
|
94
|
+
* @param date Starting instant.
|
|
95
|
+
* @param months Number of calendar months to add.
|
|
96
|
+
* @param timeZone IANA timezone used for wall-clock preservation.
|
|
97
|
+
* @returns Shifted date preserving local clock and clamped day-of-month.
|
|
98
|
+
*/
|
|
99
|
+
export declare function addCalendarMonths(date: Date, months: number, timeZone: string, originalClock?: Pick<TimeParts, "hour" | "minute" | "second">): Date;
|
|
100
|
+
/**
|
|
101
|
+
* Formats a date into a local `HH:MM:SS` clock for the supplied timezone.
|
|
102
|
+
*
|
|
103
|
+
* @param date Source instant.
|
|
104
|
+
* @param timeZone IANA timezone to interpret the instant.
|
|
105
|
+
* @returns Local wall-clock time in `HH:MM:SS` format.
|
|
106
|
+
*/
|
|
107
|
+
export declare function toLocalClock(date: Date, timeZone: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CanonicalScheduleInput, CanonicalSupplyOptions } from "../canonical/course";
|
|
2
|
+
import type { NextDueDoseOptions, TotalUnitsResult } from "../types";
|
|
3
|
+
export declare function nextDueDoses(dosage: CanonicalScheduleInput, options: NextDueDoseOptions): string[];
|
|
4
|
+
/** Supply math is deterministic only when the administered amount is known.
|
|
5
|
+
* Clinical conditions/PRN are represented as a maximum permitted supply,
|
|
6
|
+
* not as a claim that every available dose will actually be administered. */
|
|
7
|
+
export declare class MedicationQuantityCalculationError extends Error {
|
|
8
|
+
readonly code: string;
|
|
9
|
+
constructor(code: string, message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare function calculateTotalUnits(options: CanonicalSupplyOptions): TotalUnitsResult;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Established EMA SPOR Quantity Operator representation for R5 quantities.
|
|
2
|
+
*
|
|
3
|
+
* R5 Dosage.doseAndRate.doseQuantity / rateQuantity use SimpleQuantity,
|
|
4
|
+
* which has no comparator field. EMA's published comparator extension is
|
|
5
|
+
* applicable to Element and preserves the qualifier without erasing the
|
|
6
|
+
* numeric dose. General Quantity supports native comparators; SimpleQuantity
|
|
7
|
+
* remains comparator-free in both R5 and R6.
|
|
8
|
+
*
|
|
9
|
+
* Sources:
|
|
10
|
+
* EMA http://ema.europa.eu/fhir/extension/comparator
|
|
11
|
+
* EMA http://spor.ema.europa.eu/v1/lists/100000000008
|
|
12
|
+
* HL7 http://hl7.org/fhir/quantity-comparator
|
|
13
|
+
*/
|
|
14
|
+
/** Inactive retained wire data is shared by the version-boundary codecs.
|
|
15
|
+
* Keep this identifier in the leaf codec so annotation conversion does not
|
|
16
|
+
* initialize the course importer or clinical grammar. */
|
|
17
|
+
export declare const DOSAGE_RECONCILIATION_SOURCE_URL = "urn:ezmedicationinput:StructureDefinition:medication-course-reconciliation-source";
|
|
18
|
+
import type { FhirQuantity, FhirR6Quantity, FhirSimpleQuantity, FhirR6SimpleQuantity, FhirR6Coding, FhirR6Extension, FhirPrimitiveElement, FhirR6PrimitiveElement } from "./types";
|
|
19
|
+
export declare const EMA_QUANTITY_COMPARATOR_EXTENSION_URL = "http://ema.europa.eu/fhir/extension/comparator";
|
|
20
|
+
export declare const EMA_QUANTITY_OPERATOR_SYSTEM = "http://spor.ema.europa.eu/v1/lists/100000000008";
|
|
21
|
+
export declare const FHIR_QUANTITY_COMPARATOR_SYSTEM = "http://hl7.org/fhir/quantity-comparator";
|
|
22
|
+
/** Read the published EMA Coding without treating "average", "equivalent"
|
|
23
|
+
* or "range" as invented HL7 comparator semantics. */
|
|
24
|
+
export declare function getEmaQuantityComparator(quantity: Pick<FhirR6Quantity, "extension"> | undefined): FhirR6Quantity["comparator"];
|
|
25
|
+
/** Read the active qualifier. A clinician-edited native Quantity comparator
|
|
26
|
+
* wins over retained EMA metadata; SimpleQuantity falls back to EMA Coding.
|
|
27
|
+
* Use this for meaning/display, not the extension-only inspection API. */
|
|
28
|
+
export declare function getQuantityComparator(quantity: Pick<FhirR6Quantity, "comparator" | "extension"> | undefined): FhirR6Quantity["comparator"];
|
|
29
|
+
/** Translations describe a particular code, not an operator slot. Preserve
|
|
30
|
+
* superseded labels under their original Coding, outside the active operator. */
|
|
31
|
+
export declare const QUANTITY_OPERATOR_SOURCE_URL = "urn:ezmedicationinput:StructureDefinition:quantity-operator-source";
|
|
32
|
+
export declare function quantityAnnotationExtensions(source: FhirR6Extension[], target: "r5" | "r6"): FhirR6Extension[];
|
|
33
|
+
export declare function quantityCodingForWire(coding: FhirR6Coding | undefined, target: "r5" | "r6"): FhirR6Coding | undefined;
|
|
34
|
+
/** The known Quantity choice is projected; all unrelated opaque annotations
|
|
35
|
+
* retain their original datatype and fields at this version boundary. */
|
|
36
|
+
export declare function quantityPrimitiveForR5(primitive: FhirR6PrimitiveElement | undefined): FhirPrimitiveElement | undefined;
|
|
37
|
+
export declare function simpleQuantityForR5(quantity: FhirR6Quantity | undefined): FhirSimpleQuantity | undefined;
|
|
38
|
+
/** R6 SimpleQuantity keeps native primitive annotations while using the same
|
|
39
|
+
* comparator-free scalar representation as R5. */
|
|
40
|
+
export declare function simpleQuantityForR6(quantity: FhirR6Quantity | undefined): FhirR6SimpleQuantity | undefined;
|
|
41
|
+
/** A general R5 Quantity supports older native comparators. Its only
|
|
42
|
+
* missing R6 comparator is "~"; use the EMA extension for that case. */
|
|
43
|
+
export declare function quantityForR5(quantity: FhirR6Quantity | undefined): FhirQuantity | undefined;
|
|
44
|
+
/** A native Quantity operator has one active owner. Retain authored EMA
|
|
45
|
+
* annotations as inert source when writing that owner, so a subsequent edit
|
|
46
|
+
* of the external native comparator cannot revive a hidden duplicate. EMA-only
|
|
47
|
+
* input still owns its qualifier, and SimpleQuantity still writes active EMA. */
|
|
48
|
+
export declare function quantityForR6(quantity: FhirR6Quantity | undefined): FhirR6Quantity | undefined;
|
|
49
|
+
/** Read the current quantity operator at either FHIR boundary. The same EMA
|
|
50
|
+
* coding owns a SimpleQuantity in R5 and R6; native comparators take priority.
|
|
51
|
+
* Authored annotations and superseded labels remain recoverable source. */
|
|
52
|
+
export declare function quantityFromWire(quantity: FhirQuantity | FhirR6Quantity | FhirSimpleQuantity | undefined): FhirR6Quantity | undefined;
|
|
53
|
+
export { quantityFromWire as quantityFromR5 };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { FhirExtension, FhirPrimitiveElement } from "./types";
|
|
1
|
+
import { FhirExtension, FhirPrimitiveElement, FhirR6PrimitiveElement, FhirR6Extension } from "./types";
|
|
2
2
|
export declare const FHIR_TRANSLATION_EXTENSION_URL = "http://hl7.org/fhir/StructureDefinition/translation";
|
|
3
3
|
export declare function cloneI18nRecord(i18n: Record<string, string> | undefined): Record<string, string> | undefined;
|
|
4
4
|
export declare function mergeI18nRecords(...records: Array<Record<string, string> | undefined>): Record<string, string> | undefined;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function clonePrimitiveElement(element: FhirPrimitiveElement | undefined): FhirPrimitiveElement | undefined;
|
|
5
|
+
export declare function cloneExtensions(extensions: FhirR6Extension[] | undefined): FhirExtension[] | undefined;
|
|
6
|
+
export declare function clonePrimitiveElement(element: FhirR6PrimitiveElement | undefined): FhirPrimitiveElement | undefined;
|
|
8
7
|
export declare function buildTranslationPrimitiveElement(translations: Record<string, string> | undefined, base?: FhirPrimitiveElement): FhirPrimitiveElement | undefined;
|
|
9
8
|
export declare function mergeTranslationPrimitiveElement(base: FhirPrimitiveElement | undefined, translations: Record<string, string> | undefined): FhirPrimitiveElement | undefined;
|
|
10
|
-
export declare function getPrimitiveTranslation(element:
|
|
11
|
-
export declare function getPrimitiveTranslations(element:
|
|
9
|
+
export declare function getPrimitiveTranslation(element: FhirR6PrimitiveElement | undefined, locale: string | undefined): string | undefined;
|
|
10
|
+
export declare function getPrimitiveTranslations(element: FhirR6PrimitiveElement | undefined): Record<string, string> | undefined;
|