ezmedicationinput 0.1.31 → 0.1.33

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/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export { nextDueDoses, calculateTotalUnits } from "./schedule";
6
6
  export { parseStrength, parseStrengthIntoRatio } from "./utils/strength";
7
7
  export { getRegisteredSigLocalizations, registerSigLocalization, resolveSigLocalization, resolveSigTranslation } from "./i18n";
8
8
  export type { SigLocalization, SigLocalizationConfig, SigTranslation, SigTranslationConfig } from "./i18n";
9
+ export { DEFAULT_BODY_SITE_SNOMED, DEFAULT_BODY_SITE_SNOMED_SOURCE, DEFAULT_ROUTE_SYNONYMS, DEFAULT_UNIT_BY_ROUTE, KNOWN_DOSAGE_FORMS_TO_DOSE } from './maps';
9
10
  export declare function parseSig(input: string, options?: ParseOptions): ParseResult;
10
11
  export declare function lintSig(input: string, options?: ParseOptions): LintResult;
11
12
  export declare function parseSigAsync(input: string, options?: ParseOptions): Promise<ParseResult>;
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  });
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.resolveSigTranslation = exports.resolveSigLocalization = exports.registerSigLocalization = exports.getRegisteredSigLocalizations = exports.parseStrengthIntoRatio = exports.parseStrength = exports.calculateTotalUnits = exports.nextDueDoses = exports.suggestSig = exports.parseInternal = void 0;
26
+ exports.KNOWN_DOSAGE_FORMS_TO_DOSE = exports.DEFAULT_UNIT_BY_ROUTE = exports.DEFAULT_ROUTE_SYNONYMS = exports.DEFAULT_BODY_SITE_SNOMED_SOURCE = exports.DEFAULT_BODY_SITE_SNOMED = exports.resolveSigTranslation = exports.resolveSigLocalization = exports.registerSigLocalization = exports.getRegisteredSigLocalizations = exports.parseStrengthIntoRatio = exports.parseStrength = exports.calculateTotalUnits = exports.nextDueDoses = exports.suggestSig = exports.parseInternal = void 0;
27
27
  exports.parseSig = parseSig;
28
28
  exports.lintSig = lintSig;
29
29
  exports.parseSigAsync = parseSigAsync;
@@ -49,6 +49,12 @@ Object.defineProperty(exports, "getRegisteredSigLocalizations", { enumerable: tr
49
49
  Object.defineProperty(exports, "registerSigLocalization", { enumerable: true, get: function () { return i18n_2.registerSigLocalization; } });
50
50
  Object.defineProperty(exports, "resolveSigLocalization", { enumerable: true, get: function () { return i18n_2.resolveSigLocalization; } });
51
51
  Object.defineProperty(exports, "resolveSigTranslation", { enumerable: true, get: function () { return i18n_2.resolveSigTranslation; } });
52
+ var maps_1 = require("./maps");
53
+ Object.defineProperty(exports, "DEFAULT_BODY_SITE_SNOMED", { enumerable: true, get: function () { return maps_1.DEFAULT_BODY_SITE_SNOMED; } });
54
+ Object.defineProperty(exports, "DEFAULT_BODY_SITE_SNOMED_SOURCE", { enumerable: true, get: function () { return maps_1.DEFAULT_BODY_SITE_SNOMED_SOURCE; } });
55
+ Object.defineProperty(exports, "DEFAULT_ROUTE_SYNONYMS", { enumerable: true, get: function () { return maps_1.DEFAULT_ROUTE_SYNONYMS; } });
56
+ Object.defineProperty(exports, "DEFAULT_UNIT_BY_ROUTE", { enumerable: true, get: function () { return maps_1.DEFAULT_UNIT_BY_ROUTE; } });
57
+ Object.defineProperty(exports, "KNOWN_DOSAGE_FORMS_TO_DOSE", { enumerable: true, get: function () { return maps_1.KNOWN_DOSAGE_FORMS_TO_DOSE; } });
52
58
  function parseSig(input, options) {
53
59
  const internal = (0, parser_1.parseInternal)(input, options);
54
60
  (0, parser_1.applyPrnReasonCoding)(internal, options);
package/dist/maps.d.ts CHANGED
@@ -25,6 +25,10 @@ export declare const DEFAULT_ROUTE_SYNONYMS: Record<string, RouteSynonym>;
25
25
  * same logic to ensure consistent lookups.
26
26
  */
27
27
  export declare function normalizeBodySiteKey(value: string): string;
28
+ export declare const DEFAULT_BODY_SITE_SNOMED_SOURCE: Array<{
29
+ names: string[];
30
+ definition: BodySiteDefinition;
31
+ }>;
28
32
  export declare const DEFAULT_BODY_SITE_SNOMED: Record<string, BodySiteDefinition>;
29
33
  export declare const HOUSEHOLD_VOLUME_UNITS: readonly ["tsp", "tbsp"];
30
34
  export declare const DEFAULT_UNIT_SYNONYMS: Record<string, string>;
package/dist/maps.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS = exports.DEFAULT_ADDITIONAL_INSTRUCTION_ENTRIES = exports.DEFAULT_PRN_REASON_DEFINITIONS = exports.DEFAULT_PRN_REASON_ENTRIES = exports.DEFAULT_UNIT_BY_ROUTE = exports.DEFAULT_UNIT_BY_NORMALIZED_FORM = exports.KNOWN_TMT_DOSAGE_FORM_TO_SNOMED_ROUTE = exports.KNOWN_DOSAGE_FORMS_TO_DOSE = exports.WORD_FREQUENCIES = exports.DAY_OF_WEEK_TOKENS = exports.DISCOURAGED_TOKENS = exports.MEAL_KEYWORDS = exports.EVENT_TIMING_TOKENS = exports.TIMING_ABBREVIATIONS = exports.DEFAULT_UNIT_SYNONYMS = exports.HOUSEHOLD_VOLUME_UNITS = exports.DEFAULT_BODY_SITE_SNOMED = exports.DEFAULT_ROUTE_SYNONYMS = exports.ROUTE_BY_SNOMED = exports.ROUTE_TEXT = exports.ROUTE_SNOMED = void 0;
3
+ exports.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS = exports.DEFAULT_ADDITIONAL_INSTRUCTION_ENTRIES = exports.DEFAULT_PRN_REASON_DEFINITIONS = exports.DEFAULT_PRN_REASON_ENTRIES = exports.DEFAULT_UNIT_BY_ROUTE = exports.DEFAULT_UNIT_BY_NORMALIZED_FORM = exports.KNOWN_TMT_DOSAGE_FORM_TO_SNOMED_ROUTE = exports.KNOWN_DOSAGE_FORMS_TO_DOSE = exports.WORD_FREQUENCIES = exports.DAY_OF_WEEK_TOKENS = exports.DISCOURAGED_TOKENS = exports.MEAL_KEYWORDS = exports.EVENT_TIMING_TOKENS = exports.TIMING_ABBREVIATIONS = exports.DEFAULT_UNIT_SYNONYMS = exports.HOUSEHOLD_VOLUME_UNITS = exports.DEFAULT_BODY_SITE_SNOMED = exports.DEFAULT_BODY_SITE_SNOMED_SOURCE = exports.DEFAULT_ROUTE_SYNONYMS = exports.ROUTE_BY_SNOMED = exports.ROUTE_TEXT = exports.ROUTE_SNOMED = void 0;
4
4
  exports.normalizeBodySiteKey = normalizeBodySiteKey;
5
5
  exports.normalizePrnReasonKey = normalizePrnReasonKey;
6
6
  exports.normalizeAdditionalInstructionKey = normalizeAdditionalInstructionKey;
@@ -182,7 +182,7 @@ function normalizeBodySiteKey(value) {
182
182
  .replace(/\s+/g, " ")
183
183
  .trim();
184
184
  }
185
- const DEFAULT_BODY_SITE_SNOMED_SOURCE = [
185
+ exports.DEFAULT_BODY_SITE_SNOMED_SOURCE = [
186
186
  {
187
187
  names: ["eye", "eyes"],
188
188
  definition: { coding: { code: "81745001", display: "Eye" } }
@@ -201,7 +201,7 @@ const DEFAULT_BODY_SITE_SNOMED_SOURCE = [
201
201
  },
202
202
  {
203
203
  names: ["both eyes", "bilateral eyes"],
204
- definition: { coding: { code: "362508001", display: "Both eyes, entire" } }
204
+ definition: { coding: { code: "40638003", display: "Structure of both eyes" } }
205
205
  },
206
206
  {
207
207
  names: ["ear", "ears"],
@@ -447,7 +447,7 @@ const DEFAULT_BODY_SITE_SNOMED_SOURCE = [
447
447
  }
448
448
  }
449
449
  ];
450
- exports.DEFAULT_BODY_SITE_SNOMED = (0, object_1.objectFromEntries)(DEFAULT_BODY_SITE_SNOMED_SOURCE.reduce((entries, source) => {
450
+ exports.DEFAULT_BODY_SITE_SNOMED = (0, object_1.objectFromEntries)(exports.DEFAULT_BODY_SITE_SNOMED_SOURCE.reduce((entries, source) => {
451
451
  const { names, definition } = source;
452
452
  for (const name of names) {
453
453
  const key = normalizeBodySiteKey(name);
@@ -701,6 +701,7 @@ exports.EVENT_TIMING_TOKENS = {
701
701
  hs: types_1.EventTiming["Before Sleep"],
702
702
  bedtime: types_1.EventTiming["Before Sleep"],
703
703
  bed: types_1.EventTiming["Before Sleep"],
704
+ sleep: types_1.EventTiming["Before Sleep"],
704
705
  wake: types_1.EventTiming.Wake,
705
706
  waking: types_1.EventTiming.Wake,
706
707
  stat: types_1.EventTiming.Immediate
@@ -1335,6 +1336,18 @@ const DEFAULT_PRN_REASON_SOURCE = [
1335
1336
  i18n: { th: "นอนหลับ" }
1336
1337
  }
1337
1338
  },
1339
+ {
1340
+ names: ["sleepiness", "sleepy", "drowsiness", "drowsy"],
1341
+ definition: {
1342
+ coding: {
1343
+ system: SNOMED_SYSTEM,
1344
+ code: "79519003",
1345
+ display: "Drowsiness"
1346
+ },
1347
+ text: "Sleepiness",
1348
+ i18n: { th: "ง่วงนอน" }
1349
+ }
1350
+ },
1338
1351
  {
1339
1352
  names: ["cough", "coughing"],
1340
1353
  definition: {
package/dist/parser.js CHANGED
@@ -1499,10 +1499,14 @@ function applyWhenToken(internal, token, code) {
1499
1499
  addWhen(internal.when, code);
1500
1500
  mark(internal.consumed, token);
1501
1501
  }
1502
- function isTimingAnchorOrPrefix(tokens, index) {
1502
+ function isTimingAnchorOrPrefix(tokens, index, prnReasonStart) {
1503
1503
  const token = tokens[index];
1504
1504
  if (!token)
1505
1505
  return false;
1506
+ // Cautious handling of "sleep" in PRN zone
1507
+ if (prnReasonStart !== undefined && index >= prnReasonStart && token.lower === "sleep") {
1508
+ return false;
1509
+ }
1506
1510
  const lower = token.lower;
1507
1511
  const nextToken = tokens[index + 1];
1508
1512
  const comboKey = nextToken ? `${lower} ${nextToken.lower}` : undefined;
@@ -1933,7 +1937,7 @@ function parseInternal(input, options) {
1933
1937
  }
1934
1938
  // Skip connectors if they are followed by recognized timing tokens or prefixes
1935
1939
  if (MEAL_CONTEXT_CONNECTORS.has(token.lower) || token.lower === ",") {
1936
- if (isTimingAnchorOrPrefix(tokens, i + 1)) {
1940
+ if (isTimingAnchorOrPrefix(tokens, i + 1, prnReasonStart)) {
1937
1941
  mark(internal.consumed, token);
1938
1942
  continue;
1939
1943
  }
@@ -1977,8 +1981,15 @@ function parseInternal(input, options) {
1977
1981
  }
1978
1982
  const whenCode = maps_1.EVENT_TIMING_TOKENS[token.lower];
1979
1983
  if (whenCode) {
1980
- applyWhenToken(internal, token, whenCode);
1981
- continue;
1984
+ // If we are in the PRN zone, be cautious about common reason words like "sleep"
1985
+ // unless they were already handled by combo/anchor logic (which happens above).
1986
+ if (prnReasonStart !== undefined && i >= prnReasonStart && token.lower === "sleep") {
1987
+ // Leave for PRN reason
1988
+ }
1989
+ else {
1990
+ applyWhenToken(internal, token, whenCode);
1991
+ continue;
1992
+ }
1982
1993
  }
1983
1994
  // Day of week
1984
1995
  const day = maps_1.DAY_OF_WEEK_TOKENS[token.lower];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",