diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java index 7becef9a2..9fb41cc12 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/RendererFactory.java @@ -4,6 +4,7 @@ import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper; import org.hl7.fhir.r5.renderers.utils.RenderingContext; +import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext; public class RendererFactory { @@ -87,7 +88,7 @@ public class RendererFactory { } - public static ResourceRenderer factory(ResourceWrapper resource, RenderingContext context) { + public static ResourceRenderer factory(ResourceWrapper resource, RenderingContext context, ResourceContext resourceContext) { if (context.getTemplateProvider() != null) { String liquidTemplate = context.getTemplateProvider().findTemplate(context, resource.getName()); if (liquidTemplate != null) { @@ -102,7 +103,11 @@ public class RendererFactory { return new DiagnosticReportRenderer(context); } - return new ProfileDrivenRenderer(context); + return new ProfileDrivenRenderer(context, resourceContext); + } + + public static ResourceRenderer factory(ResourceWrapper rw, RenderingContext lrc) { + return factory(rw, lrc, null); } 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 d494dd9fc..a855e71da 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 @@ -7,6 +7,7 @@ import org.apache.commons.lang3.NotImplementedException; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent; import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; @@ -208,8 +209,9 @@ public abstract class ResourceRenderer extends DataRenderer { org.hl7.fhir.r5.elementmodel.Element bundleElement = rcontext.resolveElement(url); if (bundleElement != null) { String bundleUrl = null; - if (bundleElement.getNamedChild("resource").getChildValue("id") != null) { - bundleUrl = "#" + bundleElement.fhirType().toLowerCase() + "_" + bundleElement.getNamedChild("resource").getChildValue("id"); + Element br = bundleElement.getNamedChild("resource"); + if (br.getChildValue("id") != null) { + bundleUrl = "#" + br.fhirType().toLowerCase() + "_" + br.getChildValue("id"); } else { bundleUrl = "#" +fullUrlToAnchor(bundleElement.getChildValue("fullUrl")); }