fhir-dosage-utils 1.9.0 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
package/dist/main.js CHANGED
@@ -18,33 +18,45 @@ function $parcel$interopDefault(a) {
18
18
  $parcel$defineInteropFlag(module.exports);
19
19
 
20
20
  $parcel$export(module.exports, "default", () => $882b6d93070905b3$export$2e2bcd8739ae039);
21
- // Classe(s)
22
21
 
23
22
 
24
- // Types
23
+ function $3d60081b7152576d$export$e7321bf46d18757f(val) {
24
+ return val !== undefined;
25
+ }
26
+ function $3d60081b7152576d$export$3b3497187fd4cc1a(...args) {
27
+ return args.every($3d60081b7152576d$export$e7321bf46d18757f);
28
+ }
29
+ function $3d60081b7152576d$export$cbff5d1bcc7ff30a(...args) {
30
+ return !args.some($3d60081b7152576d$export$e7321bf46d18757f);
31
+ }
32
+
33
+
25
34
  function $1c57f108974f2805$export$b1a6aed91fad1636({ quantity: quantity }) {
26
- if (quantity.code !== undefined) return quantity.code;
27
- if (quantity.unit !== undefined) return quantity.unit;
35
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(quantity.code)) return quantity.code;
36
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(quantity.unit)) return quantity.unit;
28
37
  return "";
29
38
  }
30
39
 
31
40
 
41
+
42
+ function $7642ff4865ae4b0f$export$d9ff4a623e416a11(array) {
43
+ return !(0, $3d60081b7152576d$export$e7321bf46d18757f)(array) || array.length === 0;
44
+ }
45
+
46
+
47
+
32
48
  function $a6c648898dc8c3b6$export$f478f96b98da13a4({ code: code }) {
33
- // If no code, skip it
34
- if (code === undefined) return undefined;
35
- // Take text first
36
- if (code.text !== undefined) return code.text;
37
- // If empty, skip it
38
- if (code.coding === undefined || code.coding.length === 0) return undefined;
39
- // Take first coding; display first then code
49
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(code)) return undefined;
50
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(code.text)) return code.text;
51
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(code.coding)) return undefined;
40
52
  let firstCode = code.coding[0];
41
53
  return firstCode.display || firstCode.code;
42
54
  }
43
55
 
44
56
 
57
+
45
58
  function $34ebae8ac5b52fcd$export$30c337e25ab8e95b({ extensions: extensions }) {
46
- // If no extensions, skip it
47
- if (extensions === undefined || extensions.length === 0) return undefined;
59
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(extensions)) return undefined;
48
60
  // KIS implementation : print it as provided, without doing anything
49
61
  // Extensions have so many cases btw, that having a basic function does the trick
50
62
  return extensions.map((extension)=>JSON.stringify(extension)).join(" ");
@@ -89,28 +101,22 @@ const $99ea7fa882fd33ad$export$38cd8db2db178f58 = {
89
101
 
90
102
 
91
103
  class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
92
- // Set up lib, according provided parameters
93
104
  constructor(userConfig, i18nConfig){
94
- // User config
95
105
  this.config = {
96
- // default attributes
97
106
  ...(0, $99ea7fa882fd33ad$export$38cd8db2db178f58),
98
- // attributes set by user
99
107
  ...userConfig
100
108
  };
101
- // I18N config
102
109
  this.i18nConfig = {
103
- // default attributes
104
110
  fallbackLng: "en",
105
111
  lng: this.config.language,
106
112
  ns: [
107
113
  "common",
108
114
  "daysOfWeek",
109
115
  "eventTiming",
110
- "unitsOfTime"
116
+ "unitsOfTime",
117
+ "quantityComparator"
111
118
  ],
112
119
  defaultNS: "common",
113
- // attributes set by user
114
120
  ...i18nConfig
115
121
  };
116
122
  this.i18nInstance = (0, ($parcel$interopDefault($8zHUo$i18next))).createInstance();
@@ -178,49 +184,41 @@ class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
178
184
  }
179
185
 
180
186
 
181
- // translators
182
- // To avoid circular dependancies issue, let's have a single place for exports and imports
183
- // Functions
184
- // Types
187
+
185
188
  function $5461d5c8b4bc074f$export$76d408d587da5203(dos, key) {
186
- // If empty, return undefined
187
- if (dos.doseAndRate === undefined) return undefined;
189
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.doseAndRate)) return undefined;
188
190
  // Find the first entry that match criteria
189
- let doseAndRate = dos.doseAndRate.find((s)=>s[key] !== undefined);
190
- // If not found, skip
191
- if (doseAndRate === undefined) return undefined;
192
- // return property
191
+ let doseAndRate = dos.doseAndRate.find((s)=>(0, $3d60081b7152576d$export$e7321bf46d18757f)(s[key]));
192
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(doseAndRate)) return undefined;
193
193
  return doseAndRate[key];
194
194
  }
195
195
 
196
196
 
197
- // Function
198
- // Type
197
+
199
198
  function $6ce94eb09701f53d$export$e9106be159f8c977({ quantity: quantity, config: config, i18next: i18next }) {
200
- // extract function for the unit display from config
201
199
  const { fromFHIRQuantityUnitToString: fromFHIRQuantityUnitToString, language: language } = config;
202
- // Compute the result
203
200
  let unit = fromFHIRQuantityUnitToString({
204
201
  language: language,
205
202
  quantity: quantity
206
203
  });
207
204
  let value = quantity.value || 1;
208
- // If no unit is present (in other words ""), we don't put it
209
- if (unit.length === 0) return i18next.t("amount.quantity.withoutUnit", {
205
+ let quantityString = unit.length === 0 ? i18next.t("amount.quantity.withoutUnit", {
210
206
  quantity: value
211
- });
212
- else return i18next.t("amount.quantity.withUnit", {
207
+ }) : i18next.t("amount.quantity.withUnit", {
213
208
  quantity: value,
214
209
  unit: unit
215
210
  });
211
+ let comparatorCode = quantity.comparator;
212
+ let comparatorString = (0, $3d60081b7152576d$export$e7321bf46d18757f)(comparatorCode) ? i18next.t(`quantityComparator:${comparatorCode}`) : undefined;
213
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(comparatorString)) return quantityString;
214
+ return `${comparatorString} ${quantityString}`;
216
215
  }
217
216
 
218
217
 
218
+
219
219
  function $5ab57a471c359130$export$7de3722258b87db9({ config: config, dos: dos, i18next: i18next }) {
220
220
  let doseQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "doseQuantity");
221
- // If not found, skip
222
- if (doseQuantity === undefined) return undefined;
223
- // Otherwise rendering it
221
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(doseQuantity)) return undefined;
224
222
  return i18next.t("fields.doseQuantity", {
225
223
  quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
226
224
  quantity: doseQuantity,
@@ -231,49 +229,51 @@ function $5ab57a471c359130$export$7de3722258b87db9({ config: config, dos: dos, i
231
229
  }
232
230
 
233
231
 
234
- // Utility function
235
- // Quantity unit to string
232
+
233
+ function $c3b3b5857aef7d44$export$aace639f4c93bb3d(quantity) {
234
+ return [
235
+ quantity?.unit,
236
+ quantity?.code
237
+ ].some((0, $3d60081b7152576d$export$e7321bf46d18757f));
238
+ }
239
+
240
+
241
+
236
242
  function $9ee880701f47723b$var$transformQuantityUnitToString(i18next, quantity, config) {
237
243
  let quantityValue = quantity.value;
238
- // If common units from HL7, do the job
239
244
  if (quantity.system === "http://hl7.org/fhir/ValueSet/duration-units") {
240
245
  let code = quantity.code;
241
246
  return i18next.t(`unitsOfTime:withoutCount.${code}`, {
242
247
  count: quantityValue
243
248
  });
244
- } else // otherwise, it is UCUM, ... so let the user do the job
249
+ }
245
250
  return config.fromFHIRQuantityUnitToString({
246
251
  language: config.language,
247
252
  quantity: quantity
248
253
  });
249
254
  }
250
255
  function $9ee880701f47723b$export$be17d167ed50d870({ range: range, config: config, i18next: i18next }) {
251
- // Extract params
252
256
  const { low: low, high: high } = range;
253
257
  const lowValue = low?.value;
254
258
  const highValue = high?.value;
255
- // prepare unit display
256
259
  let quantityUnit = high || low;
257
- let hasUnit = quantityUnit?.unit !== undefined || quantityUnit?.code !== undefined;
258
- // Four cases
260
+ let hasQuantityUnit = (0, $c3b3b5857aef7d44$export$aace639f4c93bb3d)(quantityUnit);
259
261
  // 1. If we have a empty object, return undefined
260
- if (lowValue === undefined && highValue === undefined) return undefined;
261
- // quantity unit
262
- let unit = hasUnit ? $9ee880701f47723b$var$transformQuantityUnitToString(i18next, quantityUnit, config) : "";
263
- let technicalKey = hasUnit ? "withUnit" : "withoutUnit";
262
+ 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";
264
265
  // 2. Both low & high are present
265
- if (lowValue !== undefined && highValue !== undefined) return i18next.t(`amount.range.${technicalKey}.lowAndHigh`, {
266
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(lowValue, highValue)) return i18next.t(`amount.range.${technicalKey}.lowAndHigh`, {
266
267
  low: lowValue,
267
268
  high: highValue,
268
269
  unit: unit
269
270
  });
270
271
  // 3. Only high is present
271
- if (highValue !== undefined) return i18next.t(`amount.range.${technicalKey}.onlyHigh`, {
272
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(highValue)) return i18next.t(`amount.range.${technicalKey}.onlyHigh`, {
272
273
  high: highValue,
273
274
  unit: unit
274
275
  });
275
276
  // 4. Only low is present
276
- // Warning, this case is kind dangerous and clinically unsafe so minimal effort on this ...
277
277
  return i18next.t(`amount.range.${technicalKey}.onlyLow`, {
278
278
  low: lowValue,
279
279
  unit: unit
@@ -282,31 +282,28 @@ function $9ee880701f47723b$export$be17d167ed50d870({ range: range, config: confi
282
282
 
283
283
 
284
284
 
285
+
285
286
  function $9a073aa5b09aa778$export$4cd16590995531a9({ dos: dos, config: config, i18next: i18next }) {
286
287
  let doseRange = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "doseRange");
287
- // If not found, skip
288
- if (doseRange === undefined) return undefined;
289
- // Turn range into a text
288
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(doseRange)) return undefined;
290
289
  const text = (0, $9ee880701f47723b$export$be17d167ed50d870)({
291
290
  range: doseRange,
292
291
  config: config,
293
292
  i18next: i18next
294
293
  });
295
- // Reject if empty
296
- if (text === undefined) return undefined;
294
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(text)) return undefined;
297
295
  return i18next.t("fields.doseRange", {
298
296
  rangeText: text
299
297
  });
300
298
  }
301
299
 
302
300
 
303
- // Functions
301
+
304
302
 
305
303
 
306
304
  function $052c79abb28cba29$export$4e24ef8c7997cc56({ dos: dos, config: config, i18next: i18next }) {
307
305
  let rateQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateQuantity");
308
- // If not found, skip
309
- if (rateQuantity === undefined) return undefined;
306
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(rateQuantity)) return undefined;
310
307
  return i18next.t("fields.rateQuantity", {
311
308
  quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
312
309
  quantity: rateQuantity,
@@ -317,119 +314,108 @@ function $052c79abb28cba29$export$4e24ef8c7997cc56({ dos: dos, config: config, i
317
314
  }
318
315
 
319
316
 
320
- // Utility function
317
+
321
318
 
322
319
 
323
320
  function $703b645b55481398$export$d3dd7d3522271dba({ dos: dos, config: config, i18next: i18next }) {
324
321
  let rateRange = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateRange");
325
- // If not found, skip
326
- if (rateRange === undefined) return undefined;
327
- // Turn range into a text
322
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(rateRange)) return undefined;
328
323
  const rangeText = (0, $9ee880701f47723b$export$be17d167ed50d870)({
329
324
  range: rateRange,
330
325
  config: config,
331
326
  i18next: i18next
332
327
  });
333
- // Reject if empty
334
- if (rangeText === undefined) return undefined;
335
- // return the final string
328
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(rangeText)) return undefined;
336
329
  return i18next.t("fields.rateRange", {
337
330
  rangeText: rangeText
338
331
  });
339
332
  }
340
333
 
341
334
 
342
- // Quantity has an unit ?
343
- function $7895e9944cc835ce$var$hasUnit(quantity) {
344
- return (quantity?.unit || quantity?.code) !== undefined;
335
+
336
+
337
+
338
+ // To cover all nasty cases of denominator
339
+ function $7895e9944cc835ce$var$fromDenominatorToString({ config: config, i18next: i18next, quantity: quantity }) {
340
+ let hasUnitDenominator = (0, $c3b3b5857aef7d44$export$aace639f4c93bb3d)(quantity);
341
+ let value = quantity.value;
342
+ if (!hasUnitDenominator) return `:${value}`;
343
+ let linkword = i18next.t("amount.ratio.denominatorLinkword", {
344
+ count: value
345
+ });
346
+ let quantityText = value !== 1 ? (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
347
+ quantity: quantity,
348
+ config: config,
349
+ i18next: i18next
350
+ }) : config.fromFHIRQuantityUnitToString({
351
+ quantity: quantity,
352
+ language: config.language
353
+ });
354
+ // The space before is intentional so that numerator and denominator are well printed regardless of situation
355
+ return ` ${linkword} ${quantityText}`;
345
356
  }
346
357
  function $7895e9944cc835ce$export$fdc6e9cbd31555fb({ ratio: ratio, config: config, i18next: i18next }) {
347
- // Extract params
348
358
  const { denominator: denominator, numerator: numerator } = ratio;
349
- // units as text
350
- let numeratorUnit = $7895e9944cc835ce$var$hasUnit(numerator) ? config.fromFHIRQuantityUnitToString({
351
- language: config.language,
352
- quantity: numerator
353
- }) : undefined;
354
- let denominatorUnit = $7895e9944cc835ce$var$hasUnit(denominator) ? config.fromFHIRQuantityUnitToString({
355
- language: config.language,
356
- quantity: denominator
357
- }) : undefined;
358
- // quantity
359
359
  let quantityNumerator = numerator?.value;
360
360
  let quantityDenominator = denominator?.value;
361
- // Collect results
362
361
  const parts = [];
363
- let noUnits = numeratorUnit === undefined && denominatorUnit === undefined;
364
- let separator = noUnits ? "" : " ";
365
- // Deal with numerator first
366
- if (quantityNumerator !== undefined) {
367
- let technicalKey = numeratorUnit !== undefined ? "withUnit" : "withoutUnit";
368
- const numeratorString = i18next.t(`amount.ratio.${technicalKey}.numerator`, {
369
- count: quantityNumerator,
370
- numeratorUnit: numeratorUnit
362
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(quantityNumerator)) {
363
+ const numeratorString = (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
364
+ quantity: numerator,
365
+ config: config,
366
+ i18next: i18next
371
367
  });
372
368
  parts.push(numeratorString);
373
369
  }
374
- // Deal with denominator
375
- if (quantityDenominator !== undefined) {
376
- let technicalKey = denominatorUnit !== undefined ? "withUnit" : "withoutUnit";
377
- const denominatorString = i18next.t(`amount.ratio.${technicalKey}.denominator`, {
378
- count: quantityDenominator,
379
- denominatorUnit: denominatorUnit
370
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(quantityDenominator)) {
371
+ const denominatorString = $7895e9944cc835ce$var$fromDenominatorToString({
372
+ config: config,
373
+ i18next: i18next,
374
+ quantity: denominator
380
375
  });
381
376
  parts.push(denominatorString);
382
377
  }
383
- // Concatenate the result
384
- if (parts.length === 0) return undefined;
385
- else return parts.join(separator);
378
+ return parts.length > 0 ? parts.join("") : undefined;
386
379
  }
387
380
 
388
381
 
389
382
 
383
+
390
384
  function $301791f33da707fa$export$b71cfd2510242de2({ dos: dos, config: config, i18next: i18next }) {
391
385
  let rateRatio = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateRatio");
392
- // If not found, skip
393
- if (rateRatio === undefined) return undefined;
394
- // Turn ratio to text
386
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(rateRatio)) return undefined;
395
387
  const ratioText = (0, $7895e9944cc835ce$export$fdc6e9cbd31555fb)({
396
388
  config: config,
397
389
  i18next: i18next,
398
390
  ratio: rateRatio
399
391
  });
400
- if (ratioText === undefined) return undefined;
392
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(ratioText)) return undefined;
401
393
  return i18next.t("fields.rateRatio", {
402
394
  ratioText: ratioText
403
395
  });
404
396
  }
405
397
 
406
398
 
407
- function $e8251a88ed398f12$export$1d3efc96e203aa6b(dos) {
408
- // If empty, return undefined
409
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
410
- return dos.timing.repeat;
399
+
400
+ function $cc064cd9e69cf2cf$export$59de929dfa9e850b(dos, key) {
401
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.timing?.repeat)) return undefined;
402
+ return dos.timing.repeat[key];
411
403
  }
412
404
 
413
405
 
406
+
414
407
  function $1270a8f06113f53a$export$675ae45fa2875f4a({ dos: dos, i18next: i18next }) {
415
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
416
- // If empty, return undefined
417
- if (repeat === undefined) return undefined;
418
- // Pickup the repeat interesting attributes
419
- let duration = repeat.duration;
420
- let max = repeat.durationMax;
421
- let unit = repeat.durationUnit;
422
- // Do nothing if no unit, I am not a wizard
423
- if (unit === undefined) return undefined;
424
- else return [
425
- // duration
426
- duration !== undefined && i18next.t("fields.duration", {
408
+ let duration = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "duration");
409
+ let max = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "durationMax");
410
+ let unit = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "durationUnit");
411
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(unit)) return undefined;
412
+ return [
413
+ (0, $3d60081b7152576d$export$e7321bf46d18757f)(duration) && i18next.t("fields.duration", {
427
414
  durationText: i18next.t(`unitsOfTime:withCount.${unit}`, {
428
415
  count: duration
429
416
  })
430
417
  }),
431
- // durationMax
432
- max !== undefined && i18next.t("fields.durationMax", {
418
+ (0, $3d60081b7152576d$export$e7321bf46d18757f)(max) && i18next.t("fields.durationMax", {
433
419
  durationMaxText: i18next.t(`unitsOfTime:withCount.${unit}`, {
434
420
  count: max
435
421
  })
@@ -439,83 +425,66 @@ function $1270a8f06113f53a$export$675ae45fa2875f4a({ dos: dos, i18next: i18next
439
425
 
440
426
 
441
427
 
428
+
442
429
  function $bc43734b944260d2$export$d663412e0c469ce2({ dos: dos, i18next: i18next }) {
443
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
444
- // If empty, return undefined
445
- if (repeat === undefined) return undefined;
446
- // Pickup the repeat interesting attributes
447
- let frequency = repeat.frequency;
448
- let max = repeat.frequencyMax;
449
- // Do nothing if no frequency / frequencyMax, I am not a wizard
450
- if (frequency === undefined && max === undefined) return undefined;
451
- else {
452
- // Three cases
453
- // 1. Frequency and frequencyMax are present
454
- if (frequency !== undefined && max !== undefined) return i18next.t("fields.frequency.withfrequencyMax", {
455
- count: max,
456
- frequency: frequency
457
- });
458
- // 2. Only frequencyMax is present
459
- if (max !== undefined) return i18next.t("fields.frequencyMax.frequencyMax", {
460
- count: max
461
- });
462
- // 3. Only frequency is present
463
- return i18next.t("fields.frequency.onlyFrequency", {
464
- count: frequency
465
- });
466
- }
430
+ let frequency = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "frequency");
431
+ let max = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "frequencyMax");
432
+ if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(frequency, max)) return undefined;
433
+ // 1. Frequency and frequencyMax are present
434
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(frequency, max)) return i18next.t("fields.frequency.withfrequencyMax", {
435
+ count: max,
436
+ frequency: frequency
437
+ });
438
+ // 2. Only frequencyMax is present
439
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(max)) return i18next.t("fields.frequencyMax.frequencyMax", {
440
+ count: max
441
+ });
442
+ // 3. Only frequency is present
443
+ return i18next.t("fields.frequency.onlyFrequency", {
444
+ count: frequency
445
+ });
467
446
  }
468
447
 
469
448
 
470
449
 
450
+
471
451
  function $b9825dd9e0a2e687$export$aa31b783699f637({ dos: dos, i18next: i18next }) {
472
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
473
- // If empty, return undefined
474
- if (repeat === undefined) return undefined;
475
- // Pickup the repeat interesting attributes
476
- let period = repeat.period;
477
- let max = repeat.periodMax;
478
- let unit = repeat.periodUnit;
479
- // Do nothing if no unit, I am not a wizard
480
- if (unit === undefined) return undefined;
481
- else {
482
- // Three cases
483
- // 1. period and periodMax are present
484
- if (period !== undefined && max !== undefined) return i18next.t("fields.periodMax.withPeriod", {
485
- period: period,
486
- count: max,
487
- unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
488
- count: max
489
- })
490
- });
491
- // 2. Only periodMax is present
492
- if (max !== undefined) return i18next.t("fields.periodMax.onlyPeriodMax", {
493
- count: max,
494
- unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
495
- count: max
496
- })
497
- });
498
- // 3. Only period present
499
- return i18next.t("fields.period.period", {
500
- count: period,
501
- unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
502
- count: period
503
- })
504
- });
505
- }
452
+ let period = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "period");
453
+ let max = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "periodMax");
454
+ let unit = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "periodUnit");
455
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(unit)) return undefined;
456
+ // 1. period and periodMax are present
457
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(period, max)) return i18next.t("fields.periodMax.withPeriod", {
458
+ period: period,
459
+ count: max,
460
+ unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
461
+ count: max
462
+ })
463
+ });
464
+ // 2. Only periodMax is present
465
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(max)) return i18next.t("fields.periodMax.onlyPeriodMax", {
466
+ count: max,
467
+ unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
468
+ count: max
469
+ })
470
+ });
471
+ // 3. Only period present
472
+ return i18next.t("fields.period.period", {
473
+ count: period,
474
+ unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
475
+ count: period
476
+ })
477
+ });
506
478
  }
507
479
 
508
480
 
509
- // Functions
510
481
  const $93b58b7d2ead3b95$var$linkworsdMap = {
511
482
  and: "linkwords.and",
512
483
  then: "linkwords.then"
513
484
  };
514
485
  function $93b58b7d2ead3b95$export$826742c1df3eca39(i18next, arr, linkWord = "and") {
515
- // Split the array into two parts: all entries except the last one, and the last
516
486
  const firstString = arr.slice(0, -1).join(", ");
517
487
  const lastString = arr.slice(-1).join("");
518
- // concatenate the result
519
488
  const linkWordTechnicalKey = $93b58b7d2ead3b95$var$linkworsdMap[linkWord];
520
489
  const linkWordAsString = arr.length > 1 ? ` ${i18next.t(linkWordTechnicalKey)} ` : "";
521
490
  const finalString = firstString + linkWordAsString + lastString;
@@ -524,6 +493,8 @@ function $93b58b7d2ead3b95$export$826742c1df3eca39(i18next, arr, linkWord = "and
524
493
 
525
494
 
526
495
 
496
+
497
+
527
498
  // Function to extract times
528
499
  function $7a065f861a4b61f2$var$extractTime(minutes) {
529
500
  let days = Math.floor(minutes / 1440);
@@ -535,79 +506,55 @@ function $7a065f861a4b61f2$var$extractTime(minutes) {
535
506
  minutes: remainingMinutes
536
507
  };
537
508
  }
538
- // Function to transform offset into a string
539
509
  function $7a065f861a4b61f2$var$transformOffset(i18next, offset) {
540
- if (offset === undefined || offset <= 0) return undefined;
541
- // extract days / hours / minutes from it
510
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(offset) || offset <= 0) return undefined;
542
511
  let time = $7a065f861a4b61f2$var$extractTime(offset);
543
- // generate part
544
512
  let subParts = [
545
- // days
546
513
  time.days > 0 ? i18next.t("unitsOfTime:withCount.d", {
547
514
  count: time.days
548
515
  }) : undefined,
549
- // hours
550
516
  time.hours > 0 ? i18next.t("unitsOfTime:withCount.h", {
551
517
  count: time.hours
552
518
  }) : undefined,
553
- // minutes
554
519
  time.minutes > 0 ? i18next.t("unitsOfTime:withCount.min", {
555
520
  count: time.minutes
556
521
  }) : undefined
557
- ].filter((s)=>s !== undefined);
522
+ ].filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
558
523
  return subParts.join(" ");
559
524
  }
560
- // Function to transform when[] into a string
561
525
  function $7a065f861a4b61f2$var$transformWhen(i18next, when) {
562
- // Only run when array is not empty
563
- if (when === undefined || when.length === 0) return undefined;
564
- // Turn it into a string
526
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(when)) return undefined;
565
527
  const whens = when.map((whenCode)=>i18next.t(`eventTiming:${whenCode}`));
566
- const finalString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, whens);
567
- return finalString;
528
+ return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, whens);
568
529
  }
569
530
  function $7a065f861a4b61f2$export$433fa514f44031f3({ dos: dos, i18next: i18next }) {
570
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
571
- // If empty, return undefined
572
- if (repeat === undefined) return undefined;
573
- // Pickup the repeat interesting attributes
574
- let offset = repeat.offset;
575
- let when = repeat.when;
576
- // If both are undefined, don't do anything
577
- if (offset === undefined && when === undefined) return undefined;
531
+ let offset = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "offset");
532
+ let when = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "when");
533
+ if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(offset, when)) return undefined;
578
534
  return [
579
- // offset part
580
535
  $7a065f861a4b61f2$var$transformOffset(i18next, offset),
581
- // when part
582
536
  $7a065f861a4b61f2$var$transformWhen(i18next, when)
583
- ].filter((s)=>s !== undefined).join(" ");
537
+ ].filter((0, $3d60081b7152576d$export$e7321bf46d18757f)).join(" ");
584
538
  }
585
539
 
586
540
 
587
- // Function
541
+
588
542
 
589
543
 
590
544
  function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
591
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
592
- // If empty, return undefined
593
- if (repeat === undefined) return undefined;
594
- // Pickup the repeat interesting attributes
595
- let dayOfWeek = repeat.dayOfWeek;
545
+ let dayOfWeek = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "dayOfWeek");
596
546
  // If empty, skip it
597
- if (dayOfWeek === undefined || dayOfWeek.length === 0) return undefined;
598
- else {
599
- // Turn it into a string
600
- const dayOfWeeks = dayOfWeek.map((dayCode)=>i18next.t(`daysOfWeek:${dayCode}`));
601
- const dayOfWeeksAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, dayOfWeeks);
602
- return i18next.t("fields.dayOfWeek.dayOfWeek", {
603
- count: dayOfWeek.length,
604
- dayOfWeek: dayOfWeeksAsString
605
- });
606
- }
547
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(dayOfWeek)) return undefined;
548
+ const dayOfWeeks = dayOfWeek.map((dayCode)=>i18next.t(`daysOfWeek:${dayCode}`));
549
+ const dayOfWeeksAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, dayOfWeeks);
550
+ return i18next.t("fields.dayOfWeek.dayOfWeek", {
551
+ count: dayOfWeek.length,
552
+ dayOfWeek: dayOfWeeksAsString
553
+ });
607
554
  }
608
555
 
609
556
 
610
- // Functions
557
+
611
558
 
612
559
 
613
560
  /**
@@ -615,45 +562,35 @@ function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next
615
562
  * There is no date specified. Seconds must be provided due to schema type constraints but may be zero-filled
616
563
  * and may be ignored at receiver discretion
617
564
  */ function $a846209a7dd119d4$var$formatString(time) {
618
- // Split the time string by ":"
619
565
  var parts = time.split(":");
620
- // Check if the last part (seconds) is "00", if so, remove it
621
566
  if (parts.length > 2 && parts[2] === "00") parts.pop();
622
- // Join the remaining parts with ":"
623
567
  return parts.join(":");
624
568
  }
625
569
  function $a846209a7dd119d4$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
626
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
627
- // If empty, return undefined
628
- if (repeat === undefined) return undefined;
629
- // Pickup the repeat interesting attributes
630
- let timeOfDay = repeat.timeOfDay;
570
+ let timeOfDay = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "timeOfDay");
631
571
  // If empty, skip it
632
- if (timeOfDay === undefined || timeOfDay.length === 0) return undefined;
633
- else {
634
- // Turn it into a string
635
- const timeOfDays = timeOfDay.map($a846209a7dd119d4$var$formatString);
636
- const timeOfDaysAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, timeOfDays);
637
- return i18next.t("fields.timeOfDay", {
638
- timeOfDay: timeOfDaysAsString,
639
- count: timeOfDays.length
640
- });
641
- }
572
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(timeOfDay)) return undefined;
573
+ // Turn it into a string
574
+ const timeOfDays = timeOfDay.map($a846209a7dd119d4$var$formatString);
575
+ const timeOfDaysAsString = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, timeOfDays);
576
+ return i18next.t("fields.timeOfDay", {
577
+ timeOfDay: timeOfDaysAsString,
578
+ count: timeOfDays.length
579
+ });
642
580
  }
643
581
 
644
582
 
645
- // Function
583
+
646
584
 
647
585
  // Turn a list of codeable concept into a string
648
586
  function $ee04e2a8ed39962f$var$fromCodeableConceptArrayToString(i18next, codes, config) {
649
587
  const codesAsString = codes.map((code)=>config.fromCodeableConceptToString({
650
588
  code: code,
651
589
  language: config.language
652
- })).filter((s)=>s !== undefined);
590
+ })).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
653
591
  return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, codesAsString);
654
592
  }
655
593
  function $ee04e2a8ed39962f$export$5c69a2202525487a({ dos: dos, config: config, i18next: i18next }) {
656
- // Pickup the interesting attributes
657
594
  let asNeededBoolean = dos.asNeededBoolean;
658
595
  let asNeededCodeableConcept = dos.asNeededCodeableConcept;
659
596
  let asNeededFor = dos.asNeededFor;
@@ -665,18 +602,16 @@ function $ee04e2a8ed39962f$export$5c69a2202525487a({ dos: dos, config: config, i
665
602
  if (codeableList.length > 0) return i18next.t("fields.asNeededFor", {
666
603
  reasons: $ee04e2a8ed39962f$var$fromCodeableConceptArrayToString(i18next, codeableList, config)
667
604
  });
668
- else {
669
- // merge boolean to make it simpler
670
- let booleanValue = asNeededBoolean || asNeeded || false;
671
- if (booleanValue) return i18next.t("fields.asNeeded");
672
- else return undefined;
673
- }
605
+ let booleanValue = [
606
+ asNeededBoolean,
607
+ asNeeded
608
+ ].includes(true);
609
+ return booleanValue ? i18next.t("fields.asNeeded") : undefined;
674
610
  }
675
611
 
676
612
 
677
- // Functions
678
613
 
679
- // Duration to string
614
+
680
615
  function $9d632517596957df$var$transformDurationToString(i18next, duration, config) {
681
616
  let quantity = duration.value;
682
617
  // If common units from HL7, do the job
@@ -685,118 +620,102 @@ function $9d632517596957df$var$transformDurationToString(i18next, duration, conf
685
620
  return i18next.t(`unitsOfTime:withCount.${code}`, {
686
621
  count: quantity
687
622
  });
688
- } else {
689
- // otherwise, it is UCUM, ... so let the user do the job
690
- let unit = config.fromFHIRQuantityUnitToString({
691
- language: config.language,
692
- quantity: duration
693
- });
694
- return `${quantity} ${unit}`;
695
623
  }
624
+ // otherwise, it is UCUM, ... so let the user do the job
625
+ let unit = config.fromFHIRQuantityUnitToString({
626
+ language: config.language,
627
+ quantity: duration
628
+ });
629
+ return `${quantity} ${unit}`;
696
630
  }
697
631
  function $9d632517596957df$export$b927a06bc51aea32({ dos: dos, config: config, i18next: i18next }) {
698
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
699
- // If empty, return undefined
700
- if (repeat === undefined) return undefined;
701
- // Pickup the repeat interesting attributes
702
- let boundsDuration = repeat.boundsDuration;
703
- // Do nothing if no boundsDuration, I am not a wizard
704
- if (boundsDuration === undefined) return undefined;
705
- else {
706
- let durationText = $9d632517596957df$var$transformDurationToString(i18next, boundsDuration, config);
707
- return i18next.t("fields.boundsDuration", {
708
- durationText: durationText
709
- });
710
- }
632
+ let boundsDuration = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "boundsDuration");
633
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(boundsDuration)) return undefined;
634
+ let durationText = $9d632517596957df$var$transformDurationToString(i18next, boundsDuration, config);
635
+ return i18next.t("fields.boundsDuration", {
636
+ durationText: durationText
637
+ });
711
638
  }
712
639
 
713
640
 
714
- // types
641
+
715
642
 
716
643
 
717
644
  function $2da391a8a8345a3d$export$8c667cbf7bebaa93({ dos: dos, config: config, i18next: i18next }) {
718
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
719
- // If empty, return undefined
720
- if (repeat === undefined) return undefined;
721
- // Pickup the repeat interesting attributes
722
- let boundsRange = repeat.boundsRange;
723
- // Do nothing if no boundsRange, I am not a wizard
724
- if (boundsRange === undefined) return undefined;
725
- else {
726
- // Turn range into a text
727
- const rangeText = (0, $9ee880701f47723b$export$be17d167ed50d870)({
728
- range: boundsRange,
729
- config: config,
730
- i18next: i18next
731
- });
732
- // Reject if empty
733
- if (rangeText === undefined) return undefined;
734
- // return the final string
735
- return i18next.t("fields.boundsRange", {
736
- rangeText: rangeText
737
- });
738
- }
645
+ let boundsRange = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "boundsRange");
646
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(boundsRange)) return undefined;
647
+ const rangeText = (0, $9ee880701f47723b$export$be17d167ed50d870)({
648
+ range: boundsRange,
649
+ config: config,
650
+ i18next: i18next
651
+ });
652
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(rangeText)) return undefined;
653
+ return i18next.t("fields.boundsRange", {
654
+ rangeText: rangeText
655
+ });
739
656
  }
740
657
 
741
658
 
742
659
 
660
+
743
661
  function $39470eb799331038$export$498ca7f558a02e67({ dos: dos, i18next: i18next }) {
744
- let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
745
- // If empty, return undefined
746
- if (repeat === undefined) return undefined;
747
- // Pickup the repeat interesting attributes
748
- let count = repeat.count;
749
- let countMax = repeat.countMax;
750
- // Do nothing if no count, I am not a wizard
751
- if (count === undefined && countMax === undefined) return undefined;
752
- else {
753
- // Three cases
754
- // 1. Both count & countMax are present
755
- if (count !== undefined && countMax !== undefined) return i18next.t("fields.countMax.countMax", {
756
- count: countMax,
757
- low: count
758
- });
759
- // 2. Only countMax is present
760
- if (countMax !== undefined) return i18next.t("fields.count.count", {
761
- count: countMax
762
- });
763
- // 3. Only count is present
764
- return i18next.t("fields.count.count", {
765
- count: count
766
- });
767
- }
662
+ let count = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "count");
663
+ let countMax = (0, $cc064cd9e69cf2cf$export$59de929dfa9e850b)(dos, "countMax");
664
+ if ((0, $3d60081b7152576d$export$cbff5d1bcc7ff30a)(count, countMax)) return undefined;
665
+ // 1. Both count & countMax are present
666
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(count, countMax)) return i18next.t("fields.countMax.countMax", {
667
+ count: countMax,
668
+ low: count
669
+ });
670
+ // 2. Only countMax is present
671
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(countMax)) return i18next.t("fields.count.count", {
672
+ count: countMax
673
+ });
674
+ // 3. Only count is present
675
+ return i18next.t("fields.count.count", {
676
+ count: count
677
+ });
768
678
  }
769
679
 
770
680
 
771
- // Functions
772
681
 
773
- // types
682
+
774
683
  // Function to clean up the params for dateStyle situation
775
684
  // Note: dateStyle and timeStyle can be used with each other,
776
685
  // but not with other date-time component options (e.g. weekday, hour, month, etc.).
777
686
  function $208be5279f5e6c65$var$generateDateStyleFormatOptions(options) {
687
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(options.dateStyle)) return {
688
+ dateStyle: options.dateStyle
689
+ };
690
+ const defaults = {
691
+ year: "numeric",
692
+ month: "2-digit",
693
+ day: "2-digit"
694
+ };
778
695
  return {
779
- year: options.dateStyle === undefined ? options.year || "numeric" : undefined,
780
- month: options.dateStyle === undefined ? options.month || "2-digit" : undefined,
781
- day: options.dateStyle === undefined ? options.day || "2-digit" : undefined,
782
- weekday: options.dateStyle === undefined ? options.weekday : undefined
696
+ ...options,
697
+ ...defaults
783
698
  };
784
699
  }
785
700
  // Function to clean up the params for timeStyle situation
786
701
  function $208be5279f5e6c65$var$generateTimeStyleFormatOptions(options) {
702
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(options.timeStyle)) return {
703
+ timeStyle: options.timeStyle
704
+ };
705
+ const defaults = {
706
+ hour: "2-digit",
707
+ minute: "2-digit",
708
+ second: "2-digit"
709
+ };
787
710
  return {
788
- hour: options.timeStyle === undefined ? options.hour || "2-digit" : undefined,
789
- minute: options.timeStyle === undefined ? options.minute || "2-digit" : undefined,
790
- second: options.timeStyle === undefined ? options.second || "2-digit" : undefined
711
+ ...options,
712
+ ...defaults
791
713
  };
792
714
  }
793
715
  function $208be5279f5e6c65$export$a77f8869772ffca4({ config: config, datetimes: datetimes }) {
794
716
  let options = config.dateTimeFormatOptions;
795
- // prepare data for algorithm below
796
717
  const entries = datetimes.map((datetime)=>{
797
- // Convert it to date
798
718
  let date = new Date(datetime);
799
- // other properties
800
719
  let hasTimePart = datetime.includes("T");
801
720
  let hyphensCount = datetime.split("-").length - 1;
802
721
  let hasMonths = hyphensCount >= 1;
@@ -828,19 +747,12 @@ function $208be5279f5e6c65$export$a77f8869772ffca4({ config: config, datetimes:
828
747
  // If only year / month and days are defined, print it according
829
748
  if (!hasTimePart) {
830
749
  let df3 = new Intl.DateTimeFormat(config.language, {
831
- // retrieve value from user
832
- dateStyle: options.dateStyle,
833
- // fallback if dateStyle is not defined
834
750
  ...$208be5279f5e6c65$var$generateDateStyleFormatOptions(options)
835
751
  });
836
752
  return df3.format(date);
837
753
  }
838
754
  // Otherwise, we have a full datetime
839
755
  let df4 = new Intl.DateTimeFormat(config.language, {
840
- // retrieve value from user
841
- dateStyle: options.dateStyle,
842
- timeStyle: options.timeStyle,
843
- // fallback if dateStyle / timeStyle is not defined
844
756
  ...$208be5279f5e6c65$var$generateDateStyleFormatOptions(options),
845
757
  ...$208be5279f5e6c65$var$generateTimeStyleFormatOptions(options)
846
758
  });
@@ -849,9 +761,7 @@ function $208be5279f5e6c65$export$a77f8869772ffca4({ config: config, datetimes:
849
761
  return result;
850
762
  }
851
763
  function $208be5279f5e6c65$export$4699e913d5b6ffeb({ config: config, datetime: datetime }) {
852
- // Can't do magic ;)
853
- if (datetime === undefined) return undefined;
854
- // Invoke previous function, and pick up the first entry
764
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(datetime)) return undefined;
855
765
  const result = $208be5279f5e6c65$export$a77f8869772ffca4({
856
766
  config: config,
857
767
  datetimes: [
@@ -862,12 +772,10 @@ function $208be5279f5e6c65$export$4699e913d5b6ffeb({ config: config, datetime: d
862
772
  }
863
773
 
864
774
 
775
+
865
776
  function $3bceb6a4d7bec96e$export$3c2848bc0f0e3783({ dos: dos, config: config, i18next: i18next }) {
866
- // If empty, return undefined
867
- if (dos.timing === undefined || dos.timing.event === undefined || dos.timing.event.length === 0) return undefined;
868
- // Generate the string version of them
869
- let events = dos.timing.event;
870
- // List to string
777
+ let events = dos.timing?.event;
778
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(events)) return undefined;
871
779
  let eventList = (0, $208be5279f5e6c65$export$a77f8869772ffca4)({
872
780
  config: config,
873
781
  datetimes: events
@@ -880,25 +788,23 @@ function $3bceb6a4d7bec96e$export$3c2848bc0f0e3783({ dos: dos, config: config, i
880
788
  }
881
789
 
882
790
 
883
- // Function
791
+
792
+
884
793
 
885
794
  function $6c156f35df44ca41$export$21e3522d6e713036({ dos: dos, config: config, i18next: i18next }) {
886
- // If empty, return undefined
887
- if (dos.additionalInstruction === undefined || dos.additionalInstruction.length === 0) return undefined;
888
- // Turn it into strings
795
+ if ((0, $7642ff4865ae4b0f$export$d9ff4a623e416a11)(dos.additionalInstruction)) return undefined;
889
796
  let additionalInstructions = dos.additionalInstruction.map((instruction)=>config.fromCodeableConceptToString({
890
797
  code: instruction,
891
798
  language: config.language
892
- })).filter((s)=>s !== undefined);
799
+ })).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
893
800
  return (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, additionalInstructions);
894
801
  }
895
802
 
896
803
 
897
- // Functions
804
+
898
805
 
899
806
  function $e021f207f5cc63d0$export$6e78f21a88fc25ea({ dos: dos, config: config, i18next: i18next }) {
900
- // If empty, return undefined
901
- if (dos.maxDosePerLifetime === undefined) return undefined;
807
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.maxDosePerLifetime)) return undefined;
902
808
  const maxDosePerLifetime = dos.maxDosePerLifetime;
903
809
  return i18next.t("fields.maxDosePerLifetime", {
904
810
  quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
@@ -910,11 +816,10 @@ function $e021f207f5cc63d0$export$6e78f21a88fc25ea({ dos: dos, config: config, i
910
816
  }
911
817
 
912
818
 
913
- // Functions
819
+
914
820
 
915
821
  function $9ad44f2c84a9bdf4$export$58c8a9e040283a66({ dos: dos, config: config, i18next: i18next }) {
916
- // If empty, return undefined
917
- if (dos.maxDosePerAdministration === undefined) return undefined;
822
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.maxDosePerAdministration)) return undefined;
918
823
  const maxDosePerAdministration = dos.maxDosePerAdministration;
919
824
  return i18next.t("fields.maxDosePerAdministration", {
920
825
  quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
@@ -926,11 +831,10 @@ function $9ad44f2c84a9bdf4$export$58c8a9e040283a66({ dos: dos, config: config, i
926
831
  }
927
832
 
928
833
 
929
- // Functions
834
+
930
835
 
931
836
  function $45256d2a188dcbd7$export$75a89431d80a701a({ dos: dos, config: config, i18next: i18next }) {
932
- // If empty, return undefined
933
- if (dos.timing === undefined || dos.timing.repeat === undefined || dos.timing.repeat.boundsPeriod === undefined) return undefined;
837
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.timing?.repeat?.boundsPeriod)) return undefined;
934
838
  // Generate the string version of them
935
839
  const boundsPeriod = dos.timing.repeat.boundsPeriod;
936
840
  let start = (0, $208be5279f5e6c65$export$4699e913d5b6ffeb)({
@@ -941,14 +845,13 @@ function $45256d2a188dcbd7$export$75a89431d80a701a({ dos: dos, config: config, i
941
845
  config: config,
942
846
  datetime: boundsPeriod.end
943
847
  });
944
- // Three cases
945
848
  // 1. Both start and end are present
946
- if (start !== undefined && end !== undefined) return i18next.t("fields.boundsPeriod.startAndEnd", {
849
+ if ((0, $3d60081b7152576d$export$3b3497187fd4cc1a)(start, end)) return i18next.t("fields.boundsPeriod.startAndEnd", {
947
850
  start: start,
948
851
  end: end
949
852
  });
950
853
  // 2. Only start is present
951
- if (start !== undefined) return i18next.t("fields.boundsPeriod.onlyStart", {
854
+ if ((0, $3d60081b7152576d$export$e7321bf46d18757f)(start)) return i18next.t("fields.boundsPeriod.onlyStart", {
952
855
  start: start
953
856
  });
954
857
  // 3. Only end is present
@@ -960,12 +863,11 @@ function $45256d2a188dcbd7$export$75a89431d80a701a({ dos: dos, config: config, i
960
863
 
961
864
 
962
865
 
866
+
963
867
  function $39ffdeadc450f558$export$346b11a8cb220f02({ dos: dos, config: config, i18next: i18next }) {
964
- // If empty, return undefined
965
- if (dos.maxDosePerPeriod === undefined) return undefined;
868
+ if (!(0, $3d60081b7152576d$export$e7321bf46d18757f)(dos.maxDosePerPeriod)) return undefined;
966
869
  const maxDosePerPeriod = dos.maxDosePerPeriod;
967
- // In R4, it was a single object
968
- // In R5, it is an array
870
+ // In R4, it was a single object / In R5, it is an array
969
871
  // So better to have a generic approach
970
872
  const values = Array.isArray(maxDosePerPeriod) ? maxDosePerPeriod : [
971
873
  maxDosePerPeriod
@@ -979,7 +881,7 @@ function $39ffdeadc450f558$export$346b11a8cb220f02({ dos: dos, config: config, i
979
881
  i18next: i18next,
980
882
  ratio: period
981
883
  });
982
- }).filter((s)=>s !== undefined);
884
+ }).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
983
885
  const maxDosePerPeriodText = (0, $93b58b7d2ead3b95$export$826742c1df3eca39)(i18next, valuesAsString);
984
886
  return i18next.t("fields.maxDosePerPeriod", {
985
887
  count: values.length,
@@ -990,7 +892,7 @@ function $39ffdeadc450f558$export$346b11a8cb220f02({ dos: dos, config: config, i
990
892
 
991
893
 
992
894
 
993
- // Map
895
+
994
896
  const $2c21ace90ecdbde6$var$displayOrders = {
995
897
  additionalInstruction: (input)=>(0, $6c156f35df44ca41$export$21e3522d6e713036)(input),
996
898
  asNeeded: (input)=>(0, $ee04e2a8ed39962f$export$5c69a2202525487a)(input),
@@ -1016,7 +918,7 @@ const $2c21ace90ecdbde6$var$displayOrders = {
1016
918
  let subParts = [
1017
919
  (0, $bc43734b944260d2$export$d663412e0c469ce2)(input),
1018
920
  (0, $b9825dd9e0a2e687$export$aa31b783699f637)(input)
1019
- ].filter((s)=>s !== undefined);
921
+ ].filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
1020
922
  return subParts.length > 0 ? subParts.join(" ") : undefined;
1021
923
  },
1022
924
  maxDosePerAdministration: (input)=>(0, $9ad44f2c84a9bdf4$export$58c8a9e040283a66)(input),
@@ -1060,18 +962,17 @@ const $2c21ace90ecdbde6$var$displayOrders = {
1060
962
  })
1061
963
  };
1062
964
  function $2c21ace90ecdbde6$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
1063
- // Use map to provide a result without iterate on each key
1064
965
  return $2c21ace90ecdbde6$var$displayOrders[entry](args);
1065
966
  }
1066
967
 
1067
968
 
1068
969
 
1069
970
 
971
+
1070
972
  const $74b0cf9d3dbd5b46$var$defaultI18NConfig = {
1071
973
  backend: {
1072
974
  backends: [
1073
- (0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(// have to cast the function to be webpack / builder friendly
1074
- async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
975
+ (0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
1075
976
  ]
1076
977
  }
1077
978
  };
@@ -1086,35 +987,22 @@ class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $868b4eaa4f62b9f7$ex
1086
987
  /**
1087
988
  * Does this array of Dosage objects contains only "sequential" instructions ?
1088
989
  */ containsOnlySequentialInstructions(dosages) {
1089
- // 1. Collect all sequences number
1090
- let sequencesNumbers = dosages.map((d)=>d.sequence).filter((s)=>s !== undefined);
1091
- // 2. Convert it to a Set
990
+ let sequencesNumbers = dosages.map((d)=>d.sequence).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
1092
991
  let encounteredSequenceNumbers = new Set(sequencesNumbers);
1093
- // 3. We have a "sequential" situation in two cases
1094
- // A) No sequence number were provided
1095
- // B) All sequence numbers are different
1096
992
  return encounteredSequenceNumbers.size === 0 || encounteredSequenceNumbers.size === dosages.length;
1097
993
  }
1098
994
  /**
1099
995
  * Turn this array of Dosage objects into a data structure useful to handle "sequential" and "concurrent" instructions (cf. "sequence" property).
1100
996
  * @returns {Dosage[][]} - A two-dimensional array where each inner array contains Dosage objects belonging to the same sequence numberr.
1101
997
  */ groupBySequence(dosages) {
1102
- // Prepare variables
1103
998
  let groups = {};
1104
999
  let sequences = new Set();
1105
1000
  for(let idx = 0; idx < dosages.length; idx++){
1106
- // Get dosage object
1107
1001
  const dosage = dosages[idx];
1108
- // Get the sequence number (normally, in real world, it should be present in this case)
1109
- // If no sequence number, assume it is idx + 1
1110
1002
  let sequenceNr = dosage.sequence || idx + 1;
1111
- // Retrieve of create previous entries for this sequence number
1112
1003
  let localGroup = groups[sequenceNr] || [];
1113
- // Add entry
1114
1004
  localGroup.push(dosage);
1115
- // Pushback result
1116
1005
  groups[sequenceNr] = localGroup;
1117
- // For reminder of the parsed sequence
1118
1006
  sequences.add(sequenceNr);
1119
1007
  }
1120
1008
  // By using the Set values, we are sure it is returned in the way Dosages were written
@@ -1129,20 +1017,17 @@ class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $868b4eaa4f62b9f7$ex
1129
1017
  * From a single dosage, extract specific field(s) requested by user.
1130
1018
  * Some use cases could request to split part of the object for given needs (quantity and timing separately)
1131
1019
  */ getFields(dos, ...order) {
1132
- // iterate on each key and generate a string from each part
1133
1020
  let parts = order.map((entry)=>(0, $2c21ace90ecdbde6$export$9f330b4bf8c0975c)({
1134
1021
  config: this.config,
1135
1022
  dos: dos,
1136
1023
  entry: entry,
1137
1024
  i18next: this.i18nInstance
1138
- })).filter((s)=>s !== undefined);
1139
- // Join each part with a separator
1025
+ })).filter((0, $3d60081b7152576d$export$e7321bf46d18757f));
1140
1026
  return parts.join(this.config.displaySeparator);
1141
1027
  }
1142
1028
  /**
1143
1029
  * Turn a FHIR Dosage object into text
1144
1030
  */ fromDosageToText(dos) {
1145
- // iterate on each key and generate a string from each part
1146
1031
  let order = this.config.displayOrder;
1147
1032
  return this.getFields(dos, ...order);
1148
1033
  }