-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improving rendering of quantity objects
- Loading branch information
Showing
10 changed files
with
100 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Function | ||
|
||
// Type | ||
import type { QuantityParams } from "../types"; | ||
|
||
// To cover all nasty cases of Quantity, only once | ||
// https://build.fhir.org/datatypes.html#Quantity | ||
export function fromQuantityToString({ | ||
quantity, | ||
config, | ||
i18next, | ||
}: QuantityParams): string | undefined { | ||
// extract function for the unit display from config | ||
const { fromFHIRQuantityUnitToString, language } = config; | ||
|
||
// Compute the result | ||
let unit = fromFHIRQuantityUnitToString({ language, quantity }); | ||
|
||
// If no unit is present (in other words ""), we don't put it | ||
if (unit.length === 0) { | ||
return i18next.t("amount.quantity.withoutUnit", { | ||
quantity: quantity.value, | ||
}); | ||
} else { | ||
return i18next.t("amount.quantity.withUnit", { | ||
quantity: quantity.value, | ||
unit: unit, | ||
}); | ||
} | ||
} |