ezmedicationinput 0.1.58 → 0.1.59
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-locale-adapter.d.ts +19 -0
- package/dist/body-site-context-terminology.d.ts +5 -0
- package/dist/hpsg/lexical-classes.d.ts +13 -7
- package/dist/index.cjs +10641 -8574
- package/dist/index.d.ts +12 -0
- package/dist/index.js +10627 -8574
- package/dist/instruction-action-locale-adapter.d.ts +40 -0
- package/dist/instruction-action-terminology.d.ts +2 -0
- package/dist/lexer/locale.d.ts +9 -1
- package/dist/lexer/locales/th.d.ts +8 -0
- package/dist/lexer/surface-segmenter.d.ts +17 -0
- package/dist/locale-detection.d.ts +9 -0
- package/dist/locale-realization.d.ts +13 -0
- package/dist/localization.d.ts +8 -0
- package/dist/relation-terminology.d.ts +2 -1
- package/dist/suggest-locale-adapter.d.ts +31 -0
- package/dist/types.d.ts +19 -19
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AdviceArgument, AdviceFrame, MedicationInstructionActionDefinition, MedicationInstructionActionRealizer } from "./types";
|
|
2
|
+
export interface InstructionActionRealizationInput {
|
|
3
|
+
frame: AdviceFrame;
|
|
4
|
+
locale: string;
|
|
5
|
+
label: string;
|
|
6
|
+
amount?: string;
|
|
7
|
+
theme?: string;
|
|
8
|
+
container?: string;
|
|
9
|
+
destination?: string;
|
|
10
|
+
site?: string;
|
|
11
|
+
substance?: string;
|
|
12
|
+
result?: string;
|
|
13
|
+
activity?: string;
|
|
14
|
+
time?: string;
|
|
15
|
+
duration?: string;
|
|
16
|
+
material?: string;
|
|
17
|
+
manner?: string;
|
|
18
|
+
realizerConfig?: MedicationInstructionActionDefinition["realizerConfig"];
|
|
19
|
+
definition?: MedicationInstructionActionDefinition;
|
|
20
|
+
translateArgumentConcept: (arg: AdviceArgument) => string;
|
|
21
|
+
translateQuantity: (quantity: NonNullable<AdviceArgument["quantity"]>) => string;
|
|
22
|
+
}
|
|
23
|
+
export interface InstructionActionLocaleAdapter {
|
|
24
|
+
locale: string;
|
|
25
|
+
render(realizer: MedicationInstructionActionRealizer, input: InstructionActionRealizationInput): string | undefined;
|
|
26
|
+
renderNegated(input: InstructionActionRealizationInput): string;
|
|
27
|
+
applyPositiveModality(text: string, frame: AdviceFrame): string;
|
|
28
|
+
parseConditionPersistence(body: string): {
|
|
29
|
+
body: string;
|
|
30
|
+
persists: boolean;
|
|
31
|
+
};
|
|
32
|
+
renderConditionBody(base: string, conditionForm: string | undefined, persists: boolean): string;
|
|
33
|
+
joinConditionLead(lead: string, body: string): string;
|
|
34
|
+
conditionalContinuation(text: string, imperative: boolean): string;
|
|
35
|
+
postposedCondition(text: string): string;
|
|
36
|
+
sequenceSeparator(): string;
|
|
37
|
+
continuationText(text: string, understood: boolean): string;
|
|
38
|
+
}
|
|
39
|
+
export declare function registerInstructionActionLocaleAdapter(adapter: InstructionActionLocaleAdapter): void;
|
|
40
|
+
export declare function getInstructionActionLocaleAdapter(locale: string): InstructionActionLocaleAdapter;
|
|
@@ -19,6 +19,8 @@ export interface MedicationInstructionActionCodeSystem {
|
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
21
21
|
export declare function normalizeActionSurface(value: string): string;
|
|
22
|
+
export declare function cloneMedicationInstructionActionRealizerConfig(config: MedicationInstructionActionDefinition["realizerConfig"]): MedicationInstructionActionDefinition["realizerConfig"];
|
|
23
|
+
export declare function medicationInstructionActionLocaleRealizerConfig(config: MedicationInstructionActionDefinition["realizerConfig"], locale: string): import("./types").MedicationInstructionActionLocaleRealizerConfig | undefined;
|
|
22
24
|
export declare function resolveMedicationInstructionSeparableAction(lead: string, particle: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
|
|
23
25
|
export declare function medicationInstructionActionIsSafetyScopeTarget(surface: string, options?: ParseOptions): boolean;
|
|
24
26
|
export declare function resolveMedicationInstructionAction(surface: string, options?: ParseOptions): MedicationInstructionActionDefinition | undefined;
|
package/dist/lexer/locale.d.ts
CHANGED
|
@@ -3,6 +3,14 @@ export interface MedicationLocaleLexeme {
|
|
|
3
3
|
surface: string;
|
|
4
4
|
canonical: string;
|
|
5
5
|
}
|
|
6
|
+
export interface MedicationLexerLocalePack {
|
|
7
|
+
locale: string;
|
|
8
|
+
apply(tokens: readonly LexToken[], input: string): LexToken[];
|
|
9
|
+
listLexemes?(): MedicationLocaleLexeme[];
|
|
10
|
+
}
|
|
11
|
+
export declare function registerMedicationLexerLocalePack(pack: MedicationLexerLocalePack): void;
|
|
12
|
+
export declare function medicationLexerLocalePackRevision(): number;
|
|
13
|
+
export declare function getMedicationLexerLocalePack(locale: string): MedicationLexerLocalePack | undefined;
|
|
14
|
+
export declare function applyLocaleLexicon(tokens: readonly LexToken[], input: string, locale?: string): LexToken[];
|
|
6
15
|
/** Parser-owned locale lexemes for bounded autocomplete/discovery surfaces. */
|
|
7
16
|
export declare function listMedicationLocaleLexemes(locale: string): MedicationLocaleLexeme[];
|
|
8
|
-
export declare function applyLocaleLexicon(tokens: readonly LexToken[], input: string): LexToken[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LexToken } from "../token-types";
|
|
2
|
+
export interface MedicationLocaleLexeme {
|
|
3
|
+
surface: string;
|
|
4
|
+
canonical: string;
|
|
5
|
+
}
|
|
6
|
+
/** Parser-owned locale lexemes for bounded autocomplete/discovery surfaces. */
|
|
7
|
+
export declare function listThaiMedicationLocaleLexemes(locale: string): MedicationLocaleLexeme[];
|
|
8
|
+
export declare function applyThaiLocaleLexicon(tokens: readonly LexToken[], input: string): LexToken[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface MedicationSurfaceSegment {
|
|
2
|
+
segment: string;
|
|
3
|
+
index: number;
|
|
4
|
+
}
|
|
5
|
+
export interface MedicationSurfaceSegmenter {
|
|
6
|
+
locale: string;
|
|
7
|
+
script: RegExp;
|
|
8
|
+
segment(input: string): Iterable<MedicationSurfaceSegment>;
|
|
9
|
+
}
|
|
10
|
+
export declare function registerMedicationSurfaceSegmenter(segmenter: MedicationSurfaceSegmenter): void;
|
|
11
|
+
export declare function listMedicationSurfaceSegmenters(): MedicationSurfaceSegmenter[];
|
|
12
|
+
export declare function registerIntlMedicationSurfaceSegmenter(locale: string, script: RegExp): void;
|
|
13
|
+
export declare function splitMedicationScriptRuns(value: string): Array<{
|
|
14
|
+
text: string;
|
|
15
|
+
offset: number;
|
|
16
|
+
segmenter?: MedicationSurfaceSegmenter;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface MedicationLocaleDetector {
|
|
2
|
+
locale: string;
|
|
3
|
+
test(text: string): boolean;
|
|
4
|
+
priority?: number;
|
|
5
|
+
joinsAdjacentSourceTokens?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function registerMedicationLocaleDetector(detector: MedicationLocaleDetector): void;
|
|
8
|
+
export declare function shouldJoinAdjacentSourceTokens(left: string, right: string): boolean;
|
|
9
|
+
export declare function inferMedicationLocale(text: string, fallback?: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface LocaleRealizationProfile {
|
|
2
|
+
tokenSeparator: string;
|
|
3
|
+
quantitySeparator: string;
|
|
4
|
+
durationPrefix: string;
|
|
5
|
+
resultFormationPrefix: string;
|
|
6
|
+
materialPrefix: string;
|
|
7
|
+
amountMaterialDestinationTemplate: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function localeRealizationProfile(locale: string | undefined): LocaleRealizationProfile;
|
|
10
|
+
export declare function joinLocalizedTokens(locale: string | undefined, parts: Array<string | undefined>): string;
|
|
11
|
+
export declare function localizedTimeArgument(value: string, locale: string | undefined): string | undefined;
|
|
12
|
+
export declare function localizedRecordValue(record: Record<string, string> | undefined, locale: string | undefined): string | undefined;
|
|
13
|
+
export declare function renderLocaleTemplate(template: string, values: Record<string, string | undefined>): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type I18nRecord = Record<string, string>;
|
|
2
|
+
export declare function normalizeLocaleTag(locale: string | undefined): string | undefined;
|
|
3
|
+
export declare function baseLanguageTag(locale: string | undefined): string | undefined;
|
|
4
|
+
export declare function localeFallbackChain(locale: string | undefined): string[];
|
|
5
|
+
export declare function localizedValue(i18n: Record<string, string | undefined> | undefined, locale: string | undefined): string | undefined;
|
|
6
|
+
export declare function localizedConfig<T>(configs: Record<string, T> | undefined, locale: string | undefined, fallbackLocale?: string): T | undefined;
|
|
7
|
+
export declare function localeKeys(...records: Array<Record<string, unknown> | undefined>): string[];
|
|
8
|
+
export declare function composeLocalizedRecords(records: Array<I18nRecord | undefined>, compose: (values: string[], locale: string) => string | undefined): I18nRecord | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdviceRelation, FhirCoding } from "./types";
|
|
2
|
-
type SupportedLocale =
|
|
2
|
+
type SupportedLocale = string;
|
|
3
3
|
declare const BODY_SITE_LOCATIVE_RELATION_VALUES: readonly ["above", "around", "behind", "below", "beneath", "under", "inside", "near", "outside", "between", "along"];
|
|
4
4
|
export type BodySiteLocativeRelation = typeof BODY_SITE_LOCATIVE_RELATION_VALUES[number];
|
|
5
5
|
export type BodySiteRelationRenderStrategy = "prefix" | "partitive" | "suffix";
|
|
@@ -79,6 +79,7 @@ export declare function relationHasGrammarFeature(relation: AdviceRelation | und
|
|
|
79
79
|
export declare function getUniqueAdviceRelationByGrammarFeature(feature: keyof AdviceRelationGrammarFeatures): AdviceRelation | undefined;
|
|
80
80
|
export declare function relationHasSemanticClass(relation: AdviceRelation | undefined, semanticClass: string): boolean;
|
|
81
81
|
export declare function getAdviceRelationSurfaceForms(relation: AdviceRelation): readonly string[];
|
|
82
|
+
export declare function getAdviceRelationRealizations(relation: AdviceRelation | undefined, profile?: string): Record<string, string> | undefined;
|
|
82
83
|
export declare function localizeAdviceRelation(relation: AdviceRelation | undefined, locale: string, profile?: string): string | undefined;
|
|
83
84
|
export declare function listAdviceRelationDefinitions(): AdviceRelationDefinition[];
|
|
84
85
|
export declare function getAdviceRelationCanonicalSetByGrammarFeature(feature: keyof AdviceRelationGrammarFeatures): ReadonlySet<string>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RouteCode } from "./types";
|
|
2
|
+
export type SuggestLocaleLexemeResolver = (canonical: string, preferred?: string) => string | undefined;
|
|
3
|
+
export interface SuggestLocaleUnitRoutePair {
|
|
4
|
+
unit: string;
|
|
5
|
+
route: string;
|
|
6
|
+
}
|
|
7
|
+
export interface SuggestLocaleAdapter {
|
|
8
|
+
locale: string;
|
|
9
|
+
acceptsSurface(surface: string): boolean;
|
|
10
|
+
unitSuggestionUsesLocaleLexemes: boolean;
|
|
11
|
+
includeEyeAbbreviations: boolean;
|
|
12
|
+
preferRawSiteMapSurfaces: boolean;
|
|
13
|
+
compactRelationSuggestions: boolean;
|
|
14
|
+
routeSuggestionsEnabled: boolean;
|
|
15
|
+
tailLexemeSuggestionsEnabled: boolean;
|
|
16
|
+
matchBodySiteInput(input: string): {
|
|
17
|
+
lead: string;
|
|
18
|
+
partial: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
joinBodySite(lead: string, surface: string): string;
|
|
21
|
+
directPrnCompletion(input: string, reasons: string[], limit: number): string[] | undefined;
|
|
22
|
+
buildUnitCandidate(prefix: string, dose: string, surface: string, route: string): string;
|
|
23
|
+
unitSurface(unit: string, lexeme: SuggestLocaleLexemeResolver): string;
|
|
24
|
+
defaultDirections(pairs: SuggestLocaleUnitRoutePair[], limit: number, lexeme: SuggestLocaleLexemeResolver, prnReasons: () => string[]): string[];
|
|
25
|
+
trajectoryScheduleSuffixes(routeCode: RouteCode | undefined, lexeme: SuggestLocaleLexemeResolver): string[];
|
|
26
|
+
preferredPrnReasons(topical: boolean): string[];
|
|
27
|
+
appendAffectedArea(base: string, directSiteObject: boolean): string;
|
|
28
|
+
appendPrn(base: string, reason: string): string;
|
|
29
|
+
}
|
|
30
|
+
export declare function registerSuggestLocaleAdapter(adapter: SuggestLocaleAdapter): void;
|
|
31
|
+
export declare function getSuggestLocaleAdapter(locale: string): SuggestLocaleAdapter;
|
package/dist/types.d.ts
CHANGED
|
@@ -543,13 +543,7 @@ export interface AdviceFrame {
|
|
|
543
543
|
i18n?: Record<string, string>;
|
|
544
544
|
/** Persisted realization profile so caller-owned actions remain deterministic after parse/FHIR round-trip. */
|
|
545
545
|
realizer?: MedicationInstructionActionRealizer;
|
|
546
|
-
realizerConfig?:
|
|
547
|
-
thaiFallbackObject?: string;
|
|
548
|
-
thaiSuppressActivityConcepts?: string[];
|
|
549
|
-
thaiSuppressSiteConcepts?: string[];
|
|
550
|
-
thaiImplicitMedicationObject?: boolean;
|
|
551
|
-
englishDirectSiteObject?: boolean;
|
|
552
|
-
};
|
|
546
|
+
realizerConfig?: MedicationInstructionActionRealizerConfig;
|
|
553
547
|
/** Internal/custom action coding followed by any trustworthy external mappings. */
|
|
554
548
|
codings?: FhirCoding[];
|
|
555
549
|
};
|
|
@@ -695,8 +689,8 @@ export interface SmartMealExpansionScope {
|
|
|
695
689
|
*/
|
|
696
690
|
excludeDosageForms?: string[];
|
|
697
691
|
}
|
|
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";
|
|
692
|
+
export type MedicationInstructionActionArgumentParser = "default" | "container-activity" | "theme-destination-amount" | "object-amount-material" | "amount-material-destination" | "amount-duration" | "object-duration" | "object-time" | "mix-substance" | "result" | "site" | "site-relation" | "duration" | "bare-duration" | "preposed-duration" | "duration-activity" | "activity";
|
|
693
|
+
export type MedicationInstructionActionRealizer = "default" | "source-faithful" | "container-activity" | "theme-destination-amount" | "mix-substance" | "result" | "site-relation" | "object-amount-material" | "amount-material-destination" | "prime" | "amount-duration" | "object-duration" | "object-time" | "separable-object-relation" | "relation-duration" | "leave-duration" | "duration" | "duration-activity" | "activity";
|
|
700
694
|
export interface MedicationInstructionActionContextualCodingRule {
|
|
701
695
|
whenArgument: {
|
|
702
696
|
role?: AdviceArgumentRole;
|
|
@@ -706,6 +700,17 @@ export interface MedicationInstructionActionContextualCodingRule {
|
|
|
706
700
|
};
|
|
707
701
|
coding: FhirCoding;
|
|
708
702
|
}
|
|
703
|
+
export interface MedicationInstructionActionLocaleRealizerConfig {
|
|
704
|
+
fallbackObject?: string;
|
|
705
|
+
suppressActivityConcepts?: string[];
|
|
706
|
+
suppressSiteConcepts?: string[];
|
|
707
|
+
implicitMedicationObject?: boolean;
|
|
708
|
+
directSiteObject?: boolean;
|
|
709
|
+
}
|
|
710
|
+
export interface MedicationInstructionActionRealizerConfig {
|
|
711
|
+
/** Locale-specific realization behavior keyed by BCP-47-ish language tag. */
|
|
712
|
+
locales?: Record<string, MedicationInstructionActionLocaleRealizerConfig>;
|
|
713
|
+
}
|
|
709
714
|
export interface MedicationInstructionActionDefinition {
|
|
710
715
|
/** Stable semantic action code. */
|
|
711
716
|
code: string;
|
|
@@ -717,6 +722,8 @@ export interface MedicationInstructionActionDefinition {
|
|
|
717
722
|
roundtripI18n?: Record<string, string>;
|
|
718
723
|
/** Surface forms that should resolve to this action. */
|
|
719
724
|
aliases?: string[];
|
|
725
|
+
/** Locale-specific parser lexemes. Display translation belongs in `i18n`; parsing aliases are explicit. */
|
|
726
|
+
localeAliases?: Record<string, string[]>;
|
|
720
727
|
/** Discontinuous surface forms such as Thai `เอา X ออก` (remove X). */
|
|
721
728
|
separableAliases?: Array<{
|
|
722
729
|
lead: string;
|
|
@@ -734,16 +741,7 @@ export interface MedicationInstructionActionDefinition {
|
|
|
734
741
|
implicitMatchedConcept?: string;
|
|
735
742
|
implicitMatchedRole?: AdviceArgumentRole;
|
|
736
743
|
};
|
|
737
|
-
realizerConfig?:
|
|
738
|
-
thaiFallbackObject?: string;
|
|
739
|
-
thaiSuppressActivityConcepts?: string[];
|
|
740
|
-
/** Thai can omit selected site concepts already lexicalized by the verb (e.g. สระผม + hair). */
|
|
741
|
-
thaiSuppressSiteConcepts?: string[];
|
|
742
|
-
/** Thai can omit an otherwise generic medication object for this action (e.g. รับประทานหลังอาหาร). */
|
|
743
|
-
thaiImplicitMedicationObject?: boolean;
|
|
744
|
-
/** English realizes the anatomical site as the verb's direct object instead of `to/at <site>`. */
|
|
745
|
-
englishDirectSiteObject?: boolean;
|
|
746
|
-
};
|
|
744
|
+
realizerConfig?: MedicationInstructionActionRealizerConfig;
|
|
747
745
|
continuationLicenses?: Array<{
|
|
748
746
|
candidateAction: string;
|
|
749
747
|
previousConcepts?: string[];
|
|
@@ -788,6 +786,8 @@ export interface MedicationInstructionConceptDefinition {
|
|
|
788
786
|
display: string;
|
|
789
787
|
i18n?: Record<string, string>;
|
|
790
788
|
aliases?: string[];
|
|
789
|
+
/** Locale-specific parser lexemes; display translations are not implicitly grammar-active. */
|
|
790
|
+
localeAliases?: Record<string, string[]>;
|
|
791
791
|
coding?: FhirCoding;
|
|
792
792
|
externalCodings?: FhirCoding[];
|
|
793
793
|
}
|