Stream: implementers
Topic: Search to exclude multiple tokens
Erik Greif (Jun 02 2020 at 19:14):
Using a composite token search ?code=one,two,three I can easily find all records that have one or more of these codes. But I noticed the composite search specification states "Modifiers are not used on composite parameters." I think this means I can't do ?code:not=one&code:not=two to return the intersection of results without the code one and without the code two. Is that correct? If so, how are requirements like this handled?
Michele Mottini (Jun 02 2020 at 19:19):
That's a normal token search with multiple value, you can use :not
(provided that the server(s) you are interested in support it)
Erik Greif (Jun 02 2020 at 19:23):
I suppose maybe I'm confused by the naming of the section of the spec that defines this: https://hl7.org/fhir/search.html#combining
So using multiple params with & is not actually considered composite? But , is? So I still couldn't, for example, say ?code:not=one,two in this case?
Michele Mottini (Jun 02 2020 at 19:36):
&
and ?
are just the standard url parameters separator - nothing specific to FHIR
Michele Mottini (Jun 02 2020 at 19:37):
Composite search parameters are when you want to match two different things within the same element, and that uses $
Erik Greif (Jun 02 2020 at 19:44):
Yeah for sure with &, but the comma/OR syntax didn't seem to be defined anywhere else on the search page, so I assumed all of this was all considered part of "composite." Thank you for clarifying that only $ is, I'll bring this info back to my team.
Erik Greif (Jun 02 2020 at 19:49):
On this topic, do you know of a spec page/section that defines how modifiers work with OR queries? I assume something like ?code:not=one,two (example) means (NOT one) OR (NOT two), to be completely consistent with how AND works. If it's actually NOT(one OR two) (which is actually same as ?code:not=one&code:not=two) then I need to go back to the drawing board with a few things
Michele Mottini (Jun 02 2020 at 20:50):
http://hl7.org/fhir/search.html#token defines :not
as 'return all resources that do not have a matching item'. Socode:not=one, two
is 'NOT ( one OR two)'
Last updated: Apr 12 2022 at 19:14 UTC