ezmedicationinput 0.1.48 → 0.1.49

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.cjs CHANGED
@@ -1178,6 +1178,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1178
1178
  definition: {
1179
1179
  coding: { code: "81745001", display: "Eye" },
1180
1180
  text: "eye",
1181
+ i18n: { th: "\u0E15\u0E32" },
1181
1182
  routeHint: RouteCode["Ophthalmic route"]
1182
1183
  }
1183
1184
  },
@@ -1186,6 +1187,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1186
1187
  definition: {
1187
1188
  coding: { code: "1290031003", display: "Structure of left eye proper" },
1188
1189
  text: "left eye",
1190
+ i18n: { th: "\u0E15\u0E32\u0E0B\u0E49\u0E32\u0E22" },
1189
1191
  routeHint: RouteCode["Ophthalmic route"]
1190
1192
  }
1191
1193
  },
@@ -1194,6 +1196,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1194
1196
  definition: {
1195
1197
  coding: { code: "1290032005", display: "Structure of right eye proper" },
1196
1198
  text: "right eye",
1199
+ i18n: { th: "\u0E15\u0E32\u0E02\u0E27\u0E32" },
1197
1200
  routeHint: RouteCode["Ophthalmic route"]
1198
1201
  }
1199
1202
  },
@@ -1202,6 +1205,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1202
1205
  definition: {
1203
1206
  coding: { code: "40638003", display: "Structure of both eyes" },
1204
1207
  text: "both eyes",
1208
+ i18n: { th: "\u0E15\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2A\u0E2D\u0E07\u0E02\u0E49\u0E32\u0E07" },
1205
1209
  routeHint: RouteCode["Ophthalmic route"]
1206
1210
  }
1207
1211
  },
@@ -4591,7 +4595,8 @@ function buildBodySiteCoding(definition) {
4591
4595
  return {
4592
4596
  code: coding.code,
4593
4597
  display: coding.display,
4594
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3
4598
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4599
+ i18n: definition == null ? void 0 : definition.i18n
4595
4600
  };
4596
4601
  }
4597
4602
  function cloneBodySiteCode(coding) {
@@ -10288,12 +10293,13 @@ function buildSiteCodingArray(siteCoding) {
10288
10293
  if (!(siteCoding == null ? void 0 : siteCoding.code)) {
10289
10294
  return void 0;
10290
10295
  }
10296
+ const displayElement = buildTranslationPrimitiveElement(siteCoding.i18n);
10291
10297
  return [
10292
- {
10298
+ __spreadValues({
10293
10299
  system: (_a2 = siteCoding.system) != null ? _a2 : SNOMED_SYSTEM5,
10294
10300
  code: siteCoding.code,
10295
10301
  display: siteCoding.display
10296
- }
10302
+ }, displayElement ? { _display: displayElement } : {})
10297
10303
  ];
10298
10304
  }
10299
10305
  function getFallbackSiteText(site) {
@@ -10553,7 +10559,7 @@ function appendWarning(warnings, warning) {
10553
10559
  return warnings;
10554
10560
  }
10555
10561
  function canonicalToFhir(clause, textOverride, options) {
10556
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
10562
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
10557
10563
  const dosage = {};
10558
10564
  const repeat = {};
10559
10565
  let hasRepeat = false;
@@ -10653,11 +10659,13 @@ function canonicalToFhir(clause, textOverride, options) {
10653
10659
  }
10654
10660
  if (((_l = clause.site) == null ? void 0 : _l.text) || ((_n = (_m = clause.site) == null ? void 0 : _m.coding) == null ? void 0 : _n.code) || ((_o = clause.site) == null ? void 0 : _o.spatialRelation)) {
10655
10661
  const siteCoding = selectCanonicalSiteCoding(clause.site, options);
10656
- dosage.site = {
10657
- text: (_p = clause.site) == null ? void 0 : _p.text,
10662
+ const siteTextElement = buildTranslationPrimitiveElement(siteCoding == null ? void 0 : siteCoding.i18n);
10663
+ dosage.site = __spreadProps(__spreadValues({
10664
+ text: (_p = clause.site) == null ? void 0 : _p.text
10665
+ }, siteTextElement ? { _text: siteTextElement } : {}), {
10658
10666
  coding: buildSiteCodingArray(siteCoding),
10659
10667
  extension: buildBodySiteSpatialRelationExtensions((_q = clause.site) == null ? void 0 : _q.spatialRelation)
10660
- };
10668
+ });
10661
10669
  }
10662
10670
  if (((_r = clause.method) == null ? void 0 : _r.text) || ((_s = clause.method) == null ? void 0 : _s._text) || ((_u = (_t = clause.method) == null ? void 0 : _t.coding) == null ? void 0 : _u.code)) {
10663
10671
  dosage.method = {
@@ -10698,14 +10706,20 @@ function canonicalToFhir(clause, textOverride, options) {
10698
10706
  if (reason.text) {
10699
10707
  concept.text = reason.text;
10700
10708
  }
10701
- if ((_F = reason.coding) == null ? void 0 : _F.code) {
10709
+ const reasonTextElement = buildTranslationPrimitiveElement((_F = reason.coding) == null ? void 0 : _F.i18n);
10710
+ if (reasonTextElement) {
10711
+ concept._text = reasonTextElement;
10712
+ }
10713
+ if ((_G = reason.coding) == null ? void 0 : _G.code) {
10714
+ const displayElement = (_H = clonePrimitiveElement(reason.coding._display)) != null ? _H : buildTranslationPrimitiveElement(reason.coding.i18n);
10702
10715
  concept.coding = [
10703
- {
10704
- system: (_G = reason.coding.system) != null ? _G : SNOMED_SYSTEM5,
10716
+ __spreadProps(__spreadValues({
10717
+ system: (_I = reason.coding.system) != null ? _I : SNOMED_SYSTEM5,
10705
10718
  code: reason.coding.code,
10706
- display: reason.coding.display,
10719
+ display: reason.coding.display
10720
+ }, displayElement ? { _display: displayElement } : {}), {
10707
10721
  extension: cloneExtensions(reason.coding.extension)
10708
- }
10722
+ })
10709
10723
  ];
10710
10724
  }
10711
10725
  concept.extension = buildBodySiteSpatialRelationExtensions(reason.spatialRelation);
@@ -16639,7 +16653,8 @@ function applyRouteSiteDefault(state) {
16639
16653
  state.siteCoding = {
16640
16654
  system: (_i = definition.coding.system) != null ? _i : "http://snomed.info/sct",
16641
16655
  code: definition.coding.code,
16642
- display: definition.coding.display
16656
+ display: definition.coding.display,
16657
+ i18n: definition.i18n
16643
16658
  };
16644
16659
  }
16645
16660
  }
@@ -17951,7 +17966,8 @@ function applySiteDefinition(internal, definition) {
17951
17966
  internal.siteCoding = (coding == null ? void 0 : coding.code) ? {
17952
17967
  code: coding.code,
17953
17968
  display: coding.display,
17954
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9
17969
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9,
17970
+ i18n: definition.i18n
17955
17971
  } : void 0;
17956
17972
  if (definition.text) {
17957
17973
  internal.siteText = definition.text;
@@ -18307,7 +18323,8 @@ function seedKnownSiteCoding(state) {
18307
18323
  state.siteCoding = {
18308
18324
  system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM10,
18309
18325
  code: definition.coding.code,
18310
- display: definition.coding.display
18326
+ display: definition.coding.display,
18327
+ i18n: definition.i18n
18311
18328
  };
18312
18329
  }
18313
18330
  function parseClauseState(input, options) {
package/dist/index.js CHANGED
@@ -1082,6 +1082,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1082
1082
  definition: {
1083
1083
  coding: { code: "81745001", display: "Eye" },
1084
1084
  text: "eye",
1085
+ i18n: { th: "\u0E15\u0E32" },
1085
1086
  routeHint: RouteCode["Ophthalmic route"]
1086
1087
  }
1087
1088
  },
@@ -1090,6 +1091,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1090
1091
  definition: {
1091
1092
  coding: { code: "1290031003", display: "Structure of left eye proper" },
1092
1093
  text: "left eye",
1094
+ i18n: { th: "\u0E15\u0E32\u0E0B\u0E49\u0E32\u0E22" },
1093
1095
  routeHint: RouteCode["Ophthalmic route"]
1094
1096
  }
1095
1097
  },
@@ -1098,6 +1100,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1098
1100
  definition: {
1099
1101
  coding: { code: "1290032005", display: "Structure of right eye proper" },
1100
1102
  text: "right eye",
1103
+ i18n: { th: "\u0E15\u0E32\u0E02\u0E27\u0E32" },
1101
1104
  routeHint: RouteCode["Ophthalmic route"]
1102
1105
  }
1103
1106
  },
@@ -1106,6 +1109,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1106
1109
  definition: {
1107
1110
  coding: { code: "40638003", display: "Structure of both eyes" },
1108
1111
  text: "both eyes",
1112
+ i18n: { th: "\u0E15\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2A\u0E2D\u0E07\u0E02\u0E49\u0E32\u0E07" },
1109
1113
  routeHint: RouteCode["Ophthalmic route"]
1110
1114
  }
1111
1115
  },
@@ -4495,7 +4499,8 @@ function buildBodySiteCoding(definition) {
4495
4499
  return {
4496
4500
  code: coding.code,
4497
4501
  display: coding.display,
4498
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3
4502
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4503
+ i18n: definition == null ? void 0 : definition.i18n
4499
4504
  };
4500
4505
  }
4501
4506
  function cloneBodySiteCode(coding) {
@@ -10192,12 +10197,13 @@ function buildSiteCodingArray(siteCoding) {
10192
10197
  if (!(siteCoding == null ? void 0 : siteCoding.code)) {
10193
10198
  return void 0;
10194
10199
  }
10200
+ const displayElement = buildTranslationPrimitiveElement(siteCoding.i18n);
10195
10201
  return [
10196
- {
10202
+ __spreadValues({
10197
10203
  system: (_a2 = siteCoding.system) != null ? _a2 : SNOMED_SYSTEM5,
10198
10204
  code: siteCoding.code,
10199
10205
  display: siteCoding.display
10200
- }
10206
+ }, displayElement ? { _display: displayElement } : {})
10201
10207
  ];
10202
10208
  }
10203
10209
  function getFallbackSiteText(site) {
@@ -10457,7 +10463,7 @@ function appendWarning(warnings, warning) {
10457
10463
  return warnings;
10458
10464
  }
10459
10465
  function canonicalToFhir(clause, textOverride, options) {
10460
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
10466
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I;
10461
10467
  const dosage = {};
10462
10468
  const repeat = {};
10463
10469
  let hasRepeat = false;
@@ -10557,11 +10563,13 @@ function canonicalToFhir(clause, textOverride, options) {
10557
10563
  }
10558
10564
  if (((_l = clause.site) == null ? void 0 : _l.text) || ((_n = (_m = clause.site) == null ? void 0 : _m.coding) == null ? void 0 : _n.code) || ((_o = clause.site) == null ? void 0 : _o.spatialRelation)) {
10559
10565
  const siteCoding = selectCanonicalSiteCoding(clause.site, options);
10560
- dosage.site = {
10561
- text: (_p = clause.site) == null ? void 0 : _p.text,
10566
+ const siteTextElement = buildTranslationPrimitiveElement(siteCoding == null ? void 0 : siteCoding.i18n);
10567
+ dosage.site = __spreadProps(__spreadValues({
10568
+ text: (_p = clause.site) == null ? void 0 : _p.text
10569
+ }, siteTextElement ? { _text: siteTextElement } : {}), {
10562
10570
  coding: buildSiteCodingArray(siteCoding),
10563
10571
  extension: buildBodySiteSpatialRelationExtensions((_q = clause.site) == null ? void 0 : _q.spatialRelation)
10564
- };
10572
+ });
10565
10573
  }
10566
10574
  if (((_r = clause.method) == null ? void 0 : _r.text) || ((_s = clause.method) == null ? void 0 : _s._text) || ((_u = (_t = clause.method) == null ? void 0 : _t.coding) == null ? void 0 : _u.code)) {
10567
10575
  dosage.method = {
@@ -10602,14 +10610,20 @@ function canonicalToFhir(clause, textOverride, options) {
10602
10610
  if (reason.text) {
10603
10611
  concept.text = reason.text;
10604
10612
  }
10605
- if ((_F = reason.coding) == null ? void 0 : _F.code) {
10613
+ const reasonTextElement = buildTranslationPrimitiveElement((_F = reason.coding) == null ? void 0 : _F.i18n);
10614
+ if (reasonTextElement) {
10615
+ concept._text = reasonTextElement;
10616
+ }
10617
+ if ((_G = reason.coding) == null ? void 0 : _G.code) {
10618
+ const displayElement = (_H = clonePrimitiveElement(reason.coding._display)) != null ? _H : buildTranslationPrimitiveElement(reason.coding.i18n);
10606
10619
  concept.coding = [
10607
- {
10608
- system: (_G = reason.coding.system) != null ? _G : SNOMED_SYSTEM5,
10620
+ __spreadProps(__spreadValues({
10621
+ system: (_I = reason.coding.system) != null ? _I : SNOMED_SYSTEM5,
10609
10622
  code: reason.coding.code,
10610
- display: reason.coding.display,
10623
+ display: reason.coding.display
10624
+ }, displayElement ? { _display: displayElement } : {}), {
10611
10625
  extension: cloneExtensions(reason.coding.extension)
10612
- }
10626
+ })
10613
10627
  ];
10614
10628
  }
10615
10629
  concept.extension = buildBodySiteSpatialRelationExtensions(reason.spatialRelation);
@@ -16543,7 +16557,8 @@ function applyRouteSiteDefault(state) {
16543
16557
  state.siteCoding = {
16544
16558
  system: (_i = definition.coding.system) != null ? _i : "http://snomed.info/sct",
16545
16559
  code: definition.coding.code,
16546
- display: definition.coding.display
16560
+ display: definition.coding.display,
16561
+ i18n: definition.i18n
16547
16562
  };
16548
16563
  }
16549
16564
  }
@@ -17855,7 +17870,8 @@ function applySiteDefinition(internal, definition) {
17855
17870
  internal.siteCoding = (coding == null ? void 0 : coding.code) ? {
17856
17871
  code: coding.code,
17857
17872
  display: coding.display,
17858
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9
17873
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9,
17874
+ i18n: definition.i18n
17859
17875
  } : void 0;
17860
17876
  if (definition.text) {
17861
17877
  internal.siteText = definition.text;
@@ -18211,7 +18227,8 @@ function seedKnownSiteCoding(state) {
18211
18227
  state.siteCoding = {
18212
18228
  system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM10,
18213
18229
  code: definition.coding.code,
18214
- display: definition.coding.display
18230
+ display: definition.coding.display,
18231
+ i18n: definition.i18n
18215
18232
  };
18216
18233
  }
18217
18234
  function parseClauseState(input, options) {
package/dist/types.d.ts CHANGED
@@ -416,6 +416,8 @@ export interface BodySiteDefinition {
416
416
  text?: string;
417
417
  spatialRelation?: BodySiteSpatialRelation;
418
418
  routeHint?: RouteCode;
419
+ /** Optional translations for different locales (e.g., { "th": "ตา" }) */
420
+ i18n?: Record<string, string>;
419
421
  /**
420
422
  * Optional phrases that should resolve to the same coding as this entry.
421
423
  * Aliases are normalized with the same logic as map keys so callers can
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.48",
3
+ "version": "0.1.49",
4
4
  "description": "Parse concise medication sigs into FHIR R5 Dosage JSON",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -14,6 +14,11 @@
14
14
  "default": "./dist/index.js"
15
15
  }
16
16
  },
17
+ "scripts": {
18
+ "test:dist": "npm run build && vitest run test-dist",
19
+ "build": "tsup && tsc -p tsconfig.types.json",
20
+ "test": "vitest run --dir test"
21
+ },
17
22
  "files": [
18
23
  "dist"
19
24
  ],
@@ -34,10 +39,5 @@
34
39
  "tsup": "^8.5.1",
35
40
  "typescript": "^5.4.0",
36
41
  "vitest": "^1.5.0"
37
- },
38
- "scripts": {
39
- "test:dist": "npm run build && vitest run test-dist",
40
- "build": "tsup && tsc -p tsconfig.types.json",
41
- "test": "vitest run --dir test"
42
42
  }
43
- }
43
+ }