ezmedicationinput 0.1.28 → 0.1.30

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/fhir.js CHANGED
@@ -162,7 +162,7 @@ function toFhir(internal) {
162
162
  return dosage;
163
163
  }
164
164
  function internalFromFhir(dosage) {
165
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
165
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
166
166
  const internal = {
167
167
  input: (_a = dosage.text) !== null && _a !== void 0 ? _a : "",
168
168
  tokens: [],
@@ -212,34 +212,41 @@ function internalFromFhir(dosage) {
212
212
  }
213
213
  const reasonCoding = (_9 = (_8 = (_7 = dosage.asNeededFor) === null || _7 === void 0 ? void 0 : _7[0]) === null || _8 === void 0 ? void 0 : _8.coding) === null || _9 === void 0 ? void 0 : _9[0];
214
214
  if (reasonCoding === null || reasonCoding === void 0 ? void 0 : reasonCoding.code) {
215
+ const defaultDef = (0, maps_1.findPrnReasonDefinitionByCoding)((_10 = reasonCoding.system) !== null && _10 !== void 0 ? _10 : SNOMED_SYSTEM, reasonCoding.code);
215
216
  internal.asNeededReasonCoding = {
216
217
  code: reasonCoding.code,
217
218
  display: reasonCoding.display,
218
- system: reasonCoding.system
219
+ system: reasonCoding.system,
220
+ i18n: defaultDef === null || defaultDef === void 0 ? void 0 : defaultDef.i18n
219
221
  };
220
222
  }
221
- if ((_10 = dosage.additionalInstruction) === null || _10 === void 0 ? void 0 : _10.length) {
223
+ if ((_11 = dosage.additionalInstruction) === null || _11 === void 0 ? void 0 : _11.length) {
222
224
  internal.additionalInstructions = dosage.additionalInstruction.map((concept) => {
223
- var _a;
224
- return ({
225
+ var _a, _b;
226
+ const coding = (_a = concept.coding) === null || _a === void 0 ? void 0 : _a[0];
227
+ const defaultDef = (coding === null || coding === void 0 ? void 0 : coding.code)
228
+ ? (0, maps_1.findAdditionalInstructionDefinitionByCoding)((_b = coding.system) !== null && _b !== void 0 ? _b : SNOMED_SYSTEM, coding.code)
229
+ : undefined;
230
+ return {
225
231
  text: concept.text,
226
- coding: ((_a = concept.coding) === null || _a === void 0 ? void 0 : _a[0])
232
+ coding: (coding === null || coding === void 0 ? void 0 : coding.code)
227
233
  ? {
228
- code: concept.coding[0].code,
229
- display: concept.coding[0].display,
230
- system: concept.coding[0].system
234
+ code: coding.code,
235
+ display: coding.display,
236
+ system: coding.system,
237
+ i18n: defaultDef === null || defaultDef === void 0 ? void 0 : defaultDef.i18n
231
238
  }
232
239
  : undefined
233
- });
240
+ };
234
241
  });
235
242
  }
236
- const doseAndRate = (_11 = dosage.doseAndRate) === null || _11 === void 0 ? void 0 : _11[0];
243
+ const doseAndRate = (_12 = dosage.doseAndRate) === null || _12 === void 0 ? void 0 : _12[0];
237
244
  if (doseAndRate === null || doseAndRate === void 0 ? void 0 : doseAndRate.doseRange) {
238
245
  const { low, high } = doseAndRate.doseRange;
239
246
  if ((low === null || low === void 0 ? void 0 : low.value) !== undefined && (high === null || high === void 0 ? void 0 : high.value) !== undefined) {
240
247
  internal.doseRange = { low: low.value, high: high.value };
241
248
  }
242
- internal.unit = (_13 = (_12 = low === null || low === void 0 ? void 0 : low.unit) !== null && _12 !== void 0 ? _12 : high === null || high === void 0 ? void 0 : high.unit) !== null && _13 !== void 0 ? _13 : internal.unit;
249
+ internal.unit = (_14 = (_13 = low === null || low === void 0 ? void 0 : low.unit) !== null && _13 !== void 0 ? _13 : high === null || high === void 0 ? void 0 : high.unit) !== null && _14 !== void 0 ? _14 : internal.unit;
243
250
  }
244
251
  else if (doseAndRate === null || doseAndRate === void 0 ? void 0 : doseAndRate.doseQuantity) {
245
252
  const dose = doseAndRate.doseQuantity;
package/dist/i18n.js CHANGED
@@ -116,16 +116,6 @@ const WHEN_TEXT_THAI = {
116
116
  [types_1.EventTiming["After Sleep"]]: "หลังจากนอน",
117
117
  [types_1.EventTiming.Immediate]: "ทันที"
118
118
  };
119
- const INSTRUCTION_TEXT_THAI = {
120
- "Take with or after food": "รับประทานพร้อมหรือหลังอาหาร",
121
- "With or after food": "พร้อมหรือหลังอาหาร",
122
- "Take before food": "รับประทานก่อนอาหาร",
123
- "Take on an empty stomach": "รับประทานขณะท้องว่าง",
124
- "Take with plenty of water": "รับประทานพร้อมน้ำดื่มจำนวนมาก",
125
- "Dissolve or mix with water before taking": "ละลายหรือผสมน้ำก่อนรับประทาน",
126
- "Avoid alcoholic drinks": "หลีกเลี่ยงเครื่องดื่มแอลกอฮอล์",
127
- "May cause drowsiness; do not drive if affected": "อาจทำให้ง่วงซึม; ห้ามขับขี่ยานพาหนะหรือทำงานกับเครื่องจักรหากมีอาการ",
128
- };
129
119
  const DAY_NAMES_THAI = {
130
120
  mon: "วันจันทร์",
131
121
  tue: "วันอังคาร",
@@ -635,11 +625,13 @@ function describeDayOfWeekThai(internal) {
635
625
  return `ใน${joinWithAndThai(days)}`;
636
626
  }
637
627
  function formatAsNeededThai(internal) {
628
+ var _a, _b;
638
629
  if (!internal.asNeeded) {
639
630
  return undefined;
640
631
  }
641
632
  if (internal.asNeededReason) {
642
- return `ใช้เมื่อจำเป็นสำหรับ ${internal.asNeededReason}`;
633
+ const translation = (_b = (_a = internal.asNeededReasonCoding) === null || _a === void 0 ? void 0 : _a.i18n) === null || _b === void 0 ? void 0 : _b.th;
634
+ return `ใช้เมื่อจำเป็นสำหรับ ${translation || internal.asNeededReason}`;
643
635
  }
644
636
  return "ใช้เมื่อจำเป็น";
645
637
  }
@@ -770,12 +762,14 @@ function formatAdditionalInstructionsThai(internal) {
770
762
  }
771
763
  const phrases = internal.additionalInstructions
772
764
  .map((instruction) => {
773
- var _a;
774
- const original = instruction.text || ((_a = instruction.coding) === null || _a === void 0 ? void 0 : _a.display);
765
+ var _a, _b, _c;
766
+ const translation = (_b = (_a = instruction.coding) === null || _a === void 0 ? void 0 : _a.i18n) === null || _b === void 0 ? void 0 : _b.th;
767
+ if (translation)
768
+ return translation;
769
+ const original = instruction.text || ((_c = instruction.coding) === null || _c === void 0 ? void 0 : _c.display);
775
770
  if (!original)
776
771
  return undefined;
777
- const normalized = original.trim();
778
- return INSTRUCTION_TEXT_THAI[normalized] || normalized;
772
+ return original.trim();
779
773
  })
780
774
  .filter((text) => Boolean(text))
781
775
  .map((text) => text.trim())
@@ -36,12 +36,16 @@ export interface ParsedSigInternal {
36
36
  timingCode?: string;
37
37
  asNeeded?: boolean;
38
38
  asNeededReason?: string;
39
- asNeededReasonCoding?: FhirCoding;
39
+ asNeededReasonCoding?: FhirCoding & {
40
+ i18n?: Record<string, string>;
41
+ };
40
42
  warnings: string[];
41
43
  siteText?: string;
42
44
  siteSource?: "abbreviation" | "text";
43
45
  siteTokenIndices: Set<number>;
44
- siteCoding?: FhirCoding;
46
+ siteCoding?: FhirCoding & {
47
+ i18n?: Record<string, string>;
48
+ };
45
49
  siteLookupRequest?: SiteCodeLookupRequest;
46
50
  siteLookups: SiteLookupDetail[];
47
51
  customSiteHints?: Set<string>;
@@ -49,6 +53,8 @@ export interface ParsedSigInternal {
49
53
  prnReasonLookups: PrnReasonLookupDetail[];
50
54
  additionalInstructions: Array<{
51
55
  text?: string;
52
- coding?: FhirCoding;
56
+ coding?: FhirCoding & {
57
+ i18n?: Record<string, string>;
58
+ };
53
59
  }>;
54
60
  }
package/dist/maps.d.ts CHANGED
@@ -74,3 +74,11 @@ export interface AdditionalInstructionDictionaryEntry {
74
74
  }
75
75
  export declare const DEFAULT_ADDITIONAL_INSTRUCTION_ENTRIES: AdditionalInstructionDictionaryEntry[];
76
76
  export declare const DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS: Record<string, AdditionalInstructionDefinition>;
77
+ /**
78
+ * Finds a default PRN reason definition by its SNOMED coding.
79
+ */
80
+ export declare function findPrnReasonDefinitionByCoding(system: string, code: string): PrnReasonDefinition | undefined;
81
+ /**
82
+ * Finds a default additional instruction definition by its SNOMED coding.
83
+ */
84
+ export declare function findAdditionalInstructionDefinitionByCoding(system: string, code: string): AdditionalInstructionDefinition | undefined;
package/dist/maps.js CHANGED
@@ -4,6 +4,8 @@ exports.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS = exports.DEFAULT_ADDITIONAL_
4
4
  exports.normalizeBodySiteKey = normalizeBodySiteKey;
5
5
  exports.normalizePrnReasonKey = normalizePrnReasonKey;
6
6
  exports.normalizeAdditionalInstructionKey = normalizeAdditionalInstructionKey;
7
+ exports.findPrnReasonDefinitionByCoding = findPrnReasonDefinitionByCoding;
8
+ exports.findAdditionalInstructionDefinitionByCoding = findAdditionalInstructionDefinitionByCoding;
7
9
  const types_1 = require("./types");
8
10
  const object_1 = require("./utils/object");
9
11
  const SNOMED_SYSTEM = "http://snomed.info/sct";
@@ -1288,14 +1290,16 @@ const DEFAULT_PRN_REASON_SOURCE = [
1288
1290
  names: ["pain", "ache", "aches", "pains"],
1289
1291
  definition: {
1290
1292
  coding: { system: SNOMED_SYSTEM, code: "22253000", display: "Pain" },
1291
- text: "Pain"
1293
+ text: "Pain",
1294
+ i18n: { th: "ปวด" }
1292
1295
  }
1293
1296
  },
1294
1297
  {
1295
1298
  names: ["nausea", "queasiness", "vomiting", "n/v", "nausea and vomiting"],
1296
1299
  definition: {
1297
1300
  coding: { system: SNOMED_SYSTEM, code: "422587007", display: "Nausea" },
1298
- text: "Nausea"
1301
+ text: "Nausea",
1302
+ i18n: { th: "คลื่นไส้" }
1299
1303
  }
1300
1304
  },
1301
1305
  {
@@ -1306,14 +1310,16 @@ const DEFAULT_PRN_REASON_SOURCE = [
1306
1310
  code: "418363000",
1307
1311
  display: "Itching of skin"
1308
1312
  },
1309
- text: "Itching"
1313
+ text: "Itching",
1314
+ i18n: { th: "คัน" }
1310
1315
  }
1311
1316
  },
1312
1317
  {
1313
1318
  names: ["anxiety", "nervousness"],
1314
1319
  definition: {
1315
1320
  coding: { system: SNOMED_SYSTEM, code: "48694002", display: "Anxiety" },
1316
- text: "Anxiety"
1321
+ text: "Anxiety",
1322
+ i18n: { th: "วิตกกังวล" }
1317
1323
  }
1318
1324
  },
1319
1325
  {
@@ -1324,28 +1330,32 @@ const DEFAULT_PRN_REASON_SOURCE = [
1324
1330
  code: "193462001",
1325
1331
  display: "Insomnia"
1326
1332
  },
1327
- text: "Sleep"
1333
+ text: "Sleep",
1334
+ i18n: { th: "นอนหลับ" }
1328
1335
  }
1329
1336
  },
1330
1337
  {
1331
1338
  names: ["cough", "coughing"],
1332
1339
  definition: {
1333
1340
  coding: { system: SNOMED_SYSTEM, code: "49727002", display: "Cough" },
1334
- text: "Cough"
1341
+ text: "Cough",
1342
+ i18n: { th: "ไอ" }
1335
1343
  }
1336
1344
  },
1337
1345
  {
1338
1346
  names: ["fever", "temperature", "pyrexia"],
1339
1347
  definition: {
1340
1348
  coding: { system: SNOMED_SYSTEM, code: "386661006", display: "Fever" },
1341
- text: "Fever"
1349
+ text: "Fever",
1350
+ i18n: { th: "ไข้" }
1342
1351
  }
1343
1352
  },
1344
1353
  {
1345
1354
  names: ["spasm", "spasms", "muscle spasm"],
1346
1355
  definition: {
1347
1356
  coding: { system: SNOMED_SYSTEM, code: "45352006", display: "Spasm" },
1348
- text: "Spasm"
1357
+ text: "Spasm",
1358
+ i18n: { th: "ตะคริวหรือเกร็ง" }
1349
1359
  }
1350
1360
  },
1351
1361
  {
@@ -1356,7 +1366,8 @@ const DEFAULT_PRN_REASON_SOURCE = [
1356
1366
  code: "14760008",
1357
1367
  display: "Constipation"
1358
1368
  },
1359
- text: "Constipation"
1369
+ text: "Constipation",
1370
+ i18n: { th: "ท้องผูก" }
1360
1371
  }
1361
1372
  },
1362
1373
  {
@@ -1367,7 +1378,8 @@ const DEFAULT_PRN_REASON_SOURCE = [
1367
1378
  code: "257553007",
1368
1379
  display: "Irritation"
1369
1380
  },
1370
- text: "Irritation"
1381
+ text: "Irritation",
1382
+ i18n: { th: "ระคายเคือง" }
1371
1383
  }
1372
1384
  },
1373
1385
  {
@@ -1378,7 +1390,8 @@ const DEFAULT_PRN_REASON_SOURCE = [
1378
1390
  code: "267036007",
1379
1391
  display: "Dyspnea"
1380
1392
  },
1381
- text: "Shortness of breath"
1393
+ text: "Shortness of breath",
1394
+ i18n: { th: "เหนื่อยหรือหายใจลำบาก" }
1382
1395
  }
1383
1396
  }
1384
1397
  ];
@@ -1419,7 +1432,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1419
1432
  code: "311504000",
1420
1433
  display: "With or after food"
1421
1434
  },
1422
- text: "Take with or after food"
1435
+ text: "Take with or after food",
1436
+ i18n: { th: "รับประทานพร้อมหรือหลังอาหาร" }
1423
1437
  }
1424
1438
  },
1425
1439
  {
@@ -1430,7 +1444,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1430
1444
  code: "311501008",
1431
1445
  display: "Half to one hour before food"
1432
1446
  },
1433
- text: "Take before food"
1447
+ text: "Take before food",
1448
+ i18n: { th: "รับประทานก่อนอาหาร" }
1434
1449
  }
1435
1450
  },
1436
1451
  {
@@ -1441,7 +1456,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1441
1456
  code: "717154004",
1442
1457
  display: "Take on an empty stomach (qualifier value)"
1443
1458
  },
1444
- text: "Take on an empty stomach"
1459
+ text: "Take on an empty stomach",
1460
+ i18n: { th: "รับประทานขณะท้องว่าง" }
1445
1461
  }
1446
1462
  },
1447
1463
  {
@@ -1452,7 +1468,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1452
1468
  code: "419303009",
1453
1469
  display: "With plenty of water"
1454
1470
  },
1455
- text: "Take with plenty of water"
1471
+ text: "Take with plenty of water",
1472
+ i18n: { th: "รับประทานพร้อมน้ำดื่มจำนวนมาก" }
1456
1473
  }
1457
1474
  },
1458
1475
  {
@@ -1463,7 +1480,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1463
1480
  code: "417995008",
1464
1481
  display: "Dissolve or mix with water before taking"
1465
1482
  },
1466
- text: "Dissolve or mix with water before taking"
1483
+ text: "Dissolve or mix with water before taking",
1484
+ i18n: { th: "ละลายหรือผสมน้ำก่อนรับประทาน" }
1467
1485
  }
1468
1486
  },
1469
1487
  {
@@ -1474,7 +1492,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1474
1492
  code: "419822006",
1475
1493
  display: "Warning. Avoid alcoholic drink (qualifier value)"
1476
1494
  },
1477
- text: "Avoid alcoholic drinks"
1495
+ text: "Avoid alcoholic drinks",
1496
+ i18n: { th: "หลีกเลี่ยงเครื่องดื่มแอลกอฮอล์" }
1478
1497
  }
1479
1498
  },
1480
1499
  {
@@ -1485,7 +1504,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1485
1504
  code: "418954008",
1486
1505
  display: "Warning. May cause drowsiness. If affected do not drive or operate machinery (qualifier value)"
1487
1506
  },
1488
- text: "May cause drowsiness; do not drive if affected"
1507
+ text: "May cause drowsiness; do not drive if affected",
1508
+ i18n: { th: "อาจทำให้ง่วงซึม; ห้ามขับขี่ยานพาหนะหรือทำงานกับเครื่องจักรหากมีอาการ" }
1489
1509
  }
1490
1510
  },
1491
1511
  {
@@ -1506,7 +1526,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1506
1526
  code: "418914006",
1507
1527
  display: "Warning. May cause drowsiness. If affected do not drive or operate machinery. Avoid alcoholic drink (qualifier value)"
1508
1528
  },
1509
- text: "May cause drowsiness; avoid driving or alcohol"
1529
+ text: "May cause drowsiness; avoid driving or alcohol",
1530
+ i18n: { th: "อาจทำให้ง่วงซึม; หลีกเลี่ยงการขับขี่ยานพาหนะหรือดื่มแอลกอฮอล์" }
1510
1531
  }
1511
1532
  },
1512
1533
  {
@@ -1523,7 +1544,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1523
1544
  code: "418071006",
1524
1545
  display: "Warning. Causes drowsiness which may continue the next day. If affected do not drive or operate machinery. Avoid alcoholic drink (qualifier value)"
1525
1546
  },
1526
- text: "May cause next-day drowsiness; avoid driving or alcohol"
1547
+ text: "May cause next-day drowsiness; avoid driving or alcohol",
1548
+ i18n: { th: "อาจทำให้ง่วงซึมในวันถัดมา; หลีกเลี่ยงการขับขี่ยานพาหนะหรือดื่มแอลกอฮอล์" }
1527
1549
  }
1528
1550
  },
1529
1551
  {
@@ -1534,7 +1556,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1534
1556
  code: "418521000",
1535
1557
  display: "Avoid exposure of skin to direct sunlight or sun lamps (qualifier value)"
1536
1558
  },
1537
- text: "Avoid sunlight or sun lamps"
1559
+ text: "Avoid sunlight or sun lamps",
1560
+ i18n: { th: "หลีกเลี่ยงแสงแดดหรือหลอดไฟแสงยูวี" }
1538
1561
  }
1539
1562
  },
1540
1563
  {
@@ -1545,7 +1568,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1545
1568
  code: "418693002",
1546
1569
  display: "Swallowed whole, not chewed (qualifier value)"
1547
1570
  },
1548
- text: "Swallow whole; do not crush or chew"
1571
+ text: "Swallow whole; do not crush or chew",
1572
+ i18n: { th: "กลืนทั้งเม็ด; ห้ามเคี้ยวหรือบด" }
1549
1573
  }
1550
1574
  },
1551
1575
  {
@@ -1556,7 +1580,8 @@ const DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE = [
1556
1580
  code: "418991002",
1557
1581
  display: "Sucked or chewed (qualifier value)"
1558
1582
  },
1559
- text: "Suck or chew before swallowing"
1583
+ text: "Suck or chew before swallowing",
1584
+ i18n: { th: "เคี้ยวหรืออมให้ละลายก่อนกลืน" }
1560
1585
  }
1561
1586
  }
1562
1587
  ];
@@ -1588,3 +1613,17 @@ exports.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS = (0, object_1.objectFromEntr
1588
1613
  }
1589
1614
  return entries;
1590
1615
  }, []));
1616
+ /**
1617
+ * Finds a default PRN reason definition by its SNOMED coding.
1618
+ */
1619
+ function findPrnReasonDefinitionByCoding(system, code) {
1620
+ var _a;
1621
+ return (_a = DEFAULT_PRN_REASON_SOURCE.find((source) => { var _a, _b; return ((_a = source.definition.coding) === null || _a === void 0 ? void 0 : _a.system) === system && ((_b = source.definition.coding) === null || _b === void 0 ? void 0 : _b.code) === code; })) === null || _a === void 0 ? void 0 : _a.definition;
1622
+ }
1623
+ /**
1624
+ * Finds a default additional instruction definition by its SNOMED coding.
1625
+ */
1626
+ function findAdditionalInstructionDefinitionByCoding(system, code) {
1627
+ var _a;
1628
+ return (_a = DEFAULT_ADDITIONAL_INSTRUCTION_SOURCE.find((source) => { var _a, _b; return ((_a = source.definition.coding) === null || _a === void 0 ? void 0 : _a.system) === system && ((_b = source.definition.coding) === null || _b === void 0 ? void 0 : _b.code) === code; })) === null || _a === void 0 ? void 0 : _a.definition;
1629
+ }
package/dist/parser.js CHANGED
@@ -3126,7 +3126,7 @@ function collectAdditionalInstructions(internal, tokens) {
3126
3126
  if (/\s/.test(ch)) {
3127
3127
  continue;
3128
3128
  }
3129
- if (/-|;|:|\.|,/.test(ch)) {
3129
+ if (/-|;|:|\.|\,/.test(ch)) {
3130
3130
  separatorDetected = true;
3131
3131
  }
3132
3132
  break;
@@ -3135,9 +3135,6 @@ function collectAdditionalInstructions(internal, tokens) {
3135
3135
  const sourceText = range
3136
3136
  ? internal.input.slice(range.start, range.end)
3137
3137
  : joined;
3138
- if (!separatorDetected && !/[-;:.]/.test(sourceText)) {
3139
- return;
3140
- }
3141
3138
  const normalized = sourceText
3142
3139
  .replace(/\s*[-:]+\s*/g, "; ")
3143
3140
  .replace(/\s*(?:\r?\n)+\s*/g, "; ")
@@ -3146,6 +3143,18 @@ function collectAdditionalInstructions(internal, tokens) {
3146
3143
  .split(/(?:;|\.)/)
3147
3144
  .map((segment) => segment.trim())
3148
3145
  .filter((segment) => segment.length > 0);
3146
+ // If no punctuation was detected, we only collect if at least one segment matches a known definition.
3147
+ // This avoids capturing random trailing text as instructions unless it's codified.
3148
+ if (!separatorDetected && !/[-;:.]/.test(sourceText)) {
3149
+ const hasKnownDefinition = segments.some((phrase) => {
3150
+ const canonical = (0, maps_1.normalizeAdditionalInstructionKey)(phrase);
3151
+ return (maps_1.DEFAULT_ADDITIONAL_INSTRUCTION_DEFINITIONS[canonical] ||
3152
+ findAdditionalInstructionDefinition(phrase, canonical));
3153
+ });
3154
+ if (!hasKnownDefinition) {
3155
+ return;
3156
+ }
3157
+ }
3149
3158
  const phrases = segments.length ? segments : [joined];
3150
3159
  const seen = new Set();
3151
3160
  const instructions = [];
@@ -3168,7 +3177,8 @@ function collectAdditionalInstructions(internal, tokens) {
3168
3177
  ? {
3169
3178
  code: definition.coding.code,
3170
3179
  display: definition.coding.display,
3171
- system: (_f = definition.coding.system) !== null && _f !== void 0 ? _f : SNOMED_SYSTEM
3180
+ system: (_f = definition.coding.system) !== null && _f !== void 0 ? _f : SNOMED_SYSTEM,
3181
+ i18n: definition.i18n
3172
3182
  }
3173
3183
  : undefined
3174
3184
  });
@@ -3398,7 +3408,8 @@ function applyPrnReasonDefinition(internal, definition) {
3398
3408
  ? {
3399
3409
  code: coding.code,
3400
3410
  display: coding.display,
3401
- system: (_a = coding.system) !== null && _a !== void 0 ? _a : SNOMED_SYSTEM
3411
+ system: (_a = coding.system) !== null && _a !== void 0 ? _a : SNOMED_SYSTEM,
3412
+ i18n: definition.i18n
3402
3413
  }
3403
3414
  : undefined;
3404
3415
  if (definition.text && !internal.asNeededReason) {
package/dist/types.d.ts CHANGED
@@ -316,6 +316,8 @@ export interface CodeableConceptDefinition {
316
316
  coding?: FhirCoding;
317
317
  text?: string;
318
318
  aliases?: string[];
319
+ /** Optional translations for different locales (e.g., { "th": "ปวด" }) */
320
+ i18n?: Record<string, string>;
319
321
  }
320
322
  export interface PrnReasonDefinition extends CodeableConceptDefinition {
321
323
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",