Written and maintained by CASRAI Editorial Board
Published
On this page
The Unified Code for Units of Measure (UCUM) is a formal, unambiguous coding system for physical, chemical, and clinical units of measure developed by Gunther Schadow and Clement J. McDonald at the Regenstrief Institute (also the steward of LOINC). Unlike enumerated unit dictionaries that assign arbitrary numeric IDs to a fixed list of display strings, UCUM defines a generative context-free grammar built from seven fundamental metric base units and standardized prefixes, allowing software parsers to perform automated dimensional analysis and exact algebraic unit conversion across electronic health records (EHRs), laboratory information systems, and clinical trial repositories.
What Is UCUM and Why Does HL7 FHIR Mandate UCUM in Quantity.code?
In clinical messaging, human-readable unit strings vary wildly across hospitals—for example, white blood cell counts may arrive as K/uL, 10^3/mcL, x10E3/uL, or thou/mm3. To eliminate unit ambiguity in quantitative clinical observations, HL7 FHIR R4 separates human display text from machine-computable units inside the Quantity data type (used in Observation.valueQuantity, Observation.referenceRange, and medication dosing):
Quantity.value(decimal): The numerical magnitude (e.g.,4.8).Quantity.unit(string): The human-readable display string shown on a clinician’s screen (e.g.,10*3/uLorthousand/mcL).Quantity.system(uri): Set to the canonical URIhttp://unitsofmeasure.org.Quantity.code(code): The machine-computable unit code. In FHIR R4, the formal invariantqty-3mandates that whenever a coded unit is required orsystemishttp://unitsofmeasure.org,Quantity.codeshall be a valid case-sensitive UCUM code.
Beyond HL7 FHIR, UCUM is mandated or recommended across HL7 v2 (`OBX-6`), HL7 C-CDA (`pq` physical quantity elements), DICOM Structured Reporting (`NUM` Measurement Units Code Sequence), and ISO 11240 (Health informatics — Identification of medicinal products / IDMP units of measurement).
Why Are UCUM Expressions Case-Sensitive and Algebraically Computable?
Every valid UCUM expression can be reduced algebraically to a scalar magnitude factor multiplied by a vector of exponents over seven base dimensions: length (meter, m), time (second, s), mass (gram, g), plane angle (radian, rad), temperature (kelvin, K), electric charge (coulomb, C), and luminous intensity (candela, cd). Although the specification defines a legacy case-insensitive (`c/i`) representation for systems restricted to uppercase ASCII, standard clinical informatics pipelines use the case-sensitive (`c/s`) representation because capitalization changes metric prefixes by nine orders of magnitude (for example, m = milli = 10−3, whereas M = mega = 106; s = second, whereas S = siemens).
Common Clinical Laboratory Units in UCUM Syntax
| Clinical Measurement Example | Common Local EHR Strings (Invalid UCUM) | Valid Case-Sensitive UCUM Code | Syntactic Construction Rule |
|---|---|---|---|
| Mass concentration (e.g., Glucose, Creatinine) | mg/dl, MG/DL, mcg/mL |
mg/dL or mg/dl, ug/mL |
Uses ASCII u for micro (μ); liter may be L or l. |
| Substance concentration (e.g., Sodium, Potassium, HbA1c IFCC) | mEq/L, mmol/l, mmol/mol Hb |
meq/L, mmol/L, mmol/mol |
Equivalents use lowercase eq (meq/L); substance ratios stay pure units. |
| Leukocyte / Platelet count | K/uL, 10^3/uL, x10E9/L |
10*3/uL, 10*9/L |
Powers of ten use 10*n or 10*^n; integer exponents follow directly without ^ (e.g., m2, mm3). |
| Body Mass Index (BMI) | kg/m^2, kg/m² |
kg/m2 or kg.m-2 |
Period (.) denotes multiplication; negative integer -2 denotes inverse square. |
| eGFR (BSA-indexed filtration rate) | mL/min/1.73m2 |
mL/min/{1.73_m2} |
Encloses the normalization reference surface area inside curly braces. |
| International Units & Enzyme Activity | IU/L, mIU/mL, U/L |
[iU]/L, m[iU]/mL, U/L |
Square brackets [...] denote arbitrary or non-metric units (such as [iU], [in_i], [lb_av], [pH]). |
How Do UCUM Curly-Brace Annotations Work and What Causes Unit-Conversion Errors?
A frequent source of confusion in clinical data warehouses is the role of curly braces ({...}) vs. square brackets ([...]) in UCUM:
- Square brackets (
[...]) are an integral part of a unit’s formal symbol—distinguishing non-SI or arbitrary biological units from metric base units (for example,[iU]for international unit,[Hg]inmm[Hg]for millimeters of mercury, or[USP'U]for USP units). Stripping square brackets alters or invalidates the unit. - Curly braces (
{...}) contain annotations—human-readable qualifying strings attached to dimensionless counts or ratios (such as{cells}/uL,{copies}/mL,{rbc}/[HPF], or{INR}). In the formal UCUM algebra, every curly-brace expression evaluates numerically to the dimensionless scalar1(unity).
Because curly braces evaluate to 1, a UCUM conversion engine treats 10*3.{cells}/uL and 10*3.{platelets}/uL as algebraically commensurate with 10*3/uL. Consequently, both Regenstrief LOINC guidelines and HL7 FHIR best practices warn against placing essential clinical semantics—such as what substance was measured (`{creat}` or `{Hb}`)—solely inside a UCUM curly-brace annotation; the analyte identity belongs in the LOINC code (`Observation.code`), while the UCUM code expresses the pure unit of measure.
Dimensional Analysis vs. Molar-to-Mass Conversions in ETL Pipelines
When harmonizing laboratory measurements into research repositories such as the OMOP Common Data Model or N3C, a standard UCUM library (such as the NLM `ucum-lhc` JavaScript/Java library) can convert directly between any two commensurate units (for example, ug/mL to mg/L, or 10*3/uL to 10*9/L) because their base dimensional vectors are identical. However, converting between a mass concentration (mg/dL) and a molar substance concentration (mmol/L)—such as converting serum glucose (`mg/dL` to `mmol/L`) or creatinine (`mg/dL` to `umol/L`)—cannot be performed by a pure UCUM parser alone because the dimensions (`g` vs. `mol`) differ; the ETL pipeline must supply the analyte-specific molecular weight tied to the LOINC code.
Frequently Asked Questions
How do you represent a dimensionless score, ratio, or percentage in UCUM and FHIR?
For percentages, the valid UCUM symbol is % (which evaluates to 10*-2). For pure dimensionless numbers—such as a Glasgow Coma Scale total score, pH, or International Normalized Ratio (INR)—the canonical UCUM code for unity is 1 (or an annotated unity string such as {score} or {INR}, or [pH] for pH).
Why is “mcg” invalid in case-sensitive UCUM and what should be used instead?
While hospital medication safety guidelines (ISMP) encourage writing mcg in human-facing text (`Quantity.unit`) to prevent clinicians from misreading a handwritten μg as mg, in formal UCUM syntax `mc` is not a valid prefix. In `Quantity.code`, micrograms must always be encoded as ug (while `Quantity.unit` can still display `mcg` to the user).
How does the NLM UCUM API validate and convert units?
The National Library of Medicine (NLM) provides both the open-source `ucum-lhc` software library and a RESTful web service (`https://ucum.nlm.nih.gov/ucum-service/v1`) that validates whether strings conform to the UCUM grammar (`toBaseUnits`), explains unit components, and computes exact conversion factors between commensurate source and target UCUM strings.







