Search code examples
hl7-fhirsmart-on-fhir

fhir search not equal to any of the values


I'm having trouble constructing search query where I need to retrieve FHIR Patient Resources that do not contain any of the tags in an array.

To retrieve FHIR Patient resources that contain a specific tag value, we can construct query like GET [base]Patient?_tag=abcd.

To retrieve FHIR Patient resources that container either abcd or efgh as the tag, we can query GET [base]Patient?_tag=abcd,efgh.

To retrieve Patient resources that do not contain tag abcd, we can use GET [base]Patient?_tag:not=abcd

But to retrieve Patient resources that do not contain either abcd or efgh, what should be the search expression? The query GET [base]Patient?_tag:not=abcd,efgh does not work as explained here.

I have tried to use the _filter option as suggested in the document but it doesn't seem to work. I tried GET [base]Patient?_filter=meta.tag+ne+abcd but it returned results that contain the specific tag.

How can this query be constructed?


Solution

  • It will depend on the server implementation whether GET [base]Patient?_tag:not=abcd,efgh works or not. The documentation just details that it might not work as expected.

    If your server does not implement the 'or' search in the way you want, you could try and see what the result is when you 'and' multiple _tag filters: GET [base]Patient?_tag:not=abcd&_tag:not=efgh