fhir-dosage-utils 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,12 +28,15 @@
28
28
  "denominator_other": ":{{count}}"
29
29
  }
30
30
  },
31
- "quantity": "{{quantity}} {{unit}}"
31
+ "quantity": {
32
+ "withUnit": "{{quantity}} {{unit}}",
33
+ "withoutUnit": "{{quantity}}"
34
+ }
32
35
  },
33
36
  "fields": {
34
- "doseQuantity": "{{quantity}} {{unit}}",
37
+ "doseQuantity": "{{quantityText}}",
35
38
  "doseRange": "{{rangeText}}",
36
- "rateQuantity": "mit einem Verhältnis von {{quantity}} {{unit}}",
39
+ "rateQuantity": "mit einem Verhältnis von {{quantityText}}",
37
40
  "rateRange": "mit einem Verhältnis von {{rangeText}}",
38
41
  "rateRatio": "mit einem Verhältnis von {{ratioText}}",
39
42
  "duration": "für {{durationText}}",
@@ -83,8 +86,8 @@
83
86
  "event_one": "{{event}}",
84
87
  "event_other": "{{event}}"
85
88
  },
86
- "maxDosePerLifetime": "bis zu einer maximalen Menge von {{count}} {{unit}} über die Lebenszeit des Patienten",
87
- "maxDosePerAdministration": "bis zu einer maximalen Menge von {{count}} {{unit}} pro Dosis",
89
+ "maxDosePerLifetime": "bis zu einer maximalen Menge von {{quantityText}} über die Lebenszeit des Patienten",
90
+ "maxDosePerAdministration": "bis zu einer maximalen Menge von {{quantityText}} pro Dosis",
88
91
  "maxDosePerPeriod": "bis zu einer maximalen Menge von {{maxDosePerPeriodText}}"
89
92
  }
90
93
  }
@@ -28,12 +28,15 @@
28
28
  "denominator_other": ":{{count}}"
29
29
  }
30
30
  },
31
- "quantity": "{{quantity}} {{unit}}"
31
+ "quantity": {
32
+ "withUnit": "{{quantity}} {{unit}}",
33
+ "withoutUnit": "{{quantity}}"
34
+ }
32
35
  },
33
36
  "fields": {
34
- "doseQuantity": "{{quantity}} {{unit}}",
37
+ "doseQuantity": "{{quantityText}}",
35
38
  "doseRange": "{{rangeText}}",
36
- "rateQuantity": "at a rate of {{quantity}} {{unit}}",
39
+ "rateQuantity": "at a rate of {{quantityText}}",
37
40
  "rateRange": "at a rate of {{rangeText}}",
38
41
  "rateRatio": "at a rate of {{ratioText}}",
39
42
  "duration": "over {{durationText}}",
@@ -83,8 +86,8 @@
83
86
  "event_one": "on {{event}}",
84
87
  "event_other": "on {{event}}"
85
88
  },
86
- "maxDosePerLifetime": "up to a maximum of {{count}} {{unit}} for the lifetime of patient",
87
- "maxDosePerAdministration": "up to a maximum of {{count}} {{unit}} per dose",
89
+ "maxDosePerLifetime": "up to a maximum of {{quantityText}} for the lifetime of patient",
90
+ "maxDosePerAdministration": "up to a maximum of {{quantityText}} per dose",
88
91
  "maxDosePerPeriod": "up to a maximum of {{maxDosePerPeriodText}}"
89
92
  }
90
93
  }
@@ -28,12 +28,15 @@
28
28
  "denominator_other": ":{{count}}"
29
29
  }
30
30
  },
31
- "quantity": "{{quantity}} {{unit}}"
31
+ "quantity": {
32
+ "withUnit": "{{quantity}} {{unit}}",
33
+ "withoutUnit": "{{quantity}}"
34
+ }
32
35
  },
33
36
  "fields": {
34
- "doseQuantity": "{{quantity}} {{unit}}",
37
+ "doseQuantity": "{{quantityText}}",
35
38
  "doseRange": "{{rangeText}}",
36
- "rateQuantity": "au taux de {{quantity}} {{unit}}",
39
+ "rateQuantity": "au taux de {{quantityText}}",
37
40
  "rateRange": "au taux de {{rangeText}}",
38
41
  "rateRatio": "au taux de {{ratioText}}",
39
42
  "duration": "durant {{durationText}}",
@@ -83,8 +86,8 @@
83
86
  "event_one": "{{event}}",
84
87
  "event_other": "{{event}}"
85
88
  },
86
- "maxDosePerLifetime": "jusqu'à un maximum de {{count}} {{unit}} pour la durée de vie du patient",
87
- "maxDosePerAdministration": "jusqu'à un maximum de {{count}} {{unit}} par dose",
89
+ "maxDosePerLifetime": "jusqu'à un maximum de {{quantityText}} pour la durée de vie du patient",
90
+ "maxDosePerAdministration": "jusqu'à un maximum de {{quantityText}} par dose",
88
91
  "maxDosePerPeriod": "jusqu'à un maximum de {{maxDosePerPeriodText}}"
89
92
  }
90
93
  }
@@ -28,12 +28,15 @@
28
28
  "denominator_other": ":{{count}}"
29
29
  }
30
30
  },
31
- "quantity": "{{quantity}} {{unit}}"
31
+ "quantity": {
32
+ "withUnit": "{{quantity}} {{unit}}",
33
+ "withoutUnit": "{{quantity}}"
34
+ }
32
35
  },
33
36
  "fields": {
34
- "doseQuantity": "{{quantity}} {{unit}}",
37
+ "doseQuantity": "{{quantityText}}",
35
38
  "doseRange": "{{rangeText}}",
36
- "rateQuantity": "met een verhouding van {{quantity}} {{unit}}",
39
+ "rateQuantity": "met een verhouding van {{quantityText}}",
37
40
  "rateRange": "met een verhouding van {{rangeText}}",
38
41
  "rateRatio": "met een verhouding van {{ratioText}}",
39
42
  "duration": "gedurende {{durationText}}",
@@ -83,8 +86,8 @@
83
86
  "event_one": "{{event}}",
84
87
  "event_other": "{{event}}"
85
88
  },
86
- "maxDosePerLifetime": "tot een maximum van {{count}} {{unit}} gedurende de levensduur van de patiënt",
87
- "maxDosePerAdministration": "tot een maximum van {{count}} {{unit}} per dosis",
89
+ "maxDosePerLifetime": "tot een maximum van {{quantityText}} gedurende de levensduur van de patiënt",
90
+ "maxDosePerAdministration": "tot een maximum van {{quantityText}} per dosis",
88
91
  "maxDosePerPeriod": "tot een maximum van {{maxDosePerPeriodText}}"
89
92
  }
90
93
  }
package/dist/main.js CHANGED
@@ -180,6 +180,7 @@ class $868b4eaa4f62b9f7$export$f807d9a22ff8372d {
180
180
 
181
181
  // translators
182
182
  // To avoid circular dependancies issue, let's have a single place for exports and imports
183
+ // Functions
183
184
  // Types
184
185
  function $5461d5c8b4bc074f$export$76d408d587da5203(dos, key) {
185
186
  // If empty, return undefined
@@ -193,18 +194,39 @@ function $5461d5c8b4bc074f$export$76d408d587da5203(dos, key) {
193
194
  }
194
195
 
195
196
 
197
+ // Function
198
+ // Type
199
+ function $6ce94eb09701f53d$export$e9106be159f8c977({ quantity: quantity, config: config, i18next: i18next }) {
200
+ // extract function for the unit display from config
201
+ const { fromFHIRQuantityUnitToString: fromFHIRQuantityUnitToString, language: language } = config;
202
+ // Compute the result
203
+ let unit = fromFHIRQuantityUnitToString({
204
+ language: language,
205
+ quantity: quantity
206
+ });
207
+ let value = quantity.value || 1;
208
+ // If no unit is present (in other words ""), we don't put it
209
+ if (unit.length === 0) return i18next.t("amount.quantity.withoutUnit", {
210
+ quantity: value
211
+ });
212
+ else return i18next.t("amount.quantity.withUnit", {
213
+ quantity: value,
214
+ unit: unit
215
+ });
216
+ }
217
+
218
+
196
219
  function $5ab57a471c359130$export$7de3722258b87db9({ config: config, dos: dos, i18next: i18next }) {
197
220
  let doseQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "doseQuantity");
198
221
  // If not found, skip
199
222
  if (doseQuantity === undefined) return undefined;
200
- let quantity = doseQuantity.value || 1;
201
- let unit = config.fromFHIRQuantityUnitToString({
202
- language: config.language,
203
- quantity: doseQuantity
204
- });
223
+ // Otherwise rendering it
205
224
  return i18next.t("fields.doseQuantity", {
206
- quantity: quantity,
207
- unit: unit
225
+ quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
226
+ quantity: doseQuantity,
227
+ config: config,
228
+ i18next: i18next
229
+ })
208
230
  });
209
231
  }
210
232
 
@@ -278,21 +300,19 @@ function $9a073aa5b09aa778$export$4cd16590995531a9({ dos: dos, config: config, i
278
300
  }
279
301
 
280
302
 
303
+ // Functions
304
+
281
305
 
282
306
  function $052c79abb28cba29$export$4e24ef8c7997cc56({ dos: dos, config: config, i18next: i18next }) {
283
307
  let rateQuantity = (0, $5461d5c8b4bc074f$export$76d408d587da5203)(dos, "rateQuantity");
284
308
  // If not found, skip
285
309
  if (rateQuantity === undefined) return undefined;
286
- // information from rate
287
- let value = rateQuantity.value || 1;
288
- // quantity unit
289
- let unit = config.fromFHIRQuantityUnitToString({
290
- language: config.language,
291
- quantity: rateQuantity
292
- });
293
310
  return i18next.t("fields.rateQuantity", {
294
- quantity: value,
295
- unit: unit
311
+ quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
312
+ quantity: rateQuantity,
313
+ config: config,
314
+ i18next: i18next
315
+ })
296
316
  });
297
317
  }
298
318
 
@@ -338,8 +358,10 @@ function $7895e9944cc835ce$export$fdc6e9cbd31555fb({ ratio: ratio, config: confi
338
358
  // quantity
339
359
  let quantityNumerator = numerator?.value;
340
360
  let quantityDenominator = denominator?.value;
341
- // Collect
361
+ // Collect results
342
362
  const parts = [];
363
+ let noUnits = numeratorUnit === undefined && denominatorUnit === undefined;
364
+ let separator = noUnits ? "" : " ";
343
365
  // Deal with numerator first
344
366
  if (quantityNumerator !== undefined) {
345
367
  let technicalKey = numeratorUnit !== undefined ? "withUnit" : "withoutUnit";
@@ -360,7 +382,7 @@ function $7895e9944cc835ce$export$fdc6e9cbd31555fb({ ratio: ratio, config: confi
360
382
  }
361
383
  // Concatenate the result
362
384
  if (parts.length === 0) return undefined;
363
- else return parts.join(" ");
385
+ else return parts.join(separator);
364
386
  }
365
387
 
366
388
 
@@ -872,34 +894,34 @@ function $6c156f35df44ca41$export$21e3522d6e713036({ dos: dos, config: config, i
872
894
  }
873
895
 
874
896
 
875
- // types
897
+ // Functions
898
+
876
899
  function $e021f207f5cc63d0$export$6e78f21a88fc25ea({ dos: dos, config: config, i18next: i18next }) {
877
900
  // If empty, return undefined
878
901
  if (dos.maxDosePerLifetime === undefined) return undefined;
879
902
  const maxDosePerLifetime = dos.maxDosePerLifetime;
880
- let unit = config.fromFHIRQuantityUnitToString({
881
- language: config.language,
882
- quantity: maxDosePerLifetime
883
- });
884
903
  return i18next.t("fields.maxDosePerLifetime", {
885
- count: maxDosePerLifetime.value || 1,
886
- unit: unit
904
+ quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
905
+ quantity: maxDosePerLifetime,
906
+ config: config,
907
+ i18next: i18next
908
+ })
887
909
  });
888
910
  }
889
911
 
890
912
 
891
- // types
913
+ // Functions
914
+
892
915
  function $9ad44f2c84a9bdf4$export$58c8a9e040283a66({ dos: dos, config: config, i18next: i18next }) {
893
916
  // If empty, return undefined
894
917
  if (dos.maxDosePerAdministration === undefined) return undefined;
895
918
  const maxDosePerAdministration = dos.maxDosePerAdministration;
896
- let unit = config.fromFHIRQuantityUnitToString({
897
- language: config.language,
898
- quantity: maxDosePerAdministration
899
- });
900
919
  return i18next.t("fields.maxDosePerAdministration", {
901
- count: maxDosePerAdministration.value || 1,
902
- unit: unit
920
+ quantityText: (0, $6ce94eb09701f53d$export$e9106be159f8c977)({
921
+ quantity: maxDosePerAdministration,
922
+ config: config,
923
+ i18next: i18next
924
+ })
903
925
  });
904
926
  }
905
927