fhir-dosage-utils 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/dist/locales/de/common.json +82 -0
- package/dist/locales/de/daysOfWeek.json +9 -0
- package/dist/locales/de/eventTiming.json +29 -0
- package/dist/locales/de/unitsOfTime.json +34 -0
- package/dist/locales/en/common.json +82 -0
- package/dist/locales/en/daysOfWeek.json +9 -0
- package/dist/locales/en/eventTiming.json +29 -0
- package/dist/locales/en/unitsOfTime.json +34 -0
- package/dist/locales/fr/common.json +82 -0
- package/dist/locales/fr/daysOfWeek.json +9 -0
- package/dist/locales/fr/eventTiming.json +29 -0
- package/dist/locales/fr/unitsOfTime.json +34 -0
- package/dist/locales/nl/common.json +82 -0
- package/dist/locales/nl/daysOfWeek.json +9 -0
- package/dist/locales/nl/eventTiming.json +29 -0
- package/dist/locales/nl/unitsOfTime.json +34 -0
- package/dist/main.js +1030 -0
- package/dist/main.js.map +1 -0
- package/dist/module.js +1015 -0
- package/dist/module.js.map +1 -0
- package/dist/types.d.ts +248 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +63 -0
package/dist/module.js
ADDED
@@ -0,0 +1,1015 @@
|
|
1
|
+
import $hgUW1$i18next from "i18next";
|
2
|
+
import $hgUW1$i18nextchainedbackend from "i18next-chained-backend";
|
3
|
+
import $hgUW1$i18nextresourcestobackend from "i18next-resources-to-backend";
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
function $a620268c8b5a46fd$export$b1a6aed91fad1636({ quantity: quantity }) {
|
9
|
+
if (quantity.code !== undefined) return quantity.code;
|
10
|
+
if (quantity.unit !== undefined) return quantity.unit;
|
11
|
+
return "";
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
function $f2878500cc217687$export$f478f96b98da13a4({ code: code }) {
|
16
|
+
// If no code, skip it
|
17
|
+
if (code === undefined) return undefined;
|
18
|
+
// Take text first
|
19
|
+
if (code.text !== undefined) return code.text;
|
20
|
+
// If empty, skip it
|
21
|
+
if (code.coding === undefined || code.coding.length === 0) return undefined;
|
22
|
+
// Take first coding; display first then code
|
23
|
+
let firstCode = code.coding[0];
|
24
|
+
return firstCode.display || firstCode.code;
|
25
|
+
}
|
26
|
+
|
27
|
+
|
28
|
+
function $a31aaee21175037d$export$30c337e25ab8e95b({ extensions: extensions }) {
|
29
|
+
// If no extensions, skip it
|
30
|
+
if (extensions === undefined || extensions.length === 0) return undefined;
|
31
|
+
// KIS implementation : print it as provided, without doing anything
|
32
|
+
// Extensions have so many cases btw, that having a basic function does the trick
|
33
|
+
return extensions.map((extension)=>JSON.stringify(extension)).join(" ");
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
// translators
|
38
|
+
// 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 }) {
|
41
|
+
// If empty, return undefined
|
42
|
+
if (dos.doseAndRate === undefined) return undefined;
|
43
|
+
// Find the first entry that match criteria
|
44
|
+
let doseQuantity = dos.doseAndRate.find((s)=>s.doseQuantity !== undefined);
|
45
|
+
// If not found, skip
|
46
|
+
if (doseQuantity === undefined) return undefined;
|
47
|
+
let quantity = doseQuantity.doseQuantity.value || 1;
|
48
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
49
|
+
language: config.language,
|
50
|
+
quantity: doseQuantity.doseQuantity
|
51
|
+
});
|
52
|
+
return i18next.t("fields.doseQuantity", {
|
53
|
+
quantity: quantity,
|
54
|
+
unit: unit
|
55
|
+
});
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
// types
|
60
|
+
function $465e6e43e1df9717$export$4cd16590995531a9({ dos: dos, config: config, i18next: i18next }) {
|
61
|
+
// If empty, return undefined
|
62
|
+
if (dos.doseAndRate === undefined) return undefined;
|
63
|
+
// Find the first entry that match criteria
|
64
|
+
let doseRange = dos.doseAndRate.find((s)=>s.doseRange !== undefined);
|
65
|
+
// If not found, skip
|
66
|
+
if (doseRange === undefined) return undefined;
|
67
|
+
let low = doseRange.doseRange.low?.value;
|
68
|
+
let high = doseRange.doseRange.high?.value;
|
69
|
+
let quantityUnit = doseRange.doseRange.high !== undefined ? doseRange.doseRange.high : doseRange.doseRange.low;
|
70
|
+
// quantity unit
|
71
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
72
|
+
language: config.language,
|
73
|
+
quantity: quantityUnit
|
74
|
+
});
|
75
|
+
// Three cases
|
76
|
+
// 1. Both low & high are present
|
77
|
+
if (high !== undefined && low !== undefined) return i18next.t("fields.doseRange.lowAndHigh", {
|
78
|
+
low: low,
|
79
|
+
high: high,
|
80
|
+
unit: unit
|
81
|
+
});
|
82
|
+
// 2. Only high is present
|
83
|
+
if (high !== undefined) return i18next.t("fields.doseRange.onlyHigh", {
|
84
|
+
high: high,
|
85
|
+
unit: unit
|
86
|
+
});
|
87
|
+
// 3. Only low is present
|
88
|
+
// Warning, this case is kind dangerous and clinically unsafe so minimal effort on this ...
|
89
|
+
return i18next.t("fields.doseRange.onlyLow", {
|
90
|
+
low: low,
|
91
|
+
unit: unit
|
92
|
+
});
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
// types
|
97
|
+
function $bbbd1877a73b7a2b$export$4e24ef8c7997cc56({ dos: dos, config: config, i18next: i18next }) {
|
98
|
+
// If empty, return undefined
|
99
|
+
if (dos.doseAndRate === undefined) return undefined;
|
100
|
+
// Find the first entry that match criteria
|
101
|
+
let rateQuantity = dos.doseAndRate.find((s)=>s.rateQuantity !== undefined);
|
102
|
+
// If not found, skip
|
103
|
+
if (rateQuantity === undefined) return undefined;
|
104
|
+
// information from rate
|
105
|
+
let value = rateQuantity.rateQuantity.value || 1;
|
106
|
+
// quantity unit
|
107
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
108
|
+
language: config.language,
|
109
|
+
quantity: rateQuantity.rateQuantity
|
110
|
+
});
|
111
|
+
return i18next.t("fields.rateQuantity", {
|
112
|
+
quantity: value,
|
113
|
+
unit: unit
|
114
|
+
});
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
// types
|
119
|
+
function $09db039855b6d015$export$d3dd7d3522271dba({ dos: dos, config: config, i18next: i18next }) {
|
120
|
+
// If empty, return undefined
|
121
|
+
if (dos.doseAndRate === undefined) return undefined;
|
122
|
+
// Find the first entry that match criteria
|
123
|
+
let rateRange = dos.doseAndRate.find((s)=>s.rateRange !== undefined);
|
124
|
+
// If not found, skip
|
125
|
+
if (rateRange === undefined) return undefined;
|
126
|
+
// low / high
|
127
|
+
let low = rateRange.rateRange.low;
|
128
|
+
let high = rateRange.rateRange.high;
|
129
|
+
let quantityLow = low?.value;
|
130
|
+
let quantityHigh = high?.value;
|
131
|
+
// quantity unit
|
132
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
133
|
+
language: config.language,
|
134
|
+
quantity: high || low
|
135
|
+
});
|
136
|
+
// Three cases
|
137
|
+
// 1. Both low & high are present
|
138
|
+
if (quantityHigh !== undefined && quantityLow !== undefined) return i18next.t("fields.rateRange.lowAndHigh", {
|
139
|
+
low: quantityLow,
|
140
|
+
high: quantityHigh,
|
141
|
+
unit: unit
|
142
|
+
});
|
143
|
+
// 2. Only high is present
|
144
|
+
if (quantityHigh !== undefined) return i18next.t("fields.rateRange.onlyHigh", {
|
145
|
+
high: quantityHigh,
|
146
|
+
unit: unit
|
147
|
+
});
|
148
|
+
// 3. Only low is present
|
149
|
+
// Warning, this case is kind dangerous and clinically unsafe so minimal effort on this ...
|
150
|
+
return i18next.t("fields.rateRange.onlyLow", {
|
151
|
+
low: quantityLow,
|
152
|
+
unit: unit
|
153
|
+
});
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
// types
|
158
|
+
function $520e93a43a731e9b$export$b71cfd2510242de2({ dos: dos, config: config, i18next: i18next }) {
|
159
|
+
// If empty, return undefined
|
160
|
+
if (dos.doseAndRate === undefined) return undefined;
|
161
|
+
// Find the first entry that match criteria
|
162
|
+
let rateRatio = dos.doseAndRate.find((s)=>s.rateRatio !== undefined);
|
163
|
+
// If not found, skip
|
164
|
+
if (rateRatio === undefined) return undefined;
|
165
|
+
// num / dem
|
166
|
+
let numerator = rateRatio.rateRatio.numerator;
|
167
|
+
let denominator = rateRatio.rateRatio.denominator;
|
168
|
+
let quantityNum = numerator?.value || 1;
|
169
|
+
let quantityDenom = denominator?.value || 1;
|
170
|
+
// units as text
|
171
|
+
let numeratorUnit = numerator !== undefined ? config.fromFHIRQuantityUnitToString({
|
172
|
+
language: config.language,
|
173
|
+
quantity: numerator
|
174
|
+
}) : "";
|
175
|
+
let denominatorUnit = denominator !== undefined ? config.fromFHIRQuantityUnitToString({
|
176
|
+
language: config.language,
|
177
|
+
quantity: denominator
|
178
|
+
}) : "";
|
179
|
+
return i18next.t("fields.rateRatio.rateRatio", {
|
180
|
+
count: quantityDenom,
|
181
|
+
quantityNumerator: quantityNum,
|
182
|
+
numeratorUnit: numeratorUnit,
|
183
|
+
denominatorUnit: denominatorUnit
|
184
|
+
});
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
function $9b80fa365533c8a7$export$675ae45fa2875f4a({ dos: dos, i18next: i18next }) {
|
189
|
+
// If empty, return undefined
|
190
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
191
|
+
// Pickup the repeat interesting attributes
|
192
|
+
let repeat = dos.timing.repeat;
|
193
|
+
let duration = repeat.duration;
|
194
|
+
let max = repeat.durationMax;
|
195
|
+
let unit = repeat.durationUnit;
|
196
|
+
// Do nothing if no unit, I am not a wizard
|
197
|
+
if (unit === undefined) return undefined;
|
198
|
+
else return [
|
199
|
+
// duration
|
200
|
+
duration !== undefined && i18next.t("fields.duration", {
|
201
|
+
durationText: i18next.t(`unitsOfTime:withCount.${unit}`, {
|
202
|
+
count: duration
|
203
|
+
})
|
204
|
+
}),
|
205
|
+
// durationMax
|
206
|
+
max !== undefined && i18next.t("fields.durationMax", {
|
207
|
+
durationMaxText: i18next.t(`unitsOfTime:withCount.${unit}`, {
|
208
|
+
count: max
|
209
|
+
})
|
210
|
+
})
|
211
|
+
].filter((s)=>s !== false).join(" ");
|
212
|
+
}
|
213
|
+
|
214
|
+
|
215
|
+
function $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2({ dos: dos, i18next: i18next }) {
|
216
|
+
// If empty, return undefined
|
217
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
218
|
+
// Pickup the repeat interesting attributes
|
219
|
+
let repeat = dos.timing.repeat;
|
220
|
+
let frequency = repeat.frequency;
|
221
|
+
let max = repeat.frequencyMax;
|
222
|
+
// Do nothing if no frequency / frequencyMax, I am not a wizard
|
223
|
+
if (frequency === undefined && max === undefined) return undefined;
|
224
|
+
else {
|
225
|
+
// Three cases
|
226
|
+
// 1. Frequency and frequencyMax are present
|
227
|
+
if (frequency !== undefined && max !== undefined) return i18next.t("fields.frequency.withfrequencyMax", {
|
228
|
+
count: max,
|
229
|
+
frequency: frequency
|
230
|
+
});
|
231
|
+
// 2. Only frequencyMax is present
|
232
|
+
if (max !== undefined) return i18next.t("fields.frequencyMax.frequencyMax", {
|
233
|
+
count: max
|
234
|
+
});
|
235
|
+
// 3. Only frequency is present
|
236
|
+
return i18next.t("fields.frequency.onlyFrequency", {
|
237
|
+
count: frequency
|
238
|
+
});
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
|
243
|
+
function $fcc6c325de921010$export$aa31b783699f637({ dos: dos, i18next: i18next }) {
|
244
|
+
// If empty, return undefined
|
245
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
246
|
+
// Pickup the repeat interesting attributes
|
247
|
+
let repeat = dos.timing.repeat;
|
248
|
+
let period = repeat.period;
|
249
|
+
let max = repeat.periodMax;
|
250
|
+
let unit = repeat.periodUnit;
|
251
|
+
// Do nothing if no unit, I am not a wizard
|
252
|
+
if (unit === undefined) return undefined;
|
253
|
+
else {
|
254
|
+
// Three cases
|
255
|
+
// 1. period and periodMax are present
|
256
|
+
if (period !== undefined && max !== undefined) return i18next.t("fields.periodMax.withPeriod", {
|
257
|
+
period: period,
|
258
|
+
count: max,
|
259
|
+
unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
|
260
|
+
count: max
|
261
|
+
})
|
262
|
+
});
|
263
|
+
// 2. Only periodMax is present
|
264
|
+
if (max !== undefined) return i18next.t("fields.periodMax.onlyPeriodMax", {
|
265
|
+
count: max,
|
266
|
+
unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
|
267
|
+
count: max
|
268
|
+
})
|
269
|
+
});
|
270
|
+
// 3. Only period present
|
271
|
+
return i18next.t("fields.period.period", {
|
272
|
+
count: period,
|
273
|
+
unit: i18next.t(`unitsOfTime:withoutCount.${unit}`, {
|
274
|
+
count: period
|
275
|
+
})
|
276
|
+
});
|
277
|
+
}
|
278
|
+
}
|
279
|
+
|
280
|
+
|
281
|
+
// Functions
|
282
|
+
const $f475af73bad0ba43$var$linkworsdMap = {
|
283
|
+
and: "linkwords.and",
|
284
|
+
then: "linkwords.then"
|
285
|
+
};
|
286
|
+
function $f475af73bad0ba43$export$826742c1df3eca39(i18next, arr, linkWord = "and") {
|
287
|
+
// Split the array into two parts: all entries except the last one, and the last
|
288
|
+
const firstString = arr.slice(0, -1).join(", ");
|
289
|
+
const lastString = arr.slice(-1).join("");
|
290
|
+
// concatenate the result
|
291
|
+
const linkWordTechnicalKey = $f475af73bad0ba43$var$linkworsdMap[linkWord];
|
292
|
+
const linkWordAsString = arr.length > 1 ? ` ${i18next.t(linkWordTechnicalKey)} ` : "";
|
293
|
+
const finalString = firstString + linkWordAsString + lastString;
|
294
|
+
return finalString;
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
// Function to extract times
|
299
|
+
function $f88800def2ddd9e9$var$extractTime(minutes) {
|
300
|
+
let days = Math.floor(minutes / 1440);
|
301
|
+
let hours = Math.floor(minutes % 1440 / 60);
|
302
|
+
let remainingMinutes = minutes % 60;
|
303
|
+
return {
|
304
|
+
days: days,
|
305
|
+
hours: hours,
|
306
|
+
minutes: remainingMinutes
|
307
|
+
};
|
308
|
+
}
|
309
|
+
// Function to transform offset into a string
|
310
|
+
function $f88800def2ddd9e9$var$transformOffset(i18next, offset) {
|
311
|
+
if (offset === undefined || offset <= 0) return undefined;
|
312
|
+
// extract days / hours / minutes from it
|
313
|
+
let time = $f88800def2ddd9e9$var$extractTime(offset);
|
314
|
+
// generate part
|
315
|
+
let subParts = [
|
316
|
+
// days
|
317
|
+
time.days > 0 ? i18next.t("unitsOfTime:withCount.d", {
|
318
|
+
count: time.days
|
319
|
+
}) : undefined,
|
320
|
+
// hours
|
321
|
+
time.hours > 0 ? i18next.t("unitsOfTime:withCount.h", {
|
322
|
+
count: time.hours
|
323
|
+
}) : undefined,
|
324
|
+
// minutes
|
325
|
+
time.minutes > 0 ? i18next.t("unitsOfTime:withCount.min", {
|
326
|
+
count: time.minutes
|
327
|
+
}) : undefined
|
328
|
+
].filter((s)=>s !== undefined);
|
329
|
+
return subParts.join(" ");
|
330
|
+
}
|
331
|
+
// Function to transform when[] into a string
|
332
|
+
function $f88800def2ddd9e9$var$transformWhen(i18next, when) {
|
333
|
+
// Only run when array is not empty
|
334
|
+
if (when === undefined || when.length === 0) return undefined;
|
335
|
+
// Turn it into a string
|
336
|
+
const whens = when.map((whenCode)=>i18next.t(`eventTiming:${whenCode}`));
|
337
|
+
const finalString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, whens);
|
338
|
+
return finalString;
|
339
|
+
}
|
340
|
+
function $f88800def2ddd9e9$export$433fa514f44031f3({ dos: dos, i18next: i18next }) {
|
341
|
+
// If empty, return undefined
|
342
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
343
|
+
// Pickup the repeat interesting attributes
|
344
|
+
let repeat = dos.timing.repeat;
|
345
|
+
let offset = repeat.offset;
|
346
|
+
let when = repeat.when;
|
347
|
+
// If both are undefined, don't do anything
|
348
|
+
if (offset === undefined && when === undefined) return undefined;
|
349
|
+
return [
|
350
|
+
// offset part
|
351
|
+
$f88800def2ddd9e9$var$transformOffset(i18next, offset),
|
352
|
+
// when part
|
353
|
+
$f88800def2ddd9e9$var$transformWhen(i18next, when)
|
354
|
+
].filter((s)=>s !== undefined).join(" ");
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
// Function
|
359
|
+
|
360
|
+
function $80e4a0390d11feb3$export$f6325e43097e9543({ dos: dos, i18next: i18next }) {
|
361
|
+
// If empty, return undefined
|
362
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
363
|
+
// Pickup the repeat interesting attributes
|
364
|
+
let repeat = dos.timing.repeat;
|
365
|
+
let dayOfWeek = repeat.dayOfWeek;
|
366
|
+
// If empty, skip it
|
367
|
+
if (dayOfWeek === undefined || dayOfWeek.length === 0) return undefined;
|
368
|
+
else {
|
369
|
+
// Turn it into a string
|
370
|
+
const dayOfWeeks = dayOfWeek.map((dayCode)=>i18next.t(`daysOfWeek:${dayCode}`));
|
371
|
+
const dayOfWeeksAsString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, dayOfWeeks);
|
372
|
+
return i18next.t("fields.dayOfWeek.dayOfWeek", {
|
373
|
+
count: dayOfWeek.length,
|
374
|
+
dayOfWeek: dayOfWeeksAsString
|
375
|
+
});
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
// Functions
|
381
|
+
|
382
|
+
/**
|
383
|
+
* time during the day, in the format hh:mm:ss (a subset of [ISO8601] icon).
|
384
|
+
* There is no date specified. Seconds must be provided due to schema type constraints but may be zero-filled
|
385
|
+
* and may be ignored at receiver discretion
|
386
|
+
*/ function $a1b58a85293e76cc$var$formatString(time) {
|
387
|
+
// Split the time string by ":"
|
388
|
+
var parts = time.split(":");
|
389
|
+
// Check if the last part (seconds) is "00", if so, remove it
|
390
|
+
if (parts.length > 2 && parts[2] === "00") parts.pop();
|
391
|
+
// Join the remaining parts with ":"
|
392
|
+
return parts.join(":");
|
393
|
+
}
|
394
|
+
function $a1b58a85293e76cc$export$ee205fa48981886d({ dos: dos, i18next: i18next }) {
|
395
|
+
// If empty, return undefined
|
396
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
397
|
+
// Pickup the repeat interesting attributes
|
398
|
+
let repeat = dos.timing.repeat;
|
399
|
+
let timeOfDay = repeat.timeOfDay;
|
400
|
+
// If empty, skip it
|
401
|
+
if (timeOfDay === undefined || timeOfDay.length === 0) return undefined;
|
402
|
+
else {
|
403
|
+
// Turn it into a string
|
404
|
+
const timeOfDays = timeOfDay.map($a1b58a85293e76cc$var$formatString);
|
405
|
+
const timeOfDaysAsString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, timeOfDays);
|
406
|
+
return i18next.t("fields.timeOfDay", {
|
407
|
+
timeOfDay: timeOfDaysAsString,
|
408
|
+
count: timeOfDays.length
|
409
|
+
});
|
410
|
+
}
|
411
|
+
}
|
412
|
+
|
413
|
+
|
414
|
+
// Function
|
415
|
+
|
416
|
+
// Turn a list of codeable concept into a string
|
417
|
+
function $ab507771e2827c53$var$fromCodeableConceptArrayToString(i18next, codes, config) {
|
418
|
+
const codesAsString = codes.map((code)=>config.fromCodeableConceptToString({
|
419
|
+
code: code,
|
420
|
+
language: config.language
|
421
|
+
})).filter((s)=>s !== undefined);
|
422
|
+
return (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, codesAsString);
|
423
|
+
}
|
424
|
+
function $ab507771e2827c53$export$5c69a2202525487a({ dos: dos, config: config, i18next: i18next }) {
|
425
|
+
// Pickup the interesting attributes
|
426
|
+
let asNeededBoolean = dos.asNeededBoolean;
|
427
|
+
let asNeededCodeableConcept = dos.asNeededCodeableConcept;
|
428
|
+
let asNeededFor = dos.asNeededFor;
|
429
|
+
let asNeeded = dos.asNeeded;
|
430
|
+
// Codeable concept as list, to make algorithm simpler
|
431
|
+
let codeableList = asNeededFor || (asNeededCodeableConcept !== undefined ? [
|
432
|
+
asNeededCodeableConcept
|
433
|
+
] : []);
|
434
|
+
if (codeableList.length > 0) return i18next.t("fields.asNeededFor", {
|
435
|
+
reasons: $ab507771e2827c53$var$fromCodeableConceptArrayToString(i18next, codeableList, config)
|
436
|
+
});
|
437
|
+
else {
|
438
|
+
// merge boolean to make it simpler
|
439
|
+
let booleanValue = asNeededBoolean || asNeeded || false;
|
440
|
+
if (booleanValue) return i18next.t("fields.asNeeded");
|
441
|
+
else return undefined;
|
442
|
+
}
|
443
|
+
}
|
444
|
+
|
445
|
+
|
446
|
+
// types
|
447
|
+
// Duration to string
|
448
|
+
function $ac69a26e361175ba$var$transformDurationToString(i18next, duration, config) {
|
449
|
+
let quantity = duration.value;
|
450
|
+
// If common units from HL7, do the job
|
451
|
+
if (duration.system === "http://hl7.org/fhir/ValueSet/duration-units") {
|
452
|
+
let code = duration.code;
|
453
|
+
return i18next.t(`unitsOfTime:withCount.${code}`, {
|
454
|
+
count: quantity
|
455
|
+
});
|
456
|
+
} else {
|
457
|
+
// otherwise, it is UCUM, ... so let the user do the job
|
458
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
459
|
+
language: config.language,
|
460
|
+
quantity: duration
|
461
|
+
});
|
462
|
+
return `${quantity} ${unit}`;
|
463
|
+
}
|
464
|
+
}
|
465
|
+
function $ac69a26e361175ba$export$b927a06bc51aea32({ dos: dos, config: config, i18next: i18next }) {
|
466
|
+
// If empty, return undefined
|
467
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
468
|
+
// Pickup the repeat interesting attributes
|
469
|
+
let repeat = dos.timing.repeat;
|
470
|
+
let boundsDuration = repeat.boundsDuration;
|
471
|
+
// Do nothing if no boundsDuration, I am not a wizard
|
472
|
+
if (boundsDuration === undefined) return undefined;
|
473
|
+
else {
|
474
|
+
let durationText = $ac69a26e361175ba$var$transformDurationToString(i18next, boundsDuration, config);
|
475
|
+
return i18next.t("fields.boundsDuration", {
|
476
|
+
durationText: durationText
|
477
|
+
});
|
478
|
+
}
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
// types
|
483
|
+
// Quantity unit to string
|
484
|
+
function $6b27b297c2af1001$var$transformQuantityUnitToString(i18next, quantity, config) {
|
485
|
+
let quantityValue = quantity.value;
|
486
|
+
// If common units from HL7, do the job
|
487
|
+
if (quantity.system === "http://hl7.org/fhir/ValueSet/duration-units") {
|
488
|
+
let code = quantity.code;
|
489
|
+
return i18next.t(`unitsOfTime:withoutCount.${code}`, {
|
490
|
+
count: quantityValue
|
491
|
+
});
|
492
|
+
} else // otherwise, it is UCUM, ... so let the user do the job
|
493
|
+
return config.fromFHIRQuantityUnitToString({
|
494
|
+
language: config.language,
|
495
|
+
quantity: quantity
|
496
|
+
});
|
497
|
+
}
|
498
|
+
function $6b27b297c2af1001$export$8c667cbf7bebaa93({ dos: dos, config: config, i18next: i18next }) {
|
499
|
+
// If empty, return undefined
|
500
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
501
|
+
// Pickup the repeat interesting attributes
|
502
|
+
let repeat = dos.timing.repeat;
|
503
|
+
let boundsRange = repeat.boundsRange;
|
504
|
+
// Do nothing if no boundsRange, I am not a wizard
|
505
|
+
if (boundsRange === undefined) return undefined;
|
506
|
+
else {
|
507
|
+
let low = boundsRange.low;
|
508
|
+
let high = boundsRange.high;
|
509
|
+
// quantity unit
|
510
|
+
let unit = $6b27b297c2af1001$var$transformQuantityUnitToString(i18next, high || low, config);
|
511
|
+
// Three cases
|
512
|
+
// 1. Both low & high are present
|
513
|
+
if (high !== undefined && low !== undefined) return i18next.t("fields.boundsRange.lowAndHigh", {
|
514
|
+
low: low.value,
|
515
|
+
high: high.value,
|
516
|
+
unit: unit
|
517
|
+
});
|
518
|
+
// 2. Only high is present
|
519
|
+
if (high !== undefined) return i18next.t("fields.boundsRange.onlyHigh", {
|
520
|
+
high: high.value,
|
521
|
+
unit: unit
|
522
|
+
});
|
523
|
+
// 3. Only low is present
|
524
|
+
return i18next.t("fields.boundsRange.onlyLow", {
|
525
|
+
low: low.value,
|
526
|
+
unit: unit
|
527
|
+
});
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
function $73a945b97fd1a22f$export$498ca7f558a02e67({ dos: dos, i18next: i18next }) {
|
533
|
+
// If empty, return undefined
|
534
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined) return undefined;
|
535
|
+
// Pickup the repeat interesting attributes
|
536
|
+
let repeat = dos.timing.repeat;
|
537
|
+
let count = repeat.count;
|
538
|
+
let countMax = repeat.countMax;
|
539
|
+
// Do nothing if no count, I am not a wizard
|
540
|
+
if (count === undefined && countMax === undefined) return undefined;
|
541
|
+
else {
|
542
|
+
// Three cases
|
543
|
+
// 1. Both count & countMax are present
|
544
|
+
if (count !== undefined && countMax !== undefined) return i18next.t("fields.countMax.countMax", {
|
545
|
+
count: countMax,
|
546
|
+
low: count
|
547
|
+
});
|
548
|
+
// 2. Only countMax is present
|
549
|
+
if (countMax !== undefined) return i18next.t("fields.count.count", {
|
550
|
+
count: countMax
|
551
|
+
});
|
552
|
+
// 3. Only count is present
|
553
|
+
return i18next.t("fields.count.count", {
|
554
|
+
count: count
|
555
|
+
});
|
556
|
+
}
|
557
|
+
}
|
558
|
+
|
559
|
+
|
560
|
+
// Functions
|
561
|
+
|
562
|
+
// types
|
563
|
+
// Function to clean up the params for dateStyle situation
|
564
|
+
// Note: dateStyle and timeStyle can be used with each other,
|
565
|
+
// but not with other date-time component options (e.g. weekday, hour, month, etc.).
|
566
|
+
function $d3afe3c00981fd78$var$generateDateStyleFormatOptions(options) {
|
567
|
+
return {
|
568
|
+
year: options.dateStyle === undefined ? options.year || "numeric" : undefined,
|
569
|
+
month: options.dateStyle === undefined ? options.month || "2-digit" : undefined,
|
570
|
+
day: options.dateStyle === undefined ? options.day || "2-digit" : undefined,
|
571
|
+
weekday: options.dateStyle === undefined ? options.weekday : undefined
|
572
|
+
};
|
573
|
+
}
|
574
|
+
// Function to clean up the params for timeStyle situation
|
575
|
+
function $d3afe3c00981fd78$var$generateTimeStyleFormatOptions(options) {
|
576
|
+
return {
|
577
|
+
hour: options.timeStyle === undefined ? options.hour || "2-digit" : undefined,
|
578
|
+
minute: options.timeStyle === undefined ? options.minute || "2-digit" : undefined,
|
579
|
+
second: options.timeStyle === undefined ? options.second || "2-digit" : undefined
|
580
|
+
};
|
581
|
+
}
|
582
|
+
function $d3afe3c00981fd78$export$a77f8869772ffca4({ config: config, datetimes: datetimes }) {
|
583
|
+
let options = config.dateTimeFormatOptions;
|
584
|
+
// prepare data for algorithm below
|
585
|
+
const entries = datetimes.map((datetime)=>{
|
586
|
+
// Convert it to date
|
587
|
+
let date = new Date(datetime);
|
588
|
+
// other properties
|
589
|
+
let hasTimePart = datetime.includes("T");
|
590
|
+
let hyphensCount = datetime.split("-").length - 1;
|
591
|
+
let hasMonths = hyphensCount >= 1;
|
592
|
+
let hasDays = hyphensCount >= 2;
|
593
|
+
return {
|
594
|
+
date: date,
|
595
|
+
hasTimePart: hasTimePart,
|
596
|
+
hasMonths: hasMonths,
|
597
|
+
hasDays: hasDays
|
598
|
+
};
|
599
|
+
});
|
600
|
+
// Time to do the magic
|
601
|
+
const result = entries.map(({ date: date, hasTimePart: hasTimePart, hasMonths: hasMonths, hasDays: hasDays })=>{
|
602
|
+
// If only year is defined, print it fully (e.g. 2024)
|
603
|
+
if (!hasMonths) {
|
604
|
+
let df1 = new Intl.DateTimeFormat(config.language, {
|
605
|
+
year: "numeric"
|
606
|
+
});
|
607
|
+
return df1.format(date);
|
608
|
+
}
|
609
|
+
// If only year and month are defined, print it nicely (e.g. 2024-03 => May 2024 )
|
610
|
+
if (!hasDays) {
|
611
|
+
let df2 = new Intl.DateTimeFormat(config.language, {
|
612
|
+
year: "numeric",
|
613
|
+
month: "long"
|
614
|
+
});
|
615
|
+
return df2.format(date);
|
616
|
+
}
|
617
|
+
// If only year / month and days are defined, print it according
|
618
|
+
if (!hasTimePart) {
|
619
|
+
let df3 = new Intl.DateTimeFormat(config.language, {
|
620
|
+
// retrieve value from user
|
621
|
+
dateStyle: options.dateStyle,
|
622
|
+
// fallback if dateStyle is not defined
|
623
|
+
...$d3afe3c00981fd78$var$generateDateStyleFormatOptions(options)
|
624
|
+
});
|
625
|
+
return df3.format(date);
|
626
|
+
}
|
627
|
+
// Otherwise, we have a full datetime
|
628
|
+
let df4 = new Intl.DateTimeFormat(config.language, {
|
629
|
+
// retrieve value from user
|
630
|
+
dateStyle: options.dateStyle,
|
631
|
+
timeStyle: options.timeStyle,
|
632
|
+
// fallback if dateStyle / timeStyle is not defined
|
633
|
+
...$d3afe3c00981fd78$var$generateDateStyleFormatOptions(options),
|
634
|
+
...$d3afe3c00981fd78$var$generateTimeStyleFormatOptions(options)
|
635
|
+
});
|
636
|
+
return df4.format(date);
|
637
|
+
});
|
638
|
+
return result;
|
639
|
+
}
|
640
|
+
function $d3afe3c00981fd78$export$4699e913d5b6ffeb({ config: config, datetime: datetime }) {
|
641
|
+
// Can't do magic ;)
|
642
|
+
if (datetime === undefined) return undefined;
|
643
|
+
// Invoke previous function, and pick up the first entry
|
644
|
+
const result = $d3afe3c00981fd78$export$a77f8869772ffca4({
|
645
|
+
config: config,
|
646
|
+
datetimes: [
|
647
|
+
datetime
|
648
|
+
]
|
649
|
+
});
|
650
|
+
return result[0];
|
651
|
+
}
|
652
|
+
|
653
|
+
|
654
|
+
function $5f0331fa51f3283d$export$3c2848bc0f0e3783({ dos: dos, config: config, i18next: i18next }) {
|
655
|
+
// If empty, return undefined
|
656
|
+
if (dos.timing === undefined || dos.timing.event === undefined || dos.timing.event.length === 0) return undefined;
|
657
|
+
// Generate the string version of them
|
658
|
+
let events = dos.timing.event;
|
659
|
+
// List to string
|
660
|
+
let eventList = (0, $d3afe3c00981fd78$export$a77f8869772ffca4)({
|
661
|
+
config: config,
|
662
|
+
datetimes: events
|
663
|
+
});
|
664
|
+
let eventsAsString = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, eventList);
|
665
|
+
return i18next.t("fields.event.event", {
|
666
|
+
count: events.length,
|
667
|
+
event: eventsAsString
|
668
|
+
});
|
669
|
+
}
|
670
|
+
|
671
|
+
|
672
|
+
// Function
|
673
|
+
|
674
|
+
function $f40067ed55113d89$export$21e3522d6e713036({ dos: dos, config: config, i18next: i18next }) {
|
675
|
+
// If empty, return undefined
|
676
|
+
if (dos.additionalInstruction === undefined || dos.additionalInstruction.length === 0) return undefined;
|
677
|
+
// Turn it into strings
|
678
|
+
let additionalInstructions = dos.additionalInstruction.map((instruction)=>config.fromCodeableConceptToString({
|
679
|
+
code: instruction,
|
680
|
+
language: config.language
|
681
|
+
})).filter((s)=>s !== undefined);
|
682
|
+
return (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, additionalInstructions);
|
683
|
+
}
|
684
|
+
|
685
|
+
|
686
|
+
// types
|
687
|
+
function $08154e876fe3b2b0$export$6e78f21a88fc25ea({ dos: dos, config: config, i18next: i18next }) {
|
688
|
+
// If empty, return undefined
|
689
|
+
if (dos.maxDosePerLifetime === undefined) return undefined;
|
690
|
+
const maxDosePerLifetime = dos.maxDosePerLifetime;
|
691
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
692
|
+
language: config.language,
|
693
|
+
quantity: maxDosePerLifetime
|
694
|
+
});
|
695
|
+
return i18next.t("fields.maxDosePerLifetime", {
|
696
|
+
count: maxDosePerLifetime.value || 1,
|
697
|
+
unit: unit
|
698
|
+
});
|
699
|
+
}
|
700
|
+
|
701
|
+
|
702
|
+
// types
|
703
|
+
function $e372e1d4df385570$export$58c8a9e040283a66({ dos: dos, config: config, i18next: i18next }) {
|
704
|
+
// If empty, return undefined
|
705
|
+
if (dos.maxDosePerAdministration === undefined) return undefined;
|
706
|
+
const maxDosePerAdministration = dos.maxDosePerAdministration;
|
707
|
+
let unit = config.fromFHIRQuantityUnitToString({
|
708
|
+
language: config.language,
|
709
|
+
quantity: maxDosePerAdministration
|
710
|
+
});
|
711
|
+
return i18next.t("fields.maxDosePerAdministration", {
|
712
|
+
count: maxDosePerAdministration.value || 1,
|
713
|
+
unit: unit
|
714
|
+
});
|
715
|
+
}
|
716
|
+
|
717
|
+
|
718
|
+
// Functions
|
719
|
+
|
720
|
+
function $f28938e27e1e9773$export$75a89431d80a701a({ dos: dos, config: config, i18next: i18next }) {
|
721
|
+
// If empty, return undefined
|
722
|
+
if (dos.timing === undefined || dos.timing.repeat === undefined || dos.timing.repeat.boundsPeriod === undefined) return undefined;
|
723
|
+
// Generate the string version of them
|
724
|
+
const boundsPeriod = dos.timing.repeat.boundsPeriod;
|
725
|
+
let start = (0, $d3afe3c00981fd78$export$4699e913d5b6ffeb)({
|
726
|
+
config: config,
|
727
|
+
datetime: boundsPeriod.start
|
728
|
+
});
|
729
|
+
let end = (0, $d3afe3c00981fd78$export$4699e913d5b6ffeb)({
|
730
|
+
config: config,
|
731
|
+
datetime: boundsPeriod.end
|
732
|
+
});
|
733
|
+
// Three cases
|
734
|
+
// 1. Both start and end are present
|
735
|
+
if (start !== undefined && end !== undefined) return i18next.t("fields.boundsPeriod.startAndEnd", {
|
736
|
+
start: start,
|
737
|
+
end: end
|
738
|
+
});
|
739
|
+
// 2. Only start is present
|
740
|
+
if (start !== undefined) return i18next.t("fields.boundsPeriod.onlyStart", {
|
741
|
+
start: start
|
742
|
+
});
|
743
|
+
// 3. Only end is present
|
744
|
+
return i18next.t("fields.boundsPeriod.onlyEnd", {
|
745
|
+
end: end
|
746
|
+
});
|
747
|
+
}
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
function $252769c9f296cd6d$export$346b11a8cb220f02({ dos: dos, config: config, i18next: i18next }) {
|
752
|
+
// If empty, return undefined
|
753
|
+
if (dos.maxDosePerPeriod === undefined) return undefined;
|
754
|
+
const maxDosePerPeriod = dos.maxDosePerPeriod;
|
755
|
+
// In R4, it was a single object
|
756
|
+
// In R5, it is an array
|
757
|
+
// So better to have a generic approach
|
758
|
+
const values = Array.isArray(maxDosePerPeriod) ? maxDosePerPeriod : [
|
759
|
+
maxDosePerPeriod
|
760
|
+
];
|
761
|
+
// Only consider not empty array
|
762
|
+
if (values.length === 0) return undefined;
|
763
|
+
// Periods are expressed as ratio (like rateRatio)
|
764
|
+
const valuesAsString = values.map((period)=>{
|
765
|
+
// num / dem
|
766
|
+
let numerator = period.numerator;
|
767
|
+
let denominator = period.denominator;
|
768
|
+
let quantityNum = numerator?.value || 1;
|
769
|
+
let quantityDenom = denominator?.value || 1;
|
770
|
+
// units as text
|
771
|
+
let numeratorUnit = numerator !== undefined ? config.fromFHIRQuantityUnitToString({
|
772
|
+
language: config.language,
|
773
|
+
quantity: numerator
|
774
|
+
}) : "";
|
775
|
+
let denominatorUnit = denominator !== undefined ? config.fromFHIRQuantityUnitToString({
|
776
|
+
language: config.language,
|
777
|
+
quantity: denominator
|
778
|
+
}) : "";
|
779
|
+
return i18next.t("fields.maxDosePerPeriod.maxDosePerPeriod", {
|
780
|
+
count: quantityDenom,
|
781
|
+
quantityNumerator: quantityNum,
|
782
|
+
numeratorUnit: numeratorUnit,
|
783
|
+
denominatorUnit: denominatorUnit
|
784
|
+
});
|
785
|
+
});
|
786
|
+
const maxDosePerPeriodText = (0, $f475af73bad0ba43$export$826742c1df3eca39)(i18next, valuesAsString);
|
787
|
+
return i18next.t("fields.maxDosePerPeriod.general", {
|
788
|
+
count: values.length,
|
789
|
+
maxDosePerPeriodText: maxDosePerPeriodText
|
790
|
+
});
|
791
|
+
}
|
792
|
+
|
793
|
+
|
794
|
+
|
795
|
+
|
796
|
+
// Map
|
797
|
+
const $9b1af2fba509609e$var$displayOrders = {
|
798
|
+
additionalInstruction: (input)=>(0, $f40067ed55113d89$export$21e3522d6e713036)(input),
|
799
|
+
asNeeded: (input)=>(0, $ab507771e2827c53$export$5c69a2202525487a)(input),
|
800
|
+
boundsDuration: (input)=>(0, $ac69a26e361175ba$export$b927a06bc51aea32)(input),
|
801
|
+
boundsRange: (input)=>(0, $6b27b297c2af1001$export$8c667cbf7bebaa93)(input),
|
802
|
+
boundsPeriod: (input)=>(0, $f28938e27e1e9773$export$75a89431d80a701a)(input),
|
803
|
+
code: ({ dos: dos, config: config })=>config.fromCodeableConceptToString({
|
804
|
+
language: config.language,
|
805
|
+
code: dos.timing?.code
|
806
|
+
}),
|
807
|
+
countCountMax: (input)=>(0, $73a945b97fd1a22f$export$498ca7f558a02e67)(input),
|
808
|
+
dayOfWeek: (input)=>(0, $80e4a0390d11feb3$export$f6325e43097e9543)(input),
|
809
|
+
doseQuantity: (input)=>(0, $7cf24331c38efaf1$export$7de3722258b87db9)(input),
|
810
|
+
doseRange: (input)=>(0, $465e6e43e1df9717$export$4cd16590995531a9)(input),
|
811
|
+
durationDurationMax: (input)=>(0, $9b80fa365533c8a7$export$675ae45fa2875f4a)(input),
|
812
|
+
event: (input)=>(0, $5f0331fa51f3283d$export$3c2848bc0f0e3783)(input),
|
813
|
+
extension: ({ dos: dos, config: config })=>config.fromExtensionsToString({
|
814
|
+
language: config.language,
|
815
|
+
extensions: dos.extension
|
816
|
+
}),
|
817
|
+
frequencyFrequencyMax: (input)=>(0, $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2)(input),
|
818
|
+
frequencyFrequencyMaxPeriodPeriodMax: (input)=>{
|
819
|
+
let subParts = [
|
820
|
+
(0, $7e1bdc5bf5cdf5bd$export$d663412e0c469ce2)(input),
|
821
|
+
(0, $fcc6c325de921010$export$aa31b783699f637)(input)
|
822
|
+
].filter((s)=>s !== undefined);
|
823
|
+
return subParts.length > 0 ? subParts.join(" ") : undefined;
|
824
|
+
},
|
825
|
+
maxDosePerAdministration: (input)=>(0, $e372e1d4df385570$export$58c8a9e040283a66)(input),
|
826
|
+
maxDosePerLifetime: (input)=>(0, $08154e876fe3b2b0$export$6e78f21a88fc25ea)(input),
|
827
|
+
maxDosePerPeriod: (input)=>(0, $252769c9f296cd6d$export$346b11a8cb220f02)(input),
|
828
|
+
method: ({ dos: dos, config: config })=>config.fromCodeableConceptToString({
|
829
|
+
language: config.language,
|
830
|
+
code: dos.method
|
831
|
+
}),
|
832
|
+
offsetWhen: (input)=>(0, $f88800def2ddd9e9$export$433fa514f44031f3)(input),
|
833
|
+
patientInstruction: ({ dos: dos })=>dos.patientInstruction,
|
834
|
+
periodPeriodMax: (input)=>(0, $fcc6c325de921010$export$aa31b783699f637)(input),
|
835
|
+
rateQuantity: (input)=>(0, $bbbd1877a73b7a2b$export$4e24ef8c7997cc56)(input),
|
836
|
+
rateRange: (input)=>(0, $09db039855b6d015$export$d3dd7d3522271dba)(input),
|
837
|
+
rateRatio: (input)=>(0, $520e93a43a731e9b$export$b71cfd2510242de2)(input),
|
838
|
+
route: ({ dos: dos, config: config })=>config.fromCodeableConceptToString({
|
839
|
+
language: config.language,
|
840
|
+
code: dos.route
|
841
|
+
}),
|
842
|
+
site: ({ dos: dos, config: config })=>config.fromCodeableConceptToString({
|
843
|
+
language: config.language,
|
844
|
+
code: dos.site
|
845
|
+
}),
|
846
|
+
text: ({ dos: dos })=>dos.text,
|
847
|
+
timeOfDay: (input)=>(0, $a1b58a85293e76cc$export$ee205fa48981886d)(input)
|
848
|
+
};
|
849
|
+
function $9b1af2fba509609e$export$9f330b4bf8c0975c({ entry: entry, ...args }) {
|
850
|
+
// Use map to provide a result without iterate on each key
|
851
|
+
return $9b1af2fba509609e$var$displayOrders[entry](args);
|
852
|
+
}
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
// backends i18next
|
857
|
+
const $8435b8d847fb3eb7$var$localeImport = async (lng, ns)=>import(`./locales/${lng}/${ns}.json`);
|
858
|
+
class $8435b8d847fb3eb7$export$1c191bca55f84a03 {
|
859
|
+
// Set up lib, according provided parameters
|
860
|
+
constructor(args){
|
861
|
+
this.config = {
|
862
|
+
// default attributes
|
863
|
+
language: "en",
|
864
|
+
fromFHIRQuantityUnitToString: (0, $a620268c8b5a46fd$export$b1a6aed91fad1636),
|
865
|
+
fromCodeableConceptToString: (0, $f2878500cc217687$export$f478f96b98da13a4),
|
866
|
+
fromExtensionsToString: (0, $a31aaee21175037d$export$30c337e25ab8e95b),
|
867
|
+
displayOrder: [
|
868
|
+
"method",
|
869
|
+
"doseQuantity",
|
870
|
+
"doseRange",
|
871
|
+
"rateRatio",
|
872
|
+
"rateQuantity",
|
873
|
+
"rateRange",
|
874
|
+
"durationDurationMax",
|
875
|
+
"frequencyFrequencyMaxPeriodPeriodMax",
|
876
|
+
"offsetWhen",
|
877
|
+
"dayOfWeek",
|
878
|
+
"timeOfDay",
|
879
|
+
"route",
|
880
|
+
"site",
|
881
|
+
"asNeeded",
|
882
|
+
"boundsDuration",
|
883
|
+
"boundsPeriod",
|
884
|
+
"boundsRange",
|
885
|
+
"countCountMax",
|
886
|
+
"event",
|
887
|
+
"code",
|
888
|
+
"maxDosePerPeriod",
|
889
|
+
"maxDosePerAdministration",
|
890
|
+
"maxDosePerLifetime",
|
891
|
+
"additionalInstruction",
|
892
|
+
"patientInstruction"
|
893
|
+
],
|
894
|
+
displaySeparator: " - ",
|
895
|
+
dateTimeFormatOptions: {},
|
896
|
+
// attributes set by user
|
897
|
+
...args
|
898
|
+
};
|
899
|
+
this.i18nInstance = (0, $hgUW1$i18next).createInstance();
|
900
|
+
}
|
901
|
+
/**
|
902
|
+
* To init i18next properly according requested criteria
|
903
|
+
*/ async init() {
|
904
|
+
// You should wait for init to complete (wait for the callback or promise resolution)
|
905
|
+
// before using the t function!
|
906
|
+
return await this.i18nInstance.use((0, $hgUW1$i18nextchainedbackend)).init({
|
907
|
+
//debug: true,
|
908
|
+
fallbackLng: "en",
|
909
|
+
lng: this.config.language,
|
910
|
+
ns: [
|
911
|
+
"common",
|
912
|
+
"daysOfWeek",
|
913
|
+
"eventTiming",
|
914
|
+
"unitsOfTime"
|
915
|
+
],
|
916
|
+
defaultNS: "common",
|
917
|
+
backend: {
|
918
|
+
backends: [
|
919
|
+
(0, $hgUW1$i18nextresourcestobackend)(// have to cast the function to be webpack / builder friendly
|
920
|
+
$8435b8d847fb3eb7$var$localeImport)
|
921
|
+
]
|
922
|
+
}
|
923
|
+
});
|
924
|
+
}
|
925
|
+
/**
|
926
|
+
* Factory to create a fine-tuned instance of the utility class
|
927
|
+
*/ static async build(args) {
|
928
|
+
const instance = new $8435b8d847fb3eb7$export$1c191bca55f84a03(args);
|
929
|
+
await instance.init();
|
930
|
+
return instance;
|
931
|
+
}
|
932
|
+
/**
|
933
|
+
* To change language
|
934
|
+
*/ async changeLanguage(lng) {
|
935
|
+
this.config = {
|
936
|
+
...this.config,
|
937
|
+
language: lng
|
938
|
+
};
|
939
|
+
return this.i18nInstance.changeLanguage(lng);
|
940
|
+
}
|
941
|
+
/**
|
942
|
+
* To change display order
|
943
|
+
*/ changeDisplayOrder(order) {
|
944
|
+
this.config = {
|
945
|
+
...this.config,
|
946
|
+
displayOrder: order
|
947
|
+
};
|
948
|
+
}
|
949
|
+
/**
|
950
|
+
* Turn a FHIR Dosage object into text
|
951
|
+
*/ fromDosageToText(dos) {
|
952
|
+
// iterate on each key and generate a string from each part
|
953
|
+
let order = this.config.displayOrder;
|
954
|
+
let parts = order.map((entry)=>(0, $9b1af2fba509609e$export$9f330b4bf8c0975c)({
|
955
|
+
config: this.config,
|
956
|
+
dos: dos,
|
957
|
+
entry: entry,
|
958
|
+
i18next: this.i18nInstance
|
959
|
+
})).filter((s)=>s !== undefined);
|
960
|
+
// Join each part with a separator
|
961
|
+
return parts.join(this.config.displaySeparator);
|
962
|
+
}
|
963
|
+
/**
|
964
|
+
* Turn multiple FHIR Dosage object into text
|
965
|
+
*/ fromMultipleDosageToText(dosages) {
|
966
|
+
// As we can have concurrent / sequential instructions, we need a generic algorithm to do the job
|
967
|
+
// 1. Collect all sequences number
|
968
|
+
let sequencesNumbers = dosages.map((d)=>d.sequence).filter((s)=>s !== undefined);
|
969
|
+
// 2. Convert it to a Set
|
970
|
+
let encounteredSequenceNumbers = new Set(sequencesNumbers);
|
971
|
+
// 3. We have a "sequential" situation in two cases
|
972
|
+
// A) No sequence number were provided
|
973
|
+
// B) All sequence numbers are different
|
974
|
+
if (encounteredSequenceNumbers.size === 0 || encounteredSequenceNumbers.size === dosages.length) {
|
975
|
+
const dosagesAsText = dosages.map((d)=>this.fromDosageToText(d));
|
976
|
+
return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, dosagesAsText, "then");
|
977
|
+
}
|
978
|
+
// 4. We have both "sequential" and "concurrent" instructions - time to see what is the configuration
|
979
|
+
let groups = {};
|
980
|
+
let sequences = new Set();
|
981
|
+
for(let idx = 0; idx < dosages.length; idx++){
|
982
|
+
// Get dosage object
|
983
|
+
const dosage = dosages[idx];
|
984
|
+
// Get the sequence number (normally, in real world, it should be present in this case)
|
985
|
+
// If no sequence number, assume it is idx + 1
|
986
|
+
let sequenceNr = dosage.sequence || idx + 1;
|
987
|
+
// Generate the text version
|
988
|
+
let dosageAsText = this.fromDosageToText(dosage);
|
989
|
+
// Retrieve of create previous entries for this sequence number
|
990
|
+
let localGroup = groups[sequenceNr] || [];
|
991
|
+
// Add entry
|
992
|
+
localGroup.push(dosageAsText);
|
993
|
+
// Pushback result
|
994
|
+
groups[sequenceNr] = localGroup;
|
995
|
+
// For reminder of the parsed sequence
|
996
|
+
sequences.add(sequenceNr);
|
997
|
+
}
|
998
|
+
// 5. Now that data structures are filled, it is a piece of cake to generate the result
|
999
|
+
let sequentialInstructions = [
|
1000
|
+
...sequences.values()
|
1001
|
+
].map((sequence)=>{
|
1002
|
+
let concurrentInstructions = groups[sequence];
|
1003
|
+
return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, concurrentInstructions, "and");
|
1004
|
+
});
|
1005
|
+
return (0, $f475af73bad0ba43$export$826742c1df3eca39)(this.i18nInstance, sequentialInstructions, "then");
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
|
1010
|
+
var // Default export to make it user-friendly
|
1011
|
+
$149c1bd638913645$export$2e2bcd8739ae039 = (0, $8435b8d847fb3eb7$export$1c191bca55f84a03);
|
1012
|
+
|
1013
|
+
|
1014
|
+
export {$149c1bd638913645$export$2e2bcd8739ae039 as default};
|
1015
|
+
//# sourceMappingURL=module.js.map
|