Stream: implementers
Topic: Quantity.value precision
Anand Mohan Tumuluri (Jul 12 2016 at 17:36):
Are servers required to preserve insignificant decimal digits (e.g. 185.00 or 65.0) in Quantity.value while storing observations or medications? Or is it acceptable to ignore insignificant decimals and make them as 185 or 65?
The Quantity datatype has this statement but I am not able to clearly interpret it.
"The value contains the numerical value of the quantity, including an implicit precision"
Grahame Grieve (Jul 12 2016 at 19:33):
the FHIR specification never says that you must preserve precision. but your users will tell you that you must.
Grahame Grieve (Jul 12 2016 at 19:33):
note this comment:
Grahame Grieve (Jul 12 2016 at 19:34):
When using a JavaScript JSON.parse() implementation, note that JavaScript natively supports only one numeric datatype, which is a floating point number. This can cause loss of precision for FHIR numbers. In particular, trailing 0s after a decimal point will be lost e.g. 2.00 will be converted to 2. The FHIR decimal data type is defined such that precision, including trailing zeros, is preserved for presentation purposes, and this is widely regard as critical for correct presentation of clinical measurements. Implementations should consider using a custom parser and big number library (e.g. https://github.com/jtobey/javascript-bignum ) to meet these requirements.
Grahame Grieve (Jul 12 2016 at 19:34):
from http://hl7.org/fhir/json.html#primitive
Anand Mohan Tumuluri (Jul 12 2016 at 22:11):
I actually tested this against both yours (http://fhir3.healthintersections.com.au/open/Observation/1634dfbe-b003-473c-9bfa-e1e5978a4f, with 39.00 degrees celsius) as well as with HAPI (http://fhirtest.uhn.ca/baseDstu2/Observation/5234 with 29.00 resp/min). I observed that in both, the precision is not preserved.
James Agnew (Jul 12 2016 at 22:13):
The resource on the HAPI server seems to be preserving 29.00
to me. What are you expecting to be produced?
Anand Mohan Tumuluri (Jul 12 2016 at 22:15):
When I do a read at http://fhirtest.uhn.ca/baseDstu2/Observation/5234/_history/3, I get back 29 not 29.00
Anand Mohan Tumuluri (Jul 12 2016 at 22:16):
Sorry I meant JSON not XML
Anand Mohan Tumuluri (Jul 12 2016 at 22:17):
Sorry my mistake, please ignore
Anand Mohan Tumuluri (Jul 12 2016 at 22:17):
Thats because of whatever Grahame has pointed out, bug with Postman..
Anand Mohan Tumuluri (Jul 12 2016 at 22:18):
Even my server seems to return properly :-)
Last updated: Apr 12 2022 at 19:14 UTC