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/main.js +225 -194
- package/dist/main.js.map +1 -1
- package/dist/module.js +225 -194
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +35 -19
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
var $8zHUo$i18nextresourcestobackend = require("i18next-resources-to-backend");
|
1
2
|
var $8zHUo$i18next = require("i18next");
|
2
3
|
var $8zHUo$i18nextchainedbackend = require("i18next-chained-backend");
|
3
|
-
var $8zHUo$i18nextresourcestobackend = require("i18next-resources-to-backend");
|
4
4
|
|
5
5
|
|
6
6
|
function $parcel$defineInteropFlag(a) {
|
@@ -18,9 +18,10 @@ 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)
|
21
22
|
|
22
23
|
|
23
|
-
|
24
|
+
// Types
|
24
25
|
function $1c57f108974f2805$export$b1a6aed91fad1636({ quantity: quantity }) {
|
25
26
|
if (quantity.code !== undefined) return quantity.code;
|
26
27
|
if (quantity.unit !== undefined) return quantity.unit;
|
@@ -50,20 +51,156 @@ function $34ebae8ac5b52fcd$export$30c337e25ab8e95b({ extensions: extensions }) {
|
|
50
51
|
}
|
51
52
|
|
52
53
|
|
54
|
+
const $99ea7fa882fd33ad$export$38cd8db2db178f58 = {
|
55
|
+
language: "en",
|
56
|
+
fromFHIRQuantityUnitToString: (0, $1c57f108974f2805$export$b1a6aed91fad1636),
|
57
|
+
fromCodeableConceptToString: (0, $a6c648898dc8c3b6$export$f478f96b98da13a4),
|
58
|
+
fromExtensionsToString: (0, $34ebae8ac5b52fcd$export$30c337e25ab8e95b),
|
59
|
+
displayOrder: [
|
60
|
+
"method",
|
61
|
+
"doseQuantity",
|
62
|
+
"doseRange",
|
63
|
+
"rateRatio",
|
64
|
+
"rateQuantity",
|
65
|
+
"rateRange",
|
66
|
+
"durationDurationMax",
|
67
|
+
"frequencyFrequencyMaxPeriodPeriodMax",
|
68
|
+
"offsetWhen",
|
69
|
+
"dayOfWeek",
|
70
|
+
"timeOfDay",
|
71
|
+
"route",
|
72
|
+
"site",
|
73
|
+
"asNeeded",
|
74
|
+
"boundsDuration",
|
75
|
+
"boundsPeriod",
|
76
|
+
"boundsRange",
|
77
|
+
"countCountMax",
|
78
|
+
"event",
|
79
|
+
"code",
|
80
|
+
"maxDosePerPeriod",
|
81
|
+
"maxDosePerAdministration",
|
82
|
+
"maxDosePerLifetime",
|
83
|
+
"additionalInstruction",
|
84
|
+
"patientInstruction"
|
85
|
+
],
|
86
|
+
displaySeparator: " - ",
|
87
|
+
dateTimeFormatOptions: {}
|
88
|
+
};
|
89
|
+
|
90
|
+
|
91
|
+
class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
|
92
|
+
// Set up lib, according provided parameters
|
93
|
+
constructor(userConfig, i18nConfig){
|
94
|
+
// User config
|
95
|
+
this.config = {
|
96
|
+
// default attributes
|
97
|
+
...(0, $99ea7fa882fd33ad$export$38cd8db2db178f58),
|
98
|
+
// attributes set by user
|
99
|
+
...userConfig
|
100
|
+
};
|
101
|
+
// I18N config
|
102
|
+
this.i18nConfig = {
|
103
|
+
// default attributes
|
104
|
+
fallbackLng: "en",
|
105
|
+
lng: this.config.language,
|
106
|
+
ns: [
|
107
|
+
"common",
|
108
|
+
"daysOfWeek",
|
109
|
+
"eventTiming",
|
110
|
+
"unitsOfTime"
|
111
|
+
],
|
112
|
+
defaultNS: "common",
|
113
|
+
// attributes set by user
|
114
|
+
...i18nConfig
|
115
|
+
};
|
116
|
+
this.i18nInstance = (0, ($parcel$interopDefault($8zHUo$i18next))).createInstance();
|
117
|
+
}
|
118
|
+
/**
|
119
|
+
* To init i18next properly according requested criteria
|
120
|
+
*/ async init() {
|
121
|
+
// You should wait for init to complete (wait for the callback or promise resolution)
|
122
|
+
// before using the t function!
|
123
|
+
return await this.i18nInstance.use((0, ($parcel$interopDefault($8zHUo$i18nextchainedbackend)))).init(this.i18nConfig);
|
124
|
+
}
|
125
|
+
/**
|
126
|
+
* To change language
|
127
|
+
*/ async changeLanguage(lng) {
|
128
|
+
this.config = {
|
129
|
+
...this.config,
|
130
|
+
language: lng
|
131
|
+
};
|
132
|
+
return this.i18nInstance.changeLanguage(lng);
|
133
|
+
}
|
134
|
+
/**
|
135
|
+
* Get current language
|
136
|
+
*/ getLanguage() {
|
137
|
+
return this.config.language;
|
138
|
+
}
|
139
|
+
/**
|
140
|
+
* To change display order
|
141
|
+
*/ changeDisplayOrder(order) {
|
142
|
+
this.config = {
|
143
|
+
...this.config,
|
144
|
+
displayOrder: order
|
145
|
+
};
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* Get display order
|
149
|
+
*/ getDisplayOrder() {
|
150
|
+
return this.config.displayOrder;
|
151
|
+
}
|
152
|
+
/**
|
153
|
+
* Get display separator
|
154
|
+
*/ getDisplaySeparator() {
|
155
|
+
return this.config.displaySeparator;
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* Set display separator
|
159
|
+
*/ changeDisplaySeparator(sep) {
|
160
|
+
this.config = {
|
161
|
+
...this.config,
|
162
|
+
displaySeparator: sep
|
163
|
+
};
|
164
|
+
}
|
165
|
+
/**
|
166
|
+
* Get date time format options
|
167
|
+
*/ getDateTimeFormatOptions() {
|
168
|
+
return this.config.dateTimeFormatOptions;
|
169
|
+
}
|
170
|
+
/**
|
171
|
+
* Set date time format options
|
172
|
+
*/ changeDateTimeFormatOptions(opts) {
|
173
|
+
this.config = {
|
174
|
+
...this.config,
|
175
|
+
dateTimeFormatOptions: opts
|
176
|
+
};
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
|
53
181
|
// translators
|
54
182
|
// To avoid circular dependancies issue, let's have a single place for exports and imports
|
55
|
-
//
|
56
|
-
function $
|
183
|
+
// Types
|
184
|
+
function $5461d5c8b4bc074f$export$76d408d587da5203(dos, key) {
|
57
185
|
// If empty, return undefined
|
58
186
|
if (dos.doseAndRate === undefined) return undefined;
|
59
187
|
// Find the first entry that match criteria
|
60
|
-
let
|
188
|
+
let doseAndRate = dos.doseAndRate.find((s)=>s[key] !== undefined);
|
189
|
+
// If not found, skip
|
190
|
+
if (doseAndRate === undefined) return undefined;
|
191
|
+
// return property
|
192
|
+
return doseAndRate[key];
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
function $5ab57a471c359130$export$7de3722258b87db9({ config: config, dos: dos, i18next: i18next }) {
|
197
|
+
let doseQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "doseQuantity");
|
61
198
|
// If not found, skip
|
62
199
|
if (doseQuantity === undefined) return undefined;
|
63
|
-
let quantity = doseQuantity.
|
200
|
+
let quantity = doseQuantity.value || 1;
|
64
201
|
let unit = config.fromFHIRQuantityUnitToString({
|
65
202
|
language: config.language,
|
66
|
-
quantity: doseQuantity
|
203
|
+
quantity: doseQuantity
|
67
204
|
});
|
68
205
|
return i18next.t("fields.doseQuantity", {
|
69
206
|
quantity: quantity,
|
@@ -122,16 +259,14 @@ function $9ee880701f47723b$export$be17d167ed50d870({ range: range, config: confi
|
|
122
259
|
}
|
123
260
|
|
124
261
|
|
262
|
+
|
125
263
|
function $9a073aa5b09aa778$export$4cd16590995531a9({ dos: dos, config: config, i18next: i18next }) {
|
126
|
-
|
127
|
-
if (dos.doseAndRate === undefined) return undefined;
|
128
|
-
// Find the first entry that match criteria
|
129
|
-
let doseRange = dos.doseAndRate.find((s)=>s.doseRange !== undefined);
|
264
|
+
let doseRange = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "doseRange");
|
130
265
|
// If not found, skip
|
131
266
|
if (doseRange === undefined) return undefined;
|
132
267
|
// Turn range into a text
|
133
268
|
const text = (0, $9ee880701f47723b$export$be17d167ed50d870)({
|
134
|
-
range: doseRange
|
269
|
+
range: doseRange,
|
135
270
|
config: config,
|
136
271
|
i18next: i18next
|
137
272
|
});
|
@@ -143,20 +278,17 @@ function $9a073aa5b09aa778$export$4cd16590995531a9({ dos: dos, config: config, i
|
|
143
278
|
}
|
144
279
|
|
145
280
|
|
146
|
-
|
281
|
+
|
147
282
|
function $052c79abb28cba29$export$4e24ef8c7997cc56({ dos: dos, config: config, i18next: i18next }) {
|
148
|
-
|
149
|
-
if (dos.doseAndRate === undefined) return undefined;
|
150
|
-
// Find the first entry that match criteria
|
151
|
-
let rateQuantity = dos.doseAndRate.find((s)=>s.rateQuantity !== undefined);
|
283
|
+
let rateQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateQuantity");
|
152
284
|
// If not found, skip
|
153
285
|
if (rateQuantity === undefined) return undefined;
|
154
286
|
// information from rate
|
155
|
-
let value = rateQuantity.
|
287
|
+
let value = rateQuantity.value || 1;
|
156
288
|
// quantity unit
|
157
289
|
let unit = config.fromFHIRQuantityUnitToString({
|
158
290
|
language: config.language,
|
159
|
-
quantity: rateQuantity
|
291
|
+
quantity: rateQuantity
|
160
292
|
});
|
161
293
|
return i18next.t("fields.rateQuantity", {
|
162
294
|
quantity: value,
|
@@ -167,16 +299,14 @@ function $052c79abb28cba29$export$4e24ef8c7997cc56({ dos: dos, config: config, i
|
|
167
299
|
|
168
300
|
// Utility function
|
169
301
|
|
302
|
+
|
170
303
|
function $703b645b55481398$export$d3dd7d3522271dba({ dos: dos, config: config, i18next: i18next }) {
|
171
|
-
|
172
|
-
if (dos.doseAndRate === undefined) return undefined;
|
173
|
-
// Find the first entry that match criteria
|
174
|
-
let doseAndRate = dos.doseAndRate.find((s)=>s.rateRange !== undefined);
|
304
|
+
let rateRange = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateRange");
|
175
305
|
// If not found, skip
|
176
|
-
if (
|
306
|
+
if (rateRange === undefined) return undefined;
|
177
307
|
// Turn range into a text
|
178
308
|
const rangeText = (0, $9ee880701f47723b$export$be17d167ed50d870)({
|
179
|
-
range:
|
309
|
+
range: rateRange,
|
180
310
|
config: config,
|
181
311
|
i18next: i18next
|
182
312
|
});
|
@@ -234,18 +364,16 @@ function $7895e9944cc835ce$export$fdc6e9cbd31555fb({ ratio: ratio, config: confi
|
|
234
364
|
}
|
235
365
|
|
236
366
|
|
367
|
+
|
237
368
|
function $301791f33da707fa$export$b71cfd2510242de2({ dos: dos, config: config, i18next: i18next }) {
|
238
|
-
|
239
|
-
if (dos.doseAndRate === undefined) return undefined;
|
240
|
-
// Find the first entry that match criteria
|
241
|
-
let doseAndRate = dos.doseAndRate.find((s)=>s.rateRatio !== undefined);
|
369
|
+
let rateRatio = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateRatio");
|
242
370
|
// If not found, skip
|
243
|
-
if (
|
371
|
+
if (rateRatio === undefined) return undefined;
|
244
372
|
// Turn ratio to text
|
245
373
|
const ratioText = (0, $7895e9944cc835ce$export$fdc6e9cbd31555fb)({
|
246
374
|
config: config,
|
247
375
|
i18next: i18next,
|
248
|
-
ratio:
|
376
|
+
ratio: rateRatio
|
249
377
|
});
|
250
378
|
if (ratioText === undefined) return undefined;
|
251
379
|
return i18next.t("fields.rateRatio", {
|
@@ -254,11 +382,18 @@ function $301791f33da707fa$export$b71cfd2510242de2({ dos: dos, config: config, i
|
|
254
382
|
}
|
255
383
|
|
256
384
|
|
257
|
-
function $
|
385
|
+
function $e8251a88ed398f12$export$1d3efc96e203aa6b(dos) {
|
258
386
|
// If empty, return undefined
|
259
387
|
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
388
|
+
return dos.timing.repeat;
|
389
|
+
}
|
390
|
+
|
391
|
+
|
392
|
+
function $1270a8f06113f53a$export$675ae45fa2875f4a({ dos: dos, i18next: i18next }) {
|
393
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
394
|
+
// If empty, return undefined
|
395
|
+
if (repeat === undefined) return undefined;
|
260
396
|
// Pickup the repeat interesting attributes
|
261
|
-
let repeat = dos.timing.repeat;
|
262
397
|
let duration = repeat.duration;
|
263
398
|
let max = repeat.durationMax;
|
264
399
|
let unit = repeat.durationUnit;
|
@@ -281,11 +416,12 @@ function $1270a8f06113f53a$export$675ae45fa2875f4a({ dos: dos, i18next: i18next
|
|
281
416
|
}
|
282
417
|
|
283
418
|
|
419
|
+
|
284
420
|
function $bc43734b944260d2$export$d663412e0c469ce2({ dos: dos, i18next: i18next }) {
|
421
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
285
422
|
// If empty, return undefined
|
286
|
-
if (
|
423
|
+
if (repeat === undefined) return undefined;
|
287
424
|
// Pickup the repeat interesting attributes
|
288
|
-
let repeat = dos.timing.repeat;
|
289
425
|
let frequency = repeat.frequency;
|
290
426
|
let max = repeat.frequencyMax;
|
291
427
|
// Do nothing if no frequency / frequencyMax, I am not a wizard
|
@@ -309,11 +445,12 @@ function $bc43734b944260d2$export$d663412e0c469ce2({ dos: dos, i18next: i18next
|
|
309
445
|
}
|
310
446
|
|
311
447
|
|
448
|
+
|
312
449
|
function $b9825dd9e0a2e687$export$aa31b783699f637({ dos: dos, i18next: i18next }) {
|
450
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
313
451
|
// If empty, return undefined
|
314
|
-
if (
|
452
|
+
if (repeat === undefined) return undefined;
|
315
453
|
// Pickup the repeat interesting attributes
|
316
|
-
let repeat = dos.timing.repeat;
|
317
454
|
let period = repeat.period;
|
318
455
|
let max = repeat.periodMax;
|
319
456
|
let unit = repeat.periodUnit;
|
@@ -364,6 +501,7 @@ function $93b58b7d2ead3b95$export$826742c1df3eca39(i18next, arr, linkWord = "and
|
|
364
501
|
}
|
365
502
|
|
366
503
|
|
504
|
+
|
367
505
|
// Function to extract times
|
368
506
|
function $7a065f861a4b61f2$var$extractTime(minutes) {
|
369
507
|
let days = Math.floor(minutes / 1440);
|
@@ -407,10 +545,10 @@ function $7a065f861a4b61f2$var$transformWhen(i18next, when) {
|
|
407
545
|
return finalString;
|
408
546
|
}
|
409
547
|
function $7a065f861a4b61f2$export$433fa514f44031f3({ dos: dos, i18next: i18next }) {
|
548
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
410
549
|
// If empty, return undefined
|
411
|
-
if (
|
550
|
+
if (repeat === undefined) return undefined;
|
412
551
|
// Pickup the repeat interesting attributes
|
413
|
-
let repeat = dos.timing.repeat;
|
414
552
|
let offset = repeat.offset;
|
415
553
|
let when = repeat.when;
|
416
554
|
// If both are undefined, don't do anything
|
@@ -426,11 +564,12 @@ function $7a065f861a4b61f2$export$433fa514f44031f3({ dos: dos, i18next: i18next
|
|
426
564
|
|
427
565
|
// Function
|
428
566
|
|
567
|
+
|
429
568
|
function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
|
569
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
430
570
|
// If empty, return undefined
|
431
|
-
if (
|
571
|
+
if (repeat === undefined) return undefined;
|
432
572
|
// Pickup the repeat interesting attributes
|
433
|
-
let repeat = dos.timing.repeat;
|
434
573
|
let dayOfWeek = repeat.dayOfWeek;
|
435
574
|
// If empty, skip it
|
436
575
|
if (dayOfWeek === undefined || dayOfWeek.length === 0) return undefined;
|
@@ -448,6 +587,7 @@ function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next
|
|
448
587
|
|
449
588
|
// Functions
|
450
589
|
|
590
|
+
|
451
591
|
/**
|
452
592
|
* time during the day, in the format hh:mm:ss (a subset of [ISO8601] icon).
|
453
593
|
* There is no date specified. Seconds must be provided due to schema type constraints but may be zero-filled
|
@@ -461,10 +601,10 @@ function $46f2142e76cf7e45$export$f6325e43097e9543({ dos: dos, i18next: i18next
|
|
461
601
|
return parts.join(":");
|
462
602
|
}
|
463
603
|
function $a846209a7dd119d4$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
|
604
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
464
605
|
// If empty, return undefined
|
465
|
-
if (
|
606
|
+
if (repeat === undefined) return undefined;
|
466
607
|
// Pickup the repeat interesting attributes
|
467
|
-
let repeat = dos.timing.repeat;
|
468
608
|
let timeOfDay = repeat.timeOfDay;
|
469
609
|
// If empty, skip it
|
470
610
|
if (timeOfDay === undefined || timeOfDay.length === 0) return undefined;
|
@@ -512,7 +652,8 @@ function $ee04e2a8ed39962f$export$5c69a2202525487a({ dos: dos, config: config, i
|
|
512
652
|
}
|
513
653
|
|
514
654
|
|
515
|
-
//
|
655
|
+
// Functions
|
656
|
+
|
516
657
|
// Duration to string
|
517
658
|
function $9d632517596957df$var$transformDurationToString(i18next, duration, config) {
|
518
659
|
let quantity = duration.value;
|
@@ -532,10 +673,10 @@ function $9d632517596957df$var$transformDurationToString(i18next, duration, conf
|
|
532
673
|
}
|
533
674
|
}
|
534
675
|
function $9d632517596957df$export$b927a06bc51aea32({ dos: dos, config: config, i18next: i18next }) {
|
676
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
535
677
|
// If empty, return undefined
|
536
|
-
if (
|
678
|
+
if (repeat === undefined) return undefined;
|
537
679
|
// Pickup the repeat interesting attributes
|
538
|
-
let repeat = dos.timing.repeat;
|
539
680
|
let boundsDuration = repeat.boundsDuration;
|
540
681
|
// Do nothing if no boundsDuration, I am not a wizard
|
541
682
|
if (boundsDuration === undefined) return undefined;
|
@@ -550,11 +691,12 @@ function $9d632517596957df$export$b927a06bc51aea32({ dos: dos, config: config, i
|
|
550
691
|
|
551
692
|
// types
|
552
693
|
|
694
|
+
|
553
695
|
function $2da391a8a8345a3d$export$8c667cbf7bebaa93({ dos: dos, config: config, i18next: i18next }) {
|
696
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
554
697
|
// If empty, return undefined
|
555
|
-
if (
|
698
|
+
if (repeat === undefined) return undefined;
|
556
699
|
// Pickup the repeat interesting attributes
|
557
|
-
let repeat = dos.timing.repeat;
|
558
700
|
let boundsRange = repeat.boundsRange;
|
559
701
|
// Do nothing if no boundsRange, I am not a wizard
|
560
702
|
if (boundsRange === undefined) return undefined;
|
@@ -575,11 +717,12 @@ function $2da391a8a8345a3d$export$8c667cbf7bebaa93({ dos: dos, config: config, i
|
|
575
717
|
}
|
576
718
|
|
577
719
|
|
720
|
+
|
578
721
|
function $39470eb799331038$export$498ca7f558a02e67({ dos: dos, i18next: i18next }) {
|
722
|
+
let repeat = (0, $e8251a88ed398f12$export$1d3efc96e203aa6b)(dos);
|
579
723
|
// If empty, return undefined
|
580
|
-
if (
|
724
|
+
if (repeat === undefined) return undefined;
|
581
725
|
// Pickup the repeat interesting attributes
|
582
|
-
let repeat = dos.timing.repeat;
|
583
726
|
let count = repeat.count;
|
584
727
|
let countMax = repeat.countMax;
|
585
728
|
// Do nothing if no count, I am not a wizard
|
@@ -885,157 +1028,24 @@ function $2c21ace90ecdbde6$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
|
|
885
1028
|
|
886
1029
|
|
887
1030
|
|
888
|
-
|
889
|
-
const $74b0cf9d3dbd5b46$var$
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
language: "en",
|
896
|
-
fromFHIRQuantityUnitToString: (0, $1c57f108974f2805$export$b1a6aed91fad1636),
|
897
|
-
fromCodeableConceptToString: (0, $a6c648898dc8c3b6$export$f478f96b98da13a4),
|
898
|
-
fromExtensionsToString: (0, $34ebae8ac5b52fcd$export$30c337e25ab8e95b),
|
899
|
-
displayOrder: [
|
900
|
-
"method",
|
901
|
-
"doseQuantity",
|
902
|
-
"doseRange",
|
903
|
-
"rateRatio",
|
904
|
-
"rateQuantity",
|
905
|
-
"rateRange",
|
906
|
-
"durationDurationMax",
|
907
|
-
"frequencyFrequencyMaxPeriodPeriodMax",
|
908
|
-
"offsetWhen",
|
909
|
-
"dayOfWeek",
|
910
|
-
"timeOfDay",
|
911
|
-
"route",
|
912
|
-
"site",
|
913
|
-
"asNeeded",
|
914
|
-
"boundsDuration",
|
915
|
-
"boundsPeriod",
|
916
|
-
"boundsRange",
|
917
|
-
"countCountMax",
|
918
|
-
"event",
|
919
|
-
"code",
|
920
|
-
"maxDosePerPeriod",
|
921
|
-
"maxDosePerAdministration",
|
922
|
-
"maxDosePerLifetime",
|
923
|
-
"additionalInstruction",
|
924
|
-
"patientInstruction"
|
925
|
-
],
|
926
|
-
displaySeparator: " - ",
|
927
|
-
dateTimeFormatOptions: {},
|
928
|
-
// attributes set by user
|
929
|
-
...args
|
930
|
-
};
|
931
|
-
this.i18nInstance = (0, ($parcel$interopDefault($8zHUo$i18next))).createInstance();
|
932
|
-
}
|
933
|
-
/**
|
934
|
-
* To init i18next properly according requested criteria
|
935
|
-
*/ async init() {
|
936
|
-
// You should wait for init to complete (wait for the callback or promise resolution)
|
937
|
-
// before using the t function!
|
938
|
-
return await this.i18nInstance.use((0, ($parcel$interopDefault($8zHUo$i18nextchainedbackend)))).init({
|
939
|
-
//debug: true,
|
940
|
-
fallbackLng: "en",
|
941
|
-
lng: this.config.language,
|
942
|
-
ns: [
|
943
|
-
"common",
|
944
|
-
"daysOfWeek",
|
945
|
-
"eventTiming",
|
946
|
-
"unitsOfTime"
|
947
|
-
],
|
948
|
-
defaultNS: "common",
|
949
|
-
backend: {
|
950
|
-
backends: [
|
951
|
-
(0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(// have to cast the function to be webpack / builder friendly
|
952
|
-
$74b0cf9d3dbd5b46$var$localeImport)
|
953
|
-
]
|
954
|
-
}
|
955
|
-
});
|
1031
|
+
|
1032
|
+
const $74b0cf9d3dbd5b46$var$defaultI18NConfig = {
|
1033
|
+
backend: {
|
1034
|
+
backends: [
|
1035
|
+
(0, ($parcel$interopDefault($8zHUo$i18nextresourcestobackend)))(// have to cast the function to be webpack / builder friendly
|
1036
|
+
async (lng, ns)=>import(`./locales/${lng}/${ns}.json`))
|
1037
|
+
]
|
956
1038
|
}
|
1039
|
+
};
|
1040
|
+
class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 extends (0, $868b4eaa4f62b9f7$export$f807d9a22ff8372d) {
|
957
1041
|
/**
|
958
1042
|
* Factory to create a fine-tuned instance of the utility class
|
959
|
-
*/ static async build(
|
960
|
-
const instance = new $74b0cf9d3dbd5b46$export$1c191bca55f84a03(
|
1043
|
+
*/ static async build(userConfig, i18nConfig = $74b0cf9d3dbd5b46$var$defaultI18NConfig) {
|
1044
|
+
const instance = new $74b0cf9d3dbd5b46$export$1c191bca55f84a03(userConfig, i18nConfig);
|
961
1045
|
await instance.init();
|
962
1046
|
return instance;
|
963
1047
|
}
|
964
1048
|
/**
|
965
|
-
* To change language
|
966
|
-
*/ async changeLanguage(lng) {
|
967
|
-
this.config = {
|
968
|
-
...this.config,
|
969
|
-
language: lng
|
970
|
-
};
|
971
|
-
return this.i18nInstance.changeLanguage(lng);
|
972
|
-
}
|
973
|
-
/**
|
974
|
-
* Get current language
|
975
|
-
*/ getLanguage() {
|
976
|
-
return this.config.language;
|
977
|
-
}
|
978
|
-
/**
|
979
|
-
* To change display order
|
980
|
-
*/ changeDisplayOrder(order) {
|
981
|
-
this.config = {
|
982
|
-
...this.config,
|
983
|
-
displayOrder: order
|
984
|
-
};
|
985
|
-
}
|
986
|
-
/**
|
987
|
-
* Get display order
|
988
|
-
*/ getDisplayOrder() {
|
989
|
-
return this.config.displayOrder;
|
990
|
-
}
|
991
|
-
/**
|
992
|
-
* Get display separator
|
993
|
-
*/ getDisplaySeparator() {
|
994
|
-
return this.config.displaySeparator;
|
995
|
-
}
|
996
|
-
/**
|
997
|
-
* Set display separator
|
998
|
-
*/ changeDisplaySeparator(sep) {
|
999
|
-
this.config = {
|
1000
|
-
...this.config,
|
1001
|
-
displaySeparator: sep
|
1002
|
-
};
|
1003
|
-
}
|
1004
|
-
/**
|
1005
|
-
* Get date time format options
|
1006
|
-
*/ getDateTimeFormatOptions() {
|
1007
|
-
return this.config.dateTimeFormatOptions;
|
1008
|
-
}
|
1009
|
-
/**
|
1010
|
-
* Set date time format options
|
1011
|
-
*/ changeDateTimeFormatOptions(opts) {
|
1012
|
-
this.config = {
|
1013
|
-
...this.config,
|
1014
|
-
dateTimeFormatOptions: opts
|
1015
|
-
};
|
1016
|
-
}
|
1017
|
-
/**
|
1018
|
-
* From a single dosage, extract specific field(s) requested by user.
|
1019
|
-
* Some use cases could request to split part of the object for given needs (quantity and timing separately)
|
1020
|
-
*/ getFields(dos, ...order) {
|
1021
|
-
// iterate on each key and generate a string from each part
|
1022
|
-
let parts = order.map((entry)=>(0, $2c21ace90ecdbde6$export$9f330b4bf8c0975c)({
|
1023
|
-
config: this.config,
|
1024
|
-
dos: dos,
|
1025
|
-
entry: entry,
|
1026
|
-
i18next: this.i18nInstance
|
1027
|
-
})).filter((s)=>s !== undefined);
|
1028
|
-
// Join each part with a separator
|
1029
|
-
return parts.join(this.config.displaySeparator);
|
1030
|
-
}
|
1031
|
-
/**
|
1032
|
-
* Turn a FHIR Dosage object into text
|
1033
|
-
*/ fromDosageToText(dos) {
|
1034
|
-
// iterate on each key and generate a string from each part
|
1035
|
-
let order = this.config.displayOrder;
|
1036
|
-
return this.getFields(dos, ...order);
|
1037
|
-
}
|
1038
|
-
/**
|
1039
1049
|
* Does this array of Dosage objects contains only "sequential" instructions ?
|
1040
1050
|
*/ containsOnlySequentialInstructions(dosages) {
|
1041
1051
|
// 1. Collect all sequences number
|
@@ -1078,6 +1088,27 @@ class $74b0cf9d3dbd5b46$export$1c191bca55f84a03 {
|
|
1078
1088
|
});
|
1079
1089
|
}
|
1080
1090
|
/**
|
1091
|
+
* From a single dosage, extract specific field(s) requested by user.
|
1092
|
+
* Some use cases could request to split part of the object for given needs (quantity and timing separately)
|
1093
|
+
*/ getFields(dos, ...order) {
|
1094
|
+
// iterate on each key and generate a string from each part
|
1095
|
+
let parts = order.map((entry)=>(0, $2c21ace90ecdbde6$export$9f330b4bf8c0975c)({
|
1096
|
+
config: this.config,
|
1097
|
+
dos: dos,
|
1098
|
+
entry: entry,
|
1099
|
+
i18next: this.i18nInstance
|
1100
|
+
})).filter((s)=>s !== undefined);
|
1101
|
+
// Join each part with a separator
|
1102
|
+
return parts.join(this.config.displaySeparator);
|
1103
|
+
}
|
1104
|
+
/**
|
1105
|
+
* Turn a FHIR Dosage object into text
|
1106
|
+
*/ fromDosageToText(dos) {
|
1107
|
+
// iterate on each key and generate a string from each part
|
1108
|
+
let order = this.config.displayOrder;
|
1109
|
+
return this.getFields(dos, ...order);
|
1110
|
+
}
|
1111
|
+
/**
|
1081
1112
|
* Turn multiple FHIR Dosage objects into text
|
1082
1113
|
*/ fromMultipleDosageToText(dosages) {
|
1083
1114
|
// As we can have concurrent / sequential instructions, we need a generic algorithm to do the job
|