FHIR Chat · HAPI Code for OR between search parameters · hapi

Stream: hapi

Topic: HAPI Code for OR between search parameters


view this post on Zulip Virendra Shinde (Aug 01 2020 at 06:26):

#hapi

We are presently using HAPI FHIR 5.0 (Labrador) release for our Implementation.

Presently I have HAPI code for below AND Query which is working fine.
http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir/Organization?name=SIMPLY&address=SIMPLY
Bundle bundle = client.search().forResource(Organization.class).where(Organization.ADDRESS.contains().value("SIMPLY")).where(Organization.NAME.contains().value("SIMPLY")).returnBundle(Bundle.class).execute();

Can anyone help us with the OR Query code between the search parameters ?
http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir/Organization?name=SIMPLY,address=SIMPLY

view this post on Zulip René Spronk (Aug 01 2020 at 14:00):

That would be your own custom syntax, this is not a syntax allowed by FHIR. You can't OR between parameters (using this URL based syntax). You'll have to define a custom operation or named _query.

view this post on Zulip Jens Villadsen (Aug 01 2020 at 14:01):

You can use filter

view this post on Zulip Jens Villadsen (Aug 01 2020 at 14:04):

https://www.hl7.org/fhir/search_filter.html

view this post on Zulip René Spronk (Aug 01 2020 at 14:09):

True - my point was that the URL based syntax doesn't support OR in the way which was suggested. filter is not supported by all FHIR servers, but apparently it is supported by HAPI (I've never played with the filter syntax myself).

view this post on Zulip Jens Villadsen (Aug 01 2020 at 14:11):

(for the record we use it heavily as part of search narrowing and security)

view this post on Zulip David Hay (Aug 01 2020 at 19:29):

Or graphQL

view this post on Zulip Virendra Shinde (Aug 03 2020 at 20:42):

@Jens Villadsen Can you please share an example of HAPI code of using _filter ?

view this post on Zulip Virendra Shinde (Aug 03 2020 at 20:58):

For example the http://127.0.0.1:8080/hapi-fhir-jpaserver/fhir/Organization?_filter=name co "SIMPLY " or address co "SIMPLY"

view this post on Zulip Jens Villadsen (Aug 03 2020 at 21:30):

take a look at eg. https://hapifhir.io/hapi-fhir/docs/client/generic_client.html#search-by-plain-url if you want HAPI Client example code


Last updated: Apr 12 2022 at 19:14 UTC