fhir-dosage-utils 1.10.3 → 2.0.0

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/module.js CHANGED
@@ -1,6 +1,8 @@
1
- import $hgUW1$i18nextresourcestobackend from "i18next-resources-to-backend";
2
1
  import $hgUW1$i18next from "i18next";
3
2
  import $hgUW1$i18nextchainedbackend from "i18next-chained-backend";
3
+ import $hgUW1$i18nextresourcestobackend from "i18next-resources-to-backend";
4
+
5
+ // Export utility class
4
6
 
5
7
 
6
8
 
@@ -41,13 +43,11 @@ function $f2878500cc217687$export$f478f96b98da13a4({ code: code }) {
41
43
 
42
44
  function $a31aaee21175037d$export$30c337e25ab8e95b({ extensions: extensions }) {
43
45
  if ((0, $1c8530b981ded822$export$d9ff4a623e416a11)(extensions)) return undefined;
44
- // KIS implementation : print it as provided, without doing anything
45
- // Extensions have so many cases btw, that having a basic function does the trick
46
46
  return extensions.map((extension)=>JSON.stringify(extension)).join(" ");
47
47
  }
48
48
 
49
49
 
50
- const $c03f5f20816d8d50$export$38cd8db2db178f58 = {
50
+ const $d5ca4938758304ae$export$38cd8db2db178f58 = {
51
51
  language: "en",
52
52
  fromFHIRQuantityUnitToString: (0, $a620268c8b5a46fd$export$b1a6aed91fad1636),
53
53
  fromCodeableConceptToString: (0, $f2878500cc217687$export$f478f96b98da13a4),
@@ -80,90 +80,38 @@ const $c03f5f20816d8d50$export$38cd8db2db178f58 = {
80
80
  "patientInstruction"
81
81
  ],
82
82
  displaySeparator: " - ",
83
- dateTimeFormatOptions: {}
83
+ dateTimeFormatOptions: {},
84
+ i18nConfig: {
85
+ backend: {
86
+ backends: [
87
+ (0, $hgUW1$i18nextresourcestobackend)(async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
88
+ ]
89
+ }
90
+ }
84
91
  };
85
92
 
86
93
 
87
- class $2422495f2648c580$export$f807d9a22ff8372d {
88
- constructor(userConfig, i18nConfig){
89
- this.config = {
90
- ...(0, $c03f5f20816d8d50$export$38cd8db2db178f58),
91
- ...userConfig
92
- };
93
- this.i18nConfig = {
94
- fallbackLng: "en",
95
- lng: this.config.language,
96
- ns: [
97
- "common",
98
- "daysOfWeek",
99
- "eventTiming",
100
- "unitsOfTime",
101
- "quantityComparator"
102
- ],
103
- defaultNS: "common",
104
- ...i18nConfig
105
- };
106
- this.i18nInstance = (0, $hgUW1$i18next).createInstance();
107
- }
108
- /**
109
- * To init i18next properly according requested criteria
110
- */ async init() {
111
- // You should wait for init to complete (wait for the callback or promise resolution)
112
- // before using the t function!
113
- return await this.i18nInstance.use((0, $hgUW1$i18nextchainedbackend)).init(this.i18nConfig);
114
- }
115
- /**
116
- * To change language
117
- */ async changeLanguage(lng) {
118
- this.config = {
119
- ...this.config,
120
- language: lng
121
- };
122
- return this.i18nInstance.changeLanguage(lng);
123
- }
124
- /**
125
- * Get current language
126
- */ getLanguage() {
127
- return this.config.language;
128
- }
129
- /**
130
- * To change display order
131
- */ changeDisplayOrder(order) {
132
- this.config = {
133
- ...this.config,
134
- displayOrder: order
135
- };
136
- }
137
- /**
138
- * Get display order
139
- */ getDisplayOrder() {
140
- return this.config.displayOrder;
141
- }
142
- /**
143
- * Get display separator
144
- */ getDisplaySeparator() {
145
- return this.config.displaySeparator;
146
- }
147
- /**
148
- * Set display separator
149
- */ changeDisplaySeparator(sep) {
150
- this.config = {
151
- ...this.config,
152
- displaySeparator: sep
153
- };
154
- }
155
- /**
156
- * Get date time format options
157
- */ getDateTimeFormatOptions() {
158
- return this.config.dateTimeFormatOptions;
94
+
95
+ class $928801c629c03bf9$export$d2ca453b913dcdea {
96
+ containsOnlySequentialInstructions(dosages) {
97
+ let sequencesNumbers = dosages.map((d)=>d.sequence).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f));
98
+ let encounteredSequenceNumbers = new Set(sequencesNumbers);
99
+ return [
100
+ 0,
101
+ dosages.length
102
+ ].includes(encounteredSequenceNumbers.size);
159
103
  }
160
- /**
161
- * Set date time format options
162
- */ changeDateTimeFormatOptions(opts) {
163
- this.config = {
164
- ...this.config,
165
- dateTimeFormatOptions: opts
166
- };
104
+ groupBySequence(dosages) {
105
+ let sequences = new Set();
106
+ let sequencesMap = new Map();
107
+ for (let dosage of dosages){
108
+ let sequenceNr = dosage.sequence;
109
+ let localGroup = sequencesMap.get(sequenceNr) ?? [];
110
+ localGroup.push(dosage);
111
+ sequencesMap.set(sequenceNr, localGroup);
112
+ sequences.add(sequenceNr);
113
+ }
114
+ return Array.from(sequences, (sequence)=>sequencesMap.get(sequence));
167
115
  }
168
116
  }
169
117
 
@@ -171,7 +119,6 @@ class $2422495f2648c580$export$f807d9a22ff8372d {
171
119
 
172
120
  function $a8a8a2e7c5a5225c$export$76d408d587da5203(dos, key) {
173
121
  if (!(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(dos.doseAndRate)) return undefined;
174
- // Find the first entry that match criteria
175
122
  let doseAndRate = dos.doseAndRate.find((s)=>(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(s[key]));
176
123
  if (!(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(doseAndRate)) return undefined;
177
124
  return doseAndRate[key];
@@ -236,29 +183,39 @@ function $73073500f7f08f16$var$transformQuantityUnitToString(i18next, quantity,
236
183
  quantity: quantity
237
184
  });
238
185
  }
186
+ function $73073500f7f08f16$var$getParams({ range: range, config: config, i18next: i18next }) {
187
+ const { low: low, high: high } = range;
188
+ let quantityUnit = high || low;
189
+ let hasQuantityUnit = (0, $5892466f7fd97165$export$aace639f4c93bb3d)(quantityUnit);
190
+ if (hasQuantityUnit) return {
191
+ prefix: `amount.range.withUnit`,
192
+ unit: $73073500f7f08f16$var$transformQuantityUnitToString(i18next, quantityUnit, config)
193
+ };
194
+ return {
195
+ prefix: `amount.range.withoutUnit`,
196
+ unit: ""
197
+ };
198
+ }
239
199
  function $73073500f7f08f16$export$be17d167ed50d870({ range: range, config: config, i18next: i18next }) {
240
200
  const { low: low, high: high } = range;
241
201
  const lowValue = low?.value;
242
202
  const highValue = high?.value;
243
- let quantityUnit = high || low;
244
- let hasQuantityUnit = (0, $5892466f7fd97165$export$aace639f4c93bb3d)(quantityUnit);
245
- // 1. If we have a empty object, return undefined
246
203
  if ((0, $c65c41ac1f3ea82b$export$cbff5d1bcc7ff30a)(lowValue, highValue)) return undefined;
247
- let unit = hasQuantityUnit ? $73073500f7f08f16$var$transformQuantityUnitToString(i18next, quantityUnit, config) : "";
248
- let technicalKey = hasQuantityUnit ? "withUnit" : "withoutUnit";
249
- // 2. Both low & high are present
250
- if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(lowValue, highValue)) return i18next.t(`amount.range.${technicalKey}.lowAndHigh`, {
204
+ const { prefix: prefix, unit: unit } = $73073500f7f08f16$var$getParams({
205
+ range: range,
206
+ config: config,
207
+ i18next: i18next
208
+ });
209
+ if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(lowValue, highValue)) return i18next.t(`${prefix}.lowAndHigh`, {
251
210
  low: lowValue,
252
211
  high: highValue,
253
212
  unit: unit
254
213
  });
255
- // 3. Only high is present
256
- if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(highValue)) return i18next.t(`amount.range.${technicalKey}.onlyHigh`, {
214
+ if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(highValue)) return i18next.t(`${prefix}.onlyHigh`, {
257
215
  high: highValue,
258
216
  unit: unit
259
217
  });
260
- // 4. Only low is present
261
- return i18next.t(`amount.range.${technicalKey}.onlyLow`, {
218
+ return i18next.t(`${prefix}.onlyLow`, {
262
219
  low: lowValue,
263
220
  unit: unit
264
221
  });
@@ -414,16 +371,13 @@ function $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2({ dos: dos, i18next: i18next
414
371
  let frequency = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "frequency");
415
372
  let max = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "frequencyMax");
416
373
  if ((0, $c65c41ac1f3ea82b$export$cbff5d1bcc7ff30a)(frequency, max)) return undefined;
417
- // 1. Frequency and frequencyMax are present
418
374
  if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(frequency, max)) return i18next.t("fields.frequency.withfrequencyMax", {
419
375
  count: max,
420
376
  frequency: frequency
421
377
  });
422
- // 2. Only frequencyMax is present
423
378
  if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(max)) return i18next.t("fields.frequencyMax.frequencyMax", {
424
379
  count: max
425
380
  });
426
- // 3. Only frequency is present
427
381
  return i18next.t("fields.frequency.onlyFrequency", {
428
382
  count: frequency
429
383
  });
@@ -437,7 +391,6 @@ function $fcc6c325de921010$export$aa31b783699f637({ dos: dos, i18next: i18next }
437
391
  let max = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "periodMax");
438
392
  let unit = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "periodUnit");
439
393
  if (!(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(unit)) return undefined;
440
- // 1. period and periodMax are present
441
394
  if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(period, max)) return i18next.t("fields.periodMax.withPeriod", {
442
395
  period: period,
443
396
  count: max,
@@ -445,14 +398,12 @@ function $fcc6c325de921010$export$aa31b783699f637({ dos: dos, i18next: i18next }
445
398
  count: max
446
399
  })
447
400
  });
448
- // 2. Only periodMax is present
449
401
  if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(max)) return i18next.t("fields.periodMax.onlyPeriodMax", {
450
402
  count: max,
451
403
  unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
452
404
  count: max
453
405
  })
454
406
  });
455
- // 3. Only period present
456
407
  return i18next.t("fields.period.period", {
457
408
  count: period,
458
409
  unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
@@ -497,9 +448,9 @@ function $f88800def2ddd9e9$var$transformOffset(i18next, offset) {
497
448
  "h",
498
449
  "min"
499
450
  ];
500
- return order.map((unit)=>time[unit] > 0 ? i18next.t(`unitsOfTime:withCount.${unit}`, {
451
+ return order.filter((unit)=>time[unit] > 0).map((unit)=>i18next.t(`unitsOfTime:withCount.${unit}`, {
501
452
  count: time[unit]
502
- }) : undefined).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)).join(" ");
453
+ })).join(" ");
503
454
  }
504
455
  function $f88800def2ddd9e9$var$transformWhen(i18next, when) {
505
456
  if ((0, $1c8530b981ded822$export$d9ff4a623e416a11)(when)) return undefined;
@@ -522,7 +473,6 @@ function $f88800def2ddd9e9$export$433fa514f44031f3({ dos: dos, i18next: i18next
522
473
 
523
474
  function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
524
475
  let dayOfWeek = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "dayOfWeek");
525
- // If empty, skip it
526
476
  if ((0, $1c8530b981ded822$export$d9ff4a623e416a11)(dayOfWeek)) return undefined;
527
477
  const dayOfWeeks = dayOfWeek.map((dayCode)=>i18next.t(`daysOfWeek:${dayCode}`));
528
478
  const dayOfWeeksAsString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, dayOfWeeks);
@@ -547,9 +497,7 @@ function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next
547
497
  }
548
498
  function $a1b58a85293e76cc$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
549
499
  let timeOfDay = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "timeOfDay");
550
- // If empty, skip it
551
500
  if ((0, $1c8530b981ded822$export$d9ff4a623e416a11)(timeOfDay)) return undefined;
552
- // Turn it into a string
553
501
  const timeOfDays = timeOfDay.map($a1b58a85293e76cc$var$formatString);
554
502
  const timeOfDaysAsString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, timeOfDays);
555
503
  return i18next.t("fields.timeOfDay", {
@@ -642,16 +590,13 @@ function $73a945b97fd1a22f$export$498ca7f558a02e67({ dos: dos, i18next: i18next
642
590
  let count = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "count");
643
591
  let countMax = (0, $334e06743cc7d5ed$export$59de929dfa9e850b)(dos, "countMax");
644
592
  if ((0, $c65c41ac1f3ea82b$export$cbff5d1bcc7ff30a)(count, countMax)) return undefined;
645
- // 1. Both count & countMax are present
646
593
  if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(count, countMax)) return i18next.t("fields.countMax.countMax", {
647
594
  count: countMax,
648
595
  low: count
649
596
  });
650
- // 2. Only countMax is present
651
597
  if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(countMax)) return i18next.t("fields.count.count", {
652
598
  count: countMax
653
599
  });
654
- // 3. Only count is present
655
600
  return i18next.t("fields.count.count", {
656
601
  count: count
657
602
  });
@@ -804,7 +749,6 @@ function $e372e1d4df385570$export$58c8a9e040283a66({ dos: dos, config: config, i
804
749
 
805
750
  function $f28938e27e1e9773$export$75a89431d80a701a({ dos: dos, config: config, i18next: i18next }) {
806
751
  if (!(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(dos.timing?.repeat?.boundsPeriod)) return undefined;
807
- // Generate the string version of them
808
752
  const boundsPeriod = dos.timing.repeat.boundsPeriod;
809
753
  let start = (0, $d3afe3c00981fd78$export$4699e913d5b6ffeb)({
810
754
  config: config,
@@ -814,16 +758,13 @@ function $f28938e27e1e9773$export$75a89431d80a701a({ dos: dos, config: config, i
814
758
  config: config,
815
759
  datetime: boundsPeriod.end
816
760
  });
817
- // 1. Both start and end are present
818
761
  if ((0, $c65c41ac1f3ea82b$export$3b3497187fd4cc1a)(start, end)) return i18next.t("fields.boundsPeriod.startAndEnd", {
819
762
  start: start,
820
763
  end: end
821
764
  });
822
- // 2. Only start is present
823
765
  if ((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(start)) return i18next.t("fields.boundsPeriod.onlyStart", {
824
766
  start: start
825
767
  });
826
- // 3. Only end is present
827
768
  return i18next.t("fields.boundsPeriod.onlyEnd", {
828
769
  end: end
829
770
  });
@@ -837,20 +778,16 @@ function $252769c9f296cd6d$export$346b11a8cb220f02({ dos: dos, config: config, i
837
778
  if (!(0, $c65c41ac1f3ea82b$export$e7321bf46d18757f)(dos.maxDosePerPeriod)) return undefined;
838
779
  const maxDosePerPeriod = dos.maxDosePerPeriod;
839
780
  // In R4, it was a single object / In R5, it is an array
840
- // So better to have a generic approach
841
781
  const values = Array.isArray(maxDosePerPeriod) ? maxDosePerPeriod : [
842
782
  maxDosePerPeriod
843
783
  ];
844
- // Only consider not empty array
845
784
  if (values.length === 0) return undefined;
846
785
  // Periods are expressed as ratio (like rateRatio)
847
- const valuesAsString = values.map((period)=>{
848
- return (0, $eb371feb739abc89$export$fdc6e9cbd31555fb)({
786
+ const valuesAsString = values.map((period)=>(0, $eb371feb739abc89$export$fdc6e9cbd31555fb)({
849
787
  config: config,
850
788
  i18next: i18next,
851
789
  ratio: period
852
- });
853
- }).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f));
790
+ })).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f));
854
791
  const maxDosePerPeriodText = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, valuesAsString);
855
792
  return i18next.t("fields.maxDosePerPeriod", {
856
793
  count: values.length,
@@ -937,50 +874,46 @@ function $9b1af2fba509609e$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
937
874
 
938
875
 
939
876
 
940
-
941
- const $8435b8d847fb3eb7$var$defaultI18NConfig = {
942
- backend: {
943
- backends: [
944
- (0, $hgUW1$i18nextresourcestobackend)(async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
945
- ]
877
+ class $8435b8d847fb3eb7$export$1c191bca55f84a03 extends (0, $928801c629c03bf9$export$d2ca453b913dcdea) {
878
+ constructor(config){
879
+ super();
880
+ this.config = {
881
+ ...(0, $d5ca4938758304ae$export$38cd8db2db178f58),
882
+ ...config
883
+ };
884
+ this.i18nInstance = (0, $hgUW1$i18next).createInstance();
946
885
  }
947
- };
948
- class $8435b8d847fb3eb7$export$1c191bca55f84a03 extends (0, $2422495f2648c580$export$f807d9a22ff8372d) {
949
- /**
950
- * Factory to create a fine-tuned instance of the utility class
951
- */ static async build(userConfig, i18nConfig = $8435b8d847fb3eb7$var$defaultI18NConfig) {
952
- const instance = new $8435b8d847fb3eb7$export$1c191bca55f84a03(userConfig, i18nConfig);
886
+ async init() {
887
+ return await this.i18nInstance.use((0, $hgUW1$i18nextchainedbackend)).init({
888
+ fallbackLng: "en",
889
+ lng: this.config.language,
890
+ ns: [
891
+ "common",
892
+ "daysOfWeek",
893
+ "eventTiming",
894
+ "unitsOfTime",
895
+ "quantityComparator"
896
+ ],
897
+ defaultNS: "common",
898
+ ...this.config.i18nConfig
899
+ });
900
+ }
901
+ static async build(config = {}) {
902
+ const instance = new $8435b8d847fb3eb7$export$1c191bca55f84a03(config);
953
903
  await instance.init();
954
904
  return instance;
955
905
  }
956
- /**
957
- * Does this array of Dosage objects contains only "sequential" instructions ?
958
- */ containsOnlySequentialInstructions(dosages) {
959
- let sequencesNumbers = dosages.map((d)=>d.sequence).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f));
960
- let encounteredSequenceNumbers = new Set(sequencesNumbers);
961
- return encounteredSequenceNumbers.size === 0 || encounteredSequenceNumbers.size === dosages.length;
906
+ getProperty(key) {
907
+ return this.config[key];
962
908
  }
963
- /**
964
- * Turn this array of Dosage objects into a data structure useful to handle "sequential" and "concurrent" instructions (cf. "sequence" property).
965
- * @returns {Dosage[][]} - A two-dimensional array where each inner array contains Dosage objects belonging to the same sequence numberr.
966
- */ groupBySequence(dosages) {
967
- let groups = {};
968
- let sequences = new Set();
969
- for(let idx = 0; idx < dosages.length; idx++){
970
- const dosage = dosages[idx];
971
- let sequenceNr = dosage.sequence || idx + 1;
972
- let localGroup = groups[sequenceNr] || [];
973
- localGroup.push(dosage);
974
- groups[sequenceNr] = localGroup;
975
- sequences.add(sequenceNr);
976
- }
977
- // By using the Set values, we are sure it is returned in the way Dosages were written
978
- return Array.from(sequences, (sequence)=>groups[sequence]);
909
+ setProperty(key, value) {
910
+ this.config[key] = value;
911
+ }
912
+ async changeLanguage(lng) {
913
+ this.config["language"] = lng;
914
+ return this.i18nInstance.changeLanguage(lng);
979
915
  }
980
- /**
981
- * From a single dosage, extract specific field(s) requested by user.
982
- * Some use cases could request to split part of the object for given needs (quantity and timing separately)
983
- */ getFields(dos, ...order) {
916
+ getFields(dos, ...order) {
984
917
  let parts = order.map((entry)=>(0, $9b1af2fba509609e$export$9f330b4bf8c0975c)({
985
918
  config: this.config,
986
919
  dos: dos,
@@ -989,37 +922,31 @@ class $8435b8d847fb3eb7$export$1c191bca55f84a03 extends (0, $2422495f2648c580$ex
989
922
  })).filter((0, $c65c41ac1f3ea82b$export$e7321bf46d18757f));
990
923
  return parts.join(this.config.displaySeparator);
991
924
  }
992
- /**
993
- * Turn a FHIR Dosage object into text
994
- */ fromDosageToText(dos) {
925
+ fromDosageToText(dos) {
995
926
  let order = this.config.displayOrder;
996
927
  return this.getFields(dos, ...order);
997
928
  }
998
- /**
999
- * Turn multiple FHIR Dosage objects into text
1000
- */ fromMultipleDosageToText(dosages) {
1001
- // As we can have concurrent / sequential instructions, we need a generic algorithm to do the job
1002
- const hasOnlySequentialInstructions = this.containsOnlySequentialInstructions(dosages);
1003
- // Sequential instructions
1004
- if (hasOnlySequentialInstructions) {
1005
- const dosagesAsText = dosages.map((d)=>this.fromDosageToText(d));
1006
- return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, dosagesAsText, "then");
1007
- }
1008
- // We have both "sequential" and "concurrent" instructions - time to see what is the configuration
1009
- let sortedDosages = this.groupBySequence(dosages);
1010
- // Now that data structures are filled, it is a piece of cake to generate the result
1011
- let sequentialInstructions = sortedDosages.map((concurrentInstructions)=>{
1012
- let concurrentInstructionsAsString = concurrentInstructions.map((dosage)=>this.fromDosageToText(dosage));
1013
- return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, concurrentInstructionsAsString, "and");
1014
- });
929
+ fromMultipleDosageToText(dosages) {
930
+ if (this.containsOnlySequentialInstructions(dosages)) return this.convertSequentialDosagesToText(dosages);
931
+ return this.convertGroupedDosagesToText(dosages);
932
+ }
933
+ convertSequentialDosagesToText(dosages) {
934
+ const dosagesAsText = dosages.map((d)=>this.fromDosageToText(d));
935
+ return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, dosagesAsText, "then");
936
+ }
937
+ convertConcurrentDosagesToText(dosages) {
938
+ const concurrentInstructionsAsString = dosages.map((d)=>this.fromDosageToText(d));
939
+ return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, concurrentInstructionsAsString, "and");
940
+ }
941
+ convertGroupedDosagesToText(dosages) {
942
+ const sortedDosages = this.groupBySequence(dosages);
943
+ const sequentialInstructions = sortedDosages.map((d)=>this.convertConcurrentDosagesToText(d));
1015
944
  return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, sequentialInstructions, "then");
1016
945
  }
1017
946
  }
1018
947
 
1019
948
 
1020
- var // Default export to make it user-friendly
1021
- $149c1bd638913645$export$2e2bcd8739ae039 = (0, $8435b8d847fb3eb7$export$1c191bca55f84a03);
1022
949
 
1023
950
 
1024
- export {$149c1bd638913645$export$2e2bcd8739ae039 as default};
951
+ export {$8435b8d847fb3eb7$export$1c191bca55f84a03 as FhirDosageUtils};
1025
952
  //# sourceMappingURL=module.js.map