ucum

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package ucum provides UCUM (Unified Code for Units of Measure) normalization for FHIR quantity search parameters.

UCUM is the standard unit system used in FHIR for quantities. This package normalizes units to canonical base units to enable cross-unit search (e.g., 10mg = 0.01g).

Reference: https://ucum.org/ucum.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCanonicalUnit

func GetCanonicalUnit(code string) string

GetCanonicalUnit returns the canonical unit for a given code. Returns the original code if not found.

func IsKnownUnit

func IsKnownUnit(code string) bool

IsKnownUnit returns true if the unit code is recognized for normalization.

Types

type NormalizedQuantity

type NormalizedQuantity struct {
	Value float64 // Normalized value in canonical units
	Code  string  // Canonical unit code
}

NormalizedQuantity represents a quantity normalized to canonical UCUM units.

func Normalize

func Normalize(value float64, code string) NormalizedQuantity

Normalize converts a quantity to its canonical UCUM form. Returns the original values if the unit is not recognized.

func NormalizeWithSystem

func NormalizeWithSystem(value float64, system, code string) NormalizedQuantity

NormalizeWithSystem converts a quantity considering both system and code. For UCUM system (http://unitsofmeasure.org), it applies normalization. For other systems, it returns values unchanged.

type UnitConversion

type UnitConversion struct {
	CanonicalCode string  // The canonical unit code (e.g., "g" for mass)
	Factor        float64 // Multiply original value by this to get canonical
}

UnitConversion defines a conversion from a unit to its canonical form.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL