FHIR Chat · Possible to Include distant relations? · implementers

Stream: implementers

Topic: Possible to Include distant relations?


view this post on Zulip Jonas Toft (Jan 25 2021 at 14:35):

Is it possible to include entities that are not directly related to the current entity, but related through a related entity?

My scenario is I have a Task that is related to an Encounter and the Encounter has a few Observation relations. How can I, in one query, get the task including the Encounter and the Observations?

I have been looking at the _include query syntax and docs, but I am unsure if this is the right approach.

view this post on Zulip Michele Mottini (Jan 25 2021 at 14:39):

_include:iterate - if the server supports it

view this post on Zulip René Spronk (Jan 25 2021 at 14:39):

GET /Task?_include=Task.encounter&_revinclude:iterate=Observation.encounter - if you wish to define specific criteria on either Observation or Encounter it gets a bit more tricky, as -(rev)includes don't allow for the expression of any conditions.

view this post on Zulip Jonas Toft (Jan 25 2021 at 15:08):

Thanks for the swift reply. Yes, filtering on a criteria would actually be my next investigation to do. Imagine I wanted to only retrieve the Task entities (and relations) related to a specific Organization. Is something like the below even possible/intended use?

Task?_filter = Task:requester:Organization.identifier eq my_organization_id &_include=Task:encounter&_include=Task:requester:Organization

view this post on Zulip René Spronk (Jan 25 2021 at 15:24):

Support for _filter is pretty rare in servers (so I'm not very familiar with its syntax), and this can probably be supported by regular search in FHIR ..

view this post on Zulip Jonas Toft (Jan 25 2021 at 18:38):

As you can probably understand, FHIR is new to me. You refer to a regular search, but I dont know what that is. I did read through the docs at https://www.hl7.org/fhir/search.html, but did not find any evident answers. In essens I am trying to find out if it is possible to do several "joins" and combine that with filtering on any of the joined entities, and returning the entities from the joins. The SQL equivalent would be SELECT x.a,z.b,y.c FROM x JOIN y on x.id=y.id JOIN z on z.Id = x.Id where z.id="z_id"

view this post on Zulip Lloyd McKenzie (Jan 25 2021 at 18:57):

FHIR doesn't presume that the underlying data is relational. FHIR's RESTful search mechanism is focused on a single resource. Including additional resources is possible with _include or _revinclude. However, there's no ability to include anything that doesn't have a direct relationship. So if you want to include A and C where A points to B and B points to C, there's no choice but to get B back as well.

view this post on Zulip René Spronk (Jan 26 2021 at 09:28):

Basic search means: everything on http://build.fhir.org/search.html except for _filter and _query. Task?requester:Organization.identifier=XYZ&_include=Task.encounter&_include=Task.requester:Organization


Last updated: Apr 12 2022 at 19:14 UTC