Stream: implementers
Topic: How to dynamically specify client search criteria?
Volker Wick (Aug 20 2020 at 14:29):
I am implementing a FHIR server where I need to delegate a patient search query to another server backend. The server function that implements this search is called with three parameters family, given (both StringParam) and a birthday (DateParam)
My delegation code I have envisioned looks something like this ...
return fhirContext.newRestfulGenericClient(backendInstance)
.search()
.forResource(Patient.class)
.where(criteria) // ??? can't use .where(Patient.FAMILY.matches().value(family.getValue()))
.execute();
However, I am not sure about how to fill the criteria parameter. Depending on whether family, given and birthday are present, criteria should be set accordingly. (That's why I can't use Patient.FAMILY.matches() ... or other similar functions here)
I did not get very far with the implementation of where() that accepts an ICriterion<...> object and was considering the alternative where() that takes a Map<String, List<IQueryParameterType>>
Here is the code that sets up the criteria HashMap as I would guess how it might work. Unfortunately I am probably missing something as my code does not yield any results (unless my search criteria are all empty):
// family is a StringParam
Map<String, List<IQueryParameterType>> criteria = new HashMap<>();
if (family != null && !family.isEmpty()) {
criteria.put("family", Arrays.asList(family));
}
Can somebody point me in the right direction or post a documentation link that clears this up?
Thanks in advance,
Volker
Michele Mottini (Aug 20 2020 at 14:47):
Is this about HAPI? Or some other server? There is a #hapi stream
Volker Wick (Aug 21 2020 at 04:55):
Yes, it is about hapi. I was not aware of the hapi Stream and will move my question. Thanks
Last updated: Apr 12 2022 at 19:14 UTC