ezmedicationinput 0.1.15 → 0.1.17

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/maps.js CHANGED
@@ -1,9 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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_ROUTE_SYNONYMS = exports.ROUTE_BY_SNOMED = exports.ROUTE_TEXT = exports.ROUTE_SNOMED = void 0;
4
4
  exports.normalizeBodySiteKey = normalizeBodySiteKey;
5
+ exports.normalizePrnReasonKey = normalizePrnReasonKey;
6
+ exports.normalizeAdditionalInstructionKey = normalizeAdditionalInstructionKey;
5
7
  const types_1 = require("./types");
6
8
  const object_1 = require("./utils/object");
9
+ const SNOMED_SYSTEM = "http://snomed.info/sct";
7
10
  const ROUTE_TEXT_OVERRIDES = {
8
11
  [types_1.RouteCode["Oral route"]]: "by mouth",
9
12
  [types_1.RouteCode["Sublingual route"]]: "sublingual",
@@ -1251,5 +1254,316 @@ exports.DEFAULT_UNIT_BY_ROUTE = (() => {
1251
1254
  ensure(types_1.RouteCode["Otic route"], "drop");
1252
1255
  ensure(types_1.RouteCode["Respiratory tract route (qualifier value)"], "puff");
1253
1256
  ensure(types_1.RouteCode["Transdermal route"], "patch");
1257
+ ensure(types_1.RouteCode["Per rectum"], "suppository");
1254
1258
  return resolved;
1255
1259
  })();
1260
+ function normalizePrnReasonKey(value) {
1261
+ return value
1262
+ .trim()
1263
+ .toLowerCase()
1264
+ .replace(/[^\p{L}\p{N}]+/gu, " ")
1265
+ .replace(/\s+/g, " ")
1266
+ .trim();
1267
+ }
1268
+ function normalizeAdditionalInstructionKey(value) {
1269
+ return value
1270
+ .trim()
1271
+ .toLowerCase()
1272
+ .replace(/[^\p{L}\p{N}]+/gu, " ")
1273
+ .replace(/\s+/g, " ")
1274
+ .trim();
1275
+ }
1276
+ const DEFAULT_PRN_REASON_SOURCE = [
1277
+ {
1278
+ names: ["pain", "ache", "aches", "pains"],
1279
+ definition: {
1280
+ coding: { system: SNOMED_SYSTEM, code: "22253000", display: "Pain" },
1281
+ text: "Pain"
1282
+ }
1283
+ },
1284
+ {
1285
+ names: ["nausea", "queasiness", "vomiting", "n/v", "nausea and vomiting"],
1286
+ definition: {
1287
+ coding: { system: SNOMED_SYSTEM, code: "422587007", display: "Nausea" },
1288
+ text: "Nausea"
1289
+ }
1290
+ },
1291
+ {
1292
+ names: ["itch", "itching", "itchy"],
1293
+ definition: {
1294
+ coding: {
1295
+ system: SNOMED_SYSTEM,
1296
+ code: "418363000",
1297
+ display: "Itching of skin"
1298
+ },
1299
+ text: "Itching"
1300
+ }
1301
+ },
1302
+ {
1303
+ names: ["anxiety", "nervousness"],
1304
+ definition: {
1305
+ coding: { system: SNOMED_SYSTEM, code: "48694002", display: "Anxiety" },
1306
+ text: "Anxiety"
1307
+ }
1308
+ },
1309
+ {
1310
+ names: ["sleep", "sleeping", "insomnia", "sleep issues"],
1311
+ definition: {
1312
+ coding: {
1313
+ system: SNOMED_SYSTEM,
1314
+ code: "193462001",
1315
+ display: "Insomnia"
1316
+ },
1317
+ text: "Sleep"
1318
+ }
1319
+ },
1320
+ {
1321
+ names: ["cough", "coughing"],
1322
+ definition: {
1323
+ coding: { system: SNOMED_SYSTEM, code: "49727002", display: "Cough" },
1324
+ text: "Cough"
1325
+ }
1326
+ },
1327
+ {
1328
+ names: ["fever", "temperature", "pyrexia"],
1329
+ definition: {
1330
+ coding: { system: SNOMED_SYSTEM, code: "386661006", display: "Fever" },
1331
+ text: "Fever"
1332
+ }
1333
+ },
1334
+ {
1335
+ names: ["spasm", "spasms", "muscle spasm"],
1336
+ definition: {
1337
+ coding: { system: SNOMED_SYSTEM, code: "45352006", display: "Spasm" },
1338
+ text: "Spasm"
1339
+ }
1340
+ },
1341
+ {
1342
+ names: ["constipation"],
1343
+ definition: {
1344
+ coding: {
1345
+ system: SNOMED_SYSTEM,
1346
+ code: "14760008",
1347
+ display: "Constipation"
1348
+ },
1349
+ text: "Constipation"
1350
+ }
1351
+ },
1352
+ {
1353
+ names: ["dyspnea", "shortness of breath", "sob", "breathlessness"],
1354
+ definition: {
1355
+ coding: {
1356
+ system: SNOMED_SYSTEM,
1357
+ code: "267036007",
1358
+ display: "Dyspnea"
1359
+ },
1360
+ text: "Shortness of breath"
1361
+ }
1362
+ }
1363
+ ];
1364
+ exports.DEFAULT_PRN_REASON_ENTRIES = DEFAULT_PRN_REASON_SOURCE.map((source) => {
1365
+ var _a, _b, _c;
1366
+ const canonicalTerm = (_c = (_a = source.definition.text) !== null && _a !== void 0 ? _a : (_b = source.definition.coding) === null || _b === void 0 ? void 0 : _b.display) !== null && _c !== void 0 ? _c : source.names[0];
1367
+ return {
1368
+ canonical: normalizePrnReasonKey(canonicalTerm !== null && canonicalTerm !== void 0 ? canonicalTerm : ""),
1369
+ definition: source.definition,
1370
+ terms: [...source.names]
1371
+ };
1372
+ });
1373
+ exports.DEFAULT_PRN_REASON_DEFINITIONS = (0, object_1.objectFromEntries)(DEFAULT_PRN_REASON_SOURCE.reduce((entries, source) => {
1374
+ for (const name of source.names) {
1375
+ const key = normalizePrnReasonKey(name);
1376
+ if (!key) {
1377
+ continue;
1378
+ }
1379
+ entries.push([key, source.definition]);
1380
+ }
1381
+ if (source.definition.aliases) {
1382
+ for (const alias of source.definition.aliases) {
1383
+ const key = normalizePrnReasonKey(alias);
1384
+ if (!key) {
1385
+ continue;
1386
+ }
1387
+ entries.push([key, source.definition]);
1388
+ }
1389
+ }
1390
+ return entries;
1391
+ }, []));
1392
+ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1393
+ {
1394
+ names: ["with food", "with meals", "with meal", "after food", "after meals"],
1395
+ definition: {
1396
+ coding: {
1397
+ system: SNOMED_SYSTEM,
1398
+ code: "311504000",
1399
+ display: "With or after food"
1400
+ },
1401
+ text: "Take with or after food"
1402
+ }
1403
+ },
1404
+ {
1405
+ names: ["before food", "before meals", "before meal", "1 hour before food"],
1406
+ definition: {
1407
+ coding: {
1408
+ system: SNOMED_SYSTEM,
1409
+ code: "311501008",
1410
+ display: "Half to one hour before food"
1411
+ },
1412
+ text: "Take before food"
1413
+ }
1414
+ },
1415
+ {
1416
+ names: ["empty stomach", "on empty stomach"],
1417
+ definition: {
1418
+ coding: {
1419
+ system: SNOMED_SYSTEM,
1420
+ code: "717154004",
1421
+ display: "Take on an empty stomach (qualifier value)"
1422
+ },
1423
+ text: "Take on an empty stomach"
1424
+ }
1425
+ },
1426
+ {
1427
+ names: ["with water", "with plenty of water", "drink water", "with lots of water"],
1428
+ definition: {
1429
+ coding: {
1430
+ system: SNOMED_SYSTEM,
1431
+ code: "419303009",
1432
+ display: "With plenty of water"
1433
+ },
1434
+ text: "Take with plenty of water"
1435
+ }
1436
+ },
1437
+ {
1438
+ names: ["dissolve in water", "mix with water", "mix in water"],
1439
+ definition: {
1440
+ coding: {
1441
+ system: SNOMED_SYSTEM,
1442
+ code: "417995008",
1443
+ display: "Dissolve or mix with water before taking"
1444
+ },
1445
+ text: "Dissolve or mix with water before taking"
1446
+ }
1447
+ },
1448
+ {
1449
+ names: ["avoid alcohol", "no alcohol", "no alc", "avoid alcoholic drink"],
1450
+ definition: {
1451
+ coding: {
1452
+ system: SNOMED_SYSTEM,
1453
+ code: "419822006",
1454
+ display: "Warning. Avoid alcoholic drink (qualifier value)"
1455
+ },
1456
+ text: "Avoid alcoholic drinks"
1457
+ }
1458
+ },
1459
+ {
1460
+ names: ["may cause drowsiness", "do not drive", "avoid driving", "no driving", "no drive"],
1461
+ definition: {
1462
+ coding: {
1463
+ system: SNOMED_SYSTEM,
1464
+ code: "418954008",
1465
+ display: "Warning. May cause drowsiness. If affected do not drive or operate machinery (qualifier value)"
1466
+ },
1467
+ text: "May cause drowsiness; do not drive if affected"
1468
+ }
1469
+ },
1470
+ {
1471
+ names: [
1472
+ "drowsiness avoid alcohol",
1473
+ "may cause drowsiness avoid alcohol",
1474
+ "do not drive avoid alcohol",
1475
+ "drowsy avoid alc",
1476
+ "drowsy avoid drive",
1477
+ "drowsy avoid driving",
1478
+ "drowsy no drive",
1479
+ "drowsy no driving",
1480
+ "drowsy no alc"
1481
+ ],
1482
+ definition: {
1483
+ coding: {
1484
+ system: SNOMED_SYSTEM,
1485
+ code: "418914006",
1486
+ display: "Warning. May cause drowsiness. If affected do not drive or operate machinery. Avoid alcoholic drink (qualifier value)"
1487
+ },
1488
+ text: "May cause drowsiness; avoid driving or alcohol"
1489
+ }
1490
+ },
1491
+ {
1492
+ names: [
1493
+ "drowsiness next day",
1494
+ "drowsiness next day avoid alcohol",
1495
+ "may cause drowsiness next day",
1496
+ "may next day drowsy",
1497
+ "may drowsy next day"
1498
+ ],
1499
+ definition: {
1500
+ coding: {
1501
+ system: SNOMED_SYSTEM,
1502
+ code: "418071006",
1503
+ display: "Warning. Causes drowsiness which may continue the next day. If affected do not drive or operate machinery. Avoid alcoholic drink (qualifier value)"
1504
+ },
1505
+ text: "May cause next-day drowsiness; avoid driving or alcohol"
1506
+ }
1507
+ },
1508
+ {
1509
+ names: ["avoid sun", "avoid sunlight", "avoid sun lamps"],
1510
+ definition: {
1511
+ coding: {
1512
+ system: SNOMED_SYSTEM,
1513
+ code: "418521000",
1514
+ display: "Avoid exposure of skin to direct sunlight or sun lamps (qualifier value)"
1515
+ },
1516
+ text: "Avoid sunlight or sun lamps"
1517
+ }
1518
+ },
1519
+ {
1520
+ names: ["swallow whole", "do not chew", "do not crush", "do not crush or chew", "no chewing"],
1521
+ definition: {
1522
+ coding: {
1523
+ system: SNOMED_SYSTEM,
1524
+ code: "418693002",
1525
+ display: "Swallowed whole, not chewed (qualifier value)"
1526
+ },
1527
+ text: "Swallow whole; do not crush or chew"
1528
+ }
1529
+ },
1530
+ {
1531
+ names: ["chew", "chewed", "sucked or chewed", "please chew", "must chew"],
1532
+ definition: {
1533
+ coding: {
1534
+ system: SNOMED_SYSTEM,
1535
+ code: "418991002",
1536
+ display: "Sucked or chewed (qualifier value)"
1537
+ },
1538
+ text: "Suck or chew before swallowing"
1539
+ }
1540
+ }
1541
+ ];
1542
+ exports.DEFAULT_ADDITIONAL_INSTRUCTION_ENTRIES = DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE.map((source) => {
1543
+ var _a, _b, _c;
1544
+ const canonicalTerm = (_c = (_a = source.definition.text) !== null && _a !== void 0 ? _a : (_b = source.definition.coding) === null || _b === void 0 ? void 0 : _b.display) !== null && _c !== void 0 ? _c : source.names[0];
1545
+ return {
1546
+ canonical: normalizeAdditionalInstructionKey(canonicalTerm !== null && canonicalTerm !== void 0 ? canonicalTerm : ""),
1547
+ definition: source.definition,
1548
+ terms: [...source.names]
1549
+ };
1550
+ });
1551
+ exports.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS = (0, object_1.objectFromEntries)(DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE.reduce((entries, source) => {
1552
+ for (const name of source.names) {
1553
+ const key = normalizeAdditionalInstructionKey(name);
1554
+ if (!key) {
1555
+ continue;
1556
+ }
1557
+ entries.push([key, source.definition]);
1558
+ }
1559
+ if (source.definition.aliases) {
1560
+ for (const alias of source.definition.aliases) {
1561
+ const key = normalizeAdditionalInstructionKey(alias);
1562
+ if (!key) {
1563
+ continue;
1564
+ }
1565
+ entries.push([key, source.definition]);
1566
+ }
1567
+ }
1568
+ return entries;
1569
+ }, []));
package/dist/parser.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare function parseInternal(input: string, options?: ParseOptions): Pa
6
6
  * Resolves parsed site text against SNOMED dictionaries and synchronous
7
7
  * callbacks, applying the best match to the in-progress parse result.
8
8
  */
9
+ export declare function applyPrnReasonCoding(internal: ParsedSigInternal, options?: ParseOptions): void;
10
+ export declare function applyPrnReasonCodingAsync(internal: ParsedSigInternal, options?: ParseOptions): Promise<void>;
9
11
  export declare function applySiteCoding(internal: ParsedSigInternal, options?: ParseOptions): void;
10
12
  /**
11
13
  * Asynchronous counterpart to {@link applySiteCoding} that awaits resolver and