From 1cdb7ea6956307aaa45969647c261674fe81db76 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 2 Dec 2024 06:50:31 +0300 Subject: [PATCH] questionnaire rendering improvements --- .../r5/renderers/DiagnosticReportRenderer.java | 2 +- .../fhir/r5/renderers/QuestionnaireRenderer.java | 4 ++-- .../hl7/fhir/r5/renderers/RendererFactory.java | 1 + .../hl7/fhir/r5/renderers/ResourceRenderer.java | 16 +++++++++++++--- .../r5/renderers/utils/ResourceWrapperModel.java | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DiagnosticReportRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DiagnosticReportRenderer.java index 3a8faa241..c5a26bda6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DiagnosticReportRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/DiagnosticReportRenderer.java @@ -99,7 +99,7 @@ public class DiagnosticReportRenderer extends ResourceRenderer { for (ResourceWrapper cont : dr.children("contained")) { x.hr(); - RendererFactory.factory(cont, context.forContained()).buildNarrative(status, x, cont); + RendererFactory.factory(cont, context.forContained()).setInner(true).buildNarrative(status, x, cont); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/QuestionnaireRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/QuestionnaireRenderer.java index 20d3166f0..b635a37a4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/QuestionnaireRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/QuestionnaireRenderer.java @@ -75,7 +75,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer { first = false; } x.hr(); - RendererFactory.factory(cont, context.forContained()).buildNarrative(status, x, cont); + RendererFactory.factory(cont, context.forContained()).setInner(true).buildNarrative(status, x, cont); } } @@ -565,7 +565,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer { if (i.has("answerValueSet")) { if (!defn.getPieces().isEmpty()) defn.addPiece(gen.new Piece("br")); defn.getPieces().add(gen.new Piece(null, (context.formatPhrase(RenderingContext.QUEST_VALUE)+" "), null)); - if (Utilities.noString(i.primitiveValue("answerValueSet")) && i.primitiveValue("answerValueSet").startsWith("#")) { + if (Utilities.noString(i.primitiveValue("answerValueSet")) && i.primitiveValue("answerValueSet").startsWith("#")) { ResourceWrapper vs = q.getContained(i.primitiveValue("answerValueSet").substring(1)); if (vs == null) { defn.getPieces().add(gen.new Piece(null, i.primitiveValue("answerValueSet"), null)); 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 a557f287a..92149ae8f 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 @@ -76,6 +76,7 @@ public class RendererFactory { case "Patient": return new PatientRenderer(context); case "Provenance": return new ProvenanceRenderer(context); case "Parameters": return new ParametersRenderer(context); + case "Questionnaire": return new QuestionnaireRenderer(context); case "QuestionnaireResponse": return new QuestionnaireResponseRenderer(context); } if (resource.isDirect()) { 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 ba4d22bf4..f38131309 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 @@ -51,6 +51,7 @@ public abstract class ResourceRenderer extends DataRenderer { protected XVerExtensionManager xverManager; protected boolean multiLangMode; + protected boolean inner; public ResourceRenderer(RenderingContext context) { @@ -70,6 +71,15 @@ public abstract class ResourceRenderer extends DataRenderer { return false; } + public boolean isInner() { + return inner; + } + + public ResourceRenderer setInner(boolean inner) { + this.inner = inner; + return this; + } + /** * Just build the narrative that would go in the resource (per @renderResource()), but don't put it in the resource * @param dr @@ -837,9 +847,9 @@ public abstract class ResourceRenderer extends DataRenderer { XhtmlNode p = x.para().attribute("class", "res-header-id"); String ft = context.getTranslatedCode(r.fhirType(), "http://hl7.org/fhir/fhir-types"); if (desc == null) { - p.b().tx(context.formatPhrase(context.isTechnicalMode() ? RenderingContext.PROF_DRIV_GEN_NARR_TECH : RenderingContext.PROF_DRIV_GEN_NARR, ft, "")); + p.b().tx(context.formatPhrase(context.isTechnicalMode() && !isInner() ? RenderingContext.PROF_DRIV_GEN_NARR_TECH : RenderingContext.PROF_DRIV_GEN_NARR, ft, "")); } else { - p.b().tx(context.formatPhrase(context.isTechnicalMode() ? RenderingContext.PROF_DRIV_GEN_NARR_TECH : RenderingContext.PROF_DRIV_GEN_NARR, ft, desc)); + p.b().tx(context.formatPhrase(context.isTechnicalMode() && !isInner() ? RenderingContext.PROF_DRIV_GEN_NARR_TECH : RenderingContext.PROF_DRIV_GEN_NARR, ft, desc)); } // first thing we do is lay down the resource anchors. @@ -1464,7 +1474,7 @@ public abstract class ResourceRenderer extends DataRenderer { context.addAnchor(id); x.an(context.prefixAnchor(id)); } - RendererFactory.factory(c, context.forContained()).buildNarrative(status, x, c); + RendererFactory.factory(c, context.forContained()).setInner(true).buildNarrative(status, x, c); } } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ResourceWrapperModel.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ResourceWrapperModel.java index b64c98f24..b97dd2e1c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ResourceWrapperModel.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/utils/ResourceWrapperModel.java @@ -256,7 +256,7 @@ public class ResourceWrapperModel extends ResourceWrapper { } public String getWebPath() { - return null; + return model.getWebPath(); } public String getCodeSystemUri() {