ezmedicationinput 0.1.55 → 0.1.56
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/dist/advice.d.ts +1 -0
- package/dist/body-site-grammar.d.ts +2 -1
- package/dist/fhir.d.ts +5 -1
- package/dist/hpsg/lexical-classes.d.ts +35 -12
- package/dist/hpsg/rules/core-rules.d.ts +1 -0
- package/dist/hpsg/rules/prn-rules.d.ts +3 -0
- package/dist/hpsg/rules/timing-rules.d.ts +9 -0
- package/dist/hpsg/signature.d.ts +6 -1
- package/dist/index.cjs +6124 -2279
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6111 -2279
- package/dist/instruction-graph.d.ts +2 -0
- package/dist/parser-state.d.ts +8 -0
- package/dist/prn.d.ts +1 -0
- package/dist/relation-terminology.d.ts +101 -0
- package/dist/stable-structure.d.ts +1 -0
- package/dist/types.d.ts +42 -2
- package/package.json +1 -1
|
@@ -2,8 +2,10 @@ import { AdviceFrame, AdviceModality, CanonicalInstructionGraph, CanonicalSigCla
|
|
|
2
2
|
export declare function parseInstructionActions(sourceText: string, baseOffset?: number, options?: ParseOptions): AdviceFrame[];
|
|
3
3
|
export declare function refreshInstructionGraphDerivedState(graph: CanonicalInstructionGraph): void;
|
|
4
4
|
export declare function buildInstructionGraph(input: string, clause: CanonicalSigClause, options?: ParseOptions): CanonicalInstructionGraph | undefined;
|
|
5
|
+
export declare function realizeInstructionAction(frame: AdviceFrame, locale?: string): string;
|
|
5
6
|
export declare function instructionGraphRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
|
|
6
7
|
export declare function instructionGraphSingleActionRepresentsText(graph: CanonicalInstructionGraph, text: string): boolean;
|
|
8
|
+
export declare function instructionGraphRichPrimaryAction(clause: CanonicalSigClause): AdviceFrame | undefined;
|
|
7
9
|
export declare function instructionGraphPrimaryAdministrationModality(clause: CanonicalSigClause): AdviceModality | undefined;
|
|
8
10
|
export declare function instructionGraphHasNovelNonWarningContent(graph: CanonicalInstructionGraph, representedTexts: readonly string[]): boolean;
|
|
9
11
|
export declare function realizeInstructionGraph(graph: CanonicalInstructionGraph, locale?: string, options?: {
|
package/dist/parser-state.d.ts
CHANGED
|
@@ -49,6 +49,8 @@ export declare class ParserState {
|
|
|
49
49
|
set methodCoding(value: LocalizedCoding | undefined);
|
|
50
50
|
get count(): number | undefined;
|
|
51
51
|
set count(value: number | undefined);
|
|
52
|
+
get countMax(): number | undefined;
|
|
53
|
+
set countMax(value: number | undefined);
|
|
52
54
|
get duration(): number | undefined;
|
|
53
55
|
set duration(value: number | undefined);
|
|
54
56
|
get durationMax(): number | undefined;
|
|
@@ -75,12 +77,18 @@ export declare class ParserState {
|
|
|
75
77
|
get when(): EventTiming[];
|
|
76
78
|
get timeOfDay(): string[] | undefined;
|
|
77
79
|
set timeOfDay(value: string[] | undefined);
|
|
80
|
+
get activityTiming(): import("./types").CanonicalActivityTimingExpr[] | undefined;
|
|
81
|
+
set activityTiming(value: import("./types").CanonicalActivityTimingExpr[] | undefined);
|
|
82
|
+
get occurrenceCap(): import("./types").CanonicalOccurrenceCapExpr | undefined;
|
|
83
|
+
set occurrenceCap(value: import("./types").CanonicalOccurrenceCapExpr | undefined);
|
|
78
84
|
get timingCode(): string | undefined;
|
|
79
85
|
set timingCode(value: string | undefined);
|
|
80
86
|
get asNeeded(): boolean | undefined;
|
|
81
87
|
set asNeeded(value: boolean | undefined);
|
|
82
88
|
get asNeededReason(): string | undefined;
|
|
83
89
|
set asNeededReason(value: string | undefined);
|
|
90
|
+
get asNeededReasonTriggerPhase(): "onset" | undefined;
|
|
91
|
+
set asNeededReasonTriggerPhase(value: "onset" | undefined);
|
|
84
92
|
get asNeededReasons(): CanonicalPrnReasonExpr[] | undefined;
|
|
85
93
|
set asNeededReasons(value: CanonicalPrnReasonExpr[] | undefined);
|
|
86
94
|
get asNeededReasonCoding(): LocalizedCoding | undefined;
|
package/dist/prn.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { CanonicalPrnReasonExpr } from "./types";
|
|
|
2
2
|
export declare function getCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined): string | undefined;
|
|
3
3
|
export declare function joinCanonicalPrnReasonTexts(reasons: CanonicalPrnReasonExpr[] | undefined, conjunction?: string): string | undefined;
|
|
4
4
|
export declare function getPreferredCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined, reasons: CanonicalPrnReasonExpr[] | undefined, conjunction?: string): string | undefined;
|
|
5
|
+
export declare function getLocalizedCanonicalPrnReasonText(reason: CanonicalPrnReasonExpr | undefined, reasons: CanonicalPrnReasonExpr[] | undefined, locale: string, conjunction?: string): string | undefined;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AdviceRelation, FhirCoding } from "./types";
|
|
2
|
+
type SupportedLocale = "en" | "th";
|
|
3
|
+
declare const BODY_SITE_LOCATIVE_RELATION_VALUES: readonly ["above", "around", "behind", "below", "beneath", "under", "inside", "near", "outside", "between", "along"];
|
|
4
|
+
export type BodySiteLocativeRelation = typeof BODY_SITE_LOCATIVE_RELATION_VALUES[number];
|
|
5
|
+
export type BodySiteRelationRenderStrategy = "prefix" | "partitive" | "suffix";
|
|
6
|
+
export interface RelationLocaleLexeme {
|
|
7
|
+
surface: string;
|
|
8
|
+
canonical: string;
|
|
9
|
+
splitPrefix?: boolean;
|
|
10
|
+
/** Preferred semantic relation when a locale surface is lexically ambiguous. */
|
|
11
|
+
defaultForAmbiguousSurface?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface AdviceRelationGrammarFeatures {
|
|
14
|
+
preposedAction?: boolean;
|
|
15
|
+
conditionScope?: boolean;
|
|
16
|
+
conditionalTail?: boolean;
|
|
17
|
+
detectInActionGap?: boolean;
|
|
18
|
+
timeComplement?: boolean;
|
|
19
|
+
rinseTimeComplement?: boolean;
|
|
20
|
+
durationComplement?: boolean;
|
|
21
|
+
activityFallback?: boolean;
|
|
22
|
+
includeDuration?: boolean;
|
|
23
|
+
negatedObjectAttachment?: boolean;
|
|
24
|
+
negatedRelationTarget?: boolean;
|
|
25
|
+
accompanimentComplement?: boolean;
|
|
26
|
+
directTimeRealization?: boolean;
|
|
27
|
+
timeRealizationProfile?: string;
|
|
28
|
+
symptomOnsetPrnLead?: boolean;
|
|
29
|
+
roundtripRichRelation?: boolean;
|
|
30
|
+
mealStateComplement?: boolean;
|
|
31
|
+
workflowStart?: boolean;
|
|
32
|
+
workflowActionLead?: boolean;
|
|
33
|
+
conditionalInstructionExclusive?: boolean;
|
|
34
|
+
durationLead?: boolean;
|
|
35
|
+
instructionStart?: boolean;
|
|
36
|
+
freeTextDirectiveStart?: boolean;
|
|
37
|
+
defaultSequenceRelation?: boolean;
|
|
38
|
+
defaultSiteRelation?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface AdviceRelationDefinition {
|
|
41
|
+
relation: AdviceRelation;
|
|
42
|
+
semanticClass: string;
|
|
43
|
+
grammar: AdviceRelationGrammarFeatures;
|
|
44
|
+
actionSurfaces: string[];
|
|
45
|
+
adviceSurfaces: string[];
|
|
46
|
+
sequenceMarkerSurfaces: string[];
|
|
47
|
+
sequenceRelationSurfaces: string[];
|
|
48
|
+
localeLexemes: Partial<Record<SupportedLocale, RelationLocaleLexeme[]>>;
|
|
49
|
+
realization: Record<SupportedLocale, string>;
|
|
50
|
+
realizationProfiles: Record<string, Partial<Record<SupportedLocale, string>>>;
|
|
51
|
+
}
|
|
52
|
+
export interface BodySiteRelationGrammarFeatures {
|
|
53
|
+
externalSiteLocativePrefix?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface BodySiteRelationRealization {
|
|
56
|
+
surface: string;
|
|
57
|
+
strategy: BodySiteRelationRenderStrategy;
|
|
58
|
+
article?: "the" | "none";
|
|
59
|
+
omitOuterSitePreposition?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface BodySiteRelationDefinition {
|
|
62
|
+
canonical: string;
|
|
63
|
+
aliases: string[];
|
|
64
|
+
locative: boolean;
|
|
65
|
+
grammar: BodySiteRelationGrammarFeatures;
|
|
66
|
+
localeLexemes: Partial<Record<SupportedLocale, RelationLocaleLexeme[]>>;
|
|
67
|
+
coding?: FhirCoding;
|
|
68
|
+
realization: Partial<Record<SupportedLocale, BodySiteRelationRealization>>;
|
|
69
|
+
}
|
|
70
|
+
export declare const ACTION_SEQUENCE_MARKERS: ReadonlySet<string>;
|
|
71
|
+
export declare const ACTION_SEQUENCE_RELATION_SURFACES: ReadonlySet<string>;
|
|
72
|
+
export declare function resolveActionRelationSurfaceCandidates(surface: string): readonly AdviceRelation[];
|
|
73
|
+
export declare function resolveActionRelationSurface(surface: string, preferredSemanticClasses?: readonly string[]): AdviceRelation | undefined;
|
|
74
|
+
export declare function resolveActionRelationSurfaceByGrammarFeature(surface: string, feature: keyof AdviceRelationGrammarFeatures): AdviceRelation | undefined;
|
|
75
|
+
export declare function resolveAdviceRelationSurface(surface: string): AdviceRelation | undefined;
|
|
76
|
+
export declare function getAdviceRelationDefinition(relation: AdviceRelation): AdviceRelationDefinition | undefined;
|
|
77
|
+
export declare function relationHasGrammarFeature(relation: AdviceRelation | undefined, feature: keyof AdviceRelationGrammarFeatures): boolean;
|
|
78
|
+
export declare function getUniqueAdviceRelationByGrammarFeature(feature: keyof AdviceRelationGrammarFeatures): AdviceRelation | undefined;
|
|
79
|
+
export declare function relationHasSemanticClass(relation: AdviceRelation | undefined, semanticClass: string): boolean;
|
|
80
|
+
export declare function getAdviceRelationSurfaceForms(relation: AdviceRelation): readonly string[];
|
|
81
|
+
export declare function localizeAdviceRelation(relation: AdviceRelation | undefined, locale: string, profile?: string): string | undefined;
|
|
82
|
+
export declare function listAdviceRelationDefinitions(): AdviceRelationDefinition[];
|
|
83
|
+
export declare function getAdviceRelationCanonicalSetByGrammarFeature(feature: keyof AdviceRelationGrammarFeatures): ReadonlySet<string>;
|
|
84
|
+
export declare const BODY_SITE_EXTERNAL_LOCATIVE_PREFIXES: ReadonlySet<string>;
|
|
85
|
+
export declare const BODY_SITE_LOCATIVE_RELATIONS: ReadonlySet<BodySiteLocativeRelation>;
|
|
86
|
+
export declare const BODY_SITE_LOCATIVE_RELATION_ALIASES: ReadonlyMap<string, string>;
|
|
87
|
+
export declare const BODY_SITE_LOCATIVE_RELATION_PHRASES: ReadonlyMap<string, string>;
|
|
88
|
+
export declare const BODY_SITE_SPATIAL_RELATION_CODINGS: ReadonlyMap<string, FhirCoding>;
|
|
89
|
+
export declare const BODY_SITE_LOCATIVE_LEAD_TOKENS: ReadonlySet<string>;
|
|
90
|
+
export declare function normalizeBodySiteRelation(value: string): string | undefined;
|
|
91
|
+
export declare function getBodySiteRelationDefinition(value: string): BodySiteRelationDefinition | undefined;
|
|
92
|
+
export declare function getBodySiteRelationRealization(value: string, locale: string): BodySiteRelationRealization | undefined;
|
|
93
|
+
export declare function listBodySiteRelationDefinitions(): BodySiteRelationDefinition[];
|
|
94
|
+
export declare function getRelationLocaleLexemeAliases(locale: string): Map<string, string>;
|
|
95
|
+
export declare function getRelationLocaleSuggestionLexemes(locale: string): RelationLocaleLexeme[];
|
|
96
|
+
export declare function getRelationLocalePhrases(locale: string): Array<{
|
|
97
|
+
parts: string[];
|
|
98
|
+
canonical: string;
|
|
99
|
+
}>;
|
|
100
|
+
export declare function getRelationSplitPrefixes(locale: string): string[];
|
|
101
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stableStructureKey(value: unknown): string;
|
package/dist/types.d.ts
CHANGED
|
@@ -307,6 +307,7 @@ export interface FhirPeriod {
|
|
|
307
307
|
}
|
|
308
308
|
export interface FhirTimingRepeat extends FhirElement {
|
|
309
309
|
count?: number;
|
|
310
|
+
countMax?: number;
|
|
310
311
|
boundsDuration?: FhirQuantity;
|
|
311
312
|
boundsPeriod?: FhirPeriod;
|
|
312
313
|
boundsRange?: FhirRange;
|
|
@@ -431,6 +432,10 @@ export interface BodySiteDefinition {
|
|
|
431
432
|
spatialRelation?: BodySiteSpatialRelation;
|
|
432
433
|
routeHint?: RouteCode;
|
|
433
434
|
administrationTargetCount?: number;
|
|
435
|
+
/** Optional surface used when the dose applies independently to each target. */
|
|
436
|
+
perTargetText?: string;
|
|
437
|
+
/** Locale-specific per-target surface, e.g. Thai `รูจมูกข้างละ`. */
|
|
438
|
+
perTargetI18n?: Record<string, string>;
|
|
434
439
|
/** Optional translations for different locales (e.g., { "th": "ตา" }) */
|
|
435
440
|
i18n?: Record<string, string>;
|
|
436
441
|
/**
|
|
@@ -482,6 +487,7 @@ export declare enum AdviceRelation {
|
|
|
482
487
|
Before = "before",
|
|
483
488
|
After = "after",
|
|
484
489
|
During = "during",
|
|
490
|
+
Between = "between",
|
|
485
491
|
Then = "then",
|
|
486
492
|
Until = "until",
|
|
487
493
|
For = "for",
|
|
@@ -540,6 +546,9 @@ export interface AdviceFrame {
|
|
|
540
546
|
realizerConfig?: {
|
|
541
547
|
thaiFallbackObject?: string;
|
|
542
548
|
thaiSuppressActivityConcepts?: string[];
|
|
549
|
+
thaiSuppressSiteConcepts?: string[];
|
|
550
|
+
thaiImplicitMedicationObject?: boolean;
|
|
551
|
+
englishDirectSiteObject?: boolean;
|
|
543
552
|
};
|
|
544
553
|
/** Internal/custom action coding followed by any trustworthy external mappings. */
|
|
545
554
|
codings?: FhirCoding[];
|
|
@@ -686,8 +695,8 @@ export interface SmartMealExpansionScope {
|
|
|
686
695
|
*/
|
|
687
696
|
excludeDosageForms?: string[];
|
|
688
697
|
}
|
|
689
|
-
export type MedicationInstructionActionArgumentParser = "default" | "container-activity" | "theme-destination-amount" | "object-amount-material" | "amount-duration" | "object-duration" | "object-time" | "mix-substance" | "result" | "site" | "site-relation" | "duration" | "bare-duration" | "activity";
|
|
690
|
-
export type MedicationInstructionActionRealizer = "default" | "source-faithful" | "container-activity" | "theme-destination-amount" | "mix-substance" | "result" | "site-relation" | "object-amount-material" | "prime" | "amount-duration" | "object-duration" | "object-time" | "separable-object-relation" | "relation-duration" | "leave-duration" | "duration" | "activity";
|
|
698
|
+
export type MedicationInstructionActionArgumentParser = "default" | "container-activity" | "theme-destination-amount" | "object-amount-material" | "amount-duration" | "object-duration" | "object-time" | "mix-substance" | "result" | "site" | "site-relation" | "duration" | "bare-duration" | "preposed-duration" | "duration-activity" | "activity";
|
|
699
|
+
export type MedicationInstructionActionRealizer = "default" | "source-faithful" | "container-activity" | "theme-destination-amount" | "mix-substance" | "result" | "site-relation" | "object-amount-material" | "prime" | "amount-duration" | "object-duration" | "object-time" | "separable-object-relation" | "relation-duration" | "leave-duration" | "duration" | "duration-activity" | "activity";
|
|
691
700
|
export interface MedicationInstructionActionContextualCodingRule {
|
|
692
701
|
whenArgument: {
|
|
693
702
|
role?: AdviceArgumentRole;
|
|
@@ -728,6 +737,8 @@ export interface MedicationInstructionActionDefinition {
|
|
|
728
737
|
realizerConfig?: {
|
|
729
738
|
thaiFallbackObject?: string;
|
|
730
739
|
thaiSuppressActivityConcepts?: string[];
|
|
740
|
+
/** Thai can omit selected site concepts already lexicalized by the verb (e.g. สระผม + hair). */
|
|
741
|
+
thaiSuppressSiteConcepts?: string[];
|
|
731
742
|
/** Thai can omit an otherwise generic medication object for this action (e.g. รับประทานหลังอาหาร). */
|
|
732
743
|
thaiImplicitMedicationObject?: boolean;
|
|
733
744
|
/** English realizes the anatomical site as the verb's direct object instead of `to/at <site>`. */
|
|
@@ -740,6 +751,8 @@ export interface MedicationInstructionActionDefinition {
|
|
|
740
751
|
nextConcepts?: string[];
|
|
741
752
|
}>;
|
|
742
753
|
continuationAfterRelations?: string[];
|
|
754
|
+
/** Preferred relation semantic classes used to resolve lexically ambiguous relation surfaces. */
|
|
755
|
+
preferredRelationSemanticClasses?: string[];
|
|
743
756
|
/** Exact coding for FHIR Dosage.method when this action can head administration. */
|
|
744
757
|
administrationMethod?: FhirCoding;
|
|
745
758
|
/** Route candidate licensed by the action surface itself (e.g. take -> oral). */
|
|
@@ -982,9 +995,29 @@ export interface CanonicalMethodExpr {
|
|
|
982
995
|
coding?: FhirCoding;
|
|
983
996
|
evidence?: CanonicalEvidence[];
|
|
984
997
|
}
|
|
998
|
+
export interface CanonicalOccurrenceCapExpr {
|
|
999
|
+
max: number;
|
|
1000
|
+
period: number;
|
|
1001
|
+
periodUnit: FhirPeriodUnit;
|
|
1002
|
+
}
|
|
1003
|
+
export interface CanonicalActivityTimingExpr {
|
|
1004
|
+
relation: "before" | "after";
|
|
1005
|
+
activity: {
|
|
1006
|
+
text: string;
|
|
1007
|
+
i18n?: Record<string, string>;
|
|
1008
|
+
coding?: FhirCoding;
|
|
1009
|
+
};
|
|
1010
|
+
/** Exact offset from the activity in minutes. */
|
|
1011
|
+
offset?: number;
|
|
1012
|
+
/** Minimum offset from the activity in minutes. */
|
|
1013
|
+
offsetMin?: number;
|
|
1014
|
+
/** Maximum offset from the activity in minutes. */
|
|
1015
|
+
offsetMax?: number;
|
|
1016
|
+
}
|
|
985
1017
|
export interface CanonicalScheduleExpr {
|
|
986
1018
|
timingCode?: string;
|
|
987
1019
|
count?: number;
|
|
1020
|
+
countMax?: number;
|
|
988
1021
|
duration?: number;
|
|
989
1022
|
durationMax?: number;
|
|
990
1023
|
durationUnit?: FhirPeriodUnit;
|
|
@@ -1002,6 +1035,8 @@ export interface CanonicalScheduleExpr {
|
|
|
1002
1035
|
dayOfWeek?: FhirDayOfWeek[];
|
|
1003
1036
|
when?: EventTiming[];
|
|
1004
1037
|
timeOfDay?: string[];
|
|
1038
|
+
activityTiming?: CanonicalActivityTimingExpr[];
|
|
1039
|
+
occurrenceCap?: CanonicalOccurrenceCapExpr;
|
|
1005
1040
|
evidence?: CanonicalEvidence[];
|
|
1006
1041
|
}
|
|
1007
1042
|
export interface CanonicalPrnReasonExpr {
|
|
@@ -1009,6 +1044,8 @@ export interface CanonicalPrnReasonExpr {
|
|
|
1009
1044
|
i18n?: Record<string, string>;
|
|
1010
1045
|
coding?: FhirCoding;
|
|
1011
1046
|
spatialRelation?: BodySiteSpatialRelation;
|
|
1047
|
+
/** Clinical trigger phase qualifying this PRN reason, e.g. symptom onset. */
|
|
1048
|
+
triggerPhase?: "onset";
|
|
1012
1049
|
}
|
|
1013
1050
|
export interface CanonicalPrnExpr {
|
|
1014
1051
|
enabled: boolean;
|
|
@@ -1018,6 +1055,7 @@ export interface CanonicalPrnExpr {
|
|
|
1018
1055
|
}
|
|
1019
1056
|
export interface CanonicalAdditionalInstructionExpr {
|
|
1020
1057
|
text?: string;
|
|
1058
|
+
i18n?: Record<string, string>;
|
|
1021
1059
|
coding?: FhirCoding;
|
|
1022
1060
|
frames?: AdviceFrame[];
|
|
1023
1061
|
evidence?: CanonicalEvidence[];
|
|
@@ -1239,6 +1277,8 @@ export interface NextDueDoseOptions {
|
|
|
1239
1277
|
orderedAt?: Date | string;
|
|
1240
1278
|
limit?: number;
|
|
1241
1279
|
priorCount?: number;
|
|
1280
|
+
/** Actual prior administration timestamps used for per-period occurrence caps. */
|
|
1281
|
+
priorDoseTimes?: Array<Date | string>;
|
|
1242
1282
|
timeZone?: string;
|
|
1243
1283
|
eventClock?: EventClockMap;
|
|
1244
1284
|
mealOffsets?: MealOffsetMap;
|