hl7-fhir

FHIR: get all active Encounter resources for any Location that is recursively "part-of" a given Location to any depth


I'd like to find a list of Encounters at, say, a given hospital, but where the Encounter's "location" reference may point to just a ward Location within that hospital, or even a just a bed on a ward in that hospital.

In either case, one could "_revinclude" the hospital using:

Encounter?_include=Encounter:location&_revinclude:iterate=Location:partof

Similarly, one could retrieve Encounter resources at a known depth using:

Encounter?location.partof=Location/{{hospital id}}

But how would I go about filtering this, within the same query, such that the only Encounters returned are those at locations that are, to any depth, "partof" a hospital with a known "id"?

The Encounter needs to be the focal resource, because it is being filtered by other properties too.


Solution

  • If the server you are hitting supports it, you can use the below modifier to get all locations that are part of another one (see Searching Hierarchies). In that case, your search would look something like:

    Encounter?location:below=Location/{hospital location id}&_include=Encounter:location

    If the server does not support that modifier, I am not sure you will be able to get everything in a single query.