ezmedicationinput 0.1.0 → 0.1.2
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 +19 -19
- package/dist/context.js +10 -5
- package/dist/fhir.d.ts +1 -1
- package/dist/fhir.js +40 -32
- package/dist/format.d.ts +3 -2
- package/dist/format.js +371 -86
- package/dist/i18n.d.ts +31 -0
- package/dist/i18n.js +664 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +53 -18
- package/dist/internal-types.d.ts +33 -0
- package/dist/internal-types.js +2 -0
- package/dist/maps.d.ts +1 -0
- package/dist/maps.js +434 -345
- package/dist/package.json +3 -0
- package/dist/parser.d.ts +2 -31
- package/dist/parser.js +690 -143
- package/dist/safety.js +7 -4
- package/dist/schedule.js +148 -76
- package/dist/suggest.d.ts +12 -0
- package/dist/suggest.js +228 -0
- package/dist/types.d.ts +17 -8
- package/dist/types.js +13 -9
- package/dist/utils/array.d.ts +1 -0
- package/dist/utils/array.js +11 -0
- package/dist/utils/enum.d.ts +2 -0
- package/dist/utils/enum.js +7 -0
- package/dist/utils/object.d.ts +7 -0
- package/dist/utils/object.js +34 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.resolveSigTranslation = exports.resolveSigLocalization = exports.registerSigLocalization = exports.getRegisteredSigLocalizations = exports.nextDueDoses = exports.suggestSig = exports.parseInternal = void 0;
|
|
18
|
+
exports.parseSig = parseSig;
|
|
19
|
+
exports.formatSig = formatSig;
|
|
20
|
+
exports.fromFhirDosage = fromFhirDosage;
|
|
21
|
+
const format_1 = require("./format");
|
|
22
|
+
const fhir_1 = require("./fhir");
|
|
23
|
+
const i18n_1 = require("./i18n");
|
|
24
|
+
const parser_1 = require("./parser");
|
|
25
|
+
var parser_2 = require("./parser");
|
|
26
|
+
Object.defineProperty(exports, "parseInternal", { enumerable: true, get: function () { return parser_2.parseInternal; } });
|
|
27
|
+
var suggest_1 = require("./suggest");
|
|
28
|
+
Object.defineProperty(exports, "suggestSig", { enumerable: true, get: function () { return suggest_1.suggestSig; } });
|
|
29
|
+
__exportStar(require("./types"), exports);
|
|
30
|
+
var schedule_1 = require("./schedule");
|
|
31
|
+
Object.defineProperty(exports, "nextDueDoses", { enumerable: true, get: function () { return schedule_1.nextDueDoses; } });
|
|
32
|
+
var i18n_2 = require("./i18n");
|
|
33
|
+
Object.defineProperty(exports, "getRegisteredSigLocalizations", { enumerable: true, get: function () { return i18n_2.getRegisteredSigLocalizations; } });
|
|
34
|
+
Object.defineProperty(exports, "registerSigLocalization", { enumerable: true, get: function () { return i18n_2.registerSigLocalization; } });
|
|
35
|
+
Object.defineProperty(exports, "resolveSigLocalization", { enumerable: true, get: function () { return i18n_2.resolveSigLocalization; } });
|
|
36
|
+
Object.defineProperty(exports, "resolveSigTranslation", { enumerable: true, get: function () { return i18n_2.resolveSigTranslation; } });
|
|
37
|
+
function parseSig(input, options) {
|
|
38
|
+
const internal = (0, parser_1.parseInternal)(input, options);
|
|
39
|
+
const localization = (0, i18n_1.resolveSigLocalization)(options === null || options === void 0 ? void 0 : options.locale, options === null || options === void 0 ? void 0 : options.i18n);
|
|
40
|
+
const shortText = (0, format_1.formatInternal)(internal, "short", localization);
|
|
41
|
+
const longText = (0, format_1.formatInternal)(internal, "long", localization);
|
|
42
|
+
const fhir = (0, fhir_1.toFhir)(internal);
|
|
12
43
|
if (longText) {
|
|
13
44
|
fhir.text = longText;
|
|
14
45
|
}
|
|
@@ -33,14 +64,18 @@ export function parseSig(input, options) {
|
|
|
33
64
|
}
|
|
34
65
|
};
|
|
35
66
|
}
|
|
36
|
-
|
|
37
|
-
const internal = internalFromFhir(dosage);
|
|
38
|
-
|
|
67
|
+
function formatSig(dosage, style = "short", options) {
|
|
68
|
+
const internal = (0, fhir_1.internalFromFhir)(dosage);
|
|
69
|
+
const localization = (0, i18n_1.resolveSigLocalization)(options === null || options === void 0 ? void 0 : options.locale, options === null || options === void 0 ? void 0 : options.i18n);
|
|
70
|
+
return (0, format_1.formatInternal)(internal, style, localization);
|
|
39
71
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
72
|
+
function fromFhirDosage(dosage, options) {
|
|
73
|
+
var _a;
|
|
74
|
+
const internal = (0, fhir_1.internalFromFhir)(dosage);
|
|
75
|
+
const localization = (0, i18n_1.resolveSigLocalization)(options === null || options === void 0 ? void 0 : options.locale, options === null || options === void 0 ? void 0 : options.i18n);
|
|
76
|
+
const shortText = (0, format_1.formatInternal)(internal, "short", localization);
|
|
77
|
+
const computedLong = (0, format_1.formatInternal)(internal, "long", localization);
|
|
78
|
+
const longText = localization ? computedLong : (_a = dosage.text) !== null && _a !== void 0 ? _a : computedLong;
|
|
44
79
|
return {
|
|
45
80
|
fhir: dosage,
|
|
46
81
|
shortText,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { EventTiming, FhirDayOfWeek, FhirPeriodUnit, RouteCode } from "./types";
|
|
2
|
+
export interface Token {
|
|
3
|
+
original: string;
|
|
4
|
+
lower: string;
|
|
5
|
+
index: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ParsedSigInternal {
|
|
8
|
+
input: string;
|
|
9
|
+
tokens: Token[];
|
|
10
|
+
consumed: Set<number>;
|
|
11
|
+
dose?: number;
|
|
12
|
+
doseRange?: {
|
|
13
|
+
low: number;
|
|
14
|
+
high: number;
|
|
15
|
+
};
|
|
16
|
+
unit?: string;
|
|
17
|
+
routeCode?: RouteCode;
|
|
18
|
+
routeText?: string;
|
|
19
|
+
frequency?: number;
|
|
20
|
+
frequencyMax?: number;
|
|
21
|
+
period?: number;
|
|
22
|
+
periodMax?: number;
|
|
23
|
+
periodUnit?: FhirPeriodUnit;
|
|
24
|
+
dayOfWeek: FhirDayOfWeek[];
|
|
25
|
+
when: EventTiming[];
|
|
26
|
+
timingCode?: string;
|
|
27
|
+
asNeeded?: boolean;
|
|
28
|
+
asNeededReason?: string;
|
|
29
|
+
warnings: string[];
|
|
30
|
+
siteText?: string;
|
|
31
|
+
siteSource?: "abbreviation" | "text";
|
|
32
|
+
siteTokenIndices: Set<number>;
|
|
33
|
+
}
|
package/dist/maps.d.ts
CHANGED
|
@@ -49,3 +49,4 @@ export declare const KNOWN_DOSAGE_FORMS_TO_DOSE: Record<string, string>;
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const KNOWN_TMT_DOSAGE_FORM_TO_SNOMED_ROUTE: Record<string, SNOMEDCTRouteCodes>;
|
|
51
51
|
export declare const DEFAULT_UNIT_BY_NORMALIZED_FORM: Record<string, string>;
|
|
52
|
+
export declare const DEFAULT_UNIT_BY_ROUTE: Partial<Record<RouteCode, string>>;
|