-
-
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.
Merge pull request #38 from jy95/quantityImprovements
feat: improving rendering of quantity objects
- Loading branch information
Showing
11 changed files
with
102 additions
and
53 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
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,31 @@ | ||
// 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 }); | ||
let value = quantity.value || 1; | ||
|
||
// If no unit is present (in other words ""), we don't put it | ||
if (unit.length === 0) { | ||
return i18next.t("amount.quantity.withoutUnit", { | ||
quantity: value, | ||
}); | ||
} else { | ||
return i18next.t("amount.quantity.withUnit", { | ||
quantity: value, | ||
unit: unit, | ||
}); | ||
} | ||
} |