Skip to content

Commit

Permalink
OperationOutcome warnings now shown underneath table
Browse files Browse the repository at this point in the history
  • Loading branch information
hhund committed Aug 21, 2023
1 parent 0d1c238 commit d0826b7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -141,6 +143,16 @@ public void writeHtml(String basePath, URI resourceUri, Bundle resource, OutputS
out.write("<div id=\"footer\"><p style=\"font-style: italic;\">" + includeResources + " include "
+ (includeResources == 1 ? "resource" : "resources") + " hidden.</div>");

List<String> 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("<div id=\"footer\"><p style=\"font-style: italic;\">" + diag.replaceAll("&", "&amp;")
.replaceAll("\"", "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;") + "</div>");

out.write("</div>");
}

Expand Down

0 comments on commit d0826b7

Please sign in to comment.