FHIR
FHIR copied to clipboard
Operation $stats on Observation
**Describe the solution
https://build.fhir.org/observation-operation-stats.html
The Statistics operation performs a set of statistical calculations on a set of clinical measurements such as a blood pressure as stored on the server. This operation evaluates Observation resources having valueQuantity elements that have UCUM unit codes
This operation seems to assume unit conversion that we don't implement at the moment (e.g. suppose you have body height measurements with some in SI and some in imperial units). We had plans to incorporate https://github.com/FHIR/Ucum-java for that at one point, but its never risen to the top.
Also we should be mindful of this caveat:
Observations with a status of 'entered-in-error' will be excluded from the calculations.
It would be interesting to see if we could implement it at the database level (e.g. off of the extract search parameters), although that could be tricky if we need to support all of the optional parameters.
I thought we had a backlog item for the unit conversion / "canonical unit" search, but I didn't see one and so I've now opened https://github.com/LinuxForHealth/FHIR/issues/3797 and I'm marking this one blocked by it.
some ideas:
- initially implement directly in the database. the tricky bit is filtering out the values from 'entered-in-error' and the like.
- if too expensive, consider building on our async indexing work and compute the stats as we go, but not wait for that in the main ingestion path
- other ideas...