fhir-dosage-utils 1.2.0 → 1.3.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,10 +1,11 @@
1
+ import $hgUW1$i18nextresourcestobackend from "i18next-resources-to-backend";
1
2
  import $hgUW1$i18next from "i18next";
2
3
  import $hgUW1$i18nextchainedbackend from "i18next-chained-backend";
3
- import $hgUW1$i18nextresourcestobackend from "i18next-resources-to-backend";
4
-
5
4
 
5
+ // Classe(s)
6
6
 
7
7
 
8
+ // Types
8
9
  function $a620268c8b5a46fd$export$b1a6aed91fad1636({ quantity: quantity }) {
9
10
  if (quantity.code !== undefined) return quantity.code;
10
11
  if (quantity.unit !== undefined) return quantity.unit;
@@ -34,20 +35,156 @@ function $a31aaee21175037d$export$30c337e25ab8e95b({ extensions: extensions }) {
34
35
  }
35
36
 
36
37
 
38
+ const $c03f5f20816d8d50$export$38cd8db2db178f58 = {
39
+ language: "en",
40
+ fromFHIRQuantityUnitToString: (0, $a620268c8b5a46fd$export$b1a6aed91fad1636),
41
+ fromCodeableConceptToString: (0, $f2878500cc217687$export$f478f96b98da13a4),
42
+ fromExtensionsToString: (0, $a31aaee21175037d$export$30c337e25ab8e95b),
43
+ displayOrder: [
44
+ "method",
45
+ "doseQuantity",
46
+ "doseRange",
47
+ "rateRatio",
48
+ "rateQuantity",
49
+ "rateRange",
50
+ "durationDurationMax",
51
+ "frequencyFrequencyMaxPeriodPeriodMax",
52
+ "offsetWhen",
53
+ "dayOfWeek",
54
+ "timeOfDay",
55
+ "route",
56
+ "site",
57
+ "asNeeded",
58
+ "boundsDuration",
59
+ "boundsPeriod",
60
+ "boundsRange",
61
+ "countCountMax",
62
+ "event",
63
+ "code",
64
+ "maxDosePerPeriod",
65
+ "maxDosePerAdministration",
66
+ "maxDosePerLifetime",
67
+ "additionalInstruction",
68
+ "patientInstruction"
69
+ ],
70
+ displaySeparator: " - ",
71
+ dateTimeFormatOptions: {}
72
+ };
73
+
74
+
75
+ class $2422495f2648c580$export$f807d9a22ff8372d {
76
+ // Set up lib, according provided parameters
77
+ constructor(userConfig, i18nConfig){
78
+ // User config
79
+ this.config = {
80
+ // default attributes
81
+ ...(0, $c03f5f20816d8d50$export$38cd8db2db178f58),
82
+ // attributes set by user
83
+ ...userConfig
84
+ };
85
+ // I18N config
86
+ this.i18nConfig = {
87
+ // default attributes
88
+ fallbackLng: "en",
89
+ lng: this.config.language,
90
+ ns: [
91
+ "common",
92
+ "daysOfWeek",
93
+ "eventTiming",
94
+ "unitsOfTime"
95
+ ],
96
+ defaultNS: "common",
97
+ // attributes set by user
98
+ ...i18nConfig
99
+ };
100
+ this.i18nInstance = (0, $hgUW1$i18next).createInstance();
101
+ }
102
+ /**
103
+ * To init i18next properly according requested criteria
104
+ */ async init() {
105
+ // You should wait for init to complete (wait for the callback or promise resolution)
106
+ // before using the t function!
107
+ return await this.i18nInstance.use((0, $hgUW1$i18nextchainedbackend)).init(this.i18nConfig);
108
+ }
109
+ /**
110
+ * To change language
111
+ */ async changeLanguage(lng) {
112
+ this.config = {
113
+ ...this.config,
114
+ language: lng
115
+ };
116
+ return this.i18nInstance.changeLanguage(lng);
117
+ }
118
+ /**
119
+ * Get current language
120
+ */ getLanguage() {
121
+ return this.config.language;
122
+ }
123
+ /**
124
+ * To change display order
125
+ */ changeDisplayOrder(order) {
126
+ this.config = {
127
+ ...this.config,
128
+ displayOrder: order
129
+ };
130
+ }
131
+ /**
132
+ * Get display order
133
+ */ getDisplayOrder() {
134
+ return this.config.displayOrder;
135
+ }
136
+ /**
137
+ * Get display separator
138
+ */ getDisplaySeparator() {
139
+ return this.config.displaySeparator;
140
+ }
141
+ /**
142
+ * Set display separator
143
+ */ changeDisplaySeparator(sep) {
144
+ this.config = {
145
+ ...this.config,
146
+ displaySeparator: sep
147
+ };
148
+ }
149
+ /**
150
+ * Get date time format options
151
+ */ getDateTimeFormatOptions() {
152
+ return this.config.dateTimeFormatOptions;
153
+ }
154
+ /**
155
+ * Set date time format options
156
+ */ changeDateTimeFormatOptions(opts) {
157
+ this.config = {
158
+ ...this.config,
159
+ dateTimeFormatOptions: opts
160
+ };
161
+ }
162
+ }
163
+
164
+
37
165
  // translators
38
166
  // To avoid circular dependancies issue, let's have a single place for exports and imports
39
- // types
40
- function $7cf24331c38efaf1$export$7de3722258b87db9({ config: config, dos: dos, i18next: i18next }) {
167
+ // Types
168
+ function $a8a8a2e7c5a5225c$export$76d408d587da5203(dos, key) {
41
169
  // If empty, return undefined
42
170
  if (dos.doseAndRate === undefined) return undefined;
43
171
  // Find the first entry that match criteria
44
- let doseQuantity = dos.doseAndRate.find((s)=>s.doseQuantity !== undefined);
172
+ let doseAndRate = dos.doseAndRate.find((s)=>s[key] !== undefined);
173
+ // If not found, skip
174
+ if (doseAndRate === undefined) return undefined;
175
+ // return property
176
+ return doseAndRate[key];
177
+ }
178
+
179
+
180
+ function $7cf24331c38efaf1$export$7de3722258b87db9({ config: config, dos: dos, i18next: i18next }) {
181
+ let doseQuantity = (0, $a8a8a2e7c5a5225c$export$76d408d587da5203)(dos, "doseQuantity");
45
182
  // If not found, skip
46
183
  if (doseQuantity === undefined) return undefined;
47
- let quantity = doseQuantity.doseQuantity.value || 1;
184
+ let quantity = doseQuantity.value || 1;
48
185
  let unit = config.fromFHIRQuantityUnitToString({
49
186
  language: config.language,
50
- quantity: doseQuantity.doseQuantity
187
+ quantity: doseQuantity
51
188
  });
52
189
  return i18next.t("fields.doseQuantity", {
53
190
  quantity: quantity,
@@ -106,16 +243,14 @@ function $73073500f7f08f16$export$be17d167ed50d870({ range: range, config: confi
106
243
  }
107
244
 
108
245
 
246
+
109
247
  function $465e6e43e1df9717$export$4cd16590995531a9({ dos: dos, config: config, i18next: i18next }) {
110
- // If empty, return undefined
111
- if (dos.doseAndRate === undefined) return undefined;
112
- // Find the first entry that match criteria
113
- let doseRange = dos.doseAndRate.find((s)=>s.doseRange !== undefined);
248
+ let doseRange = (0, $a8a8a2e7c5a5225c$export$76d408d587da5203)(dos, "doseRange");
114
249
  // If not found, skip
115
250
  if (doseRange === undefined) return undefined;
116
251
  // Turn range into a text
117
252
  const text = (0, $73073500f7f08f16$export$be17d167ed50d870)({
118
- range: doseRange.doseRange,
253
+ range: doseRange,
119
254
  config: config,
120
255
  i18next: i18next
121
256
  });
@@ -127,20 +262,17 @@ function $465e6e43e1df9717$export$4cd16590995531a9({ dos: dos, config: config, i
127
262
  }
128
263
 
129
264
 
130
- // types
265
+
131
266
  function $bbbd1877a73b7a2b$export$4e24ef8c7997cc56({ dos: dos, config: config, i18next: i18next }) {
132
- // If empty, return undefined
133
- if (dos.doseAndRate === undefined) return undefined;
134
- // Find the first entry that match criteria
135
- let rateQuantity = dos.doseAndRate.find((s)=>s.rateQuantity !== undefined);
267
+ let rateQuantity = (0, $a8a8a2e7c5a5225c$export$76d408d587da5203)(dos, "rateQuantity");
136
268
  // If not found, skip
137
269
  if (rateQuantity === undefined) return undefined;
138
270
  // information from rate
139
- let value = rateQuantity.rateQuantity.value || 1;
271
+ let value = rateQuantity.value || 1;
140
272
  // quantity unit
141
273
  let unit = config.fromFHIRQuantityUnitToString({
142
274
  language: config.language,
143
- quantity: rateQuantity.rateQuantity
275
+ quantity: rateQuantity
144
276
  });
145
277
  return i18next.t("fields.rateQuantity", {
146
278
  quantity: value,
@@ -151,16 +283,14 @@ function $bbbd1877a73b7a2b$export$4e24ef8c7997cc56({ dos: dos, config: config, i
151
283
 
152
284
  // Utility function
153
285
 
286
+
154
287
  function $09db039855b6d015$export$d3dd7d3522271dba({ dos: dos, config: config, i18next: i18next }) {
155
- // If empty, return undefined
156
- if (dos.doseAndRate === undefined) return undefined;
157
- // Find the first entry that match criteria
158
- let doseAndRate = dos.doseAndRate.find((s)=>s.rateRange !== undefined);
288
+ let rateRange = (0, $a8a8a2e7c5a5225c$export$76d408d587da5203)(dos, "rateRange");
159
289
  // If not found, skip
160
- if (doseAndRate === undefined) return undefined;
290
+ if (rateRange === undefined) return undefined;
161
291
  // Turn range into a text
162
292
  const rangeText = (0, $73073500f7f08f16$export$be17d167ed50d870)({
163
- range: doseAndRate.rateRange,
293
+ range: rateRange,
164
294
  config: config,
165
295
  i18next: i18next
166
296
  });
@@ -218,18 +348,16 @@ function $eb371feb739abc89$export$fdc6e9cbd31555fb({ ratio: ratio, config: confi
218
348
  }
219
349
 
220
350
 
351
+
221
352
  function $520e93a43a731e9b$export$b71cfd2510242de2({ dos: dos, config: config, i18next: i18next }) {
222
- // If empty, return undefined
223
- if (dos.doseAndRate === undefined) return undefined;
224
- // Find the first entry that match criteria
225
- let doseAndRate = dos.doseAndRate.find((s)=>s.rateRatio !== undefined);
353
+ let rateRatio = (0, $a8a8a2e7c5a5225c$export$76d408d587da5203)(dos, "rateRatio");
226
354
  // If not found, skip
227
- if (doseAndRate === undefined) return undefined;
355
+ if (rateRatio === undefined) return undefined;
228
356
  // Turn ratio to text
229
357
  const ratioText = (0, $eb371feb739abc89$export$fdc6e9cbd31555fb)({
230
358
  config: config,
231
359
  i18next: i18next,
232
- ratio: doseAndRate.rateRatio
360
+ ratio: rateRatio
233
361
  });
234
362
  if (ratioText === undefined) return undefined;
235
363
  return i18next.t("fields.rateRatio", {
@@ -238,11 +366,18 @@ function $520e93a43a731e9b$export$b71cfd2510242de2({ dos: dos, config: config, i
238
366
  }
239
367
 
240
368
 
241
- function $9b80fa365533c8a7$export$675ae45fa2875f4a({ dos: dos, i18next: i18next }) {
369
+ function $23009b94f0a4a8ee$export$1d3efc96e203aa6b(dos) {
242
370
  // If empty, return undefined
243
371
  if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
372
+ return dos.timing.repeat;
373
+ }
374
+
375
+
376
+ function $9b80fa365533c8a7$export$675ae45fa2875f4a({ dos: dos, i18next: i18next }) {
377
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
378
+ // If empty, return undefined
379
+ if (repeat === undefined) return undefined;
244
380
  // Pickup the repeat interesting attributes
245
- let repeat = dos.timing.repeat;
246
381
  let duration = repeat.duration;
247
382
  let max = repeat.durationMax;
248
383
  let unit = repeat.durationUnit;
@@ -265,11 +400,12 @@ function $9b80fa365533c8a7$export$675ae45fa2875f4a({ dos: dos, i18next: i18next
265
400
  }
266
401
 
267
402
 
403
+
268
404
  function $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2({ dos: dos, i18next: i18next }) {
405
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
269
406
  // If empty, return undefined
270
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
407
+ if (repeat === undefined) return undefined;
271
408
  // Pickup the repeat interesting attributes
272
- let repeat = dos.timing.repeat;
273
409
  let frequency = repeat.frequency;
274
410
  let max = repeat.frequencyMax;
275
411
  // Do nothing if no frequency / frequencyMax, I am not a wizard
@@ -293,11 +429,12 @@ function $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2({ dos: dos, i18next: i18next
293
429
  }
294
430
 
295
431
 
432
+
296
433
  function $fcc6c325de921010$export$aa31b783699f637({ dos: dos, i18next: i18next }) {
434
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
297
435
  // If empty, return undefined
298
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
436
+ if (repeat === undefined) return undefined;
299
437
  // Pickup the repeat interesting attributes
300
- let repeat = dos.timing.repeat;
301
438
  let period = repeat.period;
302
439
  let max = repeat.periodMax;
303
440
  let unit = repeat.periodUnit;
@@ -348,6 +485,7 @@ function $f475af73bad0ba43$export$826742c1df3eca39(i18next, arr, linkWord = "and
348
485
  }
349
486
 
350
487
 
488
+
351
489
  // Function to extract times
352
490
  function $f88800def2ddd9e9$var$extractTime(minutes) {
353
491
  let days = Math.floor(minutes / 1440);
@@ -391,10 +529,10 @@ function $f88800def2ddd9e9$var$transformWhen(i18next, when) {
391
529
  return finalString;
392
530
  }
393
531
  function $f88800def2ddd9e9$export$433fa514f44031f3({ dos: dos, i18next: i18next }) {
532
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
394
533
  // If empty, return undefined
395
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
534
+ if (repeat === undefined) return undefined;
396
535
  // Pickup the repeat interesting attributes
397
- let repeat = dos.timing.repeat;
398
536
  let offset = repeat.offset;
399
537
  let when = repeat.when;
400
538
  // If both are undefined, don't do anything
@@ -410,11 +548,12 @@ function $f88800def2ddd9e9$export$433fa514f44031f3({ dos: dos, i18next: i18next
410
548
 
411
549
  // Function
412
550
 
551
+
413
552
  function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
553
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
414
554
  // If empty, return undefined
415
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
555
+ if (repeat === undefined) return undefined;
416
556
  // Pickup the repeat interesting attributes
417
- let repeat = dos.timing.repeat;
418
557
  let dayOfWeek = repeat.dayOfWeek;
419
558
  // If empty, skip it
420
559
  if (dayOfWeek === undefined || dayOfWeek.length === 0) return undefined;
@@ -432,6 +571,7 @@ function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next
432
571
 
433
572
  // Functions
434
573
 
574
+
435
575
  /**
436
576
  * time during the day, in the format hh:mm:ss (a subset of [ISO8601] icon).
437
577
  * There is no date specified. Seconds must be provided due to schema type constraints but may be zero-filled
@@ -445,10 +585,10 @@ function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next
445
585
  return parts.join(":");
446
586
  }
447
587
  function $a1b58a85293e76cc$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
588
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
448
589
  // If empty, return undefined
449
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
590
+ if (repeat === undefined) return undefined;
450
591
  // Pickup the repeat interesting attributes
451
- let repeat = dos.timing.repeat;
452
592
  let timeOfDay = repeat.timeOfDay;
453
593
  // If empty, skip it
454
594
  if (timeOfDay === undefined || timeOfDay.length === 0) return undefined;
@@ -496,7 +636,8 @@ function $ab507771e2827c53$export$5c69a2202525487a({ dos: dos, config: config, i
496
636
  }
497
637
 
498
638
 
499
- // types
639
+ // Functions
640
+
500
641
  // Duration to string
501
642
  function $ac69a26e361175ba$var$transformDurationToString(i18next, duration, config) {
502
643
  let quantity = duration.value;
@@ -516,10 +657,10 @@ function $ac69a26e361175ba$var$transformDurationToString(i18next, duration, conf
516
657
  }
517
658
  }
518
659
  function $ac69a26e361175ba$export$b927a06bc51aea32({ dos: dos, config: config, i18next: i18next }) {
660
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
519
661
  // If empty, return undefined
520
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
662
+ if (repeat === undefined) return undefined;
521
663
  // Pickup the repeat interesting attributes
522
- let repeat = dos.timing.repeat;
523
664
  let boundsDuration = repeat.boundsDuration;
524
665
  // Do nothing if no boundsDuration, I am not a wizard
525
666
  if (boundsDuration === undefined) return undefined;
@@ -534,11 +675,12 @@ function $ac69a26e361175ba$export$b927a06bc51aea32({ dos: dos, config: config, i
534
675
 
535
676
  // types
536
677
 
678
+
537
679
  function $6b27b297c2af1001$export$8c667cbf7bebaa93({ dos: dos, config: config, i18next: i18next }) {
680
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
538
681
  // If empty, return undefined
539
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
682
+ if (repeat === undefined) return undefined;
540
683
  // Pickup the repeat interesting attributes
541
- let repeat = dos.timing.repeat;
542
684
  let boundsRange = repeat.boundsRange;
543
685
  // Do nothing if no boundsRange, I am not a wizard
544
686
  if (boundsRange === undefined) return undefined;
@@ -559,11 +701,12 @@ function $6b27b297c2af1001$export$8c667cbf7bebaa93({ dos: dos, config: config, i
559
701
  }
560
702
 
561
703
 
704
+
562
705
  function $73a945b97fd1a22f$export$498ca7f558a02e67({ dos: dos, i18next: i18next }) {
706
+ let repeat = (0, $23009b94f0a4a8ee$export$1d3efc96e203aa6b)(dos);
563
707
  // If empty, return undefined
564
- if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
708
+ if (repeat === undefined) return undefined;
565
709
  // Pickup the repeat interesting attributes
566
- let repeat = dos.timing.repeat;
567
710
  let count = repeat.count;
568
711
  let countMax = repeat.countMax;
569
712
  // Do nothing if no count, I am not a wizard
@@ -869,157 +1012,24 @@ function $9b1af2fba509609e$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
869
1012
 
870
1013
 
871
1014
 
872
- // backends i18next
873
- const $8435b8d847fb3eb7$var$localeImport = async (lng, ns)=>import(`./locales/${lng}/${ns}.json`);
874
- class $8435b8d847fb3eb7$export$1c191bca55f84a03 {
875
- // Set up lib, according provided parameters
876
- constructor(args){
877
- this.config = {
878
- // default attributes
879
- language: "en",
880
- fromFHIRQuantityUnitToString: (0, $a620268c8b5a46fd$export$b1a6aed91fad1636),
881
- fromCodeableConceptToString: (0, $f2878500cc217687$export$f478f96b98da13a4),
882
- fromExtensionsToString: (0, $a31aaee21175037d$export$30c337e25ab8e95b),
883
- displayOrder: [
884
- "method",
885
- "doseQuantity",
886
- "doseRange",
887
- "rateRatio",
888
- "rateQuantity",
889
- "rateRange",
890
- "durationDurationMax",
891
- "frequencyFrequencyMaxPeriodPeriodMax",
892
- "offsetWhen",
893
- "dayOfWeek",
894
- "timeOfDay",
895
- "route",
896
- "site",
897
- "asNeeded",
898
- "boundsDuration",
899
- "boundsPeriod",
900
- "boundsRange",
901
- "countCountMax",
902
- "event",
903
- "code",
904
- "maxDosePerPeriod",
905
- "maxDosePerAdministration",
906
- "maxDosePerLifetime",
907
- "additionalInstruction",
908
- "patientInstruction"
909
- ],
910
- displaySeparator: " - ",
911
- dateTimeFormatOptions: {},
912
- // attributes set by user
913
- ...args
914
- };
915
- this.i18nInstance = (0, $hgUW1$i18next).createInstance();
916
- }
917
- /**
918
- * To init i18next properly according requested criteria
919
- */ async init() {
920
- // You should wait for init to complete (wait for the callback or promise resolution)
921
- // before using the t function!
922
- return await this.i18nInstance.use((0, $hgUW1$i18nextchainedbackend)).init({
923
- //debug: true,
924
- fallbackLng: "en",
925
- lng: this.config.language,
926
- ns: [
927
- "common",
928
- "daysOfWeek",
929
- "eventTiming",
930
- "unitsOfTime"
931
- ],
932
- defaultNS: "common",
933
- backend: {
934
- backends: [
935
- (0, $hgUW1$i18nextresourcestobackend)(// have to cast the function to be webpack / builder friendly
936
- $8435b8d847fb3eb7$var$localeImport)
937
- ]
938
- }
939
- });
1015
+
1016
+ const $8435b8d847fb3eb7$var$defaultI18NConfig = {
1017
+ backend: {
1018
+ backends: [
1019
+ (0, $hgUW1$i18nextresourcestobackend)(// have to cast the function to be webpack / builder friendly
1020
+ async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
1021
+ ]
940
1022
  }
1023
+ };
1024
+ class $8435b8d847fb3eb7$export$1c191bca55f84a03 extends (0, $2422495f2648c580$export$f807d9a22ff8372d) {
941
1025
  /**
942
1026
  * Factory to create a fine-tuned instance of the utility class
943
- */ static async build(args) {
944
- const instance = new $8435b8d847fb3eb7$export$1c191bca55f84a03(args);
1027
+ */ static async build(userConfig, i18nConfig = $8435b8d847fb3eb7$var$defaultI18NConfig) {
1028
+ const instance = new $8435b8d847fb3eb7$export$1c191bca55f84a03(userConfig, i18nConfig);
945
1029
  await instance.init();
946
1030
  return instance;
947
1031
  }
948
1032
  /**
949
- * To change language
950
- */ async changeLanguage(lng) {
951
- this.config = {
952
- ...this.config,
953
- language: lng
954
- };
955
- return this.i18nInstance.changeLanguage(lng);
956
- }
957
- /**
958
- * Get current language
959
- */ getLanguage() {
960
- return this.config.language;
961
- }
962
- /**
963
- * To change display order
964
- */ changeDisplayOrder(order) {
965
- this.config = {
966
- ...this.config,
967
- displayOrder: order
968
- };
969
- }
970
- /**
971
- * Get display order
972
- */ getDisplayOrder() {
973
- return this.config.displayOrder;
974
- }
975
- /**
976
- * Get display separator
977
- */ getDisplaySeparator() {
978
- return this.config.displaySeparator;
979
- }
980
- /**
981
- * Set display separator
982
- */ changeDisplaySeparator(sep) {
983
- this.config = {
984
- ...this.config,
985
- displaySeparator: sep
986
- };
987
- }
988
- /**
989
- * Get date time format options
990
- */ getDateTimeFormatOptions() {
991
- return this.config.dateTimeFormatOptions;
992
- }
993
- /**
994
- * Set date time format options
995
- */ changeDateTimeFormatOptions(opts) {
996
- this.config = {
997
- ...this.config,
998
- dateTimeFormatOptions: opts
999
- };
1000
- }
1001
- /**
1002
- * From a single dosage, extract specific field(s) requested by user.
1003
- * Some use cases could request to split part of the object for given needs (quantity and timing separately)
1004
- */ getFields(dos, ...order) {
1005
- // iterate on each key and generate a string from each part
1006
- let parts = order.map((entry)=>(0, $9b1af2fba509609e$export$9f330b4bf8c0975c)({
1007
- config: this.config,
1008
- dos: dos,
1009
- entry: entry,
1010
- i18next: this.i18nInstance
1011
- })).filter((s)=>s !== undefined);
1012
- // Join each part with a separator
1013
- return parts.join(this.config.displaySeparator);
1014
- }
1015
- /**
1016
- * Turn a FHIR Dosage object into text
1017
- */ fromDosageToText(dos) {
1018
- // iterate on each key and generate a string from each part
1019
- let order = this.config.displayOrder;
1020
- return this.getFields(dos, ...order);
1021
- }
1022
- /**
1023
1033
  * Does this array of Dosage objects contains only "sequential" instructions ?
1024
1034
  */ containsOnlySequentialInstructions(dosages) {
1025
1035
  // 1. Collect all sequences number
@@ -1062,6 +1072,27 @@ class $8435b8d847fb3eb7$export$1c191bca55f84a03 {
1062
1072
  });
1063
1073
  }
1064
1074
  /**
1075
+ * From a single dosage, extract specific field(s) requested by user.
1076
+ * Some use cases could request to split part of the object for given needs (quantity and timing separately)
1077
+ */ getFields(dos, ...order) {
1078
+ // iterate on each key and generate a string from each part
1079
+ let parts = order.map((entry)=>(0, $9b1af2fba509609e$export$9f330b4bf8c0975c)({
1080
+ config: this.config,
1081
+ dos: dos,
1082
+ entry: entry,
1083
+ i18next: this.i18nInstance
1084
+ })).filter((s)=>s !== undefined);
1085
+ // Join each part with a separator
1086
+ return parts.join(this.config.displaySeparator);
1087
+ }
1088
+ /**
1089
+ * Turn a FHIR Dosage object into text
1090
+ */ fromDosageToText(dos) {
1091
+ // iterate on each key and generate a string from each part
1092
+ let order = this.config.displayOrder;
1093
+ return this.getFields(dos, ...order);
1094
+ }
1095
+ /**
1065
1096
  * Turn multiple FHIR Dosage objects into text
1066
1097
  */ fromMultipleDosageToText(dosages) {
1067
1098
  // As we can have concurrent / sequential instructions, we need a generic algorithm to do the job