ezmedicationinput 0.1.48 → 0.1.50

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.
@@ -1,8 +1,11 @@
1
1
  import { FhirExtension, FhirPrimitiveElement } from "./types";
2
2
  export declare const FHIR_TRANSLATION_EXTENSION_URL = "http://hl7.org/fhir/StructureDefinition/translation";
3
3
  export declare function cloneI18nRecord(i18n: Record<string, string> | undefined): Record<string, string> | undefined;
4
+ export declare function mergeI18nRecords(...records: Array<Record<string, string> | undefined>): Record<string, string> | undefined;
4
5
  export declare function cloneExtension(extension: FhirExtension): FhirExtension;
5
6
  export declare function cloneExtensions(extensions: FhirExtension[] | undefined): FhirExtension[] | undefined;
6
7
  export declare function clonePrimitiveElement(element: FhirPrimitiveElement | undefined): FhirPrimitiveElement | undefined;
7
8
  export declare function buildTranslationPrimitiveElement(translations: Record<string, string> | undefined, base?: FhirPrimitiveElement): FhirPrimitiveElement | undefined;
9
+ export declare function mergeTranslationPrimitiveElement(base: FhirPrimitiveElement | undefined, translations: Record<string, string> | undefined): FhirPrimitiveElement | undefined;
8
10
  export declare function getPrimitiveTranslation(element: FhirPrimitiveElement | undefined, locale: string | undefined): string | undefined;
11
+ export declare function getPrimitiveTranslations(element: FhirPrimitiveElement | undefined): Record<string, string> | undefined;
package/dist/fhir.d.ts CHANGED
@@ -7,6 +7,11 @@ export interface FhirProjectionOptions {
7
7
  * Dosage.site.coding while preserving the spatial-relation extension.
8
8
  */
9
9
  bodySitePostcoordination?: boolean;
10
+ /**
11
+ * Emits FHIR primitive translation extensions on coded concepts when
12
+ * translation metadata is available.
13
+ */
14
+ includeTranslationExtensions?: boolean;
10
15
  }
11
16
  export declare function canonicalToFhir(clause: CanonicalSigClause, textOverride?: string, options?: FhirProjectionOptions): FhirDosage;
12
17
  export declare function toFhir(state: ParserState): FhirDosage;
package/dist/index.cjs CHANGED
@@ -481,6 +481,24 @@ function normalizeLocaleKey(locale) {
481
481
  function cloneI18nRecord(i18n) {
482
482
  return i18n ? __spreadValues({}, i18n) : void 0;
483
483
  }
484
+ function mergeI18nRecords(...records) {
485
+ var _a2;
486
+ const merged = {};
487
+ for (const record of records) {
488
+ if (!record) {
489
+ continue;
490
+ }
491
+ for (const locale in record) {
492
+ const normalizedLocale = normalizeLocaleKey(locale);
493
+ const content = (_a2 = record[locale]) == null ? void 0 : _a2.trim();
494
+ if (!normalizedLocale || !content) {
495
+ continue;
496
+ }
497
+ merged[normalizedLocale] = content;
498
+ }
499
+ }
500
+ return Object.keys(merged).length ? merged : void 0;
501
+ }
484
502
  function cloneExtension(extension) {
485
503
  var _a2, _b, _c, _d;
486
504
  return {
@@ -567,6 +585,32 @@ function buildTranslationPrimitiveElement(translations, base) {
567
585
  extension: nextExtensions
568
586
  };
569
587
  }
588
+ function mergeTranslationPrimitiveElement(base, translations) {
589
+ var _a2, _b, _c, _d;
590
+ const nextExtensions = (_b = (_a2 = base == null ? void 0 : base.extension) == null ? void 0 : _a2.map(cloneExtension)) != null ? _b : [];
591
+ const existingTranslationLocales = /* @__PURE__ */ new Set();
592
+ for (const extension of nextExtensions) {
593
+ if (extension.url !== FHIR_TRANSLATION_EXTENSION_URL) {
594
+ continue;
595
+ }
596
+ const { locale } = getTranslationParts(extension);
597
+ if (locale) {
598
+ existingTranslationLocales.add(locale);
599
+ }
600
+ }
601
+ const additions = (_d = (_c = buildTranslationPrimitiveElement(translations)) == null ? void 0 : _c.extension) != null ? _d : [];
602
+ for (const extension of additions) {
603
+ const { locale } = getTranslationParts(extension);
604
+ if (locale && existingTranslationLocales.has(locale)) {
605
+ continue;
606
+ }
607
+ if (locale) {
608
+ existingTranslationLocales.add(locale);
609
+ }
610
+ nextExtensions.push(extension);
611
+ }
612
+ return nextExtensions.length ? { extension: nextExtensions } : void 0;
613
+ }
570
614
  function getTranslationParts(extension) {
571
615
  var _a2, _b;
572
616
  const parts = (_a2 = extension.extension) != null ? _a2 : [];
@@ -610,6 +654,24 @@ function getPrimitiveTranslation(element, locale) {
610
654
  }
611
655
  return languagePrefixMatch;
612
656
  }
657
+ function getPrimitiveTranslations(element) {
658
+ var _a2;
659
+ if (!((_a2 = element == null ? void 0 : element.extension) == null ? void 0 : _a2.length)) {
660
+ return void 0;
661
+ }
662
+ const translations = {};
663
+ for (const extension of element.extension) {
664
+ if (extension.url !== FHIR_TRANSLATION_EXTENSION_URL) {
665
+ continue;
666
+ }
667
+ const { locale, content } = getTranslationParts(extension);
668
+ if (!locale || !content) {
669
+ continue;
670
+ }
671
+ translations[locale] = content;
672
+ }
673
+ return Object.keys(translations).length ? translations : void 0;
674
+ }
613
675
 
614
676
  // src/body-site-spatial.ts
615
677
  var SNOMED_SYSTEM2 = "http://snomed.info/sct";
@@ -1178,6 +1240,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1178
1240
  definition: {
1179
1241
  coding: { code: "81745001", display: "Eye" },
1180
1242
  text: "eye",
1243
+ i18n: { th: "\u0E15\u0E32" },
1181
1244
  routeHint: RouteCode["Ophthalmic route"]
1182
1245
  }
1183
1246
  },
@@ -1186,6 +1249,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1186
1249
  definition: {
1187
1250
  coding: { code: "1290031003", display: "Structure of left eye proper" },
1188
1251
  text: "left eye",
1252
+ i18n: { th: "\u0E15\u0E32\u0E0B\u0E49\u0E32\u0E22" },
1189
1253
  routeHint: RouteCode["Ophthalmic route"]
1190
1254
  }
1191
1255
  },
@@ -1194,6 +1258,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1194
1258
  definition: {
1195
1259
  coding: { code: "1290032005", display: "Structure of right eye proper" },
1196
1260
  text: "right eye",
1261
+ i18n: { th: "\u0E15\u0E32\u0E02\u0E27\u0E32" },
1197
1262
  routeHint: RouteCode["Ophthalmic route"]
1198
1263
  }
1199
1264
  },
@@ -1202,6 +1267,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1202
1267
  definition: {
1203
1268
  coding: { code: "40638003", display: "Structure of both eyes" },
1204
1269
  text: "both eyes",
1270
+ i18n: { th: "\u0E15\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2A\u0E2D\u0E07\u0E02\u0E49\u0E32\u0E07" },
1205
1271
  routeHint: RouteCode["Ophthalmic route"]
1206
1272
  }
1207
1273
  },
@@ -4591,7 +4657,8 @@ function buildBodySiteCoding(definition) {
4591
4657
  return {
4592
4658
  code: coding.code,
4593
4659
  display: coding.display,
4594
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3
4660
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4661
+ i18n: mergeI18nRecords(definition == null ? void 0 : definition.i18n, coding.i18n)
4595
4662
  };
4596
4663
  }
4597
4664
  function cloneBodySiteCode(coding) {
@@ -4603,7 +4670,7 @@ function cloneBodySiteCode(coding) {
4603
4670
  code: coding.code,
4604
4671
  display: coding.display,
4605
4672
  system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4606
- i18n: coding.i18n
4673
+ i18n: mergeI18nRecords(coding.i18n)
4607
4674
  };
4608
4675
  }
4609
4676
  function lookupDefinitionForCanonical(canonical, customSiteMap) {
@@ -10026,6 +10093,7 @@ var ParserState = class {
10026
10093
  for (const reason of value) {
10027
10094
  reasons.push({
10028
10095
  text: reason.text,
10096
+ i18n: cloneI18nRecord(reason.i18n),
10029
10097
  spatialRelation: cloneBodySiteSpatialRelation(reason.spatialRelation),
10030
10098
  coding: reason.coding ? {
10031
10099
  code: reason.coding.code,
@@ -10033,7 +10101,7 @@ var ParserState = class {
10033
10101
  system: reason.coding.system,
10034
10102
  extension: cloneExtensions(reason.coding.extension),
10035
10103
  _display: clonePrimitiveElement(reason.coding._display),
10036
- i18n: reason.coding.i18n
10104
+ i18n: cloneI18nRecord(reason.coding.i18n)
10037
10105
  } : void 0
10038
10106
  });
10039
10107
  }
@@ -10065,7 +10133,7 @@ var ParserState = class {
10065
10133
  system: value.system,
10066
10134
  extension: cloneExtensions(value.extension),
10067
10135
  _display: clonePrimitiveElement(value._display),
10068
- i18n: value.i18n
10136
+ i18n: cloneI18nRecord(value.i18n)
10069
10137
  } : void 0;
10070
10138
  }
10071
10139
  get siteText() {
@@ -10098,7 +10166,7 @@ var ParserState = class {
10098
10166
  code: value.code,
10099
10167
  display: value.display,
10100
10168
  system: value.system,
10101
- i18n: value.i18n
10169
+ i18n: cloneI18nRecord(value.i18n)
10102
10170
  } : void 0;
10103
10171
  }
10104
10172
  get siteSpatialRelation() {
@@ -10283,17 +10351,18 @@ function selectCanonicalSiteCoding(site, options) {
10283
10351
  );
10284
10352
  return (options == null ? void 0 : options.bodySitePostcoordination) === true ? postcoordinated != null ? postcoordinated : site == null ? void 0 : site.coding : (_a2 = site == null ? void 0 : site.coding) != null ? _a2 : postcoordinated;
10285
10353
  }
10286
- function buildSiteCodingArray(siteCoding) {
10354
+ function buildSiteCodingArray(siteCoding, options) {
10287
10355
  var _a2;
10288
10356
  if (!(siteCoding == null ? void 0 : siteCoding.code)) {
10289
10357
  return void 0;
10290
10358
  }
10359
+ const displayElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement(siteCoding.i18n) : void 0;
10291
10360
  return [
10292
- {
10361
+ __spreadValues({
10293
10362
  system: (_a2 = siteCoding.system) != null ? _a2 : SNOMED_SYSTEM5,
10294
10363
  code: siteCoding.code,
10295
10364
  display: siteCoding.display
10296
- }
10365
+ }, displayElement ? { _display: displayElement } : {})
10297
10366
  ];
10298
10367
  }
10299
10368
  function getFallbackSiteText(site) {
@@ -10307,6 +10376,18 @@ function getFallbackSiteText(site) {
10307
10376
  display: siteCoding.display
10308
10377
  }) : void 0;
10309
10378
  }
10379
+ function codeableConceptTranslationI18n(concept, coding, fallback) {
10380
+ return {
10381
+ text: mergeI18nRecords(
10382
+ fallback,
10383
+ getPrimitiveTranslations(concept == null ? void 0 : concept._text)
10384
+ ),
10385
+ display: mergeI18nRecords(
10386
+ coding == null ? void 0 : coding.i18n,
10387
+ getPrimitiveTranslations(coding == null ? void 0 : coding._display)
10388
+ )
10389
+ };
10390
+ }
10310
10391
  function lowerFirst(value) {
10311
10392
  const trimmed = value == null ? void 0 : value.trim();
10312
10393
  return trimmed ? trimmed.charAt(0).toLowerCase() + trimmed.slice(1) : void 0;
@@ -10553,7 +10634,7 @@ function appendWarning(warnings, warning) {
10553
10634
  return warnings;
10554
10635
  }
10555
10636
  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;
10637
+ 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, _J;
10557
10638
  const dosage = {};
10558
10639
  const repeat = {};
10559
10640
  let hasRepeat = false;
@@ -10653,19 +10734,21 @@ function canonicalToFhir(clause, textOverride, options) {
10653
10734
  }
10654
10735
  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
10736
  const siteCoding = selectCanonicalSiteCoding(clause.site, options);
10656
- dosage.site = {
10657
- text: (_p = clause.site) == null ? void 0 : _p.text,
10658
- coding: buildSiteCodingArray(siteCoding),
10659
- extension: buildBodySiteSpatialRelationExtensions((_q = clause.site) == null ? void 0 : _q.spatialRelation)
10660
- };
10737
+ const siteTextElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement((_p = clause.site.i18n) != null ? _p : siteCoding == null ? void 0 : siteCoding.i18n) : void 0;
10738
+ dosage.site = __spreadProps(__spreadValues({
10739
+ text: (_q = clause.site) == null ? void 0 : _q.text
10740
+ }, siteTextElement ? { _text: siteTextElement } : {}), {
10741
+ coding: buildSiteCodingArray(siteCoding, options),
10742
+ extension: buildBodySiteSpatialRelationExtensions((_r = clause.site) == null ? void 0 : _r.spatialRelation)
10743
+ });
10661
10744
  }
10662
- 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)) {
10745
+ if (((_s = clause.method) == null ? void 0 : _s.text) || ((_t = clause.method) == null ? void 0 : _t._text) || ((_v = (_u = clause.method) == null ? void 0 : _u.coding) == null ? void 0 : _v.code)) {
10663
10746
  dosage.method = {
10664
- text: (_v = clause.method) == null ? void 0 : _v.text,
10665
- _text: clonePrimitiveElement((_w = clause.method) == null ? void 0 : _w._text),
10666
- coding: ((_y = (_x = clause.method) == null ? void 0 : _x.coding) == null ? void 0 : _y.code) ? [
10747
+ text: (_w = clause.method) == null ? void 0 : _w.text,
10748
+ _text: clonePrimitiveElement((_x = clause.method) == null ? void 0 : _x._text),
10749
+ coding: ((_z = (_y = clause.method) == null ? void 0 : _y.coding) == null ? void 0 : _z.code) ? [
10667
10750
  {
10668
- system: (_z = clause.method.coding.system) != null ? _z : SNOMED_SYSTEM5,
10751
+ system: (_A = clause.method.coding.system) != null ? _A : SNOMED_SYSTEM5,
10669
10752
  code: clause.method.coding.code,
10670
10753
  display: clause.method.coding.display,
10671
10754
  _display: clonePrimitiveElement(clause.method.coding._display)
@@ -10673,14 +10756,14 @@ function canonicalToFhir(clause, textOverride, options) {
10673
10756
  ] : void 0
10674
10757
  };
10675
10758
  }
10676
- if ((_A = clause.additionalInstructions) == null ? void 0 : _A.length) {
10759
+ if ((_B = clause.additionalInstructions) == null ? void 0 : _B.length) {
10677
10760
  dosage.additionalInstruction = [];
10678
10761
  for (const instruction of clause.additionalInstructions) {
10679
10762
  dosage.additionalInstruction.push({
10680
10763
  text: instruction.text,
10681
- coding: ((_B = instruction.coding) == null ? void 0 : _B.code) ? [
10764
+ coding: ((_C = instruction.coding) == null ? void 0 : _C.code) ? [
10682
10765
  {
10683
- system: (_C = instruction.coding.system) != null ? _C : SNOMED_SYSTEM5,
10766
+ system: (_D = instruction.coding.system) != null ? _D : SNOMED_SYSTEM5,
10684
10767
  code: instruction.coding.code,
10685
10768
  display: instruction.coding.display
10686
10769
  }
@@ -10688,9 +10771,9 @@ function canonicalToFhir(clause, textOverride, options) {
10688
10771
  });
10689
10772
  }
10690
10773
  }
10691
- if ((_D = clause.prn) == null ? void 0 : _D.enabled) {
10774
+ if ((_E = clause.prn) == null ? void 0 : _E.enabled) {
10692
10775
  dosage.asNeededBoolean = true;
10693
- const reasons = ((_E = clause.prn.reasons) == null ? void 0 : _E.length) ? clause.prn.reasons : clause.prn.reason ? [clause.prn.reason] : [];
10776
+ const reasons = ((_F = clause.prn.reasons) == null ? void 0 : _F.length) ? clause.prn.reasons : clause.prn.reason ? [clause.prn.reason] : [];
10694
10777
  if (reasons.length) {
10695
10778
  dosage.asNeededFor = [];
10696
10779
  for (const reason of reasons) {
@@ -10698,14 +10781,23 @@ function canonicalToFhir(clause, textOverride, options) {
10698
10781
  if (reason.text) {
10699
10782
  concept.text = reason.text;
10700
10783
  }
10701
- if ((_F = reason.coding) == null ? void 0 : _F.code) {
10784
+ const reasonTextElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement((_H = reason.i18n) != null ? _H : (_G = reason.coding) == null ? void 0 : _G.i18n) : void 0;
10785
+ if (reasonTextElement) {
10786
+ concept._text = reasonTextElement;
10787
+ }
10788
+ if ((_I = reason.coding) == null ? void 0 : _I.code) {
10789
+ const displayElement = (options == null ? void 0 : options.includeTranslationExtensions) ? mergeTranslationPrimitiveElement(
10790
+ reason.coding._display,
10791
+ reason.coding.i18n
10792
+ ) : clonePrimitiveElement(reason.coding._display);
10702
10793
  concept.coding = [
10703
- {
10704
- system: (_G = reason.coding.system) != null ? _G : SNOMED_SYSTEM5,
10794
+ __spreadProps(__spreadValues({
10795
+ system: (_J = reason.coding.system) != null ? _J : SNOMED_SYSTEM5,
10705
10796
  code: reason.coding.code,
10706
- display: reason.coding.display,
10797
+ display: reason.coding.display
10798
+ }, displayElement ? { _display: displayElement } : {}), {
10707
10799
  extension: cloneExtensions(reason.coding.extension)
10708
- }
10800
+ })
10709
10801
  ];
10710
10802
  }
10711
10803
  concept.extension = buildBodySiteSpatialRelationExtensions(reason.spatialRelation);
@@ -10740,14 +10832,17 @@ function canonicalFromFhir(dosage) {
10740
10832
  const siteCoding = selectPreferredSiteCoding(dosage.site);
10741
10833
  const siteSpatialRelation = parseBodySiteSpatialRelationExtension(dosage.site);
10742
10834
  const siteText = getFallbackSiteText(dosage.site);
10835
+ const siteI18n = codeableConceptTranslationI18n(dosage.site, siteCoding);
10743
10836
  if (siteText || (siteCoding == null ? void 0 : siteCoding.code) || siteSpatialRelation) {
10744
10837
  clause.site = {
10745
10838
  text: siteText,
10839
+ i18n: siteI18n.text,
10746
10840
  spatialRelation: siteSpatialRelation,
10747
10841
  coding: (siteCoding == null ? void 0 : siteCoding.code) ? {
10748
10842
  code: siteCoding.code,
10749
10843
  display: siteCoding.display,
10750
- system: siteCoding.system
10844
+ system: siteCoding.system,
10845
+ i18n: siteI18n.display
10751
10846
  } : void 0,
10752
10847
  source: "text"
10753
10848
  };
@@ -10802,16 +10897,21 @@ function canonicalFromFhir(dosage) {
10802
10897
  };
10803
10898
  }
10804
10899
  const prnReasons = ((_y = dosage.asNeededFor) == null ? void 0 : _y.length) ? dosage.asNeededFor.map((concept) => {
10805
- var _a3;
10900
+ var _a3, _b2;
10806
10901
  const coding = (_a3 = concept.coding) == null ? void 0 : _a3.find((code) => Boolean(code.code));
10902
+ const defaultDef = (coding == null ? void 0 : coding.code) ? findPrnReasonDefinitionByCoding((_b2 = coding.system) != null ? _b2 : SNOMED_SYSTEM5, coding.code) : void 0;
10903
+ const i18n = codeableConceptTranslationI18n(concept, coding, defaultDef == null ? void 0 : defaultDef.i18n);
10807
10904
  return {
10808
10905
  text: getFallbackPrnReasonText(concept),
10906
+ i18n: i18n.text,
10809
10907
  spatialRelation: parseBodySiteSpatialRelationExtension(concept),
10810
10908
  coding: (coding == null ? void 0 : coding.code) ? {
10811
10909
  code: coding.code,
10812
10910
  display: coding.display,
10813
10911
  system: coding.system,
10814
- extension: cloneExtensions(coding.extension)
10912
+ extension: cloneExtensions(coding.extension),
10913
+ _display: clonePrimitiveElement(coding._display),
10914
+ i18n: i18n.display
10815
10915
  } : void 0
10816
10916
  };
10817
10917
  }) : void 0;
@@ -16639,7 +16739,8 @@ function applyRouteSiteDefault(state) {
16639
16739
  state.siteCoding = {
16640
16740
  system: (_i = definition.coding.system) != null ? _i : "http://snomed.info/sct",
16641
16741
  code: definition.coding.code,
16642
- display: definition.coding.display
16742
+ display: definition.coding.display,
16743
+ i18n: mergeI18nRecords(definition.i18n, definition.coding.i18n)
16643
16744
  };
16644
16745
  }
16645
16746
  }
@@ -17951,7 +18052,8 @@ function applySiteDefinition(internal, definition) {
17951
18052
  internal.siteCoding = (coding == null ? void 0 : coding.code) ? {
17952
18053
  code: coding.code,
17953
18054
  display: coding.display,
17954
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9
18055
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9,
18056
+ i18n: mergeI18nRecords(definition.i18n, coding.i18n)
17955
18057
  } : void 0;
17956
18058
  if (definition.text) {
17957
18059
  internal.siteText = definition.text;
@@ -18307,7 +18409,8 @@ function seedKnownSiteCoding(state) {
18307
18409
  state.siteCoding = {
18308
18410
  system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM10,
18309
18411
  code: definition.coding.code,
18310
- display: definition.coding.display
18412
+ display: definition.coding.display,
18413
+ i18n: mergeI18nRecords(definition.i18n, definition.coding.i18n)
18311
18414
  };
18312
18415
  }
18313
18416
  function parseClauseState(input, options) {
@@ -21609,7 +21712,8 @@ function cloneBodySiteCoding2(coding) {
21609
21712
  return {
21610
21713
  code: coding.code,
21611
21714
  display: coding.display,
21612
- system: coding.system
21715
+ system: coding.system,
21716
+ i18n: cloneI18nRecord(coding.i18n)
21613
21717
  };
21614
21718
  }
21615
21719
  function buildNormalizedMetaFromClause(clause, fhir, options) {
@@ -21656,7 +21760,8 @@ function buildParseResult(state, options) {
21656
21760
  const shortText = formatCanonicalClause(clause, "short", localization, options);
21657
21761
  const longText = formatCanonicalClause(clause, "long", localization, options);
21658
21762
  const fhir = canonicalToFhir(clause, longText, {
21659
- bodySitePostcoordination: options == null ? void 0 : options.bodySitePostcoordination
21763
+ bodySitePostcoordination: options == null ? void 0 : options.bodySitePostcoordination,
21764
+ includeTranslationExtensions: Boolean((options == null ? void 0 : options.locale) || (options == null ? void 0 : options.i18n))
21660
21765
  });
21661
21766
  const consumedTokens = [];
21662
21767
  const leftoverParts = [];
package/dist/index.js CHANGED
@@ -385,6 +385,24 @@ function normalizeLocaleKey(locale) {
385
385
  function cloneI18nRecord(i18n) {
386
386
  return i18n ? __spreadValues({}, i18n) : void 0;
387
387
  }
388
+ function mergeI18nRecords(...records) {
389
+ var _a2;
390
+ const merged = {};
391
+ for (const record of records) {
392
+ if (!record) {
393
+ continue;
394
+ }
395
+ for (const locale in record) {
396
+ const normalizedLocale = normalizeLocaleKey(locale);
397
+ const content = (_a2 = record[locale]) == null ? void 0 : _a2.trim();
398
+ if (!normalizedLocale || !content) {
399
+ continue;
400
+ }
401
+ merged[normalizedLocale] = content;
402
+ }
403
+ }
404
+ return Object.keys(merged).length ? merged : void 0;
405
+ }
388
406
  function cloneExtension(extension) {
389
407
  var _a2, _b, _c, _d;
390
408
  return {
@@ -471,6 +489,32 @@ function buildTranslationPrimitiveElement(translations, base) {
471
489
  extension: nextExtensions
472
490
  };
473
491
  }
492
+ function mergeTranslationPrimitiveElement(base, translations) {
493
+ var _a2, _b, _c, _d;
494
+ const nextExtensions = (_b = (_a2 = base == null ? void 0 : base.extension) == null ? void 0 : _a2.map(cloneExtension)) != null ? _b : [];
495
+ const existingTranslationLocales = /* @__PURE__ */ new Set();
496
+ for (const extension of nextExtensions) {
497
+ if (extension.url !== FHIR_TRANSLATION_EXTENSION_URL) {
498
+ continue;
499
+ }
500
+ const { locale } = getTranslationParts(extension);
501
+ if (locale) {
502
+ existingTranslationLocales.add(locale);
503
+ }
504
+ }
505
+ const additions = (_d = (_c = buildTranslationPrimitiveElement(translations)) == null ? void 0 : _c.extension) != null ? _d : [];
506
+ for (const extension of additions) {
507
+ const { locale } = getTranslationParts(extension);
508
+ if (locale && existingTranslationLocales.has(locale)) {
509
+ continue;
510
+ }
511
+ if (locale) {
512
+ existingTranslationLocales.add(locale);
513
+ }
514
+ nextExtensions.push(extension);
515
+ }
516
+ return nextExtensions.length ? { extension: nextExtensions } : void 0;
517
+ }
474
518
  function getTranslationParts(extension) {
475
519
  var _a2, _b;
476
520
  const parts = (_a2 = extension.extension) != null ? _a2 : [];
@@ -514,6 +558,24 @@ function getPrimitiveTranslation(element, locale) {
514
558
  }
515
559
  return languagePrefixMatch;
516
560
  }
561
+ function getPrimitiveTranslations(element) {
562
+ var _a2;
563
+ if (!((_a2 = element == null ? void 0 : element.extension) == null ? void 0 : _a2.length)) {
564
+ return void 0;
565
+ }
566
+ const translations = {};
567
+ for (const extension of element.extension) {
568
+ if (extension.url !== FHIR_TRANSLATION_EXTENSION_URL) {
569
+ continue;
570
+ }
571
+ const { locale, content } = getTranslationParts(extension);
572
+ if (!locale || !content) {
573
+ continue;
574
+ }
575
+ translations[locale] = content;
576
+ }
577
+ return Object.keys(translations).length ? translations : void 0;
578
+ }
517
579
 
518
580
  // src/body-site-spatial.ts
519
581
  var SNOMED_SYSTEM2 = "http://snomed.info/sct";
@@ -1082,6 +1144,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1082
1144
  definition: {
1083
1145
  coding: { code: "81745001", display: "Eye" },
1084
1146
  text: "eye",
1147
+ i18n: { th: "\u0E15\u0E32" },
1085
1148
  routeHint: RouteCode["Ophthalmic route"]
1086
1149
  }
1087
1150
  },
@@ -1090,6 +1153,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1090
1153
  definition: {
1091
1154
  coding: { code: "1290031003", display: "Structure of left eye proper" },
1092
1155
  text: "left eye",
1156
+ i18n: { th: "\u0E15\u0E32\u0E0B\u0E49\u0E32\u0E22" },
1093
1157
  routeHint: RouteCode["Ophthalmic route"]
1094
1158
  }
1095
1159
  },
@@ -1098,6 +1162,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1098
1162
  definition: {
1099
1163
  coding: { code: "1290032005", display: "Structure of right eye proper" },
1100
1164
  text: "right eye",
1165
+ i18n: { th: "\u0E15\u0E32\u0E02\u0E27\u0E32" },
1101
1166
  routeHint: RouteCode["Ophthalmic route"]
1102
1167
  }
1103
1168
  },
@@ -1106,6 +1171,7 @@ var DEFAULT_BODY_SITE_SNOMED_SOURCE = [
1106
1171
  definition: {
1107
1172
  coding: { code: "40638003", display: "Structure of both eyes" },
1108
1173
  text: "both eyes",
1174
+ i18n: { th: "\u0E15\u0E32\u0E17\u0E31\u0E49\u0E07\u0E2A\u0E2D\u0E07\u0E02\u0E49\u0E32\u0E07" },
1109
1175
  routeHint: RouteCode["Ophthalmic route"]
1110
1176
  }
1111
1177
  },
@@ -4495,7 +4561,8 @@ function buildBodySiteCoding(definition) {
4495
4561
  return {
4496
4562
  code: coding.code,
4497
4563
  display: coding.display,
4498
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3
4564
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4565
+ i18n: mergeI18nRecords(definition == null ? void 0 : definition.i18n, coding.i18n)
4499
4566
  };
4500
4567
  }
4501
4568
  function cloneBodySiteCode(coding) {
@@ -4507,7 +4574,7 @@ function cloneBodySiteCode(coding) {
4507
4574
  code: coding.code,
4508
4575
  display: coding.display,
4509
4576
  system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM3,
4510
- i18n: coding.i18n
4577
+ i18n: mergeI18nRecords(coding.i18n)
4511
4578
  };
4512
4579
  }
4513
4580
  function lookupDefinitionForCanonical(canonical, customSiteMap) {
@@ -9930,6 +9997,7 @@ var ParserState = class {
9930
9997
  for (const reason of value) {
9931
9998
  reasons.push({
9932
9999
  text: reason.text,
10000
+ i18n: cloneI18nRecord(reason.i18n),
9933
10001
  spatialRelation: cloneBodySiteSpatialRelation(reason.spatialRelation),
9934
10002
  coding: reason.coding ? {
9935
10003
  code: reason.coding.code,
@@ -9937,7 +10005,7 @@ var ParserState = class {
9937
10005
  system: reason.coding.system,
9938
10006
  extension: cloneExtensions(reason.coding.extension),
9939
10007
  _display: clonePrimitiveElement(reason.coding._display),
9940
- i18n: reason.coding.i18n
10008
+ i18n: cloneI18nRecord(reason.coding.i18n)
9941
10009
  } : void 0
9942
10010
  });
9943
10011
  }
@@ -9969,7 +10037,7 @@ var ParserState = class {
9969
10037
  system: value.system,
9970
10038
  extension: cloneExtensions(value.extension),
9971
10039
  _display: clonePrimitiveElement(value._display),
9972
- i18n: value.i18n
10040
+ i18n: cloneI18nRecord(value.i18n)
9973
10041
  } : void 0;
9974
10042
  }
9975
10043
  get siteText() {
@@ -10002,7 +10070,7 @@ var ParserState = class {
10002
10070
  code: value.code,
10003
10071
  display: value.display,
10004
10072
  system: value.system,
10005
- i18n: value.i18n
10073
+ i18n: cloneI18nRecord(value.i18n)
10006
10074
  } : void 0;
10007
10075
  }
10008
10076
  get siteSpatialRelation() {
@@ -10187,17 +10255,18 @@ function selectCanonicalSiteCoding(site, options) {
10187
10255
  );
10188
10256
  return (options == null ? void 0 : options.bodySitePostcoordination) === true ? postcoordinated != null ? postcoordinated : site == null ? void 0 : site.coding : (_a2 = site == null ? void 0 : site.coding) != null ? _a2 : postcoordinated;
10189
10257
  }
10190
- function buildSiteCodingArray(siteCoding) {
10258
+ function buildSiteCodingArray(siteCoding, options) {
10191
10259
  var _a2;
10192
10260
  if (!(siteCoding == null ? void 0 : siteCoding.code)) {
10193
10261
  return void 0;
10194
10262
  }
10263
+ const displayElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement(siteCoding.i18n) : void 0;
10195
10264
  return [
10196
- {
10265
+ __spreadValues({
10197
10266
  system: (_a2 = siteCoding.system) != null ? _a2 : SNOMED_SYSTEM5,
10198
10267
  code: siteCoding.code,
10199
10268
  display: siteCoding.display
10200
- }
10269
+ }, displayElement ? { _display: displayElement } : {})
10201
10270
  ];
10202
10271
  }
10203
10272
  function getFallbackSiteText(site) {
@@ -10211,6 +10280,18 @@ function getFallbackSiteText(site) {
10211
10280
  display: siteCoding.display
10212
10281
  }) : void 0;
10213
10282
  }
10283
+ function codeableConceptTranslationI18n(concept, coding, fallback) {
10284
+ return {
10285
+ text: mergeI18nRecords(
10286
+ fallback,
10287
+ getPrimitiveTranslations(concept == null ? void 0 : concept._text)
10288
+ ),
10289
+ display: mergeI18nRecords(
10290
+ coding == null ? void 0 : coding.i18n,
10291
+ getPrimitiveTranslations(coding == null ? void 0 : coding._display)
10292
+ )
10293
+ };
10294
+ }
10214
10295
  function lowerFirst(value) {
10215
10296
  const trimmed = value == null ? void 0 : value.trim();
10216
10297
  return trimmed ? trimmed.charAt(0).toLowerCase() + trimmed.slice(1) : void 0;
@@ -10457,7 +10538,7 @@ function appendWarning(warnings, warning) {
10457
10538
  return warnings;
10458
10539
  }
10459
10540
  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;
10541
+ 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, _J;
10461
10542
  const dosage = {};
10462
10543
  const repeat = {};
10463
10544
  let hasRepeat = false;
@@ -10557,19 +10638,21 @@ function canonicalToFhir(clause, textOverride, options) {
10557
10638
  }
10558
10639
  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
10640
  const siteCoding = selectCanonicalSiteCoding(clause.site, options);
10560
- dosage.site = {
10561
- text: (_p = clause.site) == null ? void 0 : _p.text,
10562
- coding: buildSiteCodingArray(siteCoding),
10563
- extension: buildBodySiteSpatialRelationExtensions((_q = clause.site) == null ? void 0 : _q.spatialRelation)
10564
- };
10641
+ const siteTextElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement((_p = clause.site.i18n) != null ? _p : siteCoding == null ? void 0 : siteCoding.i18n) : void 0;
10642
+ dosage.site = __spreadProps(__spreadValues({
10643
+ text: (_q = clause.site) == null ? void 0 : _q.text
10644
+ }, siteTextElement ? { _text: siteTextElement } : {}), {
10645
+ coding: buildSiteCodingArray(siteCoding, options),
10646
+ extension: buildBodySiteSpatialRelationExtensions((_r = clause.site) == null ? void 0 : _r.spatialRelation)
10647
+ });
10565
10648
  }
10566
- 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)) {
10649
+ if (((_s = clause.method) == null ? void 0 : _s.text) || ((_t = clause.method) == null ? void 0 : _t._text) || ((_v = (_u = clause.method) == null ? void 0 : _u.coding) == null ? void 0 : _v.code)) {
10567
10650
  dosage.method = {
10568
- text: (_v = clause.method) == null ? void 0 : _v.text,
10569
- _text: clonePrimitiveElement((_w = clause.method) == null ? void 0 : _w._text),
10570
- coding: ((_y = (_x = clause.method) == null ? void 0 : _x.coding) == null ? void 0 : _y.code) ? [
10651
+ text: (_w = clause.method) == null ? void 0 : _w.text,
10652
+ _text: clonePrimitiveElement((_x = clause.method) == null ? void 0 : _x._text),
10653
+ coding: ((_z = (_y = clause.method) == null ? void 0 : _y.coding) == null ? void 0 : _z.code) ? [
10571
10654
  {
10572
- system: (_z = clause.method.coding.system) != null ? _z : SNOMED_SYSTEM5,
10655
+ system: (_A = clause.method.coding.system) != null ? _A : SNOMED_SYSTEM5,
10573
10656
  code: clause.method.coding.code,
10574
10657
  display: clause.method.coding.display,
10575
10658
  _display: clonePrimitiveElement(clause.method.coding._display)
@@ -10577,14 +10660,14 @@ function canonicalToFhir(clause, textOverride, options) {
10577
10660
  ] : void 0
10578
10661
  };
10579
10662
  }
10580
- if ((_A = clause.additionalInstructions) == null ? void 0 : _A.length) {
10663
+ if ((_B = clause.additionalInstructions) == null ? void 0 : _B.length) {
10581
10664
  dosage.additionalInstruction = [];
10582
10665
  for (const instruction of clause.additionalInstructions) {
10583
10666
  dosage.additionalInstruction.push({
10584
10667
  text: instruction.text,
10585
- coding: ((_B = instruction.coding) == null ? void 0 : _B.code) ? [
10668
+ coding: ((_C = instruction.coding) == null ? void 0 : _C.code) ? [
10586
10669
  {
10587
- system: (_C = instruction.coding.system) != null ? _C : SNOMED_SYSTEM5,
10670
+ system: (_D = instruction.coding.system) != null ? _D : SNOMED_SYSTEM5,
10588
10671
  code: instruction.coding.code,
10589
10672
  display: instruction.coding.display
10590
10673
  }
@@ -10592,9 +10675,9 @@ function canonicalToFhir(clause, textOverride, options) {
10592
10675
  });
10593
10676
  }
10594
10677
  }
10595
- if ((_D = clause.prn) == null ? void 0 : _D.enabled) {
10678
+ if ((_E = clause.prn) == null ? void 0 : _E.enabled) {
10596
10679
  dosage.asNeededBoolean = true;
10597
- const reasons = ((_E = clause.prn.reasons) == null ? void 0 : _E.length) ? clause.prn.reasons : clause.prn.reason ? [clause.prn.reason] : [];
10680
+ const reasons = ((_F = clause.prn.reasons) == null ? void 0 : _F.length) ? clause.prn.reasons : clause.prn.reason ? [clause.prn.reason] : [];
10598
10681
  if (reasons.length) {
10599
10682
  dosage.asNeededFor = [];
10600
10683
  for (const reason of reasons) {
@@ -10602,14 +10685,23 @@ function canonicalToFhir(clause, textOverride, options) {
10602
10685
  if (reason.text) {
10603
10686
  concept.text = reason.text;
10604
10687
  }
10605
- if ((_F = reason.coding) == null ? void 0 : _F.code) {
10688
+ const reasonTextElement = (options == null ? void 0 : options.includeTranslationExtensions) ? buildTranslationPrimitiveElement((_H = reason.i18n) != null ? _H : (_G = reason.coding) == null ? void 0 : _G.i18n) : void 0;
10689
+ if (reasonTextElement) {
10690
+ concept._text = reasonTextElement;
10691
+ }
10692
+ if ((_I = reason.coding) == null ? void 0 : _I.code) {
10693
+ const displayElement = (options == null ? void 0 : options.includeTranslationExtensions) ? mergeTranslationPrimitiveElement(
10694
+ reason.coding._display,
10695
+ reason.coding.i18n
10696
+ ) : clonePrimitiveElement(reason.coding._display);
10606
10697
  concept.coding = [
10607
- {
10608
- system: (_G = reason.coding.system) != null ? _G : SNOMED_SYSTEM5,
10698
+ __spreadProps(__spreadValues({
10699
+ system: (_J = reason.coding.system) != null ? _J : SNOMED_SYSTEM5,
10609
10700
  code: reason.coding.code,
10610
- display: reason.coding.display,
10701
+ display: reason.coding.display
10702
+ }, displayElement ? { _display: displayElement } : {}), {
10611
10703
  extension: cloneExtensions(reason.coding.extension)
10612
- }
10704
+ })
10613
10705
  ];
10614
10706
  }
10615
10707
  concept.extension = buildBodySiteSpatialRelationExtensions(reason.spatialRelation);
@@ -10644,14 +10736,17 @@ function canonicalFromFhir(dosage) {
10644
10736
  const siteCoding = selectPreferredSiteCoding(dosage.site);
10645
10737
  const siteSpatialRelation = parseBodySiteSpatialRelationExtension(dosage.site);
10646
10738
  const siteText = getFallbackSiteText(dosage.site);
10739
+ const siteI18n = codeableConceptTranslationI18n(dosage.site, siteCoding);
10647
10740
  if (siteText || (siteCoding == null ? void 0 : siteCoding.code) || siteSpatialRelation) {
10648
10741
  clause.site = {
10649
10742
  text: siteText,
10743
+ i18n: siteI18n.text,
10650
10744
  spatialRelation: siteSpatialRelation,
10651
10745
  coding: (siteCoding == null ? void 0 : siteCoding.code) ? {
10652
10746
  code: siteCoding.code,
10653
10747
  display: siteCoding.display,
10654
- system: siteCoding.system
10748
+ system: siteCoding.system,
10749
+ i18n: siteI18n.display
10655
10750
  } : void 0,
10656
10751
  source: "text"
10657
10752
  };
@@ -10706,16 +10801,21 @@ function canonicalFromFhir(dosage) {
10706
10801
  };
10707
10802
  }
10708
10803
  const prnReasons = ((_y = dosage.asNeededFor) == null ? void 0 : _y.length) ? dosage.asNeededFor.map((concept) => {
10709
- var _a3;
10804
+ var _a3, _b2;
10710
10805
  const coding = (_a3 = concept.coding) == null ? void 0 : _a3.find((code) => Boolean(code.code));
10806
+ const defaultDef = (coding == null ? void 0 : coding.code) ? findPrnReasonDefinitionByCoding((_b2 = coding.system) != null ? _b2 : SNOMED_SYSTEM5, coding.code) : void 0;
10807
+ const i18n = codeableConceptTranslationI18n(concept, coding, defaultDef == null ? void 0 : defaultDef.i18n);
10711
10808
  return {
10712
10809
  text: getFallbackPrnReasonText(concept),
10810
+ i18n: i18n.text,
10713
10811
  spatialRelation: parseBodySiteSpatialRelationExtension(concept),
10714
10812
  coding: (coding == null ? void 0 : coding.code) ? {
10715
10813
  code: coding.code,
10716
10814
  display: coding.display,
10717
10815
  system: coding.system,
10718
- extension: cloneExtensions(coding.extension)
10816
+ extension: cloneExtensions(coding.extension),
10817
+ _display: clonePrimitiveElement(coding._display),
10818
+ i18n: i18n.display
10719
10819
  } : void 0
10720
10820
  };
10721
10821
  }) : void 0;
@@ -16543,7 +16643,8 @@ function applyRouteSiteDefault(state) {
16543
16643
  state.siteCoding = {
16544
16644
  system: (_i = definition.coding.system) != null ? _i : "http://snomed.info/sct",
16545
16645
  code: definition.coding.code,
16546
- display: definition.coding.display
16646
+ display: definition.coding.display,
16647
+ i18n: mergeI18nRecords(definition.i18n, definition.coding.i18n)
16547
16648
  };
16548
16649
  }
16549
16650
  }
@@ -17855,7 +17956,8 @@ function applySiteDefinition(internal, definition) {
17855
17956
  internal.siteCoding = (coding == null ? void 0 : coding.code) ? {
17856
17957
  code: coding.code,
17857
17958
  display: coding.display,
17858
- system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9
17959
+ system: (_a2 = coding.system) != null ? _a2 : SNOMED_SYSTEM9,
17960
+ i18n: mergeI18nRecords(definition.i18n, coding.i18n)
17859
17961
  } : void 0;
17860
17962
  if (definition.text) {
17861
17963
  internal.siteText = definition.text;
@@ -18211,7 +18313,8 @@ function seedKnownSiteCoding(state) {
18211
18313
  state.siteCoding = {
18212
18314
  system: (_b = definition.coding.system) != null ? _b : SNOMED_SYSTEM10,
18213
18315
  code: definition.coding.code,
18214
- display: definition.coding.display
18316
+ display: definition.coding.display,
18317
+ i18n: mergeI18nRecords(definition.i18n, definition.coding.i18n)
18215
18318
  };
18216
18319
  }
18217
18320
  function parseClauseState(input, options) {
@@ -21513,7 +21616,8 @@ function cloneBodySiteCoding2(coding) {
21513
21616
  return {
21514
21617
  code: coding.code,
21515
21618
  display: coding.display,
21516
- system: coding.system
21619
+ system: coding.system,
21620
+ i18n: cloneI18nRecord(coding.i18n)
21517
21621
  };
21518
21622
  }
21519
21623
  function buildNormalizedMetaFromClause(clause, fhir, options) {
@@ -21560,7 +21664,8 @@ function buildParseResult(state, options) {
21560
21664
  const shortText = formatCanonicalClause(clause, "short", localization, options);
21561
21665
  const longText = formatCanonicalClause(clause, "long", localization, options);
21562
21666
  const fhir = canonicalToFhir(clause, longText, {
21563
- bodySitePostcoordination: options == null ? void 0 : options.bodySitePostcoordination
21667
+ bodySitePostcoordination: options == null ? void 0 : options.bodySitePostcoordination,
21668
+ includeTranslationExtensions: Boolean((options == null ? void 0 : options.locale) || (options == null ? void 0 : options.i18n))
21564
21669
  });
21565
21670
  const consumedTokens = [];
21566
21671
  const leftoverParts = [];
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
@@ -756,6 +758,7 @@ export interface CanonicalRouteExpr {
756
758
  }
757
759
  export interface CanonicalSiteExpr {
758
760
  text?: string;
761
+ i18n?: Record<string, string>;
759
762
  coding?: BodySiteCode;
760
763
  spatialRelation?: BodySiteSpatialRelation;
761
764
  source?: "abbreviation" | "text" | "selection" | "resolver";
@@ -786,6 +789,7 @@ export interface CanonicalScheduleExpr {
786
789
  }
787
790
  export interface CanonicalPrnReasonExpr {
788
791
  text?: string;
792
+ i18n?: Record<string, string>;
789
793
  coding?: FhirCoding;
790
794
  spatialRelation?: BodySiteSpatialRelation;
791
795
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezmedicationinput",
3
- "version": "0.1.48",
3
+ "version": "0.1.50",
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
+ }