ezmedicationinput 0.1.44 → 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.
Files changed (75) hide show
  1. package/README.md +265 -2
  2. package/dist/body-site-grammar.d.ts +39 -0
  3. package/dist/body-site-lookup.d.ts +84 -0
  4. package/dist/body-site-resolution.d.ts +9 -0
  5. package/dist/body-site-spatial.d.ts +6 -0
  6. package/dist/clause-tail-grammar.d.ts +18 -0
  7. package/dist/fhir-translations.d.ts +4 -1
  8. package/dist/fhir.d.ts +9 -1
  9. package/dist/hpsg/chart.d.ts +14 -0
  10. package/dist/hpsg/clause-parser.d.ts +3 -0
  11. package/dist/hpsg/defaults.d.ts +9 -0
  12. package/dist/hpsg/lexical-classes.d.ts +89 -0
  13. package/dist/hpsg/method-lexicon.d.ts +13 -0
  14. package/dist/hpsg/projection.d.ts +12 -0
  15. package/dist/hpsg/rule-context.d.ts +32 -0
  16. package/dist/hpsg/rules/core-rules.d.ts +8 -0
  17. package/dist/hpsg/rules/instruction-rules.d.ts +4 -0
  18. package/dist/hpsg/rules/prn-rules.d.ts +3 -0
  19. package/dist/hpsg/rules/product-route.d.ts +2 -0
  20. package/dist/hpsg/rules/site-rules.d.ts +4 -0
  21. package/dist/hpsg/rules/timing-rules.d.ts +12 -0
  22. package/dist/hpsg/segmenter.d.ts +6 -0
  23. package/dist/hpsg/signature.d.ts +116 -0
  24. package/dist/hpsg/timing-lexicon.d.ts +31 -0
  25. package/dist/hpsg/unification.d.ts +8 -0
  26. package/dist/index.cjs +21052 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.js +20865 -680
  29. package/dist/maps.d.ts +4 -2
  30. package/dist/parser-state.d.ts +4 -1
  31. package/dist/parser.d.ts +3 -13
  32. package/dist/prn-reason-coding.d.ts +8 -0
  33. package/dist/site-coding.d.ts +5 -0
  34. package/dist/snomed-postcoordination.d.ts +25 -0
  35. package/dist/snomed.d.ts +13 -0
  36. package/dist/types.d.ts +61 -16
  37. package/dist/unit-lexicon.d.ts +4 -0
  38. package/package.json +17 -6
  39. package/dist/advice-rules.json +0 -772
  40. package/dist/advice-terminology.json +0 -104
  41. package/dist/advice.js +0 -1375
  42. package/dist/context.js +0 -50
  43. package/dist/event-trigger.d.ts +0 -14
  44. package/dist/event-trigger.js +0 -501
  45. package/dist/fhir-translations.js +0 -117
  46. package/dist/fhir.js +0 -693
  47. package/dist/format.js +0 -1034
  48. package/dist/i18n.js +0 -1341
  49. package/dist/internal-types.d.ts +0 -60
  50. package/dist/internal-types.js +0 -2
  51. package/dist/ir.js +0 -178
  52. package/dist/lexer/lex.js +0 -401
  53. package/dist/lexer/meaning.js +0 -619
  54. package/dist/lexer/surface.js +0 -62
  55. package/dist/lexer/token-types.js +0 -19
  56. package/dist/maps.js +0 -2226
  57. package/dist/package.json +0 -3
  58. package/dist/parser-state.js +0 -441
  59. package/dist/parser.js +0 -5631
  60. package/dist/prn.js +0 -59
  61. package/dist/safety.js +0 -15
  62. package/dist/schedule.js +0 -1636
  63. package/dist/segment.d.ts +0 -6
  64. package/dist/segment.js +0 -203
  65. package/dist/site-phrases.js +0 -344
  66. package/dist/suggest.js +0 -907
  67. package/dist/timing-summary.js +0 -138
  68. package/dist/types.js +0 -276
  69. package/dist/utils/array.js +0 -11
  70. package/dist/utils/enum.d.ts +0 -2
  71. package/dist/utils/enum.js +0 -7
  72. package/dist/utils/object.js +0 -34
  73. package/dist/utils/strength.js +0 -149
  74. package/dist/utils/text.js +0 -48
  75. package/dist/utils/units.js +0 -82
@@ -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,3 @@
1
+ import { HpsgClauseContext } from "../rule-context";
2
+ import { HpsgLexicalRule } from "../signature";
3
+ export declare function prnLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
@@ -0,0 +1,2 @@
1
+ import { RouteCode } from "../../types";
2
+ export declare function productRouteHint(phrase: string | undefined): RouteCode | undefined;
@@ -0,0 +1,4 @@
1
+ import { HpsgClauseContext } from "../rule-context";
2
+ import { HpsgLexicalRule } from "../signature";
3
+ export declare function siteLexicalRule(): HpsgLexicalRule<HpsgClauseContext>;
4
+ export declare function bareSiteLexicalRule(): 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,6 @@
1
+ export interface HpsgSigSegment {
2
+ text: string;
3
+ start: number;
4
+ end: number;
5
+ }
6
+ export declare function parseSigSegments(input: string): HpsgSigSegment[];
@@ -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;