ezmedicationinput 0.2.0 → 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 +216 -18
- package/dist/adapters/canonical-course.d.ts +131 -0
- package/dist/adapters/r5-course.d.ts +27 -0
- package/dist/advice-locale-adapter.d.ts +24 -0
- package/dist/advice.d.ts +73 -6
- package/dist/body-site-grammar.d.ts +21 -2
- package/dist/body-site-lookup.d.ts +8 -0
- package/dist/body-site-spatial.d.ts +12 -2
- package/dist/body-site-target.d.ts +38 -3
- package/dist/canonical/compile.d.ts +98 -0
- package/dist/canonical/course.d.ts +388 -0
- package/dist/canonical/format-course.d.ts +38 -0
- package/dist/clause-tail-grammar.d.ts +2 -0
- package/dist/date-interpretation.d.ts +36 -2
- package/dist/dosage-course.d.ts +304 -30
- package/dist/event-timing-expression.d.ts +26 -1
- package/dist/execution/calendar.d.ts +107 -0
- package/dist/execution/engine.d.ts +11 -0
- package/dist/fhir-quantity-operator.d.ts +89 -0
- package/dist/fhir-translations.d.ts +5 -6
- package/dist/fhir.d.ts +119 -14
- package/dist/format.d.ts +106 -5
- package/dist/hpsg/constructions.d.ts +35 -8
- package/dist/hpsg/defaults.d.ts +2 -0
- package/dist/hpsg/lexical-classes.d.ts +196 -24
- package/dist/hpsg/method-lexicon.d.ts +3 -0
- package/dist/hpsg/procedural-context.d.ts +48 -5
- package/dist/hpsg/projection.d.ts +32 -1
- package/dist/hpsg/quantity-lexicon.d.ts +51 -0
- package/dist/hpsg/rule-context.d.ts +172 -7
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +16 -7
- package/dist/hpsg/rules/condition-rules.d.ts +13 -3
- package/dist/hpsg/rules/core-rules.d.ts +8 -2
- package/dist/hpsg/rules/instruction-rules.d.ts +2 -0
- package/dist/hpsg/rules/prn-rules.d.ts +12 -1
- package/dist/hpsg/rules/site-rules.d.ts +10 -1
- package/dist/hpsg/rules/timing-rules.d.ts +116 -22
- package/dist/hpsg/segmenter.d.ts +2 -2
- package/dist/hpsg/signature.d.ts +54 -7
- package/dist/hpsg/timing-lexicon.d.ts +18 -2
- package/dist/hpsg/unification.d.ts +3 -1
- package/dist/i18n.d.ts +37 -1
- package/dist/index.cjs +83231 -52284
- package/dist/index.d.ts +26 -9
- package/dist/index.js +83222 -52284
- package/dist/instruction-action-locale-adapter.d.ts +92 -5
- package/dist/instruction-action-parser.d.ts +43 -0
- package/dist/instruction-action-terminology.d.ts +44 -3
- package/dist/instruction-concept-terminology.d.ts +20 -1
- package/dist/instruction-graph-fhir.d.ts +10 -2
- package/dist/instruction-graph-ownership.d.ts +96 -0
- package/dist/instruction-graph.d.ts +68 -49
- package/dist/ir.d.ts +1 -1
- 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-segmenter.d.ts +1 -1
- package/dist/lexer/surface.d.ts +4 -1
- package/dist/lexer/token-types.d.ts +6 -0
- package/dist/locale-detection.d.ts +5 -0
- package/dist/locales/clause/en.d.ts +14 -0
- package/dist/locales/course/en.d.ts +20 -0
- package/dist/locales/course/th.d.ts +12 -0
- package/dist/localization.d.ts +76 -0
- package/dist/localized-timing.d.ts +1 -1
- package/dist/maps.d.ts +44 -10
- package/dist/medication-condition.d.ts +72 -11
- package/dist/parser-state.d.ts +12 -2
- 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 +18 -1
- package/dist/regimen/parallel-course.d.ts +13 -42
- package/dist/regimen/planner.d.ts +2 -3
- package/dist/regimen/regimen.d.ts +8 -2
- package/dist/relation-terminology.d.ts +1 -0
- package/dist/schedule.d.ts +14 -10
- 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 +114 -1
- package/dist/types.d.ts +627 -61
- package/dist/unit-lexicon.d.ts +4 -1
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/units.d.ts +22 -0
- package/package.json +1 -1
|
@@ -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>;
|
|
@@ -75,6 +76,13 @@ export declare function lookupBodySite(input: string, options?: BodySiteLookupOp
|
|
|
75
76
|
export declare function lookupBodySiteAsync(input: string, options?: BodySiteLookupOptions): Promise<BodySiteLookupResult | undefined>;
|
|
76
77
|
export declare function getBodySiteCode(input: string, options?: BodySiteLookupOptions): BodySiteCode | undefined;
|
|
77
78
|
export declare function getBodySiteCodeAsync(input: string, options?: BodySiteLookupOptions): Promise<BodySiteCode | undefined>;
|
|
79
|
+
/** Realize an already selected laterality with the existing anatomical text owner.
|
|
80
|
+
* Internal consumers must establish anatomical compatibility before calling. */
|
|
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;
|
|
78
86
|
export declare function getBodySiteText(input: BodySiteCodeInput, options?: BodySiteTextOptions): string | undefined;
|
|
79
87
|
export declare function getBodySiteTextAsync(input: BodySiteCodeInput, options?: BodySiteTextOptions): Promise<string | undefined>;
|
|
80
88
|
export declare function suggestBodySites(input: string, options?: BodySiteLookupOptions): BodySiteLookupResult[];
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { BodySiteSpatialRelation,
|
|
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
|
+
/** Top-level and nested sites share the existing anatomical Coding preference. */
|
|
4
|
+
export declare function selectPreferredSiteCoding<TCoding extends FhirR6Coding>(site: {
|
|
5
|
+
coding?: TCoding[];
|
|
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;
|
|
3
12
|
export declare function cloneBodySiteSpatialRelation(relation: BodySiteSpatialRelation | undefined): BodySiteSpatialRelation | undefined;
|
|
13
|
+
export declare function bodySiteSpatialRelationForWire(relation: BodySiteSpatialRelation | undefined, target: "r5" | "r6"): FhirR6Extension | undefined;
|
|
4
14
|
export declare function buildBodySiteSpatialRelationExtension(relation: BodySiteSpatialRelation | undefined): FhirExtension | undefined;
|
|
5
15
|
export declare function buildBodySiteSpatialRelationExtensions(relation: BodySiteSpatialRelation | undefined): FhirExtension[] | undefined;
|
|
6
|
-
export declare function parseBodySiteSpatialRelationExtension(concept:
|
|
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;
|
|
@@ -10,9 +11,43 @@ interface BodySiteTargetCountOptions {
|
|
|
10
11
|
siteCodeMap?: Record<string, BodySiteDefinition>;
|
|
11
12
|
bodySiteContext?: string;
|
|
12
13
|
}
|
|
14
|
+
export declare function normalizeAdministrationTargetCount(value: number | undefined): number | undefined;
|
|
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;
|
|
44
|
+
export declare function resolveBodySiteTargetText(site: string | SiteLike | FhirR6CodeableConcept | undefined, options?: BodySiteTargetCountOptions): string | undefined;
|
|
45
|
+
/** Realization may use a retained equivalent Coding's label without changing
|
|
46
|
+
* the selected anatomical identity or materializing text into its wire carrier. */
|
|
47
|
+
export declare function resolveBodySiteSpatialTargetText(relation: BodySiteSpatialRelation, locale?: string): string | undefined;
|
|
13
48
|
export declare function buildBodySiteAdministrationTargetCountExtension(targetCount: number | undefined): FhirExtension | undefined;
|
|
14
|
-
export declare function parseBodySiteAdministrationTargetCountExtension(concept:
|
|
49
|
+
export declare function parseBodySiteAdministrationTargetCountExtension(concept: FhirR6CodeableConcept | {
|
|
15
50
|
extension?: FhirExtension[];
|
|
16
51
|
} | undefined): number | undefined;
|
|
17
|
-
export declare function getBodySiteAdministrationTargetCount(site: string | SiteLike |
|
|
52
|
+
export declare function getBodySiteAdministrationTargetCount(site: string | SiteLike | FhirR6CodeableConcept | undefined, options?: BodySiteTargetCountOptions): number | undefined;
|
|
18
53
|
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** Compile the EXISTING scoped HPSG clause/regimen into the native clinical
|
|
2
|
+
* course. No FHIR serialization or reconstruction occurs in this module.
|
|
3
|
+
* Source grammar is interpreted once; numerical execution consumes only
|
|
4
|
+
* these normalized facts and preserves syntax as read-only evidence. */
|
|
5
|
+
import type { CanonicalSigClause, ParseOptions } from "../types";
|
|
6
|
+
import type { CanonicalAdministration, CanonicalMeasure, CanonicalRange, CanonicalCourse, CanonicalBoundary } from "./course";
|
|
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;
|
|
14
|
+
/** A single authored time denominator is shared by native and FHIR rate projection. */
|
|
15
|
+
export declare function clinicalQuantityTimeDenominator(quantity: NonNullable<CanonicalSigClause["clinicalQuantity"]>): import("../hpsg/signature").HpsgDimensionalQuantityTerm | undefined;
|
|
16
|
+
/** Choose the native rate shape once, preserving an authored numeric time
|
|
17
|
+
* denominator. Protocol adapters only encode this clinical amount. */
|
|
18
|
+
export declare function rateFromClinicalQuantity(quantity: NonNullable<CanonicalSigClause["clinicalQuantity"]>): {
|
|
19
|
+
rateRange: {
|
|
20
|
+
low: {
|
|
21
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
22
|
+
system?: string | undefined;
|
|
23
|
+
code?: string | undefined;
|
|
24
|
+
value: number;
|
|
25
|
+
unit: string;
|
|
26
|
+
} | undefined;
|
|
27
|
+
high: {
|
|
28
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
29
|
+
system?: string | undefined;
|
|
30
|
+
code?: string | undefined;
|
|
31
|
+
value: number;
|
|
32
|
+
unit: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
};
|
|
35
|
+
rateRatio?: undefined;
|
|
36
|
+
rate?: undefined;
|
|
37
|
+
} | {
|
|
38
|
+
rateRatio: {
|
|
39
|
+
numerator: {
|
|
40
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
41
|
+
system?: string | undefined;
|
|
42
|
+
code?: string | undefined;
|
|
43
|
+
value: number;
|
|
44
|
+
unit: string;
|
|
45
|
+
};
|
|
46
|
+
denominator: {
|
|
47
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
48
|
+
system?: string | undefined;
|
|
49
|
+
code?: string | undefined;
|
|
50
|
+
value: number;
|
|
51
|
+
unit: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
rateRange?: undefined;
|
|
55
|
+
rate?: undefined;
|
|
56
|
+
} | {
|
|
57
|
+
rate: {
|
|
58
|
+
comparator?: "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
59
|
+
system?: string | undefined;
|
|
60
|
+
code?: string | undefined;
|
|
61
|
+
value: number;
|
|
62
|
+
unit: string;
|
|
63
|
+
};
|
|
64
|
+
rateRange?: undefined;
|
|
65
|
+
rateRatio?: undefined;
|
|
66
|
+
};
|
|
67
|
+
export declare function administrationFromClause(clause: CanonicalSigClause, text?: string, stageOrdinal?: number, phaseStart?: CanonicalBoundary, nativeDefaultText?: boolean): CanonicalAdministration;
|
|
68
|
+
/** Calendar tracks use explicit dates; not offsets from treatment start. */
|
|
69
|
+
export declare function precedingCalendarDay(value: string): string | undefined;
|
|
70
|
+
/** Dates without times are inclusive local calendar days, never UTC timestamps. */
|
|
71
|
+
export declare function orderedCalendarBounds(earlier: string, later: string): boolean;
|
|
72
|
+
export declare function clinicalBoundary(position: RegimenPosition | {
|
|
73
|
+
value: number;
|
|
74
|
+
unit: string;
|
|
75
|
+
}): CanonicalBoundary;
|
|
76
|
+
export declare function courseFromParallel(regimen: Extract<CanonicalParallelRegimen, {
|
|
77
|
+
kind: "resolved";
|
|
78
|
+
}>, clauseTexts: readonly (string | undefined)[], instruction: string, nativeDefaultText?: boolean): CanonicalCourse;
|
|
79
|
+
/** Preserve independent member origins when global stage cuts are unresolved.
|
|
80
|
+
* Each member retains its own course length; an uncertain transition never
|
|
81
|
+
* supplies the origin or end of another track. */
|
|
82
|
+
export declare function courseFromPartialParallel(regimen: Extract<CanonicalParallelRegimen, {
|
|
83
|
+
kind: "unresolved";
|
|
84
|
+
}>, clauseTexts: readonly (string | undefined)[], instruction: string, nativeDefaultText?: boolean): CanonicalCourse;
|
|
85
|
+
/** The grammar's compact dose range has one shared unit and no endpoint
|
|
86
|
+
* operators. Rich native ranges must retain each independently authored
|
|
87
|
+
* endpoint instead of compressing them into a misleading scalar-unit view. */
|
|
88
|
+
export declare function doseRangeNeedsEndpointPreview(range: CanonicalRange): boolean;
|
|
89
|
+
/** Project native live facts back into the existing grammar realization view.
|
|
90
|
+
* This is NOT a parser and reads no wire object: grammar evidence and source
|
|
91
|
+
* spans remain unchanged; edited dose/schedule/guard values are authoritative.
|
|
92
|
+
*/
|
|
93
|
+
export declare function clauseForAdministration(a: CanonicalAdministration, options?: ParseOptions): CanonicalSigClause;
|
|
94
|
+
/** Compose the already-scoped administrations into a single clinical course.
|
|
95
|
+
* Stable stage order belongs here, not to R5 sequences or R6 conversion.
|
|
96
|
+
* Relative phase starts, shared delays and shared ends are lowered from
|
|
97
|
+
* existing typed facts once; independent component timing is not overwritten. */
|
|
98
|
+
export declare function courseFromAdministrations(members: readonly CanonicalAdministration[], instruction: string, cycleInterval?: CanonicalMeasure, repeatCount?: number): CanonicalCourse;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EZMED's clinical course normal form.
|
|
3
|
+
*
|
|
4
|
+
* Grammar owns CanonicalSigClause and CanonicalParallelRegimen; this module
|
|
5
|
+
* completes that canonical model with course-wide meaning used by execution
|
|
6
|
+
* and by BOTH interchange adapters. It does not extend a FHIR datatype and
|
|
7
|
+
* contains no extension URLs or version-specific sequence/retention markers.
|
|
8
|
+
*
|
|
9
|
+
* Unknown external fields stay in provenance and are never executed. The
|
|
10
|
+
* syntax clauses are read-only evidence, not a second editable dosage truth.
|
|
11
|
+
* A caller editing clinical fields creates the next authoritative course;
|
|
12
|
+
* adapters serialize those fields and preserve unrelated source metadata.
|
|
13
|
+
*/
|
|
14
|
+
import { convertQuantityValue } from "../utils/units";
|
|
15
|
+
import type { BodySiteSpatialRelation, CanonicalClinicalAdjuncts, CanonicalSigClause, CanonicalScheduleExpr, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalEventWindowExpr, MedicationCondition, NextDueDoseOptions, TotalUnitsOptions } from "../types";
|
|
16
|
+
export { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent } from "../types";
|
|
17
|
+
import type { FhirPeriodUnit as DurationUnit, EventTiming as TimingEvent, FhirDayOfWeek as Weekday } from "../types";
|
|
18
|
+
/** Shared clinical measurements are not a wire-format Quantity. Additional
|
|
19
|
+
* coding metadata is preserved for exact export, but execution uses only the
|
|
20
|
+
* explicitly known numeric value, unit and operator. */
|
|
21
|
+
export interface CanonicalMeasure {
|
|
22
|
+
value?: number;
|
|
23
|
+
unit?: string;
|
|
24
|
+
system?: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
comparator?: "<" | "<=" | ">=" | ">" | "~" | "ad";
|
|
27
|
+
id?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface CanonicalRange {
|
|
30
|
+
low?: CanonicalMeasure;
|
|
31
|
+
high?: CanonicalMeasure;
|
|
32
|
+
}
|
|
33
|
+
export interface CanonicalRatio {
|
|
34
|
+
numerator?: CanonicalMeasure;
|
|
35
|
+
denominator?: CanonicalMeasure;
|
|
36
|
+
}
|
|
37
|
+
export interface CanonicalExpression {
|
|
38
|
+
name?: string;
|
|
39
|
+
expression?: string;
|
|
40
|
+
language?: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
reference?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface CanonicalConcept {
|
|
45
|
+
text?: string;
|
|
46
|
+
coding?: Array<{
|
|
47
|
+
system?: string;
|
|
48
|
+
code?: string;
|
|
49
|
+
display?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
/** An amount role needs clinical wording or coding; wire annotations alone
|
|
54
|
+
* do not turn an ordinary scalar dose into a role-bearing amount. */
|
|
55
|
+
export declare function hasAmountRole(role: CanonicalConcept | undefined): boolean;
|
|
56
|
+
/** One clinical quantity limit retains its scope, independent value choice,
|
|
57
|
+
* period and source identity. Unlike R5's three maximum fields, this list can
|
|
58
|
+
* represent several differently qualified or expression-based limits without
|
|
59
|
+
* demoting the extras into an active compatibility extension. */
|
|
60
|
+
export interface CanonicalDoseLimit {
|
|
61
|
+
/** Absent only for a supplied annotation-only wire scope; it is not an executable ceiling. */
|
|
62
|
+
scope?: "dosage" | "period" | "administration" | "lifetime";
|
|
63
|
+
amount?: CanonicalMeasure;
|
|
64
|
+
count?: number;
|
|
65
|
+
expression?: CanonicalExpression;
|
|
66
|
+
period?: CanonicalMeasure;
|
|
67
|
+
text?: string;
|
|
68
|
+
/** Typed original wire limit; clinical execution uses the fields above. */
|
|
69
|
+
provenance?: import("../types").FhirR6DoseLimit | import("../types").FhirRatio;
|
|
70
|
+
}
|
|
71
|
+
/** Understood clinical safety policy, not a bag of arbitrary restrictions.
|
|
72
|
+
* Unrecognized FHIR annotations remain ONLY in external source provenance.
|
|
73
|
+
* Dose limits at step/course scope reuse the same typed limit shape. */
|
|
74
|
+
export interface CanonicalSafety {
|
|
75
|
+
ifExceeded?: string;
|
|
76
|
+
limits?: CanonicalDoseLimit[];
|
|
77
|
+
maximaDeclared?: boolean;
|
|
78
|
+
requiresReview?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface CanonicalAmount {
|
|
81
|
+
quantity?: CanonicalMeasure;
|
|
82
|
+
range?: CanonicalRange;
|
|
83
|
+
expression?: CanonicalExpression;
|
|
84
|
+
rate?: CanonicalMeasure;
|
|
85
|
+
rateRange?: CanonicalRange;
|
|
86
|
+
rateRatio?: CanonicalRatio;
|
|
87
|
+
rateExpression?: CanonicalExpression;
|
|
88
|
+
role?: CanonicalConcept;
|
|
89
|
+
provenance?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
/** Recurrence and course length are separate meanings. Optional fields retain
|
|
92
|
+
* partial structured input rather than guessing a missing rate or count. */
|
|
93
|
+
export interface CanonicalRecurrence {
|
|
94
|
+
count?: number;
|
|
95
|
+
countMax?: number;
|
|
96
|
+
/** A supplied count annotation without either bound is not an open recurrence. */
|
|
97
|
+
countUnresolved?: boolean;
|
|
98
|
+
sharedCount?: CanonicalScheduleExpr["sharedCount"];
|
|
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;
|
|
104
|
+
frequencyMax?: number;
|
|
105
|
+
period?: number;
|
|
106
|
+
periodMax?: number;
|
|
107
|
+
periodUnit?: DurationUnit;
|
|
108
|
+
occurrenceDuration?: number;
|
|
109
|
+
occurrenceDurationMax?: number;
|
|
110
|
+
occurrenceDurationUnit?: DurationUnit;
|
|
111
|
+
occurrenceDurationComparator?: CanonicalMeasure["comparator"];
|
|
112
|
+
/** Explicit endpoint quantities retain their independent units/qualifiers. */
|
|
113
|
+
occurrenceDurationRange?: CanonicalRange;
|
|
114
|
+
courseLength?: CanonicalMeasure;
|
|
115
|
+
courseLengthRange?: CanonicalRange;
|
|
116
|
+
calendarWindow?: {
|
|
117
|
+
start?: string;
|
|
118
|
+
end?: string;
|
|
119
|
+
};
|
|
120
|
+
dayOfWeek?: Weekday[];
|
|
121
|
+
clocks?: string[];
|
|
122
|
+
anchors?: TimingEvent[];
|
|
123
|
+
offset?: number;
|
|
124
|
+
offsetMin?: number;
|
|
125
|
+
offsetMax?: number;
|
|
126
|
+
monthDays?: number[];
|
|
127
|
+
weekdayOrdinal?: number;
|
|
128
|
+
activityTiming?: CanonicalActivityTimingExpr[];
|
|
129
|
+
occurrenceCap?: CanonicalOccurrenceCapExpr;
|
|
130
|
+
clockWindow?: {
|
|
131
|
+
start: string;
|
|
132
|
+
end: string;
|
|
133
|
+
endInclusive: boolean;
|
|
134
|
+
};
|
|
135
|
+
eventWindow?: CanonicalEventWindowExpr;
|
|
136
|
+
startOffset?: CanonicalMeasure;
|
|
137
|
+
endOffset?: CanonicalMeasure;
|
|
138
|
+
provenance?: Record<string, unknown>;
|
|
139
|
+
}
|
|
140
|
+
export interface CanonicalTiming {
|
|
141
|
+
recurrence?: CanonicalRecurrence;
|
|
142
|
+
explicitEvents?: string[];
|
|
143
|
+
code?: CanonicalConcept;
|
|
144
|
+
provenance?: Record<string, unknown>;
|
|
145
|
+
}
|
|
146
|
+
/** A boundary's anchor is interpreted once at import. A foreign/unknown event
|
|
147
|
+
* remains available for editing, never guessed to be treatment start. */
|
|
148
|
+
export interface CanonicalBoundary {
|
|
149
|
+
/** The previous-phase-next-day anchor denotes local midnight following
|
|
150
|
+
* the predecessor's final occupied day, derived from its exclusive end.
|
|
151
|
+
* previous-phase-end retains that exact exclusive end before a typed pause.
|
|
152
|
+
* treatment-day-start denotes midnight of the order's local calendar day,
|
|
153
|
+
* before applying its day displacement. treatment-start retains the clock.
|
|
154
|
+
* Other non-treatment anchors need an external resolver; never reinterpret
|
|
155
|
+
* them as treatment-relative dates. */
|
|
156
|
+
anchor: "treatment-start" | "treatment-day-start" | "previous-phase-next-day" | "previous-phase-end" | "coded-event" | "resource-reference" | "definition" | "path" | "unresolved";
|
|
157
|
+
contextCode?: CanonicalConcept;
|
|
158
|
+
contextReference?: CanonicalReference;
|
|
159
|
+
contextDefinition?: string;
|
|
160
|
+
contextPath?: string;
|
|
161
|
+
description?: string;
|
|
162
|
+
displacement?: CanonicalMeasure;
|
|
163
|
+
displacementRange?: CanonicalRange;
|
|
164
|
+
/** Uninterpreted external metadata, not an executable anchor. */
|
|
165
|
+
provenance?: Record<string, unknown>;
|
|
166
|
+
}
|
|
167
|
+
/** The two contextual boundaries share predecessor dependency ownership. */
|
|
168
|
+
export declare function isPreviousPhaseAnchor(anchor: CanonicalBoundary["anchor"] | undefined): anchor is "previous-phase-next-day" | "previous-phase-end";
|
|
169
|
+
export interface CanonicalChoice {
|
|
170
|
+
groupId: string;
|
|
171
|
+
branchId: string;
|
|
172
|
+
}
|
|
173
|
+
/** Known external resource identity semantics. Extra foreign Reference
|
|
174
|
+
* annotations are opaque source metadata, not additional clinical fields. */
|
|
175
|
+
export interface CanonicalReference {
|
|
176
|
+
reference?: string;
|
|
177
|
+
type?: string;
|
|
178
|
+
identifier?: {
|
|
179
|
+
system?: string;
|
|
180
|
+
value?: string;
|
|
181
|
+
use?: string;
|
|
182
|
+
type?: CanonicalConcept;
|
|
183
|
+
period?: {
|
|
184
|
+
start?: string;
|
|
185
|
+
end?: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
display?: string;
|
|
189
|
+
id?: string;
|
|
190
|
+
}
|
|
191
|
+
export interface CanonicalAdministration {
|
|
192
|
+
kind: "administration";
|
|
193
|
+
schedule?: CanonicalTiming;
|
|
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;
|
|
199
|
+
stageOrdinal?: number;
|
|
200
|
+
/** Typed parser member identity, independent of external dose sequence. */
|
|
201
|
+
sourceMember?: number;
|
|
202
|
+
/** Same-track phase dependencies by sourceMember identity. Presence marks
|
|
203
|
+
* participating nodes; an empty list retains a referenced root identity. */
|
|
204
|
+
phasePredecessors?: number[];
|
|
205
|
+
onsetDays?: number;
|
|
206
|
+
onsetReference?: "previous-phase-next-day" | "previous-phase-end" | "treatment-day-start";
|
|
207
|
+
asNeeded?: boolean;
|
|
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";
|
|
213
|
+
target?: CanonicalConcept;
|
|
214
|
+
siteReference?: CanonicalReference;
|
|
215
|
+
siteSpatialRelation?: BodySiteSpatialRelation;
|
|
216
|
+
route?: CanonicalConcept;
|
|
217
|
+
method?: CanonicalConcept;
|
|
218
|
+
text?: string;
|
|
219
|
+
patientInstruction?: string;
|
|
220
|
+
additionalInstructions?: CanonicalConcept[];
|
|
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"];
|
|
226
|
+
calendarPredicate?: MedicationCondition;
|
|
227
|
+
excludedDates?: string[];
|
|
228
|
+
excludedWeekdays?: Weekday[];
|
|
229
|
+
limits?: CanonicalDoseLimit[];
|
|
230
|
+
/** Understood safety policy; opaque source metadata lives in provenance. */
|
|
231
|
+
safety?: CanonicalSafety;
|
|
232
|
+
choice?: CanonicalChoice;
|
|
233
|
+
choiceIssue?: boolean;
|
|
234
|
+
phaseOrigin?: CanonicalMeasure;
|
|
235
|
+
/** A member phase whose event origin is not a concrete treatment offset. */
|
|
236
|
+
phaseStart?: CanonicalBoundary;
|
|
237
|
+
/** Exclusive same-track transition, independent of this member's duration. */
|
|
238
|
+
phaseEnd?: CanonicalBoundary;
|
|
239
|
+
phaseOriginIssue?: boolean;
|
|
240
|
+
delayMinutes?: number;
|
|
241
|
+
anchoredLength?: {
|
|
242
|
+
quantity?: CanonicalMeasure;
|
|
243
|
+
range?: CanonicalRange;
|
|
244
|
+
};
|
|
245
|
+
cycleDays?: CanonicalCycleDayConstraint;
|
|
246
|
+
contextIssue?: "conflicting-course-phase" | "missing-course-context";
|
|
247
|
+
syntax?: CanonicalSigClause;
|
|
248
|
+
provenance?: {
|
|
249
|
+
format: "r5" | "r6" | "syntax";
|
|
250
|
+
data: Record<string, unknown>;
|
|
251
|
+
/** False when preserved wording has no agreement proof for current clinical facts. */
|
|
252
|
+
sourceTextVerified?: boolean;
|
|
253
|
+
/** This exact component text had established source agreement; current clinical replay is separate. */
|
|
254
|
+
sourceTextAgreed?: boolean;
|
|
255
|
+
/** Original primary schedule clock ownership; independent graph clocks remain source facts. */
|
|
256
|
+
sourceHasStructuredClocks?: boolean;
|
|
257
|
+
/** Original primary schedule anchor ownership; independent graph events remain source facts. */
|
|
258
|
+
sourceHasStructuredEvents?: boolean;
|
|
259
|
+
/** Original structured primary site ownership; graph-only sites remain independent facts. */
|
|
260
|
+
sourceHasStructuredSite?: boolean;
|
|
261
|
+
/** Original foreign fields retained inside an imported R5 row. Only
|
|
262
|
+
* adapters inspect this source; execution reads the typed fields above. */
|
|
263
|
+
retained?: Partial<import("../types").FhirR6Dosage>;
|
|
264
|
+
};
|
|
265
|
+
missingContexts?: string[];
|
|
266
|
+
}
|
|
267
|
+
export interface CanonicalStage {
|
|
268
|
+
administrations: CanonicalAdministration[];
|
|
269
|
+
start?: CanonicalBoundary;
|
|
270
|
+
end?: CanonicalBoundary;
|
|
271
|
+
count?: number;
|
|
272
|
+
/** Authored stage repetition with a primitive companion but no known scalar. */
|
|
273
|
+
countUnresolved?: true;
|
|
274
|
+
safety?: CanonicalSafety;
|
|
275
|
+
provenance?: Record<string, unknown>;
|
|
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
|
+
}
|
|
289
|
+
export interface CanonicalCourse {
|
|
290
|
+
kind: "course";
|
|
291
|
+
stages: CanonicalStage[];
|
|
292
|
+
trackCycles?: CanonicalTrackCycle[];
|
|
293
|
+
instruction?: string;
|
|
294
|
+
cycleInterval?: CanonicalMeasure;
|
|
295
|
+
/** Total complete-course cycles, including the first; independent of each stage's local count. */
|
|
296
|
+
cycleCount?: number;
|
|
297
|
+
/** An authored finite count has primitive metadata but no known scalar. */
|
|
298
|
+
cycleCountUnresolved?: true;
|
|
299
|
+
safety?: CanonicalSafety;
|
|
300
|
+
contextIssue?: "conflicting-course-phase" | "missing-course-context";
|
|
301
|
+
provenance?: {
|
|
302
|
+
format: "r5" | "r6" | "syntax";
|
|
303
|
+
data: Record<string, unknown>;
|
|
304
|
+
/** Source preservation is independent of authority to replay that wording. */
|
|
305
|
+
sourceTextVerified?: boolean;
|
|
306
|
+
/** The producer established coverage of this exact header, independently of clinical replay. */
|
|
307
|
+
sourceTextAgreed?: boolean;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
export type CanonicalScheduleInput = CanonicalCourse | CanonicalAdministration | readonly CanonicalAdministration[];
|
|
311
|
+
export type CanonicalSupplyOptions = Omit<TotalUnitsOptions, "dosage"> & {
|
|
312
|
+
dosage: CanonicalScheduleInput;
|
|
313
|
+
};
|
|
314
|
+
export type CanonicalExecutionOptions = NextDueDoseOptions;
|
|
315
|
+
export interface CanonicalRegimenDueTimes {
|
|
316
|
+
dosageIndex: number;
|
|
317
|
+
stageOrdinal: number;
|
|
318
|
+
phaseStart: string;
|
|
319
|
+
timestamps: string[];
|
|
320
|
+
}
|
|
321
|
+
/** These direct semantic accessors intentionally know nothing about FHIR
|
|
322
|
+
* extensions. Wire readers normalize at the boundary, once per input. */
|
|
323
|
+
export declare const measureOperator: (q: CanonicalMeasure | undefined) => "<" | "<=" | ">=" | ">" | "ad" | "~" | undefined;
|
|
324
|
+
export declare const administrationCondition: (a: CanonicalAdministration) => MedicationCondition | undefined;
|
|
325
|
+
export declare const administrationCalendarCondition: (a: CanonicalAdministration) => MedicationCondition | undefined;
|
|
326
|
+
export declare const administrationExcludedDates: (a: CanonicalAdministration) => string[];
|
|
327
|
+
export declare const administrationExcludedWeekdays: (a: CanonicalAdministration) => Weekday[];
|
|
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;
|
|
333
|
+
export declare const courseContextIssue: (c: CanonicalCourse) => "conflicting-course-phase" | "missing-course-context" | undefined;
|
|
334
|
+
export declare const recurrenceOffset: (r: CanonicalRecurrence | undefined) => number | undefined;
|
|
335
|
+
export declare const recurrenceActivities: (r: CanonicalRecurrence | undefined) => CanonicalActivityTimingExpr[] | undefined;
|
|
336
|
+
export declare const administrationDelay: (a: CanonicalAdministration) => number | undefined;
|
|
337
|
+
export declare const anchoredDuration: (a: Pick<CanonicalAdministration, "anchoredLength">) => {
|
|
338
|
+
quantity?: CanonicalMeasure;
|
|
339
|
+
range?: CanonicalRange;
|
|
340
|
+
} | undefined;
|
|
341
|
+
export declare const recurrenceMonthDays: (r: CanonicalRecurrence | undefined) => number[] | undefined;
|
|
342
|
+
export declare const recurrenceCap: (r: CanonicalRecurrence | undefined) => CanonicalOccurrenceCapExpr | undefined;
|
|
343
|
+
export declare const administrationCycleDays: (a: CanonicalAdministration) => CanonicalCycleDayConstraint | undefined;
|
|
344
|
+
export declare const recurrenceClockWindow: (r: CanonicalRecurrence | undefined) => {
|
|
345
|
+
start: string;
|
|
346
|
+
end: string;
|
|
347
|
+
endInclusive: boolean;
|
|
348
|
+
} | undefined;
|
|
349
|
+
export declare const recurrenceEventWindow: (r: CanonicalRecurrence | undefined) => CanonicalEventWindowExpr | undefined;
|
|
350
|
+
/** Absolute-event ownership stays nominal; both execution fences follow
|
|
351
|
+
* the event's elapsed displacement. Relative recurrence keeps its own origin. */
|
|
352
|
+
export declare function absoluteEventCycleDisplacement(administration: CanonicalAdministration): number | undefined;
|
|
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.
|
|
355
|
+
* A clinical guard or PRN use does not move an authored clock to midnight;
|
|
356
|
+
* clockless clinical conditions retain their existing admission. */
|
|
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
|
|
360
|
+
* on the same day opens first, at midnight. */
|
|
361
|
+
export declare function earliestCalendarOpening(administrations: readonly CanonicalAdministration[]): {
|
|
362
|
+
start: string;
|
|
363
|
+
deferred: boolean;
|
|
364
|
+
} | undefined;
|
|
365
|
+
/** Intersect usable scoped maxima in the administration's quantity unit.
|
|
366
|
+
* Incomplete or incomparable retained constraints do not erase another
|
|
367
|
+
* known maximum. `multiple` records constraints still requiring evaluation. */
|
|
368
|
+
export declare function numericAdministrationLimits(a: CanonicalAdministration, strength?: Parameters<typeof convertQuantityValue>[3]): {
|
|
369
|
+
administration?: CanonicalMeasure;
|
|
370
|
+
lifetime?: CanonicalMeasure;
|
|
371
|
+
multiple: boolean;
|
|
372
|
+
};
|
|
373
|
+
/** Choose the last fully numeric source constraint where the clinical API
|
|
374
|
+
* expects a single bound; other choices remain retained and explicitly
|
|
375
|
+
* unevaluated. Period constraints are consumed independently by the engine. */
|
|
376
|
+
export declare function singleNumericLimit(a: CanonicalAdministration, scope: "administration" | "lifetime"): CanonicalMeasure | undefined;
|
|
377
|
+
export declare function hasPeriodLimits(a: CanonicalAdministration): boolean;
|
|
378
|
+
/** Nonnegative treatment-relative positions keep calendar months distinct
|
|
379
|
+
* from civil days. Cross-unit order is known only when conservative calendar
|
|
380
|
+
* bounds do not overlap; these bounds never become an executable duration. */
|
|
381
|
+
export interface RegimenPosition {
|
|
382
|
+
unit: 'd' | 'mo';
|
|
383
|
+
value: number;
|
|
384
|
+
}
|
|
385
|
+
export declare function compareRegimenPositions(left: RegimenPosition, right: RegimenPosition): -1 | 0 | 1 | undefined;
|
|
386
|
+
/** Text and foreign Element metadata alone do not establish clinical facts
|
|
387
|
+
* that can replace an authored instruction with a generated preview. */
|
|
388
|
+
export declare function administrationHasAmountFacts(a: Pick<CanonicalAdministration, "amounts" | "additionalInstructions">, includeRates?: boolean): boolean;
|