FHIR and UCUM Integration: Introducing a Rust Library for Unit Conversion
octofhir-ucum-fhir — Rust library // Lib.rs
Summary
This article introduces a Rust crate that integrates the UCUM core library with FHIR, enabling unit conversion and equivalence checking between different units. The developer demonstrated how this tool can be used to validate and utilize `Quantity` type values found in FHIR Observation data across various units.
Details
This library provides functionality bridging the concept of UCUM (Unified Code for Units of Measure) with the FHIR `Quantity` data type. Specifically, it allows conversion from a FHIR Quantity to a UCUM Quantity and vice versa. It also includes features to check if two FHIR Quantities, even those with different units, are mathematically equivalent. As an example, the process is shown for extracting weight measurements (in `valueQuantity`) from an Observation resource containing LOINC codes, and subsequently converting that value into another unit like pounds. Furthermore, it supports handling arbitrary units, such as International Units ([IU]) or custom units ([arb'U]), adhering to UCUM specifications. This includes checking equivalence and performing complex calculations involving these units. This capability is crucial for enhancing standardization and interoperability of measurement values in healthcare data, providing a technical foundation that ensures accurate comparison and analysis when measurement units are mixed across different systems.
Original content copyright by respective publishers