From 70e123e69b981a2b9a0b176e4f12581be438c4dd Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 5 Jul 2023 07:18:12 +1000 Subject: [PATCH] Fix up rendering of base64 content --- .../java/org/hl7/fhir/r5/renderers/DataRenderer.java | 5 ++++- .../hl7/fhir/r5/renderers/ProfileDrivenRenderer.java | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java index 8f488c801..dcbd29dd1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DataRenderer.java @@ -25,6 +25,7 @@ import org.hl7.fhir.r5.model.Address; import org.hl7.fhir.r5.model.Annotation; import org.hl7.fhir.r5.model.BackboneType; import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.Base64BinaryType; import org.hl7.fhir.r5.model.BaseDateTimeType; import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalType; @@ -99,7 +100,7 @@ public class DataRenderer extends Renderer implements CodeResolver { } // -- 2. Markdown support ------------------------------------------------------- - + public static String processRelativeUrls(String markdown, String path) { if (markdown == null) { return ""; @@ -726,6 +727,8 @@ public class DataRenderer extends Renderer implements CodeResolver { } } else if (type instanceof MarkdownType) { addMarkdown(x, ((MarkdownType) type).asStringValue()); + } else if (type instanceof Base64BinaryType) { + x.tx("(base64 data)"); } else if (type.isPrimitive()) { x.tx(type.primitiveValue()); } else { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java index bf4d99729..5dc1ee5a7 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ProfileDrivenRenderer.java @@ -377,9 +377,10 @@ public class ProfileDrivenRenderer extends ResourceRenderer { x.addText(((InstantType) e).toHumanDisplay()); else if (e instanceof DateTimeType) { renderDateTime(x, e); - } else if (e instanceof Base64BinaryType) - x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue())); - else if (e instanceof org.hl7.fhir.r5.model.DateType) { + } else if (e instanceof Base64BinaryType) { + Base64BinaryType b64 = (Base64BinaryType) e; + x.addText("(base64 data - "+(b64.getValue() == null ? "0" : b64.getValue().length)+" bytes)"); + } else if (e instanceof org.hl7.fhir.r5.model.DateType) { org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e); renderDate(x, dt); } else if (e instanceof Enumeration) { @@ -853,12 +854,12 @@ public class ProfileDrivenRenderer extends ResourceRenderer { XhtmlNode tbl = new XhtmlNode(NodeType.Element, "table"); tbl.setAttribute("class", "grid"); XhtmlNode tr = tbl.tr(); - tr.td().tx("-"); // work around problem with empty table rows + tr.td().style("display: hidden").tx("-"); // work around problem with empty table rows boolean add = addColumnHeadings(tr, grandChildren); for (BaseWrapper v : p.getValues()) { if (v != null) { tr = tbl.tr(); - tr.td().tx("*"); // work around problem with empty table rows + tr.td().style("display: hidden").tx("*"); // work around problem with empty table rows add = addColumnValues(res, tr, grandChildren, v, showCodeDetails, displayHints, path, indent) || add; } }