| CI Status (master) | Current Release | Latest SNAPSHOT |
|---|---|---|
FHIR Java library providing UCUM Services
The library provides a set of services around UCUM:
- validate a UCUM unit (and also against a particular base unit)
- decide whether one unit can be converted/compared to another
- translate a quantity from one unit to another
- prepare a human-readable display of a unit
- multiply 2 quantities together
To use the library, download ucum-essence from http://unitsofmeasure.org, and then create a UCUMEssenceService:
UcumService ucumSvc = new UcumEssenceService(definitionFile);The services are commonly used to process units and values supplied by external parties (e.g. FHIR Quantity),
so the library limits the work that any single input can cause. The limits are well beyond anything
used in practice.
Unit expressions (enforced by the parser, so units beyond these limits are reported as invalid by validate() and
rejected by all the other services):
| Limit | Value | Constant |
|---|---|---|
Exponent of any single unit (e.g. m3, 10*-24) |
+/-30 | ExpressionParser.MAX_EXPONENT |
| Sum of the absolute values of all exponents | 60 | ExpressionParser.MAX_TOTAL_EXPONENT |
| Number of units and numbers in the expression | 20 | ExpressionParser.MAX_COMPONENTS |
| Depth of nested brackets | 10 | ExpressionParser.MAX_NESTING |
| Number of terms (including annotations) | 50 | ExpressionParser.MAX_TERMS |
Note that UCUM itself does not limit these, so a few units that are legal UCUM (e.g. m31) are rejected.
Numbers (Decimal):
- Scientific notation must have an exponent within +/-1000 (
Decimal.MAX_EXPONENT) - Multiplication rounds its operands and result to at most 40 significant digits, and division rounds its operands
to 40 significant digits and calculates at most 40 digits beyond them. Applications that need different limits
can change them (application wide) using
Decimal.setMultiplyPrecisionLimit()andDecimal.setDividePrecisionLimit()
Other:
search(kind, text, true)evaluatestextas a regular expression, and throwsIllegalArgumentExceptionif it is not valid, or if the search takes longer than 500ms (protection against regular expressions that backtrack catastrophically)- Error messages truncate the caller supplied values they include to 100 characters