Stream: implementers
Topic: Multiple chained parameters
Gou Masuda (Mar 10 2021 at 10:08):
Hello,
I have a question about multiple chained parameters.
As for multiple chained parameters, the FHIR spec says "chained parameters are applied independently to the target resource."
My understanding is that the search result of the following query illustrated in the spec
GET Patient?general-practitioner.name=Joe&general-practitioner.address-state=MN
is a UNION of Patients satisfy each condition.
But I'm confusing because when I tried above query on the several public FHIR servers, all servers returned an intersection of all conditions.
Is my understanding correct?
Michele Mottini (Mar 10 2021 at 13:14):
Intersection is the expected behavior
Gino Canessa (Mar 10 2021 at 15:18):
Multiple conditions are joined via and
, so as Michele said, the expected result is the intersection. If you need the union, you can run multiple queries, or submit a single batch
(if the server supports it) to get all the results together.
Also note that the syntax supports multiple 'or' values in a single field (see Composite Search Parameters), so if you wanted the results for MN and WI, you can submit as general-practitioner.address-state=MN,WI
Paul Church (Mar 10 2021 at 16:55):
The phrase "chained parameters are applied independently to the target resource" is an important limitation that is often misunderstood.
It is only relevant when the reference field has more than one value. If a Patient has only one general-practitioner, then the example always works as expected.
The case that may be unexpected is where a Patient has two general-practitioners, where one matches name=Joe and the other matches address-state=MN. This will match the example search. There is no way to write a chained search that forces the same general-practitioner to match both, i.e. there is no syntax like Patient?general-practitioner.(name=Joe&address-state=MN)
Lloyd McKenzie (Mar 10 2021 at 17:21):
If you were to say GET Patient?general-practitioner.name=Joe&general-practioner.name=Smith
, the "applied independently" means that you would get back a Patient who had one general-practitioner with a name of Joe and another with a name of Smith - there's no implication that both Joe and Smith appear on the same Practitioner.
Gou Masuda (Mar 11 2021 at 00:32):
Thank you to everyone.
I recognized my understanding is incorrect.
Multiple conditions via '&' are joined, so intersection is expected.
"chained parameters are applied independently to the target resource" in the spec means one referenced resource doesn't need satisfy all conditions at the same time.
Thank you.
Yunwei Wang (Mar 11 2021 at 15:28):
I have seen questions about this GET Patient?general-practitioner.name=Joe&general-practitioner.address-state=MN
many times here. That means this query example and its explanation is confusing to regular reader.
Eric Prud'hommeaux (Mar 11 2021 at 15:49):
would this be an improvement?
Note that when search parameters apply to fields that can have more than one value, each chained parameters acts as an isolated filter. Because they share no context, there is no requirement that field value satisfying one search parameter be matched against the same field value satisfying another search parameter.
Eric Prud'hommeaux (Mar 11 2021 at 15:49):
... followed the the current example text:
For example,
GET Patient?general-practitioner.name=Joe&general-practitioner.address-state=MN
Paul Church (Mar 11 2021 at 15:51):
perhaps: "there is no requirement that the reference followed to satisfy one search parameter be the same reference followed to satisfy another search parameter"
Lloyd McKenzie (Mar 11 2021 at 15:53):
Feel free to submit a change request :)
Yunwei Wang (Mar 11 2021 at 18:35):
I would also add @Paul Church and @Lloyd McKenzie 's explanation above
Last updated: Apr 12 2022 at 19:14 UTC