ezmedicationinput 0.1.45 → 0.1.46
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 +265 -2
- package/dist/body-site-grammar.d.ts +39 -0
- package/dist/body-site-lookup.d.ts +84 -0
- package/dist/body-site-resolution.d.ts +9 -0
- package/dist/body-site-spatial.d.ts +6 -0
- package/dist/clause-tail-grammar.d.ts +18 -0
- package/dist/fhir-translations.d.ts +4 -1
- package/dist/fhir.d.ts +9 -1
- package/dist/hpsg/chart.d.ts +14 -0
- package/dist/hpsg/clause-parser.d.ts +3 -0
- package/dist/hpsg/defaults.d.ts +9 -0
- package/dist/hpsg/lexical-classes.d.ts +89 -0
- package/dist/hpsg/method-lexicon.d.ts +13 -0
- package/dist/hpsg/projection.d.ts +12 -0
- package/dist/hpsg/rule-context.d.ts +32 -0
- package/dist/hpsg/rules/core-rules.d.ts +8 -0
- package/dist/hpsg/rules/instruction-rules.d.ts +4 -0
- package/dist/hpsg/rules/prn-rules.d.ts +3 -0
- package/dist/hpsg/rules/product-route.d.ts +2 -0
- package/dist/hpsg/rules/site-rules.d.ts +4 -0
- package/dist/hpsg/rules/timing-rules.d.ts +12 -0
- package/dist/hpsg/segmenter.d.ts +6 -0
- package/dist/hpsg/signature.d.ts +116 -0
- package/dist/hpsg/timing-lexicon.d.ts +31 -0
- package/dist/hpsg/unification.d.ts +8 -0
- package/dist/index.cjs +14338 -12128
- package/dist/index.d.ts +5 -0
- package/dist/index.js +14299 -12128
- package/dist/maps.d.ts +4 -2
- package/dist/parser-state.d.ts +4 -1
- package/dist/parser.d.ts +3 -13
- package/dist/prn-reason-coding.d.ts +8 -0
- package/dist/site-coding.d.ts +5 -0
- package/dist/snomed-postcoordination.d.ts +25 -0
- package/dist/snomed.d.ts +13 -0
- package/dist/types.d.ts +61 -16
- package/dist/unit-lexicon.d.ts +4 -0
- package/package.json +1 -1
- package/dist/segment.d.ts +0 -6
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Token, ParserState } from "../parser-state";
|
|
2
|
+
import { ParseOptions } from "../types";
|
|
3
|
+
import { HpsgLexicalRule } from "./signature";
|
|
4
|
+
import { HpsgProjectionDeps } from "./projection";
|
|
5
|
+
import { HpsgUnificationContext } from "./unification";
|
|
6
|
+
export interface HpsgClauseContext {
|
|
7
|
+
state: ParserState;
|
|
8
|
+
tokens: Token[];
|
|
9
|
+
options?: ParseOptions;
|
|
10
|
+
limit: number;
|
|
11
|
+
deps: HpsgProjectionDeps & HpsgUnificationContext;
|
|
12
|
+
project?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function normalizeTokenLower(token: Token): string;
|
|
15
|
+
export declare function isPunctuation(lower: string): boolean;
|
|
16
|
+
export declare function isClockLikeLower(lower: string): boolean;
|
|
17
|
+
export declare function isAmPmLower(lower: string): boolean;
|
|
18
|
+
export declare function isAnteMeridiemLower(lower: string): boolean;
|
|
19
|
+
export declare function isPostMeridiemLower(lower: string): boolean;
|
|
20
|
+
export declare function parseClockToken(token: Token | undefined, meridiemToken?: Token | undefined): {
|
|
21
|
+
value: string;
|
|
22
|
+
tokens: Token[];
|
|
23
|
+
} | undefined;
|
|
24
|
+
export declare function tokensAvailable(context: HpsgClauseContext, start: number, span: number): Token[] | undefined;
|
|
25
|
+
export declare function rangeFromTokens(tokens: Token[]): {
|
|
26
|
+
start: number;
|
|
27
|
+
end: number;
|
|
28
|
+
} | undefined;
|
|
29
|
+
export declare function splitByLexicalSeparators(text: string, separators: ReadonlySet<string>): string[];
|
|
30
|
+
export declare function hasLexicalSeparator(text: string, separators: ReadonlySet<string>): boolean;
|
|
31
|
+
export declare function joinTokenText(tokens: Token[]): string;
|
|
32
|
+
export declare function lexicalRule(id: string, match: HpsgLexicalRule<HpsgClauseContext>["match"]): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
+
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
export declare function methodLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
|
+
export declare function routeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
|
+
export declare function fillerLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
6
|
+
export declare function productLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
|
+
export declare function doseLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
8
|
+
export declare function connectorLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
+
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
export declare function workflowLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
|
+
export declare function instructionLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HpsgClauseContext } from "../rule-context";
|
|
2
|
+
import { HpsgLexicalRule } from "../signature";
|
|
3
|
+
export declare function multiplicativeDoseFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
4
|
+
export declare function compactIntervalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
5
|
+
export declare function separatedIntervalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
6
|
+
export declare function countFrequencyRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
7
|
+
export declare function timingLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
8
|
+
export declare function eventTimingPhraseRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
9
|
+
export declare function dayRangeLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
10
|
+
export declare function countAndDurationRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
11
|
+
export declare function timeOfDayRule(): HpsgLexicalRule<HpsgClauseContext>;
|
|
12
|
+
export declare function isScheduleLead(context: HpsgClauseContext, index: number): boolean;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { CanonicalDoseRange, CanonicalAdditionalInstructionExpr, BodySiteSpatialRelation, EventTiming, FhirCoding, FhirDayOfWeek, FhirPeriodUnit, FhirPrimitiveElement, RouteCode, PrnReasonLookupRequest, SiteCodeLookupRequest } from "../types";
|
|
2
|
+
import { Token } from "../parser-state";
|
|
3
|
+
export type HpsgType = "sign" | "word-sign" | "phrase-sign" | "clause-sign" | "method-sign" | "route-sign" | "site-sign" | "dose-sign" | "schedule-sign" | "prn-sign" | "instruction-sign" | "connector-sign";
|
|
4
|
+
export interface HpsgEvidence {
|
|
5
|
+
rule: string;
|
|
6
|
+
tokenIndices: number[];
|
|
7
|
+
}
|
|
8
|
+
export interface HpsgMethodFeature {
|
|
9
|
+
verb: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
textElement?: FhirPrimitiveElement;
|
|
12
|
+
coding?: FhirCoding;
|
|
13
|
+
}
|
|
14
|
+
export interface HpsgRouteFeature {
|
|
15
|
+
code: RouteCode;
|
|
16
|
+
text?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface HpsgSiteFeature {
|
|
19
|
+
text?: string;
|
|
20
|
+
source?: "abbreviation" | "text" | "selection" | "resolver";
|
|
21
|
+
coding?: FhirCoding;
|
|
22
|
+
spatialRelation?: BodySiteSpatialRelation;
|
|
23
|
+
lookupRequest?: SiteCodeLookupRequest;
|
|
24
|
+
}
|
|
25
|
+
export interface HpsgPrnFeature {
|
|
26
|
+
enabled: true;
|
|
27
|
+
reasonText?: string;
|
|
28
|
+
lookupRequest?: PrnReasonLookupRequest;
|
|
29
|
+
reasons?: Array<{
|
|
30
|
+
text: string;
|
|
31
|
+
lookupRequest?: PrnReasonLookupRequest;
|
|
32
|
+
}>;
|
|
33
|
+
lookupRequests?: PrnReasonLookupRequest[];
|
|
34
|
+
}
|
|
35
|
+
export interface HpsgInstructionFeature extends CanonicalAdditionalInstructionExpr {
|
|
36
|
+
}
|
|
37
|
+
export interface HpsgPatientInstructionFeature {
|
|
38
|
+
text: string;
|
|
39
|
+
}
|
|
40
|
+
export interface HpsgDoseFeature {
|
|
41
|
+
value?: number;
|
|
42
|
+
range?: CanonicalDoseRange;
|
|
43
|
+
unit?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface HpsgScheduleFeature {
|
|
46
|
+
timingCode?: string;
|
|
47
|
+
count?: number;
|
|
48
|
+
duration?: number;
|
|
49
|
+
durationMax?: number;
|
|
50
|
+
durationUnit?: FhirPeriodUnit;
|
|
51
|
+
frequency?: number;
|
|
52
|
+
frequencyMax?: number;
|
|
53
|
+
period?: number;
|
|
54
|
+
periodMax?: number;
|
|
55
|
+
periodUnit?: FhirPeriodUnit;
|
|
56
|
+
when?: EventTiming[];
|
|
57
|
+
dayOfWeek?: FhirDayOfWeek[];
|
|
58
|
+
timeOfDay?: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface HpsgSynsem {
|
|
61
|
+
head: {
|
|
62
|
+
method?: HpsgMethodFeature;
|
|
63
|
+
route?: HpsgRouteFeature;
|
|
64
|
+
dose?: HpsgDoseFeature;
|
|
65
|
+
schedule?: HpsgScheduleFeature;
|
|
66
|
+
};
|
|
67
|
+
valence: {
|
|
68
|
+
site?: HpsgSiteFeature;
|
|
69
|
+
prn?: HpsgPrnFeature;
|
|
70
|
+
instructions?: HpsgInstructionFeature[];
|
|
71
|
+
patientInstruction?: HpsgPatientInstructionFeature;
|
|
72
|
+
};
|
|
73
|
+
cont: {
|
|
74
|
+
clauseKind?: "administration";
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export interface HpsgSign {
|
|
78
|
+
type: HpsgType;
|
|
79
|
+
span: {
|
|
80
|
+
start: number;
|
|
81
|
+
end: number;
|
|
82
|
+
};
|
|
83
|
+
tokens: Token[];
|
|
84
|
+
synsem: HpsgSynsem;
|
|
85
|
+
consumedTokenIndices: number[];
|
|
86
|
+
siteTokenIndices?: number[];
|
|
87
|
+
warnings?: string[];
|
|
88
|
+
evidence: HpsgEvidence[];
|
|
89
|
+
score: number;
|
|
90
|
+
}
|
|
91
|
+
export interface HpsgLexicalRule<TContext> {
|
|
92
|
+
id: string;
|
|
93
|
+
type: HpsgType;
|
|
94
|
+
match(context: TContext, start: number): HpsgSign[];
|
|
95
|
+
}
|
|
96
|
+
export interface HpsgPhraseRule<TContext> {
|
|
97
|
+
id: string;
|
|
98
|
+
left?: HpsgType;
|
|
99
|
+
right?: HpsgType;
|
|
100
|
+
combine(context: TContext, left: HpsgSign, right: HpsgSign): HpsgSign | undefined;
|
|
101
|
+
}
|
|
102
|
+
export interface HpsgGrammar<TContext> {
|
|
103
|
+
lexicalRules: HpsgLexicalRule<TContext>[];
|
|
104
|
+
phraseRules: HpsgPhraseRule<TContext>[];
|
|
105
|
+
}
|
|
106
|
+
export declare function emptySynsem(): HpsgSynsem;
|
|
107
|
+
export declare function lexicalSign(args: {
|
|
108
|
+
type: HpsgType;
|
|
109
|
+
rule: string;
|
|
110
|
+
tokens: Token[];
|
|
111
|
+
synsem: HpsgSynsem;
|
|
112
|
+
consumedTokenIndices?: number[];
|
|
113
|
+
siteTokenIndices?: number[];
|
|
114
|
+
warnings?: string[];
|
|
115
|
+
score?: number;
|
|
116
|
+
}): HpsgSign;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ParserState } from "../parser-state";
|
|
2
|
+
import { FhirPeriodUnit } from "../types";
|
|
3
|
+
import { HpsgScheduleFeature } from "./signature";
|
|
4
|
+
export declare const EVERY_INTERVAL_TOKENS: Set<string>;
|
|
5
|
+
export declare const COUNT_MARKER_TOKENS: Set<string>;
|
|
6
|
+
export declare const COUNT_CONNECTOR_WORDS: Set<string>;
|
|
7
|
+
export declare const FREQUENCY_SIMPLE_WORDS: Record<string, number>;
|
|
8
|
+
export declare const FREQUENCY_NUMBER_WORDS: Record<string, number>;
|
|
9
|
+
export declare const FREQUENCY_TIMES_WORDS: Set<string>;
|
|
10
|
+
export declare const FREQUENCY_CONNECTOR_WORDS: Set<string>;
|
|
11
|
+
export declare function normalizePeriodValue(value: number, unit: FhirPeriodUnit): {
|
|
12
|
+
value: number;
|
|
13
|
+
unit: FhirPeriodUnit;
|
|
14
|
+
};
|
|
15
|
+
export declare function normalizePeriodRange(low: number, high: number, unit: FhirPeriodUnit): {
|
|
16
|
+
low: number;
|
|
17
|
+
high: number;
|
|
18
|
+
unit: FhirPeriodUnit;
|
|
19
|
+
};
|
|
20
|
+
export declare function periodUnitSuffix(unit: FhirPeriodUnit): string | undefined;
|
|
21
|
+
export declare function applyPeriod(internal: ParserState, period: number, unit: FhirPeriodUnit): void;
|
|
22
|
+
export declare function buildPeriodScheduleFeature(period: number, unit: FhirPeriodUnit): HpsgScheduleFeature;
|
|
23
|
+
export declare function mapIntervalUnit(token: string): FhirPeriodUnit.Minute | FhirPeriodUnit.Hour | FhirPeriodUnit.Day | FhirPeriodUnit.Week | FhirPeriodUnit.Month | undefined;
|
|
24
|
+
export declare function mapFrequencyAdverb(token: string): FhirPeriodUnit | undefined;
|
|
25
|
+
export declare function parseNumericRange(token: string): {
|
|
26
|
+
low: number;
|
|
27
|
+
high: number;
|
|
28
|
+
} | undefined;
|
|
29
|
+
export declare function normalizeCountLimitValue(value: number | undefined): number | undefined;
|
|
30
|
+
export declare function applyDurationLimit(internal: ParserState, value: number | undefined, unit: FhirPeriodUnit | undefined, max?: number): boolean;
|
|
31
|
+
export declare function buildDurationScheduleFeature(value: number | undefined, unit: FhirPeriodUnit | undefined, max?: number): HpsgScheduleFeature | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HpsgSign, HpsgSynsem } from "./signature";
|
|
2
|
+
import { RouteCode } from "../types";
|
|
3
|
+
export interface HpsgUnificationContext {
|
|
4
|
+
normalizeSiteText(text: string): string;
|
|
5
|
+
isCompatibleRouteRefinement(current: RouteCode | undefined, next: RouteCode): boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function unifySynsem(left: HpsgSynsem, right: HpsgSynsem, context: HpsgUnificationContext): HpsgSynsem | undefined;
|
|
8
|
+
export declare function combineSigns(left: HpsgSign, right: HpsgSign, context: HpsgUnificationContext, rule: string): HpsgSign | undefined;
|