0

I'm itarating over all enteties of a ressource type like so.

    while (query.getLink(IBaseBundle.LINK_NEXT) != null) {
      query.getLink("next").setUrl(FhirUtils.replaceBaseUrl(query.getLink("next").getUrl, fhirClient.getServerBase))
      query = fhirClient.loadPage().next(query).execute()
      resources.addAll(getResourcesFromBundle(query))
    }

The issue I'm having is that the entities in the response (ex. Specimen) will not contain the field display it will be null. This field is set by the CodeSystem i've defined in the Implementation Guide, depending on the code value. Just for reference, I'm attaching a screenshot of a exemple Specimen resource.

enter image description here

If the query is performed as so (using search()): fhirClient.search().forResource(request.type).returnBundle(classOf[Bundle]).execute() the display field will be present.

Does anyone have any idea on possible solutions or why this is happening?

2 Answers2

0

The display property is not always guaranteed to be present in all FHIR resources. It is an optional property that may or may not be populated depending on the resource type and the server implementation.

If the display property is not present in a resource, you can use other properties e.g. code (if present) to identify and describe the resource or at least make sure your code can handle the scenario when the display doesn't exist e.g.

for (Resource resource : getResourcesFromBundle(query)) {
    if (resource instanceof CodeableConcept) {
        CodeableConcept concept = (CodeableConcept) resource;
        String display = concept.getText();
        if (display != null) {
            // Do something with the display property
        } else {
            // Handle case where display property is missing
        }
    }
}
BlessedHIT
  • 1,849
  • 1
  • 14
  • 21
0

What I've ended up doing is creating my own interceptor ResponseTerminologyDisplayPopulationInterceptor from hapi-fhir. I customized it a little to work also on requests of type GET_PAGE. That did the trick. Now the display field is returned for request like so:

<http://localhost:8080/fhir?_getpages=...>
user16217248
  • 3,119
  • 19
  • 19
  • 37