ezmedicationinput 0.1.0
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 +153 -0
- package/dist/context.d.ts +3 -0
- package/dist/context.js +29 -0
- package/dist/fhir.d.ts +4 -0
- package/dist/fhir.js +158 -0
- package/dist/format.d.ts +2 -0
- package/dist/format.js +322 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +57 -0
- package/dist/maps.d.ts +51 -0
- package/dist/maps.js +729 -0
- package/dist/parser.d.ts +33 -0
- package/dist/parser.js +870 -0
- package/dist/safety.d.ts +8 -0
- package/dist/safety.js +12 -0
- package/dist/schedule.d.ts +6 -0
- package/dist/schedule.js +653 -0
- package/dist/types.d.ts +363 -0
- package/dist/types.js +224 -0
- package/package.json +32 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { formatInternal } from "./format";
|
|
2
|
+
import { internalFromFhir, toFhir } from "./fhir";
|
|
3
|
+
import { parseInternal } from "./parser";
|
|
4
|
+
export { parseInternal } from "./parser";
|
|
5
|
+
export * from "./types";
|
|
6
|
+
export { nextDueDoses } from "./schedule";
|
|
7
|
+
export function parseSig(input, options) {
|
|
8
|
+
const internal = parseInternal(input, options);
|
|
9
|
+
const shortText = formatInternal(internal, "short");
|
|
10
|
+
const longText = formatInternal(internal, "long");
|
|
11
|
+
const fhir = toFhir(internal);
|
|
12
|
+
if (longText) {
|
|
13
|
+
fhir.text = longText;
|
|
14
|
+
}
|
|
15
|
+
const consumedTokens = internal.tokens
|
|
16
|
+
.filter((token) => internal.consumed.has(token.index))
|
|
17
|
+
.map((token) => token.original);
|
|
18
|
+
const leftoverTokens = internal.tokens.filter((token) => !internal.consumed.has(token.index));
|
|
19
|
+
return {
|
|
20
|
+
fhir,
|
|
21
|
+
shortText,
|
|
22
|
+
longText,
|
|
23
|
+
warnings: internal.warnings,
|
|
24
|
+
meta: {
|
|
25
|
+
consumedTokens,
|
|
26
|
+
leftoverText: leftoverTokens.length
|
|
27
|
+
? leftoverTokens.map((t) => t.original).join(" ")
|
|
28
|
+
: undefined,
|
|
29
|
+
normalized: {
|
|
30
|
+
route: internal.routeCode,
|
|
31
|
+
unit: internal.unit
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function formatSig(dosage, style = "short") {
|
|
37
|
+
const internal = internalFromFhir(dosage);
|
|
38
|
+
return formatInternal(internal, style);
|
|
39
|
+
}
|
|
40
|
+
export function fromFhirDosage(dosage) {
|
|
41
|
+
const internal = internalFromFhir(dosage);
|
|
42
|
+
const shortText = formatInternal(internal, "short");
|
|
43
|
+
const longText = dosage.text ?? formatInternal(internal, "long");
|
|
44
|
+
return {
|
|
45
|
+
fhir: dosage,
|
|
46
|
+
shortText,
|
|
47
|
+
longText,
|
|
48
|
+
warnings: [],
|
|
49
|
+
meta: {
|
|
50
|
+
consumedTokens: [],
|
|
51
|
+
normalized: {
|
|
52
|
+
route: internal.routeCode,
|
|
53
|
+
unit: internal.unit
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
package/dist/maps.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { EventTiming, FhirDayOfWeek, FhirPeriodUnit, RouteCode, SNOMEDCTRouteCodes } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* SNOMED CT codings aligned with every known RouteCode. Keeping the structure
|
|
4
|
+
* data-driven ensures any additions to the enumeration are surfaced
|
|
5
|
+
* automatically throughout the library.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ROUTE_SNOMED: Record<RouteCode, {
|
|
8
|
+
code: SNOMEDCTRouteCodes;
|
|
9
|
+
display: string;
|
|
10
|
+
}>;
|
|
11
|
+
export declare const ROUTE_TEXT: Record<RouteCode, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Inverse lookup so that SNOMED codes flowing in from FHIR can be mapped back
|
|
14
|
+
* into our internal RouteCode abstraction during round-tripping.
|
|
15
|
+
*/
|
|
16
|
+
export declare const ROUTE_BY_SNOMED: Record<SNOMEDCTRouteCodes, RouteCode>;
|
|
17
|
+
export interface RouteSynonym {
|
|
18
|
+
code: RouteCode;
|
|
19
|
+
text: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEFAULT_ROUTE_SYNONYMS: Record<string, RouteSynonym>;
|
|
22
|
+
export declare const DEFAULT_UNIT_SYNONYMS: Record<string, string>;
|
|
23
|
+
export interface FrequencyDescriptor {
|
|
24
|
+
code?: string;
|
|
25
|
+
frequency?: number;
|
|
26
|
+
frequencyMax?: number;
|
|
27
|
+
period?: number;
|
|
28
|
+
periodMax?: number;
|
|
29
|
+
periodUnit?: FhirPeriodUnit;
|
|
30
|
+
discouraged?: string;
|
|
31
|
+
when?: EventTiming[];
|
|
32
|
+
}
|
|
33
|
+
export declare const TIMING_ABBREVIATIONS: Record<string, FrequencyDescriptor>;
|
|
34
|
+
export declare const EVENT_TIMING_TOKENS: Record<string, EventTiming>;
|
|
35
|
+
export declare const MEAL_KEYWORDS: Record<string, {
|
|
36
|
+
pc: EventTiming;
|
|
37
|
+
ac: EventTiming;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const DISCOURAGED_TOKENS: Record<string, string>;
|
|
40
|
+
export declare const DAY_OF_WEEK_TOKENS: Record<string, FhirDayOfWeek>;
|
|
41
|
+
export declare const WORD_FREQUENCIES: Record<string, {
|
|
42
|
+
frequency: number;
|
|
43
|
+
periodUnit: FhirPeriodUnit;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const KNOWN_DOSAGE_FORMS_TO_DOSE: Record<string, string>;
|
|
46
|
+
/**
|
|
47
|
+
* Map of normalized dosage-form labels to their associated SNOMED route code.
|
|
48
|
+
* The keys intentionally mirror KNOWN_DOSAGE_FORMS_TO_DOSE to keep lookups simple.
|
|
49
|
+
*/
|
|
50
|
+
export declare const KNOWN_TMT_DOSAGE_FORM_TO_SNOMED_ROUTE: Record<string, SNOMEDCTRouteCodes>;
|
|
51
|
+
export declare const DEFAULT_UNIT_BY_NORMALIZED_FORM: Record<string, string>;
|