diff --git a/dsf-fhir/dsf-fhir-server/src/main/java/dev/dsf/fhir/adapter/SearchBundleHtmlGenerator.java b/dsf-fhir/dsf-fhir-server/src/main/java/dev/dsf/fhir/adapter/SearchBundleHtmlGenerator.java index 49bedeb46..81b4528f1 100644 --- a/dsf-fhir/dsf-fhir-server/src/main/java/dev/dsf/fhir/adapter/SearchBundleHtmlGenerator.java +++ b/dsf-fhir/dsf-fhir-server/src/main/java/dev/dsf/fhir/adapter/SearchBundleHtmlGenerator.java @@ -16,6 +16,8 @@ import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r4.model.Bundle.BundleLinkComponent; import org.hl7.fhir.r4.model.Bundle.SearchEntryMode; +import org.hl7.fhir.r4.model.OperationOutcome; +import org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r4.model.QuestionnaireResponse; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.StringType; @@ -141,6 +143,16 @@ public void writeHtml(String basePath, URI resourceUri, Bundle resource, OutputS out.write("

" + includeResources + " include " + (includeResources == 1 ? "resource" : "resources") + " hidden.

"); + List diagnostics = resource.getEntry().stream().filter(BundleEntryComponent::hasResource) + .map(BundleEntryComponent::getResource).filter(r -> r instanceof OperationOutcome) + .map(r -> (OperationOutcome) r).map(OperationOutcome::getIssue).flatMap(List::stream) + .filter(OperationOutcomeIssueComponent::hasSeverity) + .filter(OperationOutcomeIssueComponent::hasDiagnostics) + .map(i -> i.getSeverity().getDisplay() + ": " + i.getDiagnostics()).toList(); + for (String diag : diagnostics) + out.write("

" + diag.replaceAll("&", "&") + .replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">") + "

"); + out.write(""); }