ezmedicationinput 0.2.0 → 0.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -10
- package/dist/adapters/canonical-course.d.ts +128 -0
- package/dist/adapters/r5-course.d.ts +24 -0
- package/dist/advice.d.ts +36 -5
- package/dist/body-site-lookup.d.ts +3 -0
- package/dist/body-site-spatial.d.ts +6 -2
- package/dist/body-site-target.d.ts +9 -3
- package/dist/canonical/compile.d.ts +79 -0
- package/dist/canonical/course.d.ts +352 -0
- package/dist/canonical/format-course.d.ts +36 -0
- package/dist/dosage-course.d.ts +294 -29
- package/dist/execution/calendar.d.ts +107 -0
- package/dist/execution/engine.d.ts +11 -0
- package/dist/fhir-quantity-operator.d.ts +53 -0
- package/dist/fhir-translations.d.ts +5 -6
- package/dist/fhir.d.ts +99 -14
- package/dist/format.d.ts +105 -3
- package/dist/hpsg/constructions.d.ts +11 -3
- package/dist/hpsg/defaults.d.ts +2 -0
- package/dist/hpsg/lexical-classes.d.ts +115 -4
- package/dist/hpsg/procedural-context.d.ts +3 -3
- package/dist/hpsg/projection.d.ts +28 -1
- package/dist/hpsg/rule-context.d.ts +104 -7
- package/dist/hpsg/rules/clinical-quantity-rules.d.ts +16 -7
- package/dist/hpsg/rules/condition-rules.d.ts +0 -1
- package/dist/hpsg/rules/core-rules.d.ts +3 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +2 -0
- package/dist/hpsg/rules/prn-rules.d.ts +3 -1
- package/dist/hpsg/rules/timing-rules.d.ts +17 -1
- package/dist/hpsg/signature.d.ts +13 -3
- package/dist/hpsg/unification.d.ts +3 -1
- package/dist/i18n.d.ts +37 -1
- package/dist/index.cjs +63500 -46393
- package/dist/index.d.ts +21 -9
- package/dist/index.js +63491 -46393
- package/dist/instruction-action-locale-adapter.d.ts +31 -3
- package/dist/instruction-action-terminology.d.ts +23 -3
- package/dist/instruction-concept-terminology.d.ts +7 -0
- package/dist/instruction-graph-fhir.d.ts +8 -2
- package/dist/instruction-graph.d.ts +80 -38
- package/dist/ir.d.ts +1 -1
- package/dist/lexer/surface-segmenter.d.ts +1 -1
- package/dist/lexer/surface.d.ts +1 -0
- package/dist/locale-detection.d.ts +3 -0
- package/dist/locales/course/en.d.ts +15 -0
- package/dist/locales/course/th.d.ts +12 -0
- package/dist/localization.d.ts +73 -0
- package/dist/maps.d.ts +10 -2
- package/dist/medication-condition.d.ts +1 -1
- package/dist/parser-state.d.ts +2 -2
- package/dist/regimen/grammar.d.ts +11 -0
- package/dist/regimen/parallel-course.d.ts +8 -41
- package/dist/regimen/regimen.d.ts +6 -2
- package/dist/relation-terminology.d.ts +1 -0
- package/dist/schedule.d.ts +14 -10
- package/dist/timing-summary.d.ts +82 -1
- package/dist/types.d.ts +510 -56
- package/dist/unit-lexicon.d.ts +7 -0
- package/dist/utils/text.d.ts +3 -0
- package/dist/utils/units.d.ts +19 -0
- package/package.json +1 -1
package/dist/fhir.d.ts
CHANGED
|
@@ -1,22 +1,52 @@
|
|
|
1
|
+
import type { ParseOptions } from "./types";
|
|
2
|
+
import type { HpsgClinicalQuantityFeature } from "./hpsg/signature";
|
|
1
3
|
import { ParserState } from "./parser-state";
|
|
2
|
-
import { CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalSigClause, EventTiming, FhirDosage, FhirExtension, FhirTimingRepeat } from "./types";
|
|
4
|
+
import { CanonicalAdditionalInstructionExpr, CanonicalInstructionGraph, CanonicalActivityTimingExpr, CanonicalCycleDayConstraint, CanonicalOccurrenceCapExpr, CanonicalDoseRange, CanonicalSigClause, CanonicalScheduleExpr, EventTiming, FhirCodeableConcept, FhirR6CodeableConcept, FhirDosage, FhirExtension, FhirR6Extension, FhirR6Dosage, FhirR6Quantity, FhirRange, FhirR6Range, FhirTiming, FhirTimingRepeat, FhirR6TimingRepeat } from "./types";
|
|
3
5
|
/** Known modifier: an independent cadence is restricted by unresolved cycle days. */
|
|
4
6
|
export declare const CYCLE_DAY_ELIGIBILITY_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-cycle-day-eligibility";
|
|
5
7
|
/** Read the recognized cycle constraint without interpreting narrative text.
|
|
6
8
|
* @param dosage Editable R5/R6-compatible dosage with a retained known modifier.
|
|
7
9
|
*/
|
|
8
|
-
export declare function getCycleDayConstraint(dosage: FhirDosage): CanonicalCycleDayConstraint | undefined;
|
|
10
|
+
export declare function getCycleDayConstraint(dosage: FhirDosage | FhirR6Dosage): CanonicalCycleDayConstraint | undefined;
|
|
11
|
+
/** Preserve the source-decided cycle restriction as a genuine dosage modifier.
|
|
12
|
+
* @param constraint Recognized cycle ordinals and the unresolved calendar dependency.
|
|
13
|
+
*/
|
|
14
|
+
export declare function cycleDayConstraintExtension(constraint: CanonicalCycleDayConstraint, previous?: FhirExtension): FhirExtension;
|
|
9
15
|
export declare const TIMING_FREQUENCY_MIN_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-frequency-min";
|
|
16
|
+
/** Qualified per-administration duration, independent of a scalar rate denominator. */
|
|
17
|
+
export declare const TIMING_ADMINISTRATION_DURATION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:timing-administration-duration";
|
|
18
|
+
/** Decode one classified marker without flattening independent endpoints. */
|
|
19
|
+
export declare function parseTimingAdministrationDuration(extension: FhirR6Extension | undefined, current?: Pick<FhirTimingRepeat, "duration" | "durationMax" | "durationUnit">): (Partial<NonNullable<HpsgClinicalQuantityFeature["administrationDuration"]>> & {
|
|
20
|
+
range?: import("./canonical/course").CanonicalRange;
|
|
21
|
+
}) | undefined;
|
|
10
22
|
/** Modifier: each retained base-schedule opportunity occurs this many minutes later. */
|
|
11
23
|
export declare const ADMINISTRATION_OFFSET_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-administration-offset";
|
|
12
|
-
export declare function getAdministrationOffsetMinutes(dosage: FhirDosage): number | undefined;
|
|
24
|
+
export declare function getAdministrationOffsetMinutes(dosage: FhirDosage | FhirR6Dosage): number | undefined;
|
|
13
25
|
/** Modifier retaining a course duration alongside its absolute calendar bounds. */
|
|
14
26
|
export declare const ANCHORED_COURSE_DURATION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-anchored-course-duration";
|
|
15
27
|
/** Read the authored temporal quantity without reconstructing it from dates or text.
|
|
16
28
|
* @param dosage R5/R6-compatible dosage containing the known duration modifier.
|
|
17
29
|
* @returns The retained duration quantity or range, when supplied.
|
|
18
30
|
*/
|
|
19
|
-
export declare function getAnchoredCourseDuration(dosage: Pick<
|
|
31
|
+
export declare function getAnchoredCourseDuration(dosage: Pick<FhirR6Dosage, "modifierExtension"> & {
|
|
32
|
+
timing?: {
|
|
33
|
+
repeat?: {
|
|
34
|
+
boundsRange?: FhirR6Range;
|
|
35
|
+
boundsDuration?: FhirR6Quantity;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
}): Pick<FhirR6Extension, "valueQuantity" | "valueRange"> | undefined;
|
|
39
|
+
/** Core Range endpoints share one unit identity. The known duration modifier
|
|
40
|
+
* keeps both authored endpoints as active quantities when the wire range needs
|
|
41
|
+
* a common label or cannot express mixed elapsed/calendar units. */
|
|
42
|
+
export declare function projectCourseDurationRange(range: FhirRange): {
|
|
43
|
+
range: FhirRange;
|
|
44
|
+
source?: FhirExtension;
|
|
45
|
+
};
|
|
46
|
+
export declare function projectCourseDurationRange(range: FhirR6Range): {
|
|
47
|
+
range: FhirR6Range;
|
|
48
|
+
source?: FhirR6Extension;
|
|
49
|
+
};
|
|
20
50
|
export declare const TIMING_OFFSET_MIN_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-offset-min";
|
|
21
51
|
export declare const TIMING_OFFSET_MAX_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-offset-max";
|
|
22
52
|
export declare const TIMING_OFFSET_EXACT_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-offset-exact";
|
|
@@ -24,12 +54,25 @@ export declare const TIMING_ACTIVITY_WINDOW_EXTENSION_URL = "urn:ezmedicationinp
|
|
|
24
54
|
/** Recurring administration opportunity window; distinct from a punctual
|
|
25
55
|
* FHIR Timing.repeat.when WAKE or HS administration. */
|
|
26
56
|
export declare const TIMING_EVENT_WINDOW_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-event-window";
|
|
57
|
+
/** Independent clocks combined with event anchors share one recurrence/count.
|
|
58
|
+
* R5 and the current R6 pin forbid both core fields in that recurrence (tim-10). */
|
|
59
|
+
export declare const TIMING_ADDITIONAL_CLOCK_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-additional-clock";
|
|
60
|
+
/** Wire primitive arrays contain metadata-only null positions. The clinical
|
|
61
|
+
* event list keeps values only, while the owning Timing retains wire positions. */
|
|
62
|
+
export declare function getTimingEvents(timing: Pick<FhirTiming, "event"> | undefined): string[] | undefined;
|
|
63
|
+
/** Core clock values take priority over the bridge. Null primitive positions
|
|
64
|
+
* carry metadata only; an explicitly empty clock array remains an empty field. */
|
|
65
|
+
export declare function getTimingClocks(repeat: Pick<FhirR6TimingRepeat, "timeOfDay" | "extension"> | undefined): string[] | undefined;
|
|
66
|
+
/** Independent event and clock opportunities share one wire recurrence.
|
|
67
|
+
* The original wire repeat distinguishes a bridge read from a current core edit;
|
|
68
|
+
* no administration/count/cap is split, and retired carriers cannot revive. */
|
|
69
|
+
export declare function projectTimingClocks<T extends Pick<FhirR6TimingRepeat, "timeOfDay" | "_timeOfDay" | "when" | "_when" | "extension">>(repeat: T, wireSource?: Pick<FhirTimingRepeat, "timeOfDay">, target?: "r5" | "r6"): T;
|
|
27
70
|
export declare const TIMING_CLOCK_WINDOW_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-clock-window";
|
|
28
71
|
/** Read a local-clock recurrence window from structural timing metadata.
|
|
29
72
|
* @param repeat FHIR Timing.repeat containing a typed window extension.
|
|
30
73
|
* @returns Source clock endpoints and explicit endpoint inclusivity.
|
|
31
74
|
*/
|
|
32
|
-
export declare function getTimingClockWindow(repeat:
|
|
75
|
+
export declare function getTimingClockWindow(repeat: FhirR6TimingRepeat | undefined): {
|
|
33
76
|
start: string;
|
|
34
77
|
end: string;
|
|
35
78
|
endInclusive: boolean;
|
|
@@ -38,22 +81,24 @@ export declare function getTimingClockWindow(repeat: FhirTimingRepeat | undefine
|
|
|
38
81
|
export declare const TIMING_DAY_OF_MONTH_EXTENSION_URL = "http://hl7.org/fhir/StructureDefinition/timing-dayOfMonth";
|
|
39
82
|
/** Retrieve bounded executable month-day selection without interpreting prose.
|
|
40
83
|
* Unknown and malformed extensions remain in the original FHIR object.
|
|
41
|
-
* @param repeat Original FHIR R5 Timing.repeat with optional standard extensions.
|
|
84
|
+
* @param repeat Original FHIR R5/R6 Timing.repeat with optional standard extensions.
|
|
42
85
|
* @returns Sorted unique calendar days, or undefined when none are recognized.
|
|
43
86
|
*/
|
|
44
|
-
export declare function getTimingMonthDays(repeat:
|
|
87
|
+
export declare function getTimingMonthDays(repeat: FhirR6TimingRepeat | undefined): number[] | undefined;
|
|
45
88
|
export declare const TIMING_WEEKDAY_ORDINAL_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-weekday-ordinal";
|
|
46
89
|
/** Read the explicitly encoded ordinal, independent of prose and scheduling anchors.
|
|
47
90
|
* @param repeat Typed FHIR timing repeat containing an optional ordinal extension.
|
|
48
91
|
* @returns The source weekday occurrence, including -1 for last, when valid.
|
|
49
92
|
*/
|
|
50
|
-
export declare function getTimingWeekdayOrdinal(repeat:
|
|
93
|
+
export declare function getTimingWeekdayOrdinal(repeat: FhirR6TimingRepeat | undefined): -1 | 1 | 2 | 3 | 4 | 5 | undefined;
|
|
51
94
|
/** Read an explicitly encoded daily event window without examining SIG text. */
|
|
52
|
-
export declare function getTimingEventWindow(repeat:
|
|
95
|
+
export declare function getTimingEventWindow(repeat: FhirR6TimingRepeat | undefined): {
|
|
53
96
|
start: EventTiming;
|
|
54
97
|
end: EventTiming;
|
|
55
98
|
} | undefined;
|
|
56
99
|
export declare const TIMING_OCCURRENCE_CAP_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-occurrence-cap";
|
|
100
|
+
/** Internal current recurrence fact; deliberately absent from public index exports. */
|
|
101
|
+
export declare const TIMING_SHARED_COUNT_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-shared-count";
|
|
57
102
|
export declare const TIMING_EVENT_CALENDAR_SOURCE_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-timing-event-calendar-source";
|
|
58
103
|
export declare const PRN_TRIGGER_PHASE_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-prn-trigger-phase";
|
|
59
104
|
export declare const BODY_SITE_RESTRICTION_EXTENSION_URL = "urn:ezmedicationinput:StructureDefinition:medication-body-site-restriction";
|
|
@@ -137,12 +182,24 @@ export declare function buildInfusionCarrierMaterialStructureDefinition(): {
|
|
|
137
182
|
})[];
|
|
138
183
|
};
|
|
139
184
|
};
|
|
140
|
-
|
|
141
|
-
|
|
185
|
+
/** Preserve a clinically named vehicle without claiming it has a verified
|
|
186
|
+
* terminology identity. This describes the volume-owned material and never
|
|
187
|
+
* changes dose/rate scheduling or converts a vehicle into the active drug.
|
|
188
|
+
*/
|
|
189
|
+
export declare function infusionCarrierMaterialExtension(material: NonNullable<HpsgClinicalQuantityFeature["carrierMaterial"]>): FhirExtension;
|
|
190
|
+
/** Reconstitute dimensional R5 meaning only where the role and amount were
|
|
191
|
+
* explicitly supplied. Other external rateRatio dosages remain untouched.
|
|
192
|
+
*/
|
|
193
|
+
export declare function clinicalCarrierQuantityFromFhir(dosage: FhirDosage): HpsgClinicalQuantityFeature | undefined;
|
|
194
|
+
export declare function parsePrnTriggerPhase(concept: FhirR6CodeableConcept | undefined): "onset" | undefined;
|
|
195
|
+
export declare function getExactTimingOffsetMinutes(repeat: FhirR6TimingRepeat | undefined): number | undefined;
|
|
196
|
+
/** Read the explicit shared allowance, never derive membership from source or phase IDs. */
|
|
197
|
+
export declare function getTimingSharedCount(repeat: FhirR6TimingRepeat | undefined): CanonicalScheduleExpr["sharedCount"];
|
|
198
|
+
export declare function getTimingOccurrenceCap(repeat: FhirR6TimingRepeat | undefined): CanonicalOccurrenceCapExpr | undefined;
|
|
142
199
|
/** Read typed activity-event relations from Timing extensions without parsing
|
|
143
200
|
* narrative instructions or inferring an activity's calendar instant.
|
|
144
201
|
*/
|
|
145
|
-
export declare function parseActivityTimingExtensions(repeat:
|
|
202
|
+
export declare function parseActivityTimingExtensions(repeat: FhirR6TimingRepeat | undefined): CanonicalActivityTimingExpr[] | undefined;
|
|
146
203
|
export interface FhirProjectionOptions {
|
|
147
204
|
/** Typed regimen-graph sequence; serialized without inferring phase meaning. */
|
|
148
205
|
sequence?: number;
|
|
@@ -158,7 +215,35 @@ export interface FhirProjectionOptions {
|
|
|
158
215
|
*/
|
|
159
216
|
includeTranslationExtensions?: boolean;
|
|
160
217
|
}
|
|
218
|
+
export declare function createEmptyCanonicalClause(rawText: string): CanonicalSigClause;
|
|
219
|
+
export declare function extractCanonicalDoseRange(range: FhirRange): {
|
|
220
|
+
range?: CanonicalDoseRange;
|
|
221
|
+
unit?: string;
|
|
222
|
+
warning?: string;
|
|
223
|
+
};
|
|
224
|
+
/** Shared FHIR terminology/source serializer for BOTH output versions.
|
|
225
|
+
* This serializes coded context only; no course, dose or scheduling semantics
|
|
226
|
+
* are read back from this interchange object. R5/R6 adapters own their own
|
|
227
|
+
* quantity and timing choices around the same exact clinical code payload. */
|
|
228
|
+
export declare function serializeCanonicalContext(clause: CanonicalSigClause, options?: FhirProjectionOptions): Pick<FhirDosage, "extension" | "route" | "site" | "method" | "additionalInstruction" | "asNeeded" | "asNeededFor" | "patientInstruction">;
|
|
229
|
+
/** Core Timing offsets require a nonnegative integer and a qualified event anchor. */
|
|
230
|
+
export declare function canUseCoreTimingOffset(when: readonly (string | null)[] | undefined, offset: number | undefined): boolean;
|
|
231
|
+
/** Shared wire Timing/source metadata serializer. This projects the already
|
|
232
|
+
* scoped canonical schedule; it never parses or interprets external dosage.
|
|
233
|
+
* R5 and current-R6 adapters independently choose their Quantity encodings. */
|
|
234
|
+
export declare function serializeCanonicalSchedule(schedule: CanonicalSigClause["schedule"], options?: FhirProjectionOptions, clinicalQuantity?: HpsgClinicalQuantityFeature, asNeeded?: boolean): Pick<FhirDosage, "timing" | "modifierExtension">;
|
|
235
|
+
/** Project only independent typed warnings; related actions keep their graph scope.
|
|
236
|
+
* Existing standard entries are never rewritten or removed. Generated wording
|
|
237
|
+
* comes from the selected action/arguments, not the graph's authored source.
|
|
238
|
+
*/
|
|
239
|
+
export declare function independentGraphWarningAdvice(graph: CanonicalInstructionGraph | undefined, typed: readonly CanonicalAdditionalInstructionExpr[] | undefined): FhirCodeableConcept[] | undefined;
|
|
161
240
|
export declare function canonicalToFhir(clause: CanonicalSigClause, textOverride?: string, options?: FhirProjectionOptions): FhirDosage;
|
|
162
241
|
export declare function toFhir(state: ParserState): FhirDosage;
|
|
163
|
-
|
|
164
|
-
|
|
242
|
+
/** Decode common coded source annotations for either FHIR version.
|
|
243
|
+
* No dose, rate, Timing, course, or compatibility marker is interpreted here.
|
|
244
|
+
* Native-course import supplies an R6 CodeableReference's concept explicitly. */
|
|
245
|
+
export declare function deserializeCanonicalContext(dosage: Pick<FhirR6Dosage, "text" | "route" | "method" | "asNeeded" | "asNeededFor" | "additionalInstruction" | "patientInstruction" | "extension"> & {
|
|
246
|
+
site?: FhirR6CodeableConcept;
|
|
247
|
+
}, options?: ParseOptions): CanonicalSigClause;
|
|
248
|
+
export declare function canonicalFromFhir(dosage: FhirDosage, options?: ParseOptions): CanonicalSigClause;
|
|
249
|
+
export declare function parserStateFromFhir(dosage: FhirDosage, options?: ParseOptions): ParserState;
|
package/dist/format.d.ts
CHANGED
|
@@ -1,14 +1,116 @@
|
|
|
1
|
+
import type { CourseLanguage } from "./localization";
|
|
1
2
|
import { ParserState } from "./parser-state";
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
3
|
+
import { type SigLocalization, type SigLongContext, type SigDoseScope } from "./i18n";
|
|
4
|
+
import { type InstructionGraphPrimaryCondition } from "./instruction-graph";
|
|
5
|
+
import { type AdviceFrame, type CanonicalAdditionalInstructionExpr, CanonicalDoseExpr, CanonicalScheduleExpr, CanonicalSigClause, EventTiming, FhirPeriodUnit, type MedicationCondition, type FhirDayOfWeek } from "./types";
|
|
4
6
|
import { type TimingSummaryOptions } from "./timing-summary";
|
|
5
7
|
export declare const DAY_NAMES: Record<string, string>;
|
|
8
|
+
/** A method can name a registered manner rather than an action head. */
|
|
9
|
+
export declare function registeredMethodManner(method: CanonicalSigClause["method"], resolvedMethod?: SigLongContext["resolvedMethod"]): import("./types").AdditionalInstructionDefinition | undefined;
|
|
10
|
+
export declare function alternateDayEvent(schedule: CanonicalScheduleExpr | undefined): EventTiming | undefined;
|
|
6
11
|
/** Daily recurrence applies to every explicit clock, not one occurrence in total.
|
|
7
12
|
* Presentation may say "daily at ..." without rewriting the stored frequency.
|
|
8
13
|
* Explicit ranges and counts other than one retain their authored summary.
|
|
9
14
|
* @param schedule Typed timing to realize; source text is never inspected.
|
|
10
15
|
*/
|
|
11
16
|
export declare function hasDailyRecurrenceAcrossClocks(schedule: CanonicalScheduleExpr | undefined): boolean;
|
|
17
|
+
type FrequencyDisplayMode = "daily" | "daily-count" | "daily-range" | "daily-maximum" | "period" | "period-maximum" | "alternate-days" | "calendar-count" | "calendar-range" | "calendar-maximum" | "code" | "code-period" | "count" | "count-bounds";
|
|
18
|
+
interface FrequencyDisplay {
|
|
19
|
+
mode: FrequencyDisplayMode;
|
|
20
|
+
countPrefix: "none" | "count" | "range" | "maximum";
|
|
21
|
+
frequency?: number;
|
|
22
|
+
frequencyMax?: number;
|
|
23
|
+
period?: number;
|
|
24
|
+
periodMax?: number;
|
|
25
|
+
periodUnit?: FhirPeriodUnit;
|
|
26
|
+
rangeEnd?: number;
|
|
27
|
+
timingCode?: string;
|
|
28
|
+
codePeriod?: {
|
|
29
|
+
period: number;
|
|
30
|
+
periodUnit: FhirPeriodUnit;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Select clinical display meaning once; each locale retains its wording. */
|
|
34
|
+
export declare function frequencyDisplay(schedule: CanonicalScheduleExpr | undefined, uppercaseTimingCode?: boolean): FrequencyDisplay | undefined;
|
|
35
|
+
export declare function standaloneOccurrenceCount(schedule: CanonicalScheduleExpr | undefined): number | undefined;
|
|
36
|
+
/** A typed scalar/range, or an already complete native rich amount, can be
|
|
37
|
+
* labelled without selecting it as the administration's prescribed dose. */
|
|
38
|
+
export declare function formatDoseEnglish(dose: CanonicalDoseExpr | string, style: "short" | "long", scope?: SigDoseScope): string | undefined;
|
|
12
39
|
export declare function joinWithAnd(parts: string[]): string;
|
|
13
|
-
|
|
40
|
+
/** Discrete doses distribute across paired targets; metric amounts are totals. */
|
|
41
|
+
export declare function doseUnitUsesTargetScope(unit: string | undefined): boolean;
|
|
42
|
+
/** Whether the recurrence supports describing selected days as occurring each month. */
|
|
43
|
+
export declare function dayOfMonthUsesSingleMonth(schedule: CanonicalScheduleExpr | undefined): boolean;
|
|
44
|
+
export declare function formatDurationShort(schedule: CanonicalScheduleExpr): string | undefined;
|
|
45
|
+
export interface DurationWording {
|
|
46
|
+
readonly locale: string;
|
|
47
|
+
readonly coursePrefix: string;
|
|
48
|
+
readonly administrationPrefix: string;
|
|
49
|
+
readonly administrationShortPrefix: string;
|
|
50
|
+
readonly range: string;
|
|
51
|
+
readonly upper: string;
|
|
52
|
+
readonly lower: string;
|
|
53
|
+
administrationUnit(unit: FhirPeriodUnit, value: number | undefined, maximum: number | undefined, short: boolean, words: CourseLanguage): string;
|
|
54
|
+
}
|
|
55
|
+
export declare function describeDuration(schedule: CanonicalScheduleExpr | undefined, words: CourseLanguage, text?: DurationWording): string | undefined;
|
|
56
|
+
export declare function describeAdministrationDuration(schedule: CanonicalScheduleExpr | undefined, short?: boolean, words?: CourseLanguage, text?: DurationWording, prefix?: string): string | undefined;
|
|
57
|
+
/** Preserve free labels; recognized cadence prose yields to a typed recurrence. */
|
|
58
|
+
export declare function independentTimingText(code: string | undefined, recurrence?: Pick<CanonicalScheduleExpr, "frequency" | "frequencyMax" | "period" | "periodMax" | "periodUnit">): string | undefined;
|
|
59
|
+
export declare function timingCodeMatchesRecurrence(schedule: Pick<CanonicalScheduleExpr, "timingCode" | "frequency" | "frequencyMax" | "period" | "periodMax" | "periodUnit" | "when" | "timeOfDay">, code?: string | undefined): boolean;
|
|
60
|
+
/** A code-only event supplies display meaning without changing authored timing. */
|
|
61
|
+
export declare function timingEventPreviewSchedule(schedule: CanonicalScheduleExpr | undefined): CanonicalScheduleExpr | undefined;
|
|
62
|
+
interface LongAdministrationTimingParts {
|
|
63
|
+
frequency?: string;
|
|
64
|
+
event?: string;
|
|
65
|
+
eventWindow?: string;
|
|
66
|
+
clockWindow?: string;
|
|
67
|
+
activities: string[];
|
|
68
|
+
calendarEvents?: string;
|
|
69
|
+
dayOfWeek?: string;
|
|
70
|
+
dayOfMonth?: string;
|
|
71
|
+
calendarBounds?: string;
|
|
72
|
+
count?: string;
|
|
73
|
+
administrationDuration?: string;
|
|
74
|
+
duration?: string;
|
|
75
|
+
occurrenceCap?: string;
|
|
76
|
+
}
|
|
77
|
+
interface RichAdministrationParts {
|
|
78
|
+
route?: string;
|
|
79
|
+
frequencyWithoutEvent?: string;
|
|
80
|
+
independentTiming?: string;
|
|
81
|
+
clock?: string;
|
|
82
|
+
asNeeded?: string;
|
|
83
|
+
site?: string;
|
|
84
|
+
coversSingleEvent: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Locale realizers supply words; their clinical timing order is shared. */
|
|
87
|
+
export declare function describeClockWindow(schedule: CanonicalScheduleExpr | undefined, timing?: {
|
|
88
|
+
sharedAdministration: (body: string, total?: string) => string;
|
|
89
|
+
clockWindow: (start: string, end: string, inclusive: boolean) => string;
|
|
90
|
+
offset: (minutes: number) => string;
|
|
91
|
+
dayShift: (days: number) => string;
|
|
92
|
+
}): string | undefined;
|
|
93
|
+
export declare function appendLongAdministrationTiming(parts: string[], timing: LongAdministrationTimingParts, richTiming?: RichAdministrationParts): void;
|
|
94
|
+
export declare function richGraphAdministrationTail(clause: CanonicalSigClause, action: AdviceFrame, timing: LongAdministrationTimingParts, parts: RichAdministrationParts): string[];
|
|
95
|
+
export declare function instructionGraphMatchesDose(clause: CanonicalSigClause): boolean;
|
|
96
|
+
export declare function instructionGraphActionHasSequenceSuccessor(clause: CanonicalSigClause, action: AdviceFrame | undefined): boolean;
|
|
97
|
+
export declare function hasExplicitAdministrationMethod(clause: CanonicalSigClause): boolean;
|
|
98
|
+
export declare function instructionGraphCanStandAlone(clause: CanonicalSigClause, timingText: string | undefined, graphRepresentsDose: boolean, richPrimaryAction: AdviceFrame | undefined, graphText: string | undefined, primaryConditions: InstructionGraphPrimaryCondition[] | undefined): boolean;
|
|
99
|
+
/** Calendar qualifiers use locale-owned labels and stay on their medication
|
|
100
|
+
* primary before independent instructions are composed. */
|
|
101
|
+
export declare function appendClinicalCalendarText(text: string, dates: readonly string[] | undefined, weekdays: readonly FhirDayOfWeek[] | undefined, words: CourseLanguage): string;
|
|
102
|
+
/** A source-only primary and its recognized cadence describe one medication.
|
|
103
|
+
* Qualify that complete primary before independent advice is composed. */
|
|
104
|
+
export declare function composeNativePrimaryDirections(rendered: string, authored: string | undefined, condition: MedicationCondition | undefined, words: CourseLanguage, deferredDirections?: {
|
|
105
|
+
text?: string;
|
|
106
|
+
current?: string;
|
|
107
|
+
}, clause?: CanonicalSigClause): string;
|
|
108
|
+
export declare function isEmptyStomachInstruction(instruction: CanonicalAdditionalInstructionExpr): boolean;
|
|
109
|
+
export declare function formatNativeCanonicalClause(clause: CanonicalSigClause, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions, authoredPrimary?: string, deferredDirections?: {
|
|
110
|
+
text?: string;
|
|
111
|
+
current?: string;
|
|
112
|
+
}, sharedCountAlreadyDisplayed?: boolean): string;
|
|
113
|
+
export declare function formatCanonicalClause(clause: CanonicalSigClause, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions, nativeDefault?: (target: "short" | "long") => string): string;
|
|
14
114
|
export declare function formatInternal(internal: ParserState, style: "short" | "long", localization?: SigLocalization, options?: TimingSummaryOptions): string;
|
|
115
|
+
export declare function stripTrailingZero(value: number): string;
|
|
116
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Token } from "../parser-state";
|
|
2
|
-
import type { MedicationCondition } from "../types";
|
|
3
|
-
import { AdviceArgumentRole, type AdviceArgument, type AdviceFrame } from "../types";
|
|
2
|
+
import type { MedicationCondition, ParseOptions } from "../types";
|
|
3
|
+
import { AdviceArgumentRole, AdviceRelation, type AdviceArgument, type AdviceFrame } from "../types";
|
|
4
4
|
import type { HpsgConstruction, HpsgSign, HpsgType } from "./signature";
|
|
5
5
|
import type { BoundaryRelation, CoordinationScopeFacts, RegimenSemanticSelection } from "./signature";
|
|
6
6
|
export interface HpsgConstructionSelection {
|
|
@@ -96,6 +96,7 @@ export interface ParsedMedicationGuard {
|
|
|
96
96
|
/** Authoritative typed derivation reused by the main clause chart. */
|
|
97
97
|
sign: HpsgSign;
|
|
98
98
|
}
|
|
99
|
+
export declare function guardHasMeasurement(value: MedicationCondition): boolean;
|
|
99
100
|
/** Attach already typed procedural withholding/target scope to the same guard
|
|
100
101
|
* derivation. This retains the predicate daughters in the clause feature graph.
|
|
101
102
|
* @param guard Selected conditional head/predicate analysis.
|
|
@@ -107,5 +108,12 @@ export declare function scopeMedicationGuardSign(guard: ParsedMedicationGuard, s
|
|
|
107
108
|
* @param source Exact clinician text.
|
|
108
109
|
* @param existingTokens Already-lexed tokens when the caller has a source context.
|
|
109
110
|
* @param withholdingConsequent License supplied only by a typed medication-withholding action daughter.
|
|
111
|
+
* @param options Registered action vocabulary used by the enclosing clause.
|
|
112
|
+
* @param scope An already selected conditional relation and optional closed predicate span.
|
|
110
113
|
*/
|
|
111
|
-
export declare function parseMedicationGuard(source: string, existingTokens?: Token[], withholdingConsequent?: true
|
|
114
|
+
export declare function parseMedicationGuard(source: string, existingTokens?: Token[], withholdingConsequent?: true, options?: ParseOptions, scope?: {
|
|
115
|
+
relation: AdviceRelation;
|
|
116
|
+
start: number;
|
|
117
|
+
markerEnd: number;
|
|
118
|
+
end?: number;
|
|
119
|
+
}): ParsedMedicationGuard | undefined;
|
package/dist/hpsg/defaults.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import { ParseOptions, RouteCode } from "../types";
|
|
|
3
3
|
export interface HpsgDefaultConstraintDeps {
|
|
4
4
|
setRoute: (state: ParserState, code: RouteCode, text?: string) => void;
|
|
5
5
|
}
|
|
6
|
+
/** Resolve the duration under the selected local or inherited administration head. */
|
|
7
|
+
export declare function applyAdministrationDurationSemantics(state: ParserState, options?: ParseOptions, inheritedMethod?: boolean): void;
|
|
6
8
|
export declare function applyHpsgDefaultConstraints(state: ParserState, tokens: readonly {
|
|
7
9
|
lower: string;
|
|
8
10
|
canonical?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type LexToken } from "../lexer/token-types";
|
|
2
|
-
import { AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirPeriodUnit } from "../types";
|
|
2
|
+
import { AdviceForce, AdviceModality, AdvicePolarity, AdviceRelation, EventTiming, FhirDayOfWeek, FhirPeriodUnit, type FhirPrimitiveElement } from "../types";
|
|
3
3
|
export { ACTION_SEQUENCE_MARKERS } from "../relation-terminology";
|
|
4
|
+
type MaximumPeriodPreposition = {
|
|
5
|
+
unitDenominator?: boolean;
|
|
6
|
+
rolling?: boolean;
|
|
7
|
+
};
|
|
4
8
|
type MealRelation = "before" | "after" | "with";
|
|
5
9
|
type MealTimingByRelation = Map<MealRelation, Map<EventTiming, EventTiming>>;
|
|
6
10
|
type BodySiteFeatureKind = "nominal" | "partitive" | "locative";
|
|
@@ -87,7 +91,10 @@ export declare const PRN_DEFAULT_SITE_CONNECTOR: string;
|
|
|
87
91
|
export declare const PRN_COMPACT_REASON_SEPARATORS: Set<string>;
|
|
88
92
|
export declare const SITE_ROUTE_HINTS_ALLOWED_IN_GRAMMAR: Set<import("../types").SNOMEDCTRouteCodes>;
|
|
89
93
|
export declare const PRODUCT_METHOD_REALIZATIONS: Record<string, Partial<Record<string, Record<string, string>>>>;
|
|
90
|
-
export declare function
|
|
94
|
+
export declare function productMethodRealization(verb: string, product: string): {
|
|
95
|
+
text: string;
|
|
96
|
+
textElement?: FhirPrimitiveElement;
|
|
97
|
+
} | undefined;
|
|
91
98
|
export declare const PRODUCT_FORM_MODIFIERS: Set<string>;
|
|
92
99
|
export declare const PRODUCT_SOURCE_PREPOSITIONS: Set<string>;
|
|
93
100
|
export declare const COMPOUND_DOSE_UNITS: CompoundDoseUnit[];
|
|
@@ -101,6 +108,8 @@ export declare const DOSE_ADDITIVE_QUANTITY_CONNECTORS: Set<string>;
|
|
|
101
108
|
export declare const DOSE_FRACTION_ARTICLES: Set<string>;
|
|
102
109
|
export declare const DOSE_NUMBER_WORDS: Map<string, number>;
|
|
103
110
|
export declare const DOSE_UNIT_CONNECTORS: Set<string>;
|
|
111
|
+
/** Calendar dayparts are not elapsed periods for rolling medication limits. */
|
|
112
|
+
export declare const DAYPART_INTERVAL_TOKENS: Set<string>;
|
|
104
113
|
export declare const MILLION_DOSE_MULTIPLIER_TOKENS: Set<string>;
|
|
105
114
|
export declare const SCHEDULE_UNIT_SEPARATOR_TOKENS: Set<string>;
|
|
106
115
|
export declare const COMPACT_LIST_SEPARATORS: Set<string>;
|
|
@@ -111,9 +120,10 @@ export declare const COUNT_CONNECTOR_WORDS_DATA: Set<string>;
|
|
|
111
120
|
export declare const SUPPLEMENTAL_DOSE_MODIFIERS: Set<string>;
|
|
112
121
|
export declare const MAXIMUM_COUNT_LEAD_TOKENS: Set<string>;
|
|
113
122
|
export declare const MAXIMUM_COUNT_LEAD_SEQUENCES: string[][];
|
|
123
|
+
export declare const MAXIMUM_COUNT_LEAD_FIRST_TOKENS: Set<string>;
|
|
114
124
|
export declare const OCCURRENCE_COUNT_WORDS: Set<string>;
|
|
115
125
|
export declare const OCCURRENCE_COUNT_MODIFIERS: Set<string>;
|
|
116
|
-
export declare const MAXIMUM_PERIOD_PREPOSITIONS:
|
|
126
|
+
export declare const MAXIMUM_PERIOD_PREPOSITIONS: Map<string, MaximumPeriodPreposition>;
|
|
117
127
|
export declare const MAXIMUM_PERIOD_MODIFIERS: Set<string>;
|
|
118
128
|
export declare const OCCURRENCE_CAP_PERIOD_PHRASES: {
|
|
119
129
|
parts: string[];
|
|
@@ -159,7 +169,7 @@ export declare const OPEN_ENDED_COURSE_END_CONDITIONS: ({
|
|
|
159
169
|
})[];
|
|
160
170
|
/** Nominal quantifiers and event membership for typed medication-dose references. */
|
|
161
171
|
export declare const DOSE_TARGET_SLOT_HEADS: Set<string>;
|
|
162
|
-
export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "
|
|
172
|
+
export declare const DOSE_TARGET_QUANTIFIERS: Map<string, "all" | "both">;
|
|
163
173
|
/** Broad named dayparts can select a unique already stated clock, never invent one. */
|
|
164
174
|
export declare const DOSE_TARGET_DAYPART_CLOCK_RANGES: Map<EventTiming, {
|
|
165
175
|
startHour: number;
|
|
@@ -171,6 +181,17 @@ export declare const DOSE_TARGET_MERIDIEM_CLOCK_RANGES: Map<string, {
|
|
|
171
181
|
endHour: number;
|
|
172
182
|
}>;
|
|
173
183
|
export declare const DOSE_TARGET_EVENT_MEMBERS: Map<EventTiming, readonly EventTiming[]>;
|
|
184
|
+
export declare const CALENDAR_WEEKDAY_LEXEMES: {
|
|
185
|
+
day: FhirDayOfWeek;
|
|
186
|
+
patterns: RegExp[];
|
|
187
|
+
}[];
|
|
188
|
+
export declare const CALENDAR_WEEKDAY_GROUPS: {
|
|
189
|
+
pattern: RegExp;
|
|
190
|
+
days: FhirDayOfWeek[];
|
|
191
|
+
}[];
|
|
192
|
+
export declare const CALENDAR_DAY_LIST_CONNECTORS: RegExp;
|
|
193
|
+
export declare const CALENDAR_EXCLUSION_CUE: RegExp;
|
|
194
|
+
export declare const CALENDAR_EXCLUSION_DAY_HEADS: Set<string>;
|
|
174
195
|
export declare const CALENDAR_UNIVERSAL_DAY_QUANTIFIERS: Set<string>;
|
|
175
196
|
export declare const CALENDAR_COMPLEMENT_DAY_MODIFIERS: Set<string>;
|
|
176
197
|
export declare const CALENDAR_COMPLEMENT_DETERMINERS: Set<string>;
|
|
@@ -192,6 +213,8 @@ export declare const LIST_SEPARATORS: Set<string>;
|
|
|
192
213
|
* Numeric dose slots and non-Thai time ranges do not use this lexical sense.
|
|
193
214
|
*/
|
|
194
215
|
export declare function isThaiDaypartListSeparator(separator: LexToken | undefined, left: LexToken | undefined, right: LexToken | undefined): boolean;
|
|
216
|
+
/** Existing rate-head surfaces retain their registered action valence. */
|
|
217
|
+
export declare const CLINICAL_RATE_ADMINISTRATION_HEADS: Map<string, string>;
|
|
195
218
|
export declare const MEDICATION_OBJECT_FILLERS: Set<string>;
|
|
196
219
|
/** Typed resultative adjustment leads; the following cadence owns the new phase. */
|
|
197
220
|
export declare const PHASE_ADJUSTMENT_LEAD_SEQUENCES: string[][];
|
|
@@ -201,9 +224,16 @@ export declare const TIMING_ANAPHORA_PHRASES: string[][];
|
|
|
201
224
|
export declare const CLOCK_LEAD_TOKENS: Set<string>;
|
|
202
225
|
export declare const EVENT_PREPOSITIONS: Set<string>;
|
|
203
226
|
export declare const EVENT_ARTICLE_TOKENS: Set<string>;
|
|
227
|
+
export declare const INSTRUCTION_NOMINAL_ARTICLES: Set<string>;
|
|
204
228
|
export declare const FIXED_EVENT_PHRASES: Map<string, EventTiming>;
|
|
205
229
|
export declare const MEAL_RELATION_BY_TOKEN: Map<string, MealRelation>;
|
|
206
230
|
export declare const MEAL_TIMING_BY_RELATION: MealTimingByRelation;
|
|
231
|
+
/** Realize the existing meal lexicon's instruction wording and translations.
|
|
232
|
+
* Typed qualification and offset scope remain with the HPSG construction. */
|
|
233
|
+
export declare function mealInstructionWording(events: readonly EventTiming[], sourceText: string): {
|
|
234
|
+
text: string;
|
|
235
|
+
i18n?: Record<string, string>;
|
|
236
|
+
};
|
|
207
237
|
export declare const SLEEP_EVENT_ALIASES: Set<string>;
|
|
208
238
|
export declare const WAKE_EVENT_ALIASES: Set<string>;
|
|
209
239
|
export declare const FOOD_EVENT_ALIASES: Set<string>;
|
|
@@ -217,6 +247,13 @@ export declare const CALENDAR_MONTH_DAY_FRAMES: {
|
|
|
217
247
|
};
|
|
218
248
|
export declare const RANGE_CONNECTORS: Set<string>;
|
|
219
249
|
export declare const DURATION_LEAD_TOKENS: ReadonlySet<string>;
|
|
250
|
+
/** Complete compact interval token shared by grammar and timing preview.
|
|
251
|
+
* Consumers retain the existing unit admission and cadence normalization. */
|
|
252
|
+
export declare function compactIntervalParts(surface: string): {
|
|
253
|
+
period: number;
|
|
254
|
+
periodMax?: number;
|
|
255
|
+
unitSurface: string;
|
|
256
|
+
} | undefined;
|
|
220
257
|
/** Shared source-lexical reading of an unspaced headed duration NP.
|
|
221
258
|
* HPSG schedule and procedural action grammar consume the same daughter.
|
|
222
259
|
* No semantic meaning is assigned until each consumer licenses the unit. */
|
|
@@ -236,18 +273,31 @@ export declare const ACTION_DIRECTIVE_PREFIXES: {
|
|
|
236
273
|
parts: readonly string[];
|
|
237
274
|
polarity: AdvicePolarity | undefined;
|
|
238
275
|
modality: AdviceModality | undefined;
|
|
276
|
+
force: AdviceForce | undefined;
|
|
239
277
|
complement: "contact-clause" | undefined;
|
|
240
278
|
}[];
|
|
279
|
+
export declare const NEGATIVE_ACTION_DIRECTIVE_LEADS: Set<string>;
|
|
241
280
|
export declare const ACTION_COORDINATION_CONNECTORS: Set<string>;
|
|
242
281
|
/** Closed-class contrast that connects two instructions, not a new action. */
|
|
243
282
|
export declare const ACTION_DISCOURSE_CONNECTORS: Set<string>;
|
|
244
283
|
/** Compositional phrasal sequencers; single-token THEN remains the relation lexicon's authority. */
|
|
284
|
+
export declare const TRAILING_PHASE_RELATION_ADVERBS: Set<string>;
|
|
245
285
|
export declare const REGIMEN_SEQUENCE_CONNECTOR_PHRASES: readonly (readonly string[])[];
|
|
246
286
|
export declare function sequenceConnectorEnd(tokens: readonly LexToken[], start: number): number | undefined;
|
|
247
287
|
/** Count nouns select whole treatment cycles rather than doses or days. */
|
|
248
288
|
export declare const CYCLE_COUNT_HEADS: Set<string>;
|
|
249
289
|
/** Cheap source-lexical gate for typed treatment-relative phase onsets. */
|
|
250
290
|
export declare const TREATMENT_PERIOD_START_LEADS: Set<string>;
|
|
291
|
+
export declare const RELATIVE_TIME_END_LEADS: Set<string>;
|
|
292
|
+
export declare const NEXT_DAY_MODIFIERS: Set<string>;
|
|
293
|
+
export declare const NEXT_DAY_HEADS: Set<string>;
|
|
294
|
+
export declare const NEXT_DAY_PREPOSITIONS: Set<string>;
|
|
295
|
+
export declare const NEXT_DAY_START_LEADS: Set<string>;
|
|
296
|
+
/** Typed derivation identity shared by lexical timing and phase composition. */
|
|
297
|
+
export declare const NEXT_DAY_SCHEDULE_RULE = "hpsg.lex.schedule.nextDay";
|
|
298
|
+
export declare const NEXT_DAY_ONSET_RULE = "hpsg.lex.schedule.nextDay.onset";
|
|
299
|
+
export declare function isNextDayScheduleRule(rule: string): boolean;
|
|
300
|
+
export declare const FIXED_CLOCK_DAYPART_QUALIFICATION_RULE = "hpsg.cx.schedule.fixed-clock-daypart-qualification";
|
|
251
301
|
export declare const ACTION_COORDINATION_CONNECTOR_I18N: Record<string, Record<string, string>>;
|
|
252
302
|
export declare function coordinationConnectorKind(surface: string): "conjunction" | "disjunction" | "unknown";
|
|
253
303
|
export declare const ACTION_SEQUENCE_RELATION_TOKENS: ReadonlySet<string>;
|
|
@@ -337,3 +387,64 @@ export declare function courseContinuationDurationAt(tokens: readonly Pick<LexTo
|
|
|
337
387
|
value: number;
|
|
338
388
|
unit: FhirPeriodUnit;
|
|
339
389
|
} | undefined;
|
|
390
|
+
/** One range daughter shared by ordinary doses and dimensional quantities. */
|
|
391
|
+
export declare function doseRangeNumberAt(tokens: readonly LexToken[], start: number, limit: number): {
|
|
392
|
+
range: {
|
|
393
|
+
low: number;
|
|
394
|
+
high: number;
|
|
395
|
+
};
|
|
396
|
+
numericIndex: number;
|
|
397
|
+
} | undefined;
|
|
398
|
+
/** Authored comparative dose NPs. Only complete number+medication-unit
|
|
399
|
+
* constituents are licensed; "about 3 weeks" stays temporal, and no
|
|
400
|
+
* second text-level dose parser runs after HPSG.
|
|
401
|
+
*/
|
|
402
|
+
type DoseComparator = "<" | "<=" | ">" | ">=" | "~";
|
|
403
|
+
export declare const DOSE_COMPARATOR_PREFIXES: Map<string, {
|
|
404
|
+
words: readonly string[];
|
|
405
|
+
comparator: DoseComparator;
|
|
406
|
+
}[]>;
|
|
407
|
+
export declare const DOSE_COMPARATOR_SYMBOLS: Record<string, DoseComparator>;
|
|
408
|
+
/** Shared WHOLE + connector + optional article + fraction head. The
|
|
409
|
+
* caller still owns its medication unit; this cannot swallow two independently
|
|
410
|
+
* unit-bearing coordinated doses. Returns the last number token it owns. */
|
|
411
|
+
export declare function additiveDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, whole: number, allowMillion?: boolean): {
|
|
412
|
+
value: number;
|
|
413
|
+
numericIndex: number;
|
|
414
|
+
} | undefined;
|
|
415
|
+
/** A million is a numeric multiplier, never a medication unit.
|
|
416
|
+
* Shared by exact/comparative scalar and dimensional quantities. Source
|
|
417
|
+
* position advances past a separately spelled multiplier only when present. */
|
|
418
|
+
export declare function millionDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, value: number): {
|
|
419
|
+
value: number;
|
|
420
|
+
numericIndex: number;
|
|
421
|
+
} | undefined;
|
|
422
|
+
/** Numeric source token with an attached unit, e.g. 0.1mcg/kg.
|
|
423
|
+
* A prefix comparator is optional and remains owned by its outer lexeme.
|
|
424
|
+
* This is a bounded token form, never a second whole-SIG parser. */
|
|
425
|
+
export declare function attachedNumberUnitAt(lower: string): {
|
|
426
|
+
value: number;
|
|
427
|
+
rawUnit: string;
|
|
428
|
+
} | undefined;
|
|
429
|
+
/** A compact million suffix shares the attached-numeral decimal shape.
|
|
430
|
+
* The leading decimal point is numeric evidence, never punctuation. */
|
|
431
|
+
export declare function compactMillionDoseNumber(lower: string): number | undefined;
|
|
432
|
+
/** A denominator word belongs to the numeric head before its unit connector. */
|
|
433
|
+
export declare function fractionalDoseNumberAt(tokens: readonly LexToken[], start: number, limit: number, value: number, allowMillion?: boolean): {
|
|
434
|
+
value: number;
|
|
435
|
+
numericIndex: number;
|
|
436
|
+
} | undefined;
|
|
437
|
+
/** One bounded quantity-prefix lexeme shared by scalar and dimensional
|
|
438
|
+
* rules. It identifies source tokens; it does not assign a unit or dose.
|
|
439
|
+
* Duration daughters disable medication scaling so m remains their unit. */
|
|
440
|
+
export declare function doseComparatorNumberAt(tokens: readonly LexToken[], start: number, limit: number, lower: string, allowMillion?: boolean): {
|
|
441
|
+
comparator: "<" | "<=" | ">" | ">=" | "~";
|
|
442
|
+
value: number;
|
|
443
|
+
numericIndex: number;
|
|
444
|
+
rawUnit?: string;
|
|
445
|
+
} | undefined;
|
|
446
|
+
export declare function normalizeTokenLower(token: LexToken): string;
|
|
447
|
+
export declare function parseClockToken<T extends LexToken>(token: T | undefined, meridiemToken?: T | undefined): {
|
|
448
|
+
value: string;
|
|
449
|
+
tokens: T[];
|
|
450
|
+
} | undefined;
|
|
@@ -2,10 +2,10 @@ import { type AdviceFrame } from "../types";
|
|
|
2
2
|
import { type HpsgClauseContext } from "./rule-context";
|
|
3
3
|
/**
|
|
4
4
|
* Parse procedural semantics once per ParserState and share the result across
|
|
5
|
-
* HPSG lexical constructions. Keeping this cache
|
|
6
|
-
*
|
|
5
|
+
* HPSG lexical constructions and graph finalization. Keeping this cache in
|
|
6
|
+
* the HPSG context avoids independently parsing the same action program.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getProceduralFrames(context: HpsgClauseContext): AdviceFrame[];
|
|
8
|
+
export declare function getProceduralFrames(context: Pick<HpsgClauseContext, "state" | "options">): AdviceFrame[];
|
|
9
9
|
/** Existing action-sequence relation shared by condition closure and lexical ownership. */
|
|
10
10
|
export declare function instructionActionsAreSequenced(context: HpsgClauseContext, startSource: number, endSource: number): boolean;
|
|
11
11
|
/** Compose the consecutive action daughters selected by one fronted condition. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParserState, Token } from "../parser-state";
|
|
2
2
|
import { EventTiming, FhirDayOfWeek, RouteCode, type CanonicalSigClause, type CanonicalSiteExpr, type CanonicalLexicalCategory, type CanonicalScheduleSemanticField } from "../types";
|
|
3
|
-
import { HpsgSign } from "./signature";
|
|
3
|
+
import { HpsgScheduleFeature, HpsgSign } from "./signature";
|
|
4
4
|
export interface HpsgProjectionDeps {
|
|
5
5
|
addDayOfWeekList: (state: ParserState, days: FhirDayOfWeek[]) => void;
|
|
6
6
|
addWhen: (target: EventTiming[], whenCode: EventTiming) => void;
|
|
@@ -9,6 +9,33 @@ export interface HpsgProjectionDeps {
|
|
|
9
9
|
refreshMethodSurface: (state: ParserState) => void;
|
|
10
10
|
setRoute: (state: ParserState, code: RouteCode, text?: string) => void;
|
|
11
11
|
}
|
|
12
|
+
export declare function cloneSiteRestrictions(restrictions: NonNullable<HpsgSign["synsem"]["valence"]["site"]>["restrictions"]): {
|
|
13
|
+
range: {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
} | undefined;
|
|
17
|
+
markerRange: {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
} | undefined;
|
|
21
|
+
predicate: {
|
|
22
|
+
range: {
|
|
23
|
+
start: number;
|
|
24
|
+
end: number;
|
|
25
|
+
} | undefined;
|
|
26
|
+
text: string;
|
|
27
|
+
lemma?: string;
|
|
28
|
+
form: import("../types").BodySiteRestrictionPredicateForm;
|
|
29
|
+
focusText?: string;
|
|
30
|
+
};
|
|
31
|
+
relation: "where";
|
|
32
|
+
sourceText: string;
|
|
33
|
+
}[] | undefined;
|
|
34
|
+
export declare function hasRecurringSchedule(schedule: HpsgScheduleFeature | undefined, positionsRepeat?: boolean): boolean;
|
|
35
|
+
/** A single dated clock locates an elapsed administration; it does not
|
|
36
|
+
* supply a repeat cadence. Course bounds and independent recurrences retain
|
|
37
|
+
* their usual ownership of clock slots. */
|
|
38
|
+
export declare function hasRecurringAdministrationSchedule(schedule: HpsgScheduleFeature | undefined, positionsRepeat?: boolean): boolean;
|
|
12
39
|
export declare function projectHpsgSignToState(sign: HpsgSign, state: ParserState, tokens: Token[], deps: HpsgProjectionDeps): void;
|
|
13
40
|
/**
|
|
14
41
|
* Return the FHIR projection alternatives licensed by the typed HPSG site
|