FHIR Chat · Fetching Bundles · hapi

Stream: hapi

Topic: Fetching Bundles


view this post on Zulip Sebastian Mate (Nov 14 2019 at 14:58):

Hi all!

I'm looking for a way to basically fetch all data from an HAPI FHIR server. This is what I've tried, but it does not work:

Bundle bundle = client.search().forAllResources().returnBundle(Bundle.class).execute();

It tells me: "HTTP 400 Bad Request: This is the base URL of FHIR server. Unable to handle this request, as it does not contain a resource type or operation name." The server base is currently set to "http://localhost:8082/fhir".

This, however, works:

Bundle bundle = client.search().forResource(Observation.class).returnBundle(Bundle.class).execute();

Is there any way of getting the first example to work?

Thanks, Sebastian

view this post on Zulip Grahame Grieve (Nov 14 2019 at 19:08):

it's not in the spec. you can do it by patient, but not by server

view this post on Zulip Patrick Werner (Nov 15 2019 at 09:33):

hapi now supports bulk export: https://hl7.org/Fhir/uv/bulkdata/export/index.html
@Sebastian Mate

view this post on Zulip Sebastian Mate (Nov 15 2019 at 12:02):

Great! Thanks for the info, @Grahame Grieve and @Patrick Werner !

view this post on Zulip Sebastian Mate (Dec 06 2019 at 15:42):

OK, now I ran into an new problem. I'm trying to fetch fetch the resources of specified type (e.g., Observation.class) for a given patient. How can I do this via the api?

view this post on Zulip Sebastian Mate (Dec 06 2019 at 15:43):

This does not work:
Bundle bundle = (Bundle) client.search().forResource(Observation.class).where(Patient.IDENTIFIER.equals("10")).returnBundle(Bundle.class).execute();

view this post on Zulip Sebastian Mate (Dec 06 2019 at 15:43):

It tells me: The method where(ICriterion<?>) in the type IQuery<IBaseBundle> is not applicable for the arguments (boolean)

view this post on Zulip Sebastian Mate (Dec 06 2019 at 15:43):

Any help is highly appreciated! ;-)

view this post on Zulip Patrick Werner (Dec 06 2019 at 19:03):

you have to return an Icriterion in your where

view this post on Zulip Patrick Werner (Dec 06 2019 at 19:03):

like this

view this post on Zulip Patrick Werner (Dec 06 2019 at 19:03):

where(Patient.IDENTIFIER.exactly().systemAndIdentifier("system", "00001"))

view this post on Zulip Sebastian Mate (Dec 09 2019 at 08:59):

Patrick, got working thanks to your help. The correct syntax (in my case) was:
bundle = (Bundle) client.search().forResource(Observation.class).where(Observation.PATIENT.hasId(patientFHIR)).returnBundle(Bundle.class).execute();
where patientFHIR is a String that contains the patient ID.


Last updated: Apr 12 2022 at 19:14 UTC