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/README.md CHANGED
@@ -31,3 +31,7 @@ Special thanks to [NHS England](https://digital.nhs.uk/), the author of `Impleme
31
31
  <a href="https://github.com/jy95/fhir-dosage-utils/graphs/contributors">
32
32
  <img src="https://contrib.rocks/image?repo=jy95/fhir-dosage-utils" />
33
33
  </a>
34
+
35
+ ## Star History
36
+
37
+ [![Star History Chart](https://api.star-history.com/svg?repos=jy95/fhir-dosage-utils&type=Date)](https://star-history.com/#jy95/fhir-dosage-utils&Date)
package/dist/main.js CHANGED
@@ -1,12 +1,8 @@
1
- var $8zHUo$i18nextresourcestobackend = require("i18next-resources-to-backend");
2
1
  var $8zHUo$i18next = require("i18next");
3
2
  var $8zHUo$i18nextchainedbackend = require("i18next-chained-backend");
3
+ var $8zHUo$i18nextresourcestobackend = require("i18next-resources-to-backend");
4
4
 
5
5
 
6
- function $parcel$defineInteropFlag(a) {
7
- Object.defineProperty(a, '__esModule', {value: true, configurable: true});
8
- }
9
-
10
6
  function $parcel$export(e, n, v, s) {
11
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
12
8
  }
@@ -15,9 +11,9 @@ function $parcel$interopDefault(a) {
15
11
  return a && a.__esModule ? a.default : a;
16
12
  }
17
13
 
18
- $parcel$defineInteropFlag(module.exports);
14
+ $parcel$export(module.exports, "FhirDosageUtils", () => $74b0cf9d3dbd5b46$export$1c191bca55f84a03);
15
+ // Export utility class
19
16
 
20
- $parcel$export(module.exports, "default", () => $882b6d93070905b3$export$2e2bcd8739ae039);
21
17
 
22
18
 
23
19
  function $3d60081b7152576d$export$e7321bf46d18757f(val) {
@@ -57,13 +53,11 @@ function $a6c648898dc8c3b6$export$f478f96b98da13a4({ code: code }) {
57
53
 
58
54
  function $34ebae8ac5b52fcd$export$30c337e25ab8e95b({ extensions: extensions }) {
59
55
  if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(extensions)) return undefined;
60
- // KIS implementation : print it as provided, without doing anything
61
- // Extensions have so many cases btw, that having a basic function does the trick
62
56
  return extensions.map((extension)=>JSON.stringify(extension)).join(" ");
63
57
  }
64
58
 
65
59
 
66
- const $99ea7fa882fd33ad$export$38cd8db2db178f58 = {
60
+ const $4a853aea29761dad$export$38cd8db2db178f58 = {
67
61
  language: "en",
68
62
  fromFHIRQuantityUnitToString: (0, $1c57f108974f2805$export$b1a6aed91fad1636),
69
63
  fromCodeableConceptToString: (0, $a6c648898dc8c3b6$export$f478f96b98da13a4),
@@ -96,90 +90,38 @@ const $99ea7fa882fd33ad$export$38cd8db2db178f58 = {
96
90
  "patientInstruction"
97
91
  ],
98
92
  displaySeparator: " - ",
99
- dateTimeFormatOptions: {}
93
+ dateTimeFormatOptions: {},
94
+ i18nConfig: {
95
+ backend: {
96
+ backends: [
97
+ (0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
98
+ ]
99
+ }
100
+ }
100
101
  };
101
102
 
102
103
 
103
- class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
104
- constructor(userConfig, i18nConfig){
105
- this.config = {
106
- ...(0, $99ea7fa882fd33ad$export$38cd8db2db178f58),
107
- ...userConfig
108
- };
109
- this.i18nConfig = {
110
- fallbackLng: "en",
111
- lng: this.config.language,
112
- ns: [
113
- "common",
114
- "daysOfWeek",
115
- "eventTiming",
116
- "unitsOfTime",
117
- "quantityComparator"
118
- ],
119
- defaultNS: "common",
120
- ...i18nConfig
121
- };
122
- this.i18nInstance = (0, ($parcel$interopDefault($8zHUo$i18next))).createInstance();
123
- }
124
- /**
125
- * To init i18next properly according requested criteria
126
- */ async init() {
127
- // You should wait for init to complete (wait for the callback or promise resolution)
128
- // before using the t function!
129
- return await this.i18nInstance.use((0, ($parcel$interopDefault($8zHUo$i18nextchainedbackend)))).init(this.i18nConfig);
130
- }
131
- /**
132
- * To change language
133
- */ async changeLanguage(lng) {
134
- this.config = {
135
- ...this.config,
136
- language: lng
137
- };
138
- return this.i18nInstance.changeLanguage(lng);
139
- }
140
- /**
141
- * Get current language
142
- */ getLanguage() {
143
- return this.config.language;
144
- }
145
- /**
146
- * To change display order
147
- */ changeDisplayOrder(order) {
148
- this.config = {
149
- ...this.config,
150
- displayOrder: order
151
- };
152
- }
153
- /**
154
- * Get display order
155
- */ getDisplayOrder() {
156
- return this.config.displayOrder;
157
- }
158
- /**
159
- * Get display separator
160
- */ getDisplaySeparator() {
161
- return this.config.displaySeparator;
162
- }
163
- /**
164
- * Set display separator
165
- */ changeDisplaySeparator(sep) {
166
- this.config = {
167
- ...this.config,
168
- displaySeparator: sep
169
- };
170
- }
171
- /**
172
- * Get date time format options
173
- */ getDateTimeFormatOptions() {
174
- return this.config.dateTimeFormatOptions;
104
+
105
+ class $4f322cc1dbc51a0e$export$d2ca453b913dcdea {
106
+ containsOnlySequentialInstructions(dosages) {
107
+ let sequencesNumbers = dosages.map((d)=>d.sequence).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
108
+ let encounteredSequenceNumbers = new Set(sequencesNumbers);
109
+ return [
110
+ 0,
111
+ dosages.length
112
+ ].includes(encounteredSequenceNumbers.size);
175
113
  }
176
- /**
177
- * Set date time format options
178
- */ changeDateTimeFormatOptions(opts) {
179
- this.config = {
180
- ...this.config,
181
- dateTimeFormatOptions: opts
182
- };
114
+ groupBySequence(dosages) {
115
+ let sequences = new Set();
116
+ let sequencesMap = new Map();
117
+ for (let dosage of dosages){
118
+ let sequenceNr = dosage.sequence;
119
+ let localGroup = sequencesMap.get(sequenceNr) ?? [];
120
+ localGroup.push(dosage);
121
+ sequencesMap.set(sequenceNr, localGroup);
122
+ sequences.add(sequenceNr);
123
+ }
124
+ return Array.from(sequences, (sequence)=>sequencesMap.get(sequence));
183
125
  }
184
126
  }
185
127
 
@@ -187,7 +129,6 @@ class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
187
129
 
188
130
  function $5461d5c8b4bc074f$export$76d408d587da5203(dos, key) {
189
131
  if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.doseAndRate)) return undefined;
190
- // Find the first entry that match criteria
191
132
  let doseAndRate = dos.doseAndRate.find((s)=>(0, $3d60081b7152576d$export$e7321bf46d18757f)(s[key]));
192
133
  if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(doseAndRate)) return undefined;
193
134
  return doseAndRate[key];
@@ -252,29 +193,39 @@ function $9ee880701f47723b$var$transformQuantityUnitToString(i18next, quantity,
252
193
  quantity: quantity
253
194
  });
254
195
  }
196
+ function $9ee880701f47723b$var$getParams({ range: range, config: config, i18next: i18next }) {
197
+ const { low: low, high: high } = range;
198
+ let quantityUnit = high || low;
199
+ let hasQuantityUnit = (0, $c3b3b5857aef7d44$export$aace639f4c93bb3d)(quantityUnit);
200
+ if (hasQuantityUnit) return {
201
+ prefix: `amount.range.withUnit`,
202
+ unit: $9ee880701f47723b$var$transformQuantityUnitToString(i18next, quantityUnit, config)
203
+ };
204
+ return {
205
+ prefix: `amount.range.withoutUnit`,
206
+ unit: ""
207
+ };
208
+ }
255
209
  function $9ee880701f47723b$export$be17d167ed50d870({ range: range, config: config, i18next: i18next }) {
256
210
  const { low: low, high: high } = range;
257
211
  const lowValue = low?.value;
258
212
  const highValue = high?.value;
259
- let quantityUnit = high || low;
260
- let hasQuantityUnit = (0, $c3b3b5857aef7d44$export$aace639f4c93bb3d)(quantityUnit);
261
- // 1. If we have a empty object, return undefined
262
213
  if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(lowValue, highValue)) return undefined;
263
- let unit = hasQuantityUnit ? $9ee880701f47723b$var$transformQuantityUnitToString(i18next, quantityUnit, config) : "";
264
- let technicalKey = hasQuantityUnit ? "withUnit" : "withoutUnit";
265
- // 2. Both low & high are present
266
- if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(lowValue, highValue)) return i18next.t(`amount.range.${technicalKey}.lowAndHigh`, {
214
+ const { prefix: prefix, unit: unit } = $9ee880701f47723b$var$getParams({
215
+ range: range,
216
+ config: config,
217
+ i18next: i18next
218
+ });
219
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(lowValue, highValue)) return i18next.t(`${prefix}.lowAndHigh`, {
267
220
  low: lowValue,
268
221
  high: highValue,
269
222
  unit: unit
270
223
  });
271
- // 3. Only high is present
272
- if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(highValue)) return i18next.t(`amount.range.${technicalKey}.onlyHigh`, {
224
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(highValue)) return i18next.t(`${prefix}.onlyHigh`, {
273
225
  high: highValue,
274
226
  unit: unit
275
227
  });
276
- // 4. Only low is present
277
- return i18next.t(`amount.range.${technicalKey}.onlyLow`, {
228
+ return i18next.t(`${prefix}.onlyLow`, {
278
229
  low: lowValue,
279
230
  unit: unit
280
231
  });
@@ -430,16 +381,13 @@ function $bc43734b944260d2$export$d663412e0c469ce2({ dos: dos, i18next: i18next
430
381
  let frequency = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "frequency");
431
382
  let max = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "frequencyMax");
432
383
  if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(frequency, max)) return undefined;
433
- // 1. Frequency and frequencyMax are present
434
384
  if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(frequency, max)) return i18next.t("fields.frequency.withfrequencyMax", {
435
385
  count: max,
436
386
  frequency: frequency
437
387
  });
438
- // 2. Only frequencyMax is present
439
388
  if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(max)) return i18next.t("fields.frequencyMax.frequencyMax", {
440
389
  count: max
441
390
  });
442
- // 3. Only frequency is present
443
391
  return i18next.t("fields.frequency.onlyFrequency", {
444
392
  count: frequency
445
393
  });
@@ -453,7 +401,6 @@ function $b9825dd9e0a2e687$export$aa31b783699f637({ dos: dos, i18next: i18next }
453
401
  let max = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "periodMax");
454
402
  let unit = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "periodUnit");
455
403
  if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(unit)) return undefined;
456
- // 1. period and periodMax are present
457
404
  if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(period, max)) return i18next.t("fields.periodMax.withPeriod", {
458
405
  period: period,
459
406
  count: max,
@@ -461,14 +408,12 @@ function $b9825dd9e0a2e687$export$aa31b783699f637({ dos: dos, i18next: i18next }
461
408
  count: max
462
409
  })
463
410
  });
464
- // 2. Only periodMax is present
465
411
  if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(max)) return i18next.t("fields.periodMax.onlyPeriodMax", {
466
412
  count: max,
467
413
  unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
468
414
  count: max
469
415
  })
470
416
  });
471
- // 3. Only period present
472
417
  return i18next.t("fields.period.period", {
473
418
  count: period,
474
419
  unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
@@ -513,9 +458,9 @@ function $7a065f861a4b61f2$var$transformOffset(i18next, offset) {
513
458
  "h",
514
459
  "min"
515
460
  ];
516
- return order.map((unit)=>time[unit] > 0 ? i18next.t(`unitsOfTime:withCount.${unit}`, {
461
+ return order.filter((unit)=>time[unit] > 0).map((unit)=>i18next.t(`unitsOfTime:withCount.${unit}`, {
517
462
  count: time[unit]
518
- }) : undefined).filter((0, $3d60081b7152576d$export$e7321bf46d18757f)).join(" ");
463
+ })).join(" ");
519
464
  }
520
465
  function $7a065f861a4b61f2$var$transformWhen(i18next, when) {
521
466
  if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(when)) return undefined;
@@ -538,7 +483,6 @@ function $7a065f861a4b61f2$export$433fa514f44031f3({ dos: dos, i18next: i18next
538
483
 
539
484
  function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
540
485
  let dayOfWeek = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "dayOfWeek");
541
- // If empty, skip it
542
486
  if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(dayOfWeek)) return undefined;
543
487
  const dayOfWeeks = dayOfWeek.map((dayCode)=>i18next.t(`daysOfWeek:${dayCode}`));
544
488
  const dayOfWeeksAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, dayOfWeeks);
@@ -563,9 +507,7 @@ function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next
563
507
  }
564
508
  function $a846209a7dd119d4$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
565
509
  let timeOfDay = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "timeOfDay");
566
- // If empty, skip it
567
510
  if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(timeOfDay)) return undefined;
568
- // Turn it into a string
569
511
  const timeOfDays = timeOfDay.map($a846209a7dd119d4$var$formatString);
570
512
  const timeOfDaysAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, timeOfDays);
571
513
  return i18next.t("fields.timeOfDay", {
@@ -658,16 +600,13 @@ function $39470eb799331038$export$498ca7f558a02e67({ dos: dos, i18next: i18next
658
600
  let count = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "count");
659
601
  let countMax = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "countMax");
660
602
  if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(count, countMax)) return undefined;
661
- // 1. Both count & countMax are present
662
603
  if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(count, countMax)) return i18next.t("fields.countMax.countMax", {
663
604
  count: countMax,
664
605
  low: count
665
606
  });
666
- // 2. Only countMax is present
667
607
  if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(countMax)) return i18next.t("fields.count.count", {
668
608
  count: countMax
669
609
  });
670
- // 3. Only count is present
671
610
  return i18next.t("fields.count.count", {
672
611
  count: count
673
612
  });
@@ -820,7 +759,6 @@ function $9ad44f2c84a9bdf4$export$58c8a9e040283a66({ dos: dos, config: config, i
820
759
 
821
760
  function $45256d2a188dcbd7$export$75a89431d80a701a({ dos: dos, config: config, i18next: i18next }) {
822
761
  if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.timing?.repeat?.boundsPeriod)) return undefined;
823
- // Generate the string version of them
824
762
  const boundsPeriod = dos.timing.repeat.boundsPeriod;
825
763
  let start = (0, $208be5279f5e6c65$export$4699e913d5b6ffeb)({
826
764
  config: config,
@@ -830,16 +768,13 @@ function $45256d2a188dcbd7$export$75a89431d80a701a({ dos: dos, config: config, i
830
768
  config: config,
831
769
  datetime: boundsPeriod.end
832
770
  });
833
- // 1. Both start and end are present
834
771
  if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(start, end)) return i18next.t("fields.boundsPeriod.startAndEnd", {
835
772
  start: start,
836
773
  end: end
837
774
  });
838
- // 2. Only start is present
839
775
  if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(start)) return i18next.t("fields.boundsPeriod.onlyStart", {
840
776
  start: start
841
777
  });
842
- // 3. Only end is present
843
778
  return i18next.t("fields.boundsPeriod.onlyEnd", {
844
779
  end: end
845
780
  });
@@ -853,20 +788,16 @@ function $39ffdeadc450f558$export$346b11a8cb220f02({ dos: dos, config: config, i
853
788
  if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.maxDosePerPeriod)) return undefined;
854
789
  const maxDosePerPeriod = dos.maxDosePerPeriod;
855
790
  // In R4, it was a single object / In R5, it is an array
856
- // So better to have a generic approach
857
791
  const values = Array.isArray(maxDosePerPeriod) ? maxDosePerPeriod : [
858
792
  maxDosePerPeriod
859
793
  ];
860
- // Only consider not empty array
861
794
  if (values.length === 0) return undefined;
862
795
  // Periods are expressed as ratio (like rateRatio)
863
- const valuesAsString = values.map((period)=>{
864
- return (0, $7895e9944cc835ce$export$fdc6e9cbd31555fb)({
796
+ const valuesAsString = values.map((period)=>(0, $7895e9944cc835ce$export$fdc6e9cbd31555fb)({
865
797
  config: config,
866
798
  i18next: i18next,
867
799
  ratio: period
868
- });
869
- }).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
800
+ })).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
870
801
  const maxDosePerPeriodText = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, valuesAsString);
871
802
  return i18next.t("fields.maxDosePerPeriod", {
872
803
  count: values.length,
@@ -953,50 +884,46 @@ function $2c21ace90ecdbde6$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
953
884
 
954
885
 
955
886
 
956
-
957
- const $74b0cf9d3dbd5b46$var$defaultI18NConfig = {
958
- backend: {
959
- backends: [
960
- (0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
961
- ]
887
+ class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $4f322cc1dbc51a0e$export$d2ca453b913dcdea) {
888
+ constructor(config){
889
+ super();
890
+ this.config = {
891
+ ...(0, $4a853aea29761dad$export$38cd8db2db178f58),
892
+ ...config
893
+ };
894
+ this.i18nInstance = (0, ($parcel$interopDefault($8zHUo$i18next))).createInstance();
962
895
  }
963
- };
964
- class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $868b4eaa4f62b9f7$export$f807d9a22ff8372d) {
965
- /**
966
- * Factory to create a fine-tuned instance of the utility class
967
- */ static async build(userConfig, i18nConfig = $74b0cf9d3dbd5b46$var$defaultI18NConfig) {
968
- const instance = new $74b0cf9d3dbd5b46$export$1c191bca55f84a03(userConfig, i18nConfig);
896
+ async init() {
897
+ return await this.i18nInstance.use((0, ($parcel$interopDefault($8zHUo$i18nextchainedbackend)))).init({
898
+ fallbackLng: "en",
899
+ lng: this.config.language,
900
+ ns: [
901
+ "common",
902
+ "daysOfWeek",
903
+ "eventTiming",
904
+ "unitsOfTime",
905
+ "quantityComparator"
906
+ ],
907
+ defaultNS: "common",
908
+ ...this.config.i18nConfig
909
+ });
910
+ }
911
+ static async build(config = {}) {
912
+ const instance = new $74b0cf9d3dbd5b46$export$1c191bca55f84a03(config);
969
913
  await instance.init();
970
914
  return instance;
971
915
  }
972
- /**
973
- * Does this array of Dosage objects contains only "sequential" instructions ?
974
- */ containsOnlySequentialInstructions(dosages) {
975
- let sequencesNumbers = dosages.map((d)=>d.sequence).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
976
- let encounteredSequenceNumbers = new Set(sequencesNumbers);
977
- return encounteredSequenceNumbers.size === 0 || encounteredSequenceNumbers.size === dosages.length;
916
+ getProperty(key) {
917
+ return this.config[key];
978
918
  }
979
- /**
980
- * Turn this array of Dosage objects into a data structure useful to handle "sequential" and "concurrent" instructions (cf. "sequence" property).
981
- * @returns {Dosage[][]} - A two-dimensional array where each inner array contains Dosage objects belonging to the same sequence numberr.
982
- */ groupBySequence(dosages) {
983
- let groups = {};
984
- let sequences = new Set();
985
- for(let idx = 0; idx < dosages.length; idx++){
986
- const dosage = dosages[idx];
987
- let sequenceNr = dosage.sequence || idx + 1;
988
- let localGroup = groups[sequenceNr] || [];
989
- localGroup.push(dosage);
990
- groups[sequenceNr] = localGroup;
991
- sequences.add(sequenceNr);
992
- }
993
- // By using the Set values, we are sure it is returned in the way Dosages were written
994
- return Array.from(sequences, (sequence)=>groups[sequence]);
919
+ setProperty(key, value) {
920
+ this.config[key] = value;
921
+ }
922
+ async changeLanguage(lng) {
923
+ this.config["language"] = lng;
924
+ return this.i18nInstance.changeLanguage(lng);
995
925
  }
996
- /**
997
- * From a single dosage, extract specific field(s) requested by user.
998
- * Some use cases could request to split part of the object for given needs (quantity and timing separately)
999
- */ getFields(dos, ...order) {
926
+ getFields(dos, ...order) {
1000
927
  let parts = order.map((entry)=>(0, $2c21ace90ecdbde6$export$9f330b4bf8c0975c)({
1001
928
  config: this.config,
1002
929
  dos: dos,
@@ -1005,36 +932,30 @@ class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $868b4eaa4f62b9f7$ex
1005
932
  })).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
1006
933
  return parts.join(this.config.displaySeparator);
1007
934
  }
1008
- /**
1009
- * Turn a FHIR Dosage object into text
1010
- */ fromDosageToText(dos) {
935
+ fromDosageToText(dos) {
1011
936
  let order = this.config.displayOrder;
1012
937
  return this.getFields(dos, ...order);
1013
938
  }
1014
- /**
1015
- * Turn multiple FHIR Dosage objects into text
1016
- */ fromMultipleDosageToText(dosages) {
1017
- // As we can have concurrent / sequential instructions, we need a generic algorithm to do the job
1018
- const hasOnlySequentialInstructions = this.containsOnlySequentialInstructions(dosages);
1019
- // Sequential instructions
1020
- if (hasOnlySequentialInstructions) {
1021
- const dosagesAsText = dosages.map((d)=>this.fromDosageToText(d));
1022
- return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(this.i18nInstance, dosagesAsText, "then");
1023
- }
1024
- // We have both "sequential" and "concurrent" instructions - time to see what is the configuration
1025
- let sortedDosages = this.groupBySequence(dosages);
1026
- // Now that data structures are filled, it is a piece of cake to generate the result
1027
- let sequentialInstructions = sortedDosages.map((concurrentInstructions)=>{
1028
- let concurrentInstructionsAsString = concurrentInstructions.map((dosage)=>this.fromDosageToText(dosage));
1029
- return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(this.i18nInstance, concurrentInstructionsAsString, "and");
1030
- });
939
+ fromMultipleDosageToText(dosages) {
940
+ if (this.containsOnlySequentialInstructions(dosages)) return this.convertSequentialDosagesToText(dosages);
941
+ return this.convertGroupedDosagesToText(dosages);
942
+ }
943
+ convertSequentialDosagesToText(dosages) {
944
+ const dosagesAsText = dosages.map((d)=>this.fromDosageToText(d));
945
+ return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(this.i18nInstance, dosagesAsText, "then");
946
+ }
947
+ convertConcurrentDosagesToText(dosages) {
948
+ const concurrentInstructionsAsString = dosages.map((d)=>this.fromDosageToText(d));
949
+ return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(this.i18nInstance, concurrentInstructionsAsString, "and");
950
+ }
951
+ convertGroupedDosagesToText(dosages) {
952
+ const sortedDosages = this.groupBySequence(dosages);
953
+ const sequentialInstructions = sortedDosages.map((d)=>this.convertConcurrentDosagesToText(d));
1031
954
  return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(this.i18nInstance, sequentialInstructions, "then");
1032
955
  }
1033
956
  }
1034
957
 
1035
958
 
1036
- var // Default export to make it user-friendly
1037
- $882b6d93070905b3$export$2e2bcd8739ae039 = (0, $74b0cf9d3dbd5b46$export$1c191bca55f84a03);
1038
959
 
1039
960
 
1040
961
  //# sourceMappingURL=main.js.map