Someone six weeks into FHIR built two views and joined them — Jun 23, 2023
Demo from someone six weeks into FHIR
Two ViewDefinitions over Synthea data — haemoglobin and haematocrit — materialised and joined on the subject. The same thing was then written by hand against Postgres and against DuckDB for comparison, and the verdict on hand-rolling nested JSON access was that it is a lot more nasty.
About a week of work end to end. As a usability datapoint that is worth more than most of the arguing.
getId needs a companion
References are polymorphic — a subject may be a Patient or a Group — so the bare ID isn't a safe join key, and without string functions in the view layer you can't filter on the type either.
Proposals:
getIdtaking an optional resource type- A separate function returning the reference's type
Someone suggested going further to an opaque join key you don't have to understand, on the grounds that joining is all you wanted from it anyway.
forEachOrNull — the outer-join keyword finally gets a name
Beat unroll, expand and explode on the grounds that a descriptive name tells you what it does. The group had already leant towards a separate keyword rather than a parameter, since parameters accumulate and make things harder to read.
The real point was agreeing on something tentatively — implementations were about to diverge, and any common name beats four different ones.
Do views proliferate, or are there stock ones?
Implementing a view definition is non-trivial work, and the hope is a common catalogue covering families of use cases rather than one view per question, with authoring separated from usage so most people only consume.
The comparison offered: something like an implementation guide, but far cheaper to produce — and possibly attached to one, so the views you'd typically want over an IG ship with it.
Unit conversion — three flavours, only one obvious
- UCUM-native conversions — a single multiplication from UCUM's own database, just arithmetic, easy enough to be worth doing
- Other scaling formulas — harder
- Conversions needing outside knowledge — moles to milligrams per litre for glucose, where you must know it is glucose and know its molar mass
The group wanted a worked glucose example before deciding whether any of it belongs in the view at all, rather than in the SQL above it. If it does, with an explicit formula rather than implicit magic.