Converts laboratory values between conventional and SI units, and temperature, weight and length between systems.
5.55 mmol/L
Installation
bunx shadcn@4.22.1 add https://organui.com/r/clinical-units.jsonThis adds lib/clinical-units.ts, with no dependencies.
Usage
import {
celsiusToFahrenheit,
convertAnalyte,
roundTo,
} from "@/lib/clinical-units"
roundTo(convertAnalyte("glucose", 100, "conventional", "si"), 1) // 5.6 mmol/L
roundTo(convertAnalyte("creatinine", 88, "si", "conventional"), 2) // 1 mg/dL
roundTo(celsiusToFahrenheit(38.5), 1) // 101.3API Reference
| Export | Description |
|---|---|
convertAnalyte(analyte, value, from, to) | Converts between "conventional" and "si" units for glucose, cholesterol, triglycerides, creatinine, urea nitrogen, calcium, magnesium, phosphate, bilirubin, uric acid, hemoglobin and 25-hydroxyvitamin D. |
analyteUnit(analyte, system) | The unit for a system, such as "mmol/L". |
analytes | Each analyte's name, units and the SI value of one conventional unit. Add your own in the same shape. |
celsiusToFahrenheit, fahrenheitToCelsius | Temperature. |
kilogramsToPounds, poundsToKilograms | Weight. |
centimetresToInches, inchesToCentimetres | Length. |
roundTo(value, decimals) | Rounds for display; convert first, round last. |
Notes
Factors follow the AMA Manual of Style's SI conversion table. Laboratories can differ, for example in reporting urea rather than urea nitrogen, so check each factor against yours before clinical use.