FHIR Chat · Realizing reversed chaining with several And-conditions · implementers

Stream: implementers

Topic: Realizing reversed chaining with several And-conditions


view this post on Zulip Sebastian Lanz (Oct 19 2020 at 06:20):

Good Morning from Germany,
I got familiar with fhir for a student thesis. Its goal is to "translate" data - generated from a medical data generator - from an existing medical data warehouse (dw) into a local fhir server instance as well as "translating" the dw's query language. While I did the former using a HAPI JPA Server, I checked the RESTful Search options to realize the latter. The original dw's query language main task ist to search for patients according to the onset of a <Condition, Observation, Procedure etc.>.
If I understood correctly from the fhir search docu, this could be achieved with reverse chaining, as given in the docu:
GET [base]/Patient?_has:Observation:patient:code=8302-2 (for loinc body height)
This is fine for all Ressources for which I only want to check the onset. For Observation unfortunately, I would also like to check for the respective value (e.g. height in cm). How could a query of this type be realized?
I would have thought that this is fine:
Patient?_has:Observation:patient:code=8302-2&_has:Observation:patient:value-quantity=180.0|http://unitsofmeasure.org|cm
but in the docu it states that "_has parameter is processed independently of other _has parameters", so it can't be the solution.
I am probably missing something since this simple functionality is surely not too hard to set up.
Any help would be greatly appreciated!
Kind regards,
Sebastian
(hoping to post this in the right forum -> feel free to refer me to a different one if appropriate!)

view this post on Zulip Lloyd McKenzie (Oct 19 2020 at 14:43):

You can use the code-value-quantity composite search parameter on Observation, but there's no way to combine reverse-chained parameters to work except independently. You'd have to look at _filter

view this post on Zulip Sebastian Lanz (Oct 20 2020 at 08:29):

Yes, it seems _filter is the right solution.
Thank you a lot for your quick reply and have a good day!

view this post on Zulip Sebastian Lanz (Oct 23 2020 at 13:08):

Hello @Lloyd McKenzie ,

About the _filter (the docu afaik is not very specific about it's actual capabilities).

Let's say I want to get all Patients with:

  • either: a Condition of code A and of code B
  • or: an Observation of code C and value = 1

Knowing that the request "/Patient?_has:Condition:patient:code=A" gets me all Patients with Condition of code A.
Does the use of the _has parameter in a _filter query as used below get me the requested Patients? If not, how is it done?
/Patient?_filter=(_has:Condition:patient:code=A and _has:Condition:patient:code=B) or ( _has:Observation:patient:code=C and _has:Observation:patient:code=1)

Cheers,
Sebastian

view this post on Zulip Lloyd McKenzie (Oct 23 2020 at 18:23):

The first bit would be fine - because the conditions you're trying to match would be independent However, for the second, you'd want the same observation - you don't want a match where one Observation has code C and a different Observation has value 1. Your choices there are either to use the code-value-quantity search criteria to match on both at once, or to say _has:Condition:patient[code=C and value=1]

@Grahame Grieve, I'm not totally clear whether the latter is legal?

view this post on Zulip Sebastian Lanz (Oct 30 2020 at 09:32):

Hey @Lloyd McKenzie ,
i'm not actually sure if the first bit would be considered independent, since I do want all patients with Condition A and(!) B both, not just Patients with A or Patients with B.
From testing on the test.fhir.org/r4 server I got the impression that even "and"-ing the _has-parameters in the _filter option just logically Or-s the search criteria -> e.g. in the above example I would just get patients with Contition A or B.
Maybe there exists a server that supports the functionality i am describing.
It does definitely not seem to keen of a requirement to me, at least I would (as a practitioner or else) expect from a Fhir server to be able to process above request (get all patients with condition A and B) - or am I missing something completely?
A comment from @Grahame Grieve maybe would clear this point (mentioned server does seem to be related to him).
Cheers and thanks in advance,
Sebastian

view this post on Zulip Lloyd McKenzie (Oct 30 2020 at 16:25):

When you use _filter, you can specify filters at different levels, and you can use ands and ors and brackets within those levels. _filter itself is not widely implemented, unfortunately.

view this post on Zulip Grahame Grieve (Nov 02 2020 at 20:42):

I think my server fully implements _filter and I think that you should be able to do what you need. what specific searches are you doing?


Last updated: Apr 12 2022 at 19:14 UTC