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 a27e8cbd8..b79a4f61a 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 @@ -104,14 +104,19 @@ public class ProfileDrivenRenderer extends ResourceRenderer { @Override public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException { + boolean idDone = false; + XhtmlNode p = x.para(); if (context.isAddGeneratedNarrativeHeader()) { - x.para().b().tx("Generated Narrative: "+r.fhirType()); - } - if (!Utilities.noString(r.getId())) { - x.an(r.getId()); + p.b().tx("Generated Narrative: "+r.fhirType()); + p.an(r.getId()); + idDone = true; } if (context.isTechnicalMode() && !context.isContained()) { - renderResourceHeader(r, x); + renderResourceHeader(r, x, !idDone); + idDone = true; + } + if (!Utilities.noString(r.getId()) && !idDone) { + x.para().an(r.getId()); } try { StructureDefinition sd = r.getDefinition(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java index 72368b81a..1dc024895 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java @@ -398,12 +398,16 @@ public abstract class ResourceRenderer extends DataRenderer { return true; } - protected void renderResourceHeader(ResourceWrapper r, XhtmlNode x) throws UnsupportedEncodingException, FHIRException, IOException { + protected void renderResourceHeader(ResourceWrapper r, XhtmlNode x, boolean doId) throws UnsupportedEncodingException, FHIRException, IOException { XhtmlNode div = x.div().style("display: inline-block").style("background-color: #d9e0e7").style("padding: 6px") .style("margin: 4px").style("border: 1px solid #8da1b4") .style("border-radius: 5px").style("line-height: 60%"); String id = getPrimitiveValue(r, "id"); + if (doId) { + div.an(id); + } + String lang = getPrimitiveValue(r, "language"); String ir = getPrimitiveValue(r, "implicitRules"); BaseWrapper meta = r.getChildByName("meta").hasValues() ? r.getChildByName("meta").getValues().get(0) : null;