hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
1.94k stars 1.3k forks source link

UCUM temperature units conversion fails #6047

Open arminShv opened 2 days ago

arminShv commented 2 days ago

Hello,

The library hapi-fhir-validation-5.7.0.jar brings with it the library ucum-1.0.3.jar. UCUM-Lib has a problem converting the temperature units to canonical form (e.g. Celsius to Kelvin or Fahrenheit to Kelvin). I would like to know if you already have a solution for this.

To Reproduce Try to get a canonical value-code-pair for "20 Celsius" by UcumEssenceService.getCanonicalForm(valueCodePair)

UcumEssenceService ucumEssenceService = new UcumEssenceService(ClasspathUtil.loadResourceAsStream("/ucum-essence.xml"));
Pair canonicalFormPair = ucumEssenceService.getCanonicalForm(new Pair(new Decimal("20"), "Cel"));

The result is: image

Expected behavior If the conversion works correctly (e.g. for "20 kg"), the result will look like this: image

Environment OS: Windows 11