Rasoul
Rasoul

Reputation: 187

How to use fhir client search to include all resources i.e. ($everything)

How would you search for all resources for a given patient e.g. encounter, appointment, consent?

I know you could search for it via postman request http://localhost:9090/organId/Patient/12345/$everything and get the result. But I want to be able to execute the search query from my java program.

This is what I have so far, but I know the include part is not good and not working. Googling didn't return any result.

Bundle bundle = myFhirClient
                .search()
                .forResource(Patient.class)
                .returnBundle(Bundle.class)
                .where(new NumberClientParam(Patient.SP_RES_ID).exactly().number(patientId)).include(new Include("$everything"))
                .sort(new SortSpec().setOrder(SortOrderEnum.DESC).setParamName(Patient.SP_RES_ID))
                .execute();

Any help is much appreciated

Upvotes: 1

Views: 1298

Answers (2)

Nagarjuna Sanivarapu
Nagarjuna Sanivarapu

Reputation: 11

You could try this as well.

    String url = baseUrl+"Patient/{id}/$everything"
    
    Bundle bundle = fhirClient.search().byUrl(url).returnBundle(Bundle.class).execute();

Upvotes: 1

Rasoul
Rasoul

Reputation: 187

I had to use Fhir Client operation instead of search. This will return all the reference resources for the given patientId.

Parameters outParams = myFhirClient
                    .operation()
                    .onInstance(new IdType("Patient", patientId))
                    .named("$everything")
                    .withNoParameters(Parameters.class) // No input parameters
                    .execute();

Upvotes: 1

Related Questions