FHIR Chat · Search with multi-resource conditions · implementers

Stream: implementers

Topic: Search with multi-resource conditions


view this post on Zulip Lucile (May 20 2020 at 15:09):

Hello everyone,

I have a question about a search query on a FHIR API, in particular to include mother/daughter resources to the answer (using _include, _revinclude and _iterate parameters, here in FHIR doc) and to specify chained parameters (here and here).

Here is what I want to query to the API :
I wish to return Condition, AllergyIntolerance, Patient and Practitioner resources that meet all of the following conditions:

  • patients were born in 1970 (associated search parameter of the resource Patient : birthdate=1970)
  • they’ve been diagnosed allergic to Cashew nuts (associated search parameter of the resource AllergyIntolerance: code=http://snomed.info/sct|227493005)
  • the source of the information about the allergy is a practitioner who lives in France (associated search parameter of the resource Practitioner: address-state=france)
  • patients have had fever (associated search parameter of the resource Condition: code=http://snomed.info/sct|386661006)

A priori, I thought I could do a search that might look like:

/AllergyIntolerance?
code=http://snomed.info/sct|227493005&
patient:Patient.birthdate=1970&
patient:Patient:_has:Condition:code=http://snomed.info/sct|386661006&
asserter:Practitioner.address-state=france&
_include=AllergyIntolerance:patient&
_revinclude:iterate=Condition:subject&
_include=AllergyIntolerance:asserter

But I have serious doubts about the legality of the parameters:
patient:_has:Condition:subject:code=http://snomed.info/sct|386661006& and _revinclude:iterate=Condition:subject

In summary, the difficulty I have comes from the fact that I want to link resources together (Allergy And Condition) that refer to Patient, but that are not linked by a reference to each other.

This is my first question on this forum. Feel free to tell me if it's better that I ask my question on another stream.

Thank you in advance for your time!

diagram of the situation

view this post on Zulip Lloyd McKenzie (May 20 2020 at 15:19):

For chaining, the syntax would just be patient.birthdate=1970. I don't know that we support chaining to _has though. @Grahame Grieve @James Agnew
(this is the right place - and congrats on raising an evil first question :>)

view this post on Zulip Lucile (May 20 2020 at 15:22):

Thank you so much for getting back to me so quickly!

view this post on Zulip Scott Rossignol (May 20 2020 at 15:28):

I don't want to make assumptions about your use-case here, but most EHRs I've worked with don't support the parameters you're attempting to use. A simpler method to perform this lookup would be to pull the relevant resources via unique API calls then utilizing server-side logic to achieve your purpose with the retrieved data.

view this post on Zulip Lucile (May 20 2020 at 15:39):

It helps me a lot to know that most EHRs don't support the parameters I'm attempting to use.
I'm going to do as you suggested!

view this post on Zulip James Agnew (May 20 2020 at 17:48):

Wow. A chained _has. I have never even considered this. :)

Technically the correct syntax for that would be:

patient:Patient._has:Condition:subject:code=http://snomed.info/sct|386661006

..or just..

patient._has:Condition:subject:code=http://snomed.info/sct|386661006

I had my doubts this would work, but looks like HAPI is ok with it:

http://hapi.fhir.org/baseR4/AllergyIntolerance?patient._has:Condition:subject:code=http://snomed.info/sct|386661006

view this post on Zulip Alexander Zautke (May 20 2020 at 17:53):

Works also fine with Vonk. Not totally uncommon, I think it came up in a few threads here.

view this post on Zulip Lucile (May 20 2020 at 18:02):

I'm so glad it's working! Thank you so much for your help.

view this post on Zulip Vassil Peytchev (May 20 2020 at 18:42):

Another small correction - you probably want address_country to be France, not address-state. I suspect many French people would be dismayed that their country has become an Australian state (for example). :grinning:

view this post on Zulip Lucile (May 22 2020 at 08:00):

Thank you very much! Indeed I would have been surprised


Last updated: Apr 12 2022 at 19:14 UTC