ezmedicationinput 0.3.0-beta.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -10
- package/dist/adapters/canonical-course.d.ts +7 -4
- package/dist/adapters/r5-course.d.ts +5 -2
- package/dist/advice-locale-adapter.d.ts +24 -0
- package/dist/advice.d.ts +39 -3
- package/dist/body-site-grammar.d.ts +21 -2
- package/dist/body-site-lookup.d.ts +6 -1
- package/dist/body-site-spatial.d.ts +7 -1
- package/dist/body-site-target.d.ts +32 -3
- package/dist/canonical/compile.d.ts +22 -3
- package/dist/canonical/course.d.ts +43 -7
- package/dist/canonical/format-course.d.ts +4 -2
- package/dist/clause-tail-grammar.d.ts +2 -0
- package/dist/date-interpretation.d.ts +36 -2
- package/dist/dosage-course.d.ts +26 -17
- package/dist/event-timing-expression.d.ts +26 -1
- package/dist/fhir-quantity-operator.d.ts +37 -1
- package/dist/fhir-translations.d.ts +1 -1
- package/dist/fhir.d.ts +24 -4
- package/dist/format.d.ts +23 -24
- package/dist/hpsg/constructions.d.ts +24 -5
- package/dist/hpsg/lexical-classes.d.ts +94 -33
- package/dist/hpsg/method-lexicon.d.ts +3 -0
- package/dist/hpsg/procedural-context.d.ts +46 -3
- package/dist/hpsg/projection.d.ts +7 -3
- package/dist/hpsg/quantity-lexicon.d.ts +51 -0
- package/dist/hpsg/rule-context.d.ts +101 -33
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +1 -1
- package/dist/hpsg/rules/condition-rules.d.ts +13 -2
- package/dist/hpsg/rules/core-rules.d.ts +5 -2
- package/dist/hpsg/rules/prn-rules.d.ts +10 -1
- package/dist/hpsg/rules/site-rules.d.ts +10 -1
- package/dist/hpsg/rules/timing-rules.d.ts +102 -24
- package/dist/hpsg/segmenter.d.ts +2 -2
- package/dist/hpsg/signature.d.ts +41 -4
- package/dist/hpsg/timing-lexicon.d.ts +18 -2
- package/dist/i18n.d.ts +7 -7
- package/dist/index.cjs +75606 -61766
- package/dist/index.d.ts +7 -2
- package/dist/index.js +75606 -61766
- package/dist/instruction-action-locale-adapter.d.ts +63 -4
- package/dist/instruction-action-parser.d.ts +43 -0
- package/dist/instruction-action-terminology.d.ts +22 -1
- package/dist/instruction-concept-terminology.d.ts +13 -1
- package/dist/instruction-graph-fhir.d.ts +4 -2
- package/dist/instruction-graph-ownership.d.ts +96 -0
- package/dist/instruction-graph.d.ts +19 -42
- package/dist/lexer/lex.d.ts +5 -1
- package/dist/lexer/locale.d.ts +14 -0
- package/dist/lexer/locales/en.d.ts +11 -0
- package/dist/lexer/surface.d.ts +3 -1
- package/dist/lexer/token-types.d.ts +6 -0
- package/dist/locale-detection.d.ts +4 -2
- package/dist/locales/clause/en.d.ts +14 -0
- package/dist/locales/course/en.d.ts +5 -0
- package/dist/localization.d.ts +3 -0
- package/dist/localized-timing.d.ts +1 -1
- package/dist/maps.d.ts +38 -12
- package/dist/medication-condition.d.ts +72 -11
- package/dist/parser-state.d.ts +10 -0
- package/dist/parser.d.ts +5 -3
- package/dist/prn.d.ts +13 -2
- package/dist/regimen/coordination-scope.d.ts +13 -1
- package/dist/regimen/grammar.d.ts +7 -1
- package/dist/regimen/parallel-course.d.ts +6 -2
- package/dist/regimen/planner.d.ts +2 -3
- package/dist/regimen/regimen.d.ts +2 -0
- package/dist/snomed.d.ts +3 -0
- package/dist/suggest-locale-adapter.d.ts +15 -0
- package/dist/symptom-terminology.d.ts +5 -1
- package/dist/timing-summary.d.ts +41 -9
- package/dist/types.d.ts +127 -15
- package/dist/unit-lexicon.d.ts +2 -6
- package/dist/utils/units.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# ezmedicationinput
|
|
2
2
|
|
|
3
|
-
`ezmedicationinput` parses concise clinician shorthand medication instructions
|
|
3
|
+
`ezmedicationinput` parses concise clinician shorthand medication instructions into editable dosage rows, with [FHIR R5 Dosage](https://hl7.org/fhir/dosage.html) and current R6 export. It is designed for use in lightweight medication-entry experiences and ships with batteries-included normalization for common Thai/English sig abbreviations.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- Converts shorthand strings (e.g. `1x3 po pc`, `500 mg po q6h prn pain`) into
|
|
7
|
+
- Converts shorthand strings (e.g. `1x3 po pc`, `500 mg po q6h prn pain`) into extended editable dosage rows, with separate R5 and R6 projections.
|
|
8
8
|
- Parses multi-clause sigs into multiple dosage items (e.g. `OD ... , OS ...`), with all dosage rows available in the complete `batch.fhir` array.
|
|
9
9
|
- Emits timing abbreviations (`timing.code`) and repeat structures simultaneously where possible.
|
|
10
10
|
- Maps meal/time blocks to the correct `Timing.repeat.when` **EventTiming** codes and can auto-expand AC/PC/C into specific meals.
|
|
@@ -33,17 +33,20 @@ npm install ezmedicationinput
|
|
|
33
33
|
## Usage
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
|
-
import { parseSig } from "ezmedicationinput";
|
|
36
|
+
import { parseSig, toFhirR5Dosages } from "ezmedicationinput";
|
|
37
37
|
|
|
38
38
|
const batch = parseSig("1x3 po pc", { context: { dosageForm: "tab" } });
|
|
39
39
|
|
|
40
|
-
// Individual clause and
|
|
40
|
+
// Individual clause and its editable dosage row
|
|
41
41
|
console.log(batch.count); // 1
|
|
42
|
-
console.log(batch.items[0].fhir);
|
|
42
|
+
console.log(batch.items[0].fhir); // Single EzDosage
|
|
43
43
|
|
|
44
44
|
// Complete batch for multi-dose or phased instructions
|
|
45
|
-
console.log(batch.fhir); // EzDosage[]:
|
|
45
|
+
console.log(batch.fhir); // EzDosage[]: extended R5-shaped editable rows
|
|
46
46
|
console.log(batch.fhirNext); // Current FHIR R6 DosageInstruction
|
|
47
|
+
|
|
48
|
+
// Strict R5 wire export, including the batch course metadata
|
|
49
|
+
const r5Dosages = toFhirR5Dosages(batch.fhir, batch.course);
|
|
47
50
|
```
|
|
48
51
|
|
|
49
52
|
Example output:
|
|
@@ -78,8 +81,8 @@ Example output:
|
|
|
78
81
|
`parseSig` and `parseSigAsync` return one batch result containing:
|
|
79
82
|
|
|
80
83
|
- `count`: number of parsed dosage clauses.
|
|
81
|
-
- `items[n].fhir`: the
|
|
82
|
-
- `fhir`: `EzDosage[]` containing all
|
|
84
|
+
- `items[n].fhir`: the editable `EzDosage` for an individual clause.
|
|
85
|
+
- `fhir`: `EzDosage[]` containing all extended R5-shaped editable rows; these are not strict FHIR R5 JSON.
|
|
83
86
|
- `fhirNext`: native FHIR R6 `DosageInstruction`, with sequential steps and concurrent dosing components.
|
|
84
87
|
- `meta.segments`: source ranges for each clause.
|
|
85
88
|
- `shortText`, `longText`, `warnings`, and `meta`: batch-level display and diagnostics.
|
|
@@ -89,7 +92,10 @@ Use `items[0].fhir` when displaying or editing a single dosage, and
|
|
|
89
92
|
`formatSig` and `fromFhirDosage` accept one dosage; `formatSigBatch`
|
|
90
93
|
accepts an array of dosages.
|
|
91
94
|
|
|
92
|
-
The
|
|
95
|
+
The extended rows under `fhir` remain the compatibility/editing surface.
|
|
96
|
+
Use `toFhirR5Dosages(batch.fhir, batch.course)` for strict R5 wire export.
|
|
97
|
+
This projects the extended clinical fields into supported R5 fields and extensions,
|
|
98
|
+
while retaining the supplied course metadata.
|
|
93
99
|
The `fhirNext` object follows the **pinned HL7 R6 CI build dated November 13, 2026**,
|
|
94
100
|
whose profiles use the version label `6.0.0-snapshot1`. The
|
|
95
101
|
[checked-in contract](fhir/r6/official-snapshot1-20261113-contract.json) records
|
|
@@ -176,7 +182,8 @@ can load another version's internal model.
|
|
|
176
182
|
|
|
177
183
|
**Only the documented external interchange contracts are compatibility
|
|
178
184
|
boundaries:** `.fhir` and the established R5 editing/persistence APIs
|
|
179
|
-
remain R5;
|
|
185
|
+
remain R5-shaped; `toFhirR5Dosages` produces strict R5 wire output.
|
|
186
|
+
`.fhirNext` and `fromFhir` use the *current supported* R6
|
|
180
187
|
structure, not obsolete R6 drafts. The internal model is deliberately free
|
|
181
188
|
to evolve for maximum clinical expressiveness, performance, and
|
|
182
189
|
maintainability; no old internal representation must be retained.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* versions are projections of the same canonical clinical course. Unknown
|
|
8
8
|
* source metadata is retained separately and never consulted by execution.
|
|
9
9
|
*/
|
|
10
|
-
import type { FhirDosage, EzDosage, FhirR6Dosage, FhirR6DosageInstruction, FhirR6DosageInstructionInput, FhirR6DoseLimit, FhirR6DosageSafety, FhirR6DosageStep, CanonicalSigClause, FhirR6RelativeTime, FhirQuantity, FhirR6Quantity, FhirRange, FhirR6Range, FhirRatio, ParseBatchResult, FhirR6Extension, FormatOptions } from "../types";
|
|
10
|
+
import type { FhirDosage, EzDosage, FhirR6Dosage, FhirR6DosageInstruction, FhirR6DosageInstructionInput, FhirR6DoseLimit, FhirR6DosageSafety, FhirR6DosageStep, CanonicalSigClause, FhirR6RelativeTime, FhirQuantity, FhirR6Quantity, FhirRange, FhirR6Range, FhirRatio, ParseBatchResult, NextDueDoseOptions, FhirR6Extension, FormatOptions } from "../types";
|
|
11
11
|
import type { CanonicalMeasure, CanonicalAmount, CanonicalRange, CanonicalAdministration, CanonicalSafety, CanonicalDoseLimit, CanonicalCourse, CanonicalStage, CanonicalBoundary, CanonicalScheduleInput } from "../canonical/course";
|
|
12
12
|
import type { FhirProjectionOptions } from "../fhir";
|
|
13
13
|
/** A maximum without both endpoint objects is retained source, not an invented R6 limit. */
|
|
@@ -33,7 +33,7 @@ export declare function courseFromR6(raw: FhirR6DosageInstructionInput, sourceCo
|
|
|
33
33
|
/** Reconciliation is solely an R5 import concern, never part of native
|
|
34
34
|
* course execution. A simple scalar needs no course reconstruction. */
|
|
35
35
|
export declare function isR6DosageInstruction(input: object): input is FhirR6DosageInstructionInput;
|
|
36
|
-
export declare function inputToCanonical(input: FhirDosage | readonly FhirDosage[] | FhirR6DosageInstructionInput | ParseBatchResult | CanonicalScheduleInput): CanonicalScheduleInput;
|
|
36
|
+
export declare function inputToCanonical(input: FhirDosage | readonly FhirDosage[] | FhirR6DosageInstructionInput | ParseBatchResult | CanonicalScheduleInput, alternativeChoices?: NextDueDoseOptions["alternativeChoices"]): CanonicalScheduleInput;
|
|
37
37
|
export declare function boundaryToWire(b: CanonicalBoundary | undefined): FhirR6RelativeTime | undefined;
|
|
38
38
|
/** Use the supplied dose unit, including one carried by either range endpoint. */
|
|
39
39
|
export declare function r5MaximumDoseBasis(amounts: FhirDosage["doseAndRate"]): FhirQuantity | undefined;
|
|
@@ -56,12 +56,15 @@ export interface R5MaximumSelection extends SelectedR5Maximum {
|
|
|
56
56
|
export declare function selectR5Maximum(current: R5MaximumSelection | undefined, quantity: CanonicalMeasure, index?: number, dose?: CanonicalMeasure): R5MaximumSelection;
|
|
57
57
|
/** Shared wire serializer for current maxima and retained R5 edit baselines. */
|
|
58
58
|
export declare function periodMaximumToR5(amount: CanonicalMeasure, period: CanonicalMeasure, source?: object): FhirRatio;
|
|
59
|
+
/** Both direct wire projection and supplied parser rows carry this native
|
|
60
|
+
* dose fact. The anatomical count marker is deliberately not allocation proof. */
|
|
61
|
+
export declare function writeAdministrationDoseAllocation(output: FhirDosage | FhirR6Dosage, administration: CanonicalAdministration): void;
|
|
59
62
|
/** Direct native-to-R6 component writer. */
|
|
60
63
|
/** Emit native R6 directly from modeled clinical facts. Shared serializers
|
|
61
64
|
* encode vocabulary and grammar-source annotations only, never an R5 course. */
|
|
62
|
-
export declare function administrationToR6(a: CanonicalAdministration, options?: FhirProjectionOptions, currentSyntax?: CanonicalSigClause): FhirR6Dosage;
|
|
65
|
+
export declare function administrationToR6(a: CanonicalAdministration, options?: FhirProjectionOptions, currentSyntax?: CanonicalSigClause, phaseSequence?: number, trackCycleMember?: boolean): FhirR6Dosage;
|
|
63
66
|
/** Direct native-to-R5 component writer. No R6 component is constructed. */
|
|
64
|
-
export declare function administrationToR5(a: CanonicalAdministration, sequence: number | undefined, options?: FhirProjectionOptions, currentSyntax?: CanonicalSigClause): FhirDosage;
|
|
67
|
+
export declare function administrationToR5(a: CanonicalAdministration, sequence: number | undefined, options?: FhirProjectionOptions, currentSyntax?: CanonicalSigClause, trackCycleMember?: boolean): FhirDosage;
|
|
65
68
|
/** Header/step metadata is shared fragment serialization, NOT a course in
|
|
66
69
|
* another external format. The R5 writer encodes it directly in R5 extensions. */
|
|
67
70
|
export declare function courseMetadataToWire(course: CanonicalCourse): Omit<FhirR6DosageInstruction, "step" | "renderedInstruction">;
|
|
@@ -6,10 +6,13 @@
|
|
|
6
6
|
* stays compatible with saved client data; it is NOT an intermediate R6
|
|
7
7
|
* dosage/course used to obtain the R5 result.
|
|
8
8
|
*/
|
|
9
|
-
import type { FhirDosage, EzDosage, EzCourseMetadata } from "../types";
|
|
10
|
-
import type { CanonicalCourse } from "../canonical/course";
|
|
9
|
+
import type { FhirDosage, EzDosage, EzCourseMetadata, CanonicalSigClause } from "../types";
|
|
10
|
+
import type { CanonicalCourse, CanonicalAdministration } from "../canonical/course";
|
|
11
11
|
import type { FhirProjectionOptions } from "../fhir";
|
|
12
12
|
import { type DosageSourceTextBaseline } from "../dosage-course";
|
|
13
|
+
/** A standalone source component uses the same native facts and retained-field
|
|
14
|
+
* writer as a complete course, without inventing surrounding stages. */
|
|
15
|
+
export declare function projectNativeR5Administration(administration: CanonicalAdministration, sequence: number | undefined, options?: FhirProjectionOptions, currentSyntax?: CanonicalSigClause): FhirDosage;
|
|
13
16
|
/** Native course metadata is serialized once into its FINAL R5 extension
|
|
14
17
|
* header. Step/member loops write direct rows and their local retained fields.
|
|
15
18
|
* No R6 object is built, flattened, imported, or used as an adapter input. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MedicationConditionLexicalFeatures } from "./medication-condition";
|
|
1
2
|
import { AdviceFrame, AdviceModality } from "./types";
|
|
2
3
|
export interface AdviceLocaleRealizationInput {
|
|
3
4
|
frame: AdviceFrame;
|
|
@@ -6,14 +7,37 @@ export interface AdviceLocaleRealizationInput {
|
|
|
6
7
|
argText?: string;
|
|
7
8
|
modalityText?: string;
|
|
8
9
|
relationText?: string;
|
|
10
|
+
/** Complete wording from the selected typed action. Stock realization keeps
|
|
11
|
+
* its argument roles and relations; registered providers may replace it. */
|
|
12
|
+
typedText?: string;
|
|
9
13
|
}
|
|
10
14
|
export interface AdviceLocaleAdapter {
|
|
11
15
|
locale: string;
|
|
16
|
+
medicationConditions?: MedicationConditionLexicalFeatures;
|
|
17
|
+
referentIdentity?(text: string): string;
|
|
18
|
+
siteCoordination?(text: string): {
|
|
19
|
+
left: string;
|
|
20
|
+
right: string;
|
|
21
|
+
connector: string;
|
|
22
|
+
} | undefined;
|
|
12
23
|
realizeModality(modality: AdviceModality | undefined): string | undefined;
|
|
13
24
|
siteArgument(text: string): string;
|
|
14
25
|
joinArguments(texts: string[]): string | undefined;
|
|
15
26
|
realize(input: AdviceLocaleRealizationInput): string;
|
|
16
27
|
finalize(text: string): string;
|
|
17
28
|
}
|
|
29
|
+
/** Revision of the registered lexical capabilities used by derived caches. */
|
|
30
|
+
export declare function adviceLocaleAdapterRevision(): number;
|
|
18
31
|
export declare function registerAdviceLocaleAdapter(adapter: AdviceLocaleAdapter): void;
|
|
19
32
|
export declare function getAdviceLocaleAdapter(locale: string): AdviceLocaleAdapter;
|
|
33
|
+
/** A registered wording provider keeps its complete advice realization even
|
|
34
|
+
* when typed graph facts can supply the stock default. Recognition-only
|
|
35
|
+
* registration does not replace that default; no callback runs for this test. */
|
|
36
|
+
export declare function hasRegisteredAdviceWording(locale: string, hook?: "realize" | "realizeModality" | "siteArgument" | "joinArguments" | "finalize"): boolean;
|
|
37
|
+
/** Stock wording is used only to recognize an unchanged materialized label. */
|
|
38
|
+
export declare function getDefaultAdviceLocaleAdapter(locale: string): AdviceLocaleAdapter;
|
|
39
|
+
/** Recognize a connector independently of the languages of its two nouns. */
|
|
40
|
+
export declare function matchAdviceSiteCoordination(text: string, locale: string): ReturnType<NonNullable<AdviceLocaleAdapter["siteCoordination"]>>;
|
|
41
|
+
/** Clause admission consumes registered lexical cues independently of the
|
|
42
|
+
* language selected for rendering; registration owns matcher cursor semantics. */
|
|
43
|
+
export declare function isAdviceConditionCue(text: string): boolean;
|
package/dist/advice.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { LexToken } from "./lexer/token-types";
|
|
2
|
+
import { AdditionalInstructionDefinition, AdviceArgument, AdviceForce, AdviceFrame, FhirCoding, MedicationInstructionActionDefinition, TextRange } from "./types";
|
|
2
3
|
/** Directed clinical Coding identity; presentation and Element annotations stay on their owner. */
|
|
3
4
|
export declare function preservesAdviceCoding(selected: FhirCoding | undefined, actual: FhirCoding | undefined): boolean;
|
|
4
5
|
export declare function preservesAdviceCodings(selected: readonly FhirCoding[] | undefined, actual: readonly FhirCoding[] | undefined): boolean;
|
|
@@ -14,6 +15,8 @@ export declare function preservesAdviceComponents(selected: readonly {
|
|
|
14
15
|
/** Text, source spans and retained Element annotations are not typed argument facts. */
|
|
15
16
|
export declare function hasAdviceArgumentFacts(argument: AdviceArgument): boolean;
|
|
16
17
|
export declare function preservesAdviceArgumentFacts(selected: AdviceArgument, actual: AdviceArgument): boolean;
|
|
18
|
+
/** Argument roles are independent slots; the order within a role is retained. */
|
|
19
|
+
export declare function correspondingAdviceArguments(selected: readonly AdviceArgument[], actual: readonly AdviceArgument[], matches: (left: AdviceArgument, right: AdviceArgument) => boolean, complete?: boolean): boolean;
|
|
17
20
|
/**
|
|
18
21
|
* Preserve selected typed facts while a caller licenses the same occurrence/head.
|
|
19
22
|
* Source/value correspondence and provisional opaque valence remain caller-owned.
|
|
@@ -39,12 +42,19 @@ export interface AdviceParseContext {
|
|
|
39
42
|
export declare function matchComposedAdviceCodings(frames: readonly AdviceFrame[]): AdditionalInstructionDefinition[];
|
|
40
43
|
/** Determine whether a rule's coding must be rechecked against scoped HPSG frames. */
|
|
41
44
|
export declare function adviceCodingNeedsComposedScope(system: string, code: string): boolean;
|
|
45
|
+
/** Return the same composed-only declaration for preview lexical ownership. */
|
|
46
|
+
export declare function composedAdviceCodingDefinition(system: string, code: string): AdditionalInstructionDefinition | undefined;
|
|
47
|
+
/** Retain the selected occurrences whose complete qualifiers are represented by
|
|
48
|
+
* the coding template. One unrepresented member does not invalidate its siblings;
|
|
49
|
+
* source locations and registered lexical enrichment are not additional meaning.
|
|
50
|
+
* Association without a selected locale must retain every supplied predicate label. */
|
|
51
|
+
export declare function adviceTemplateRepresentedActions(frames: readonly AdviceFrame[], coding: Pick<FhirCoding, "system" | "code" | "_system">, locale?: string): AdviceFrame[];
|
|
42
52
|
/**
|
|
43
53
|
* Retain the existing coding matcher's exact supporting action objects for
|
|
44
54
|
* occurrence-aware realization. Clinical coding and wording remain with their
|
|
45
55
|
* existing owners; no action identity is reconstructed from rendered text.
|
|
46
56
|
*/
|
|
47
|
-
export declare function composedCodedAdviceActions(frames: readonly AdviceFrame[], coding: Pick<FhirCoding, "system" | "code"> | undefined): AdviceFrame[];
|
|
57
|
+
export declare function composedCodedAdviceActions(frames: readonly AdviceFrame[], coding: Pick<FhirCoding, "system" | "code" | "_system"> | undefined): AdviceFrame[];
|
|
48
58
|
/** Existing advice terminology supplies manner modifiers to the main action
|
|
49
59
|
* grammar. It is lexical evidence, not a second clause parser. */
|
|
50
60
|
export declare function resolveAdviceMannerModifier(surface: string): {
|
|
@@ -53,9 +63,35 @@ export declare function resolveAdviceMannerModifier(surface: string): {
|
|
|
53
63
|
} | undefined;
|
|
54
64
|
/** Exact advice nominals share their existing lexical identity with action arguments. */
|
|
55
65
|
export declare function resolveAdviceNominalArgument(surface: string, sourceText?: string): AdviceArgument | undefined;
|
|
56
|
-
|
|
66
|
+
/** A complete compound nominal retains its lexical owner when its final word
|
|
67
|
+
* also names a generic event. Only declared compounds ending at that word are checked. */
|
|
68
|
+
export declare function resolveCompoundAdviceNominalEndingAt(tokens: readonly Pick<LexToken, "canonical" | "lower">[], endExclusive: number): {
|
|
69
|
+
start: number;
|
|
70
|
+
argument: AdviceArgument;
|
|
71
|
+
} | undefined;
|
|
72
|
+
/** The same declared compound owner resolves a complete following conjunct. */
|
|
73
|
+
export declare function resolveCompoundAdviceNominalAt(tokens: readonly Pick<LexToken, "canonical" | "lower">[], start: number): {
|
|
74
|
+
end: number;
|
|
75
|
+
argument: AdviceArgument;
|
|
76
|
+
} | undefined;
|
|
77
|
+
export declare function classifyArgument(text: string, completeNominal?: boolean): AdviceArgument;
|
|
78
|
+
export declare function realizeAdviceFramesText(frames: AdviceFrame[], locale?: string, typed?: {
|
|
79
|
+
text: string;
|
|
80
|
+
argumentText: (argument: AdviceArgument) => string;
|
|
81
|
+
}): string | undefined;
|
|
57
82
|
export declare function parseAdditionalInstructions(sourceText: string, span: TextRange, context?: AdviceParseContext): ParsedAdditionalInstruction[];
|
|
83
|
+
/** Complete registered wording permits only the existing presentation variants.
|
|
84
|
+
* This proves stock lexical ownership, never equality of rendered instructions. */
|
|
85
|
+
export declare function isStockAdditionalInstructionWording(text: string | undefined, definition: AdditionalInstructionDefinition): boolean;
|
|
86
|
+
/** Exact registered advice remains one lexical constituent before a generic
|
|
87
|
+
* action frame can split its nominal or relation-shaped words. */
|
|
88
|
+
export declare function resolveRegisteredAdditionalInstruction(sourceText: string, span: TextRange, selectedAction: MedicationInstructionActionDefinition | undefined): ParsedAdditionalInstruction | undefined;
|
|
58
89
|
export declare function findAdditionalInstructionDefinitionByCoding(system: string, code: string): AdditionalInstructionDefinition | undefined;
|
|
90
|
+
/** Select known advice meaning without reducing the original wire coding list. */
|
|
91
|
+
export declare function selectAdditionalInstructionCoding<T extends {
|
|
92
|
+
system?: string;
|
|
93
|
+
code?: string;
|
|
94
|
+
}>(codings: readonly T[] | undefined): T | undefined;
|
|
59
95
|
export declare const __test__: {
|
|
60
96
|
createDefinitionFromSource(source: {
|
|
61
97
|
system?: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Token } from "./parser-state";
|
|
1
2
|
import { BodySiteDefinition, BodySiteSpatialRelation, FhirCoding, type BodySiteRestriction, type BodySiteRestrictionPredicate, type TextRange } from "./types";
|
|
2
3
|
import type { BodySiteLocativeRelation } from "./relation-terminology";
|
|
3
4
|
export type BodySiteGrammarKind = "nominal" | "partitive" | "locative";
|
|
@@ -26,6 +27,7 @@ export interface BodySiteNominalFeatures {
|
|
|
26
27
|
}
|
|
27
28
|
export interface BodySitePartitiveFeatures {
|
|
28
29
|
kind: "partitive";
|
|
30
|
+
canonical: string;
|
|
29
31
|
part: string;
|
|
30
32
|
relationKey?: string;
|
|
31
33
|
whole: BodySiteNominalFeatures;
|
|
@@ -53,6 +55,8 @@ export interface ResolvedBodySitePhrase {
|
|
|
53
55
|
* It deliberately grants no code to a qualified site merely because its
|
|
54
56
|
* unqualified anatomy is coded. */
|
|
55
57
|
siteI18n?: Record<string, string>;
|
|
58
|
+
/** Registered modifiers retained outside the selected anatomical head. */
|
|
59
|
+
nominalModifiers?: readonly string[];
|
|
56
60
|
restrictions?: BodySiteRestriction[];
|
|
57
61
|
preferredPreposition?: "to" | "at" | "in" | "into";
|
|
58
62
|
}
|
|
@@ -60,7 +64,22 @@ export interface BodySitePhraseContext {
|
|
|
60
64
|
bodySiteContext?: string;
|
|
61
65
|
allowTerminalModifierInheritance?: boolean;
|
|
62
66
|
}
|
|
67
|
+
export declare function isBodySiteNominalModifier(word: string): boolean;
|
|
68
|
+
/** Complete registered nominal evidence only. A caller must still license its
|
|
69
|
+
* grammatical role; this lookup does not attach a site or suppress an action. */
|
|
70
|
+
export declare function bodySiteModifierNominalAt(parts: readonly Token[], index: number, customSiteMap?: Record<string, BodySiteDefinition>, context?: BodySitePhraseContext, limit?: number): {
|
|
71
|
+
start: number;
|
|
72
|
+
end: number;
|
|
73
|
+
site: ResolvedBodySitePhrase;
|
|
74
|
+
} | undefined;
|
|
63
75
|
export declare function lookupBodySiteDefinition(map: Record<string, BodySiteDefinition> | undefined, canonical: string): BodySiteDefinition | undefined;
|
|
76
|
+
/** Articles belong to a nominal constituent, including a spatial target.
|
|
77
|
+
* Callers retain exact whole matches and require recognized remainder meaning. */
|
|
78
|
+
export declare function withoutBodySiteNominalArticles(text: string): string;
|
|
79
|
+
/** Position already resolved nominal modifiers through their registered class. */
|
|
80
|
+
export declare function composeBodySiteNominalModifiers(text: string, modifiers: readonly string[]): string;
|
|
81
|
+
/** Exact anatomy retains precedence over focus-only modifier inheritance. */
|
|
82
|
+
export declare function resolveBodySiteAnatomyDefinition(canonical: string, customSiteMap?: Record<string, BodySiteDefinition>): BodySiteDefinition | undefined;
|
|
64
83
|
/** One lexical interpretation for standalone and clause-level site predicates.
|
|
65
84
|
* Introducers and terminology are resolved here once, never in FHIR lowering.
|
|
66
85
|
* @param text Predicate surface text, excluding the relation marker.
|
|
@@ -79,9 +98,9 @@ export declare function resolveBodySiteRestrictionPredicate(text: string, range?
|
|
|
79
98
|
export declare function formBodySiteRestriction(predicate: BodySiteRestrictionPredicate, markerRange?: TextRange, sourceText?: string): BodySiteRestriction;
|
|
80
99
|
/** Realize a typed restriction by lexical identity, never by re-parsing prose.
|
|
81
100
|
* @param restriction Typed site-local relative clause.
|
|
82
|
-
* @param locale
|
|
101
|
+
* @param locale Registered output locale.
|
|
83
102
|
*/
|
|
84
|
-
export declare function realizeBodySiteRestriction(restriction: BodySiteRestriction, locale:
|
|
103
|
+
export declare function realizeBodySiteRestriction(restriction: BodySiteRestriction, locale: string): string | undefined;
|
|
85
104
|
export declare function resolveBodySitePhrase(text: string, customSiteMap?: Record<string, BodySiteDefinition>, context?: BodySitePhraseContext): ResolvedBodySitePhrase | undefined;
|
|
86
105
|
/** Anatomical vocabulary lookup only. Full-SIG lexical rules use this entrypoint
|
|
87
106
|
* so a lexical site cannot independently absorb a relative clause.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResolvedBodySitePhrase } from "./body-site-grammar";
|
|
1
2
|
import { BodySiteCode, BodySiteDefinition, BodySiteSpatialRelation, FhirCoding } from "./types";
|
|
2
3
|
export interface BodySiteLookupOptions {
|
|
3
4
|
siteCodeMap?: Record<string, BodySiteDefinition>;
|
|
@@ -77,7 +78,11 @@ export declare function getBodySiteCode(input: string, options?: BodySiteLookupO
|
|
|
77
78
|
export declare function getBodySiteCodeAsync(input: string, options?: BodySiteLookupOptions): Promise<BodySiteCode | undefined>;
|
|
78
79
|
/** Realize an already selected laterality with the existing anatomical text owner.
|
|
79
80
|
* Internal consumers must establish anatomical compatibility before calling. */
|
|
80
|
-
export declare function bodySiteTextWithLaterality(text: string, lateralityCode: string): string | undefined;
|
|
81
|
+
export declare function bodySiteTextWithLaterality(text: string, lateralityCode: string, features?: ResolvedBodySitePhrase["features"]): string | undefined;
|
|
82
|
+
/** Recover the registered base wording of an authored paired site. Code-only
|
|
83
|
+
* lookup keeps its exact preferred label; splitting an authored alias retains
|
|
84
|
+
* that alias through the existing language provider's laterality realization. */
|
|
85
|
+
export declare function bilateralBodySiteSourceBaseText(sourceText: string | undefined, parent: BodySiteCode): string | undefined;
|
|
81
86
|
export declare function getBodySiteText(input: BodySiteCodeInput, options?: BodySiteTextOptions): string | undefined;
|
|
82
87
|
export declare function getBodySiteTextAsync(input: BodySiteCodeInput, options?: BodySiteTextOptions): Promise<string | undefined>;
|
|
83
88
|
export declare function suggestBodySites(input: string, options?: BodySiteLookupOptions): BodySiteLookupResult[];
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { BodySiteSpatialRelation, FhirR6CodeableConcept, FhirR6Coding, FhirExtension } from "./types";
|
|
1
|
+
import { BodySiteSpatialRelation, FhirR6CodeableConcept, FhirR6Coding, FhirR6Extension, FhirExtension } from "./types";
|
|
2
2
|
export declare const BODY_SITE_SPATIAL_RELATION_EXTENSION_URL = "urn:ezmedicationinput:body-site-spatial-relation";
|
|
3
3
|
/** Top-level and nested sites share the existing anatomical Coding preference. */
|
|
4
4
|
export declare function selectPreferredSiteCoding<TCoding extends FhirR6Coding>(site: {
|
|
5
5
|
coding?: TCoding[];
|
|
6
6
|
} | undefined): TCoding | undefined;
|
|
7
|
+
/** Exact typed relation equality shared by unification and realization.
|
|
8
|
+
* Coding display/translation annotations do not change the relation; authored
|
|
9
|
+
* relation, target and source text still have to agree completely. Rendering
|
|
10
|
+
* may supply its neutral target resolver to prove equivalent retained labels. */
|
|
11
|
+
export declare function sameBodySiteSpatialRelation(left: BodySiteSpatialRelation | undefined, right: BodySiteSpatialRelation | undefined, resolveTarget?: (relation: BodySiteSpatialRelation) => string | undefined): boolean;
|
|
7
12
|
export declare function cloneBodySiteSpatialRelation(relation: BodySiteSpatialRelation | undefined): BodySiteSpatialRelation | undefined;
|
|
13
|
+
export declare function bodySiteSpatialRelationForWire(relation: BodySiteSpatialRelation | undefined, target: "r5" | "r6"): FhirR6Extension | undefined;
|
|
8
14
|
export declare function buildBodySiteSpatialRelationExtension(relation: BodySiteSpatialRelation | undefined): FhirExtension | undefined;
|
|
9
15
|
export declare function buildBodySiteSpatialRelationExtensions(relation: BodySiteSpatialRelation | undefined): FhirExtension[] | undefined;
|
|
10
16
|
export declare function parseBodySiteSpatialRelationExtension(concept: FhirR6CodeableConcept | undefined): BodySiteSpatialRelation | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type ResolvedBodySitePhrase } from "./body-site-grammar";
|
|
2
|
+
import { BodySiteCode, BodySiteDefinition, BodySiteSpatialRelation, CanonicalSiteExpr, CanonicalDoseExpr, FhirR6CodeableConcept, FhirCoding, FhirR6Coding, FhirExtension } from "./types";
|
|
2
3
|
export declare const BODY_SITE_ADMINISTRATION_TARGET_COUNT_EXTENSION_URL = "urn:ezmedicationinput:body-site-administration-target-count";
|
|
3
4
|
type SiteLike = CanonicalSiteExpr | {
|
|
4
5
|
text?: string;
|
|
@@ -11,11 +12,39 @@ interface BodySiteTargetCountOptions {
|
|
|
11
12
|
bodySiteContext?: string;
|
|
12
13
|
}
|
|
13
14
|
export declare function normalizeAdministrationTargetCount(value: number | undefined): number | undefined;
|
|
14
|
-
|
|
15
|
+
/** Intrinsic multiplicity of a registered anatomical identity, independent of
|
|
16
|
+
* an additionally supplied count or its provider-owned surface. */
|
|
17
|
+
export declare function bodySiteCodingTargetCount(coding: Pick<FhirCoding, "system" | "code"> | undefined): number | undefined;
|
|
18
|
+
/** Discrete doses distribute across paired targets; metric amounts are totals. */
|
|
19
|
+
export declare function doseUnitUsesTargetScope(unit: string | undefined, allocation?: CanonicalDoseExpr["allocation"]): boolean;
|
|
20
|
+
/** Resolve the existing discrete/metric policy only for a typed dose/site
|
|
21
|
+
* composition. An imported explicit allocation always owns its meaning. */
|
|
22
|
+
export declare function doseAllocationForTargets(unit: string | undefined, targetCount: number | undefined, allocation?: CanonicalDoseExpr["allocation"]): CanonicalDoseExpr["allocation"];
|
|
23
|
+
/** Count qualifiers for the location actually selected by a renderer. The
|
|
24
|
+
* caller supplies its resolved visible site and existing per-target wording;
|
|
25
|
+
* independently supplied coding does not replace that wording's identity. */
|
|
26
|
+
export declare function bodySiteTargetScope(count: number | undefined, resolvedSite: Pick<ResolvedBodySitePhrase, "coding" | "definition"> | undefined, unit: string | undefined, perTargetWording: boolean, allocation?: CanonicalDoseExpr["allocation"]): {
|
|
27
|
+
count?: number;
|
|
28
|
+
perTarget: boolean;
|
|
29
|
+
} | undefined;
|
|
30
|
+
/** Anatomical selection is containment; it does not weaken exact site identity. */
|
|
31
|
+
export declare function bodySiteSelectionIncludes(target: CanonicalSiteExpr, member: CanonicalSiteExpr): boolean;
|
|
32
|
+
/** Select paired anatomy from registered identity; provider wording is not a lookup key. */
|
|
33
|
+
export declare function registeredBilateralBodySiteDefinition(coding: BodySiteCode | undefined): BodySiteDefinition | undefined;
|
|
34
|
+
/** Split a typed bilateral administration only when a selective adjunct requires it. */
|
|
35
|
+
export declare function bilateralBodySiteTargets(site: CanonicalSiteExpr): CanonicalSiteExpr[] | undefined;
|
|
36
|
+
/** A broader selected anatomy may omit a side already owned by its source head.
|
|
37
|
+
* Explicit selected laterality and unrelated anatomy retain their own authority. */
|
|
38
|
+
export declare function bodySiteTextWithInheritedLaterality(selected: BodySiteDefinition, sourceHead: string | undefined): string | undefined;
|
|
39
|
+
/** A complete label or independently realized registered anatomy can retain
|
|
40
|
+
* its coded target once. wordingCoding describes recognized rendered words,
|
|
41
|
+
* never the separately supplied site coding. Broader wording retains laterality. */
|
|
42
|
+
export declare function bodySiteWordingIncludesTarget(text: string, coding: FhirCoding, wordingCoding?: FhirCoding): boolean;
|
|
43
|
+
export declare function bodySiteTextConflictsWithCoding(text: string, coding: Pick<FhirCoding | FhirR6Coding, "system" | "_system" | "code"> | undefined): boolean;
|
|
15
44
|
export declare function resolveBodySiteTargetText(site: string | SiteLike | FhirR6CodeableConcept | undefined, options?: BodySiteTargetCountOptions): string | undefined;
|
|
16
45
|
/** Realization may use a retained equivalent Coding's label without changing
|
|
17
46
|
* the selected anatomical identity or materializing text into its wire carrier. */
|
|
18
|
-
export declare function resolveBodySiteSpatialTargetText(relation: BodySiteSpatialRelation): string | undefined;
|
|
47
|
+
export declare function resolveBodySiteSpatialTargetText(relation: BodySiteSpatialRelation, locale?: string): string | undefined;
|
|
19
48
|
export declare function buildBodySiteAdministrationTargetCountExtension(targetCount: number | undefined): FhirExtension | undefined;
|
|
20
49
|
export declare function parseBodySiteAdministrationTargetCountExtension(concept: FhirR6CodeableConcept | {
|
|
21
50
|
extension?: FhirExtension[];
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
import type { CanonicalSigClause, ParseOptions } from "../types";
|
|
6
6
|
import type { CanonicalAdministration, CanonicalMeasure, CanonicalRange, CanonicalCourse, CanonicalBoundary } from "./course";
|
|
7
7
|
import type { CanonicalParallelRegimen, RegimenPosition } from "../regimen/parallel-course";
|
|
8
|
+
/** Preserve a typed occurrence maximum without inventing an executable period. */
|
|
9
|
+
export declare function unresolvedMaximumLimits(clause: CanonicalSigClause): {
|
|
10
|
+
scope: "period" | "administration";
|
|
11
|
+
count: number;
|
|
12
|
+
text?: string;
|
|
13
|
+
}[] | undefined;
|
|
8
14
|
/** A single authored time denominator is shared by native and FHIR rate projection. */
|
|
9
15
|
export declare function clinicalQuantityTimeDenominator(quantity: NonNullable<CanonicalSigClause["clinicalQuantity"]>): import("../hpsg/signature").HpsgDimensionalQuantityTerm | undefined;
|
|
10
16
|
/** Choose the native rate shape once, preserving an authored numeric time
|
|
@@ -12,10 +18,16 @@ export declare function clinicalQuantityTimeDenominator(quantity: NonNullable<Ca
|
|
|
12
18
|
export declare function rateFromClinicalQuantity(quantity: NonNullable<CanonicalSigClause["clinicalQuantity"]>): {
|
|
13
19
|
rateRange: {
|
|
14
20
|
low: {
|
|
21
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
22
|
+
system?: string | undefined;
|
|
23
|
+
code?: string | undefined;
|
|
15
24
|
value: number;
|
|
16
25
|
unit: string;
|
|
17
26
|
} | undefined;
|
|
18
27
|
high: {
|
|
28
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
29
|
+
system?: string | undefined;
|
|
30
|
+
code?: string | undefined;
|
|
19
31
|
value: number;
|
|
20
32
|
unit: string;
|
|
21
33
|
} | undefined;
|
|
@@ -26,10 +38,15 @@ export declare function rateFromClinicalQuantity(quantity: NonNullable<Canonical
|
|
|
26
38
|
rateRatio: {
|
|
27
39
|
numerator: {
|
|
28
40
|
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
41
|
+
system?: string | undefined;
|
|
42
|
+
code?: string | undefined;
|
|
29
43
|
value: number;
|
|
30
44
|
unit: string;
|
|
31
45
|
};
|
|
32
46
|
denominator: {
|
|
47
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
48
|
+
system?: string | undefined;
|
|
49
|
+
code?: string | undefined;
|
|
33
50
|
value: number;
|
|
34
51
|
unit: string;
|
|
35
52
|
};
|
|
@@ -39,13 +56,15 @@ export declare function rateFromClinicalQuantity(quantity: NonNullable<Canonical
|
|
|
39
56
|
} | {
|
|
40
57
|
rate: {
|
|
41
58
|
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
59
|
+
system?: string | undefined;
|
|
60
|
+
code?: string | undefined;
|
|
42
61
|
value: number;
|
|
43
62
|
unit: string;
|
|
44
63
|
};
|
|
45
64
|
rateRange?: undefined;
|
|
46
65
|
rateRatio?: undefined;
|
|
47
66
|
};
|
|
48
|
-
export declare function administrationFromClause(clause: CanonicalSigClause, text?: string, stageOrdinal?: number): CanonicalAdministration;
|
|
67
|
+
export declare function administrationFromClause(clause: CanonicalSigClause, text?: string, stageOrdinal?: number, phaseStart?: CanonicalBoundary, nativeDefaultText?: boolean): CanonicalAdministration;
|
|
49
68
|
/** Calendar tracks use explicit dates; not offsets from treatment start. */
|
|
50
69
|
export declare function precedingCalendarDay(value: string): string | undefined;
|
|
51
70
|
/** Dates without times are inclusive local calendar days, never UTC timestamps. */
|
|
@@ -56,13 +75,13 @@ export declare function clinicalBoundary(position: RegimenPosition | {
|
|
|
56
75
|
}): CanonicalBoundary;
|
|
57
76
|
export declare function courseFromParallel(regimen: Extract<CanonicalParallelRegimen, {
|
|
58
77
|
kind: "resolved";
|
|
59
|
-
}>, clauseTexts: readonly (string | undefined)[], instruction: string): CanonicalCourse;
|
|
78
|
+
}>, clauseTexts: readonly (string | undefined)[], instruction: string, nativeDefaultText?: boolean): CanonicalCourse;
|
|
60
79
|
/** Preserve independent member origins when global stage cuts are unresolved.
|
|
61
80
|
* Each member retains its own course length; an uncertain transition never
|
|
62
81
|
* supplies the origin or end of another track. */
|
|
63
82
|
export declare function courseFromPartialParallel(regimen: Extract<CanonicalParallelRegimen, {
|
|
64
83
|
kind: "unresolved";
|
|
65
|
-
}>, clauseTexts: readonly (string | undefined)[], instruction: string): CanonicalCourse;
|
|
84
|
+
}>, clauseTexts: readonly (string | undefined)[], instruction: string, nativeDefaultText?: boolean): CanonicalCourse;
|
|
66
85
|
/** The grammar's compact dose range has one shared unit and no endpoint
|
|
67
86
|
* operators. Rich native ranges must retain each independently authored
|
|
68
87
|
* endpoint instead of compressing them into a misleading scalar-unit view. */
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* adapters serialize those fields and preserve unrelated source metadata.
|
|
13
13
|
*/
|
|
14
14
|
import { convertQuantityValue } from "../utils/units";
|
|
15
|
-
import type { BodySiteSpatialRelation, CanonicalSigClause, CanonicalScheduleExpr, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalEventWindowExpr, MedicationCondition, NextDueDoseOptions, TotalUnitsOptions } from "../types";
|
|
15
|
+
import type { BodySiteSpatialRelation, CanonicalClinicalAdjuncts, CanonicalSigClause, CanonicalScheduleExpr, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalEventWindowExpr, MedicationCondition, NextDueDoseOptions, TotalUnitsOptions } from "../types";
|
|
16
16
|
export { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent } from "../types";
|
|
17
17
|
import type { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent, FhirDayOfWeek as Weekday } from "../types";
|
|
18
18
|
/** Shared clinical measurements are not a wire-format Quantity. Additional
|
|
@@ -58,7 +58,8 @@ export declare function hasAmountRole(role: CanonicalConcept | undefined): boole
|
|
|
58
58
|
* represent several differently qualified or expression-based limits without
|
|
59
59
|
* demoting the extras into an active compatibility extension. */
|
|
60
60
|
export interface CanonicalDoseLimit {
|
|
61
|
-
scope
|
|
61
|
+
/** Absent only for a supplied annotation-only wire scope; it is not an executable ceiling. */
|
|
62
|
+
scope?: "dosage" | "period" | "administration" | "lifetime";
|
|
62
63
|
amount?: CanonicalMeasure;
|
|
63
64
|
count?: number;
|
|
64
65
|
expression?: CanonicalExpression;
|
|
@@ -92,8 +93,14 @@ export interface CanonicalAmount {
|
|
|
92
93
|
export interface CanonicalRecurrence {
|
|
93
94
|
count?: number;
|
|
94
95
|
countMax?: number;
|
|
96
|
+
/** A supplied count annotation without either bound is not an open recurrence. */
|
|
97
|
+
countUnresolved?: boolean;
|
|
95
98
|
sharedCount?: CanonicalScheduleExpr["sharedCount"];
|
|
96
99
|
frequency?: number;
|
|
100
|
+
/** A supplied frequency annotation without a numeric bound is not an omitted frequency. */
|
|
101
|
+
frequencyUnresolved?: true;
|
|
102
|
+
/** All divided administrations occur on the first day of each whole civil-day interval. */
|
|
103
|
+
frequencyWithinDay?: true;
|
|
97
104
|
frequencyMax?: number;
|
|
98
105
|
period?: number;
|
|
99
106
|
periodMax?: number;
|
|
@@ -185,6 +192,10 @@ export interface CanonicalAdministration {
|
|
|
185
192
|
kind: "administration";
|
|
186
193
|
schedule?: CanonicalTiming;
|
|
187
194
|
amounts?: CanonicalAmount[];
|
|
195
|
+
/** Independently authored vehicle volume, separate from active dose and rate. */
|
|
196
|
+
carrierVolume?: CanonicalMeasure;
|
|
197
|
+
/** Descriptive, uncoded material belonging to the explicit carrier volume. */
|
|
198
|
+
carrierMaterial?: string;
|
|
188
199
|
stageOrdinal?: number;
|
|
189
200
|
/** Typed parser member identity, independent of external dose sequence. */
|
|
190
201
|
sourceMember?: number;
|
|
@@ -195,6 +206,10 @@ export interface CanonicalAdministration {
|
|
|
195
206
|
onsetReference?: "previous-phase-next-day" | "previous-phase-end" | "treatment-day-start";
|
|
196
207
|
asNeeded?: boolean;
|
|
197
208
|
targetCount?: number;
|
|
209
|
+
/** Counted amounts may be totals or amounts for each anatomical target.
|
|
210
|
+
* Native omission retains the established discrete per-target convention;
|
|
211
|
+
* independent wire imports explicitly own their total quantity. */
|
|
212
|
+
doseAllocation?: "total" | "per-target";
|
|
198
213
|
target?: CanonicalConcept;
|
|
199
214
|
siteReference?: CanonicalReference;
|
|
200
215
|
siteSpatialRelation?: BodySiteSpatialRelation;
|
|
@@ -204,6 +219,10 @@ export interface CanonicalAdministration {
|
|
|
204
219
|
patientInstruction?: string;
|
|
205
220
|
additionalInstructions?: CanonicalConcept[];
|
|
206
221
|
predicate?: MedicationCondition;
|
|
222
|
+
/** Selected-site conditions cannot allocate an undivided authored amount. */
|
|
223
|
+
conditionAllocationUnresolved?: boolean;
|
|
224
|
+
/** Selective allowance retained separately from a whole-administration predicate. */
|
|
225
|
+
conditionTarget?: CanonicalClinicalAdjuncts["conditionTarget"];
|
|
207
226
|
calendarPredicate?: MedicationCondition;
|
|
208
227
|
excludedDates?: string[];
|
|
209
228
|
excludedWeekdays?: Weekday[];
|
|
@@ -255,9 +274,22 @@ export interface CanonicalStage {
|
|
|
255
274
|
safety?: CanonicalSafety;
|
|
256
275
|
provenance?: Record<string, unknown>;
|
|
257
276
|
}
|
|
277
|
+
/** A shared count belongs to the course cycle unless an explicit stage
|
|
278
|
+
* repetition opens a new local allowance. Rendering and execution agree. */
|
|
279
|
+
export declare function stageRepeatsSharedAllowance(stage: Pick<CanonicalStage, "count">): boolean;
|
|
280
|
+
/** Repetition owned by one independent track, using its existing member identities. */
|
|
281
|
+
export interface CanonicalTrackCycle {
|
|
282
|
+
members: number[];
|
|
283
|
+
interval: CanonicalMeasure;
|
|
284
|
+
/** Known total complete track cycles, including the first. */
|
|
285
|
+
count?: number;
|
|
286
|
+
/** An authored finite count has primitive metadata but no known scalar. */
|
|
287
|
+
countUnresolved?: true;
|
|
288
|
+
}
|
|
258
289
|
export interface CanonicalCourse {
|
|
259
290
|
kind: "course";
|
|
260
291
|
stages: CanonicalStage[];
|
|
292
|
+
trackCycles?: CanonicalTrackCycle[];
|
|
261
293
|
instruction?: string;
|
|
262
294
|
cycleInterval?: CanonicalMeasure;
|
|
263
295
|
/** Total complete-course cycles, including the first; independent of each stage's local count. */
|
|
@@ -294,6 +326,10 @@ export declare const administrationCalendarCondition: (a: CanonicalAdministratio
|
|
|
294
326
|
export declare const administrationExcludedDates: (a: CanonicalAdministration) => string[];
|
|
295
327
|
export declare const administrationExcludedWeekdays: (a: CanonicalAdministration) => Weekday[];
|
|
296
328
|
export declare const administrationChoice: (a: CanonicalAdministration) => CanonicalChoice | undefined;
|
|
329
|
+
/** Reuse ordinary course owners for independently repeating tracks. No grouping
|
|
330
|
+
* is needed for ordinary courses; administrations retain their source identities
|
|
331
|
+
* and same-track phase dependencies. */
|
|
332
|
+
export declare function independentTrackCourses(course: CanonicalCourse, firstStageIndices?: number[]): CanonicalCourse[] | undefined;
|
|
297
333
|
export declare const courseContextIssue: (c: CanonicalCourse) => "conflicting-course-phase" | "missing-course-context" | undefined;
|
|
298
334
|
export declare const recurrenceOffset: (r: CanonicalRecurrence | undefined) => number | undefined;
|
|
299
335
|
export declare const recurrenceActivities: (r: CanonicalRecurrence | undefined) => CanonicalActivityTimingExpr[] | undefined;
|
|
@@ -314,13 +350,13 @@ export declare const recurrenceEventWindow: (r: CanonicalRecurrence | undefined)
|
|
|
314
350
|
/** Absolute-event ownership stays nominal; both execution fences follow
|
|
315
351
|
* the event's elapsed displacement. Relative recurrence keeps its own origin. */
|
|
316
352
|
export declare function absoluteEventCycleDisplacement(administration: CanonicalAdministration): number | undefined;
|
|
317
|
-
export declare function administrationHasDatedStart(a: CanonicalAdministration, resolvedStart?: Date | null): boolean;
|
|
318
|
-
/** Clock and
|
|
353
|
+
export declare function administrationHasDatedStart(a: CanonicalAdministration, resolvedStart?: Date | null, selectedEvent?: boolean): boolean;
|
|
354
|
+
/** Clock, weekday and month-day selection defer a calendar cut to execution.
|
|
319
355
|
* A clinical guard or PRN use does not move an authored clock to midnight;
|
|
320
356
|
* 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
|
|
357
|
+
export declare function administrationHasDatedSelectedStart(a: CanonicalAdministration, resolvedStart?: Date | null, selectedEvent?: boolean): boolean;
|
|
358
|
+
/** The earliest successor date owns any calendar-only cutoff. Selected clocks,
|
|
359
|
+
* calendar days or elapsed displacement leave the exact cut to execution; an unselected date-only member
|
|
324
360
|
* on the same day opens first, at midnight. */
|
|
325
361
|
export declare function earliestCalendarOpening(administrations: readonly CanonicalAdministration[]): {
|
|
326
362
|
start: string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* and the existing grammar renderer, never FHIR rows or persistence markers.
|
|
3
3
|
* Display stays separate from executable interpretation: unknown expressions
|
|
4
4
|
* and boundaries remain visible without inventing values or event dates. */
|
|
5
|
-
import type { FormatBatchOptions, FormatOptions, MedicationCondition, FhirDayOfWeek, CanonicalSigClause } from "../types";
|
|
5
|
+
import type { FormatBatchOptions, FormatOptions, MedicationCondition, FhirDayOfWeek, CanonicalSigClause, CanonicalScheduleExpr } from "../types";
|
|
6
6
|
import type { CanonicalCourse, CanonicalAdministration, CanonicalRange, CanonicalExpression, CanonicalSafety } from "./course";
|
|
7
7
|
import { type SigLocalization, type CourseLanguage } from "../i18n";
|
|
8
8
|
/** Resolved once per invocation; recursive clinical composition reuses it. */
|
|
@@ -24,12 +24,14 @@ export declare function unevaluatedExpressionText(expression: CanonicalExpressio
|
|
|
24
24
|
export declare function rateRangePreview(range: CanonicalRange): string | undefined;
|
|
25
25
|
export declare function prefersSourceInstruction(course: CanonicalCourse): boolean;
|
|
26
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>>,
|
|
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>>, sharedCountOf?: (member: T) => CanonicalScheduleExpr["sharedCount"], memberFormatOverride?: boolean, localization?: SigLocalization): string;
|
|
28
28
|
/** Transient renderer result for callers retaining independently authored text. */
|
|
29
29
|
interface AuthoredDirectionsState {
|
|
30
30
|
text: string;
|
|
31
31
|
rendered: boolean;
|
|
32
32
|
headerRendered?: boolean;
|
|
33
|
+
/** Locale-selected authored wording, supplied by the public interchange boundary. */
|
|
34
|
+
displayText?: string;
|
|
33
35
|
}
|
|
34
36
|
export declare function formatCanonicalAdministration(a: CanonicalAdministration, style?: "short" | "long", options?: FormatOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: AuthoredDirectionsState, stageSafety?: CanonicalSafety): string;
|
|
35
37
|
export declare function formatCanonicalCourse(oneOrCourse: CanonicalCourse, style?: "short" | "long", options?: FormatBatchOptions, compiled?: ReadonlyMap<CanonicalAdministration, CanonicalSigClause>, authored?: AuthoredDirectionsState): string;
|
|
@@ -6,6 +6,8 @@ export interface TailTokenSegment {
|
|
|
6
6
|
tokens: Token[];
|
|
7
7
|
leadingSeparatorTokens: Token[];
|
|
8
8
|
range: TextRange;
|
|
9
|
+
/** Original coordinates belong to this text; display text may normalize whitespace. */
|
|
10
|
+
sourceText: string;
|
|
9
11
|
text: string;
|
|
10
12
|
}
|
|
11
13
|
export interface ParsedInstructionTokenSegment {
|