From bc11ac5c5b8c03086597bdfd9b12511f7786a3cd Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 10 Aug 2020 15:53:08 +1000 Subject: [PATCH] Start working on rendering expressions --- .../org/hl7/fhir/r5/renderers/DataRenderer.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 be047566d..a51bb8a9e 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 @@ -22,6 +22,7 @@ import org.hl7.fhir.r5.model.ContactPoint.ContactPointSystem; import org.hl7.fhir.r5.model.DataType; import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.Enumeration; +import org.hl7.fhir.r5.model.Extension; import org.hl7.fhir.r5.model.HumanName; import org.hl7.fhir.r5.model.HumanName.NameUse; import org.hl7.fhir.r5.model.Identifier; @@ -45,6 +46,7 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptReferenceDesignationComponent; import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; +import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.MarkDownProcessor; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; @@ -784,7 +786,11 @@ public class DataRenderer extends Renderer { if (s.getEvent().size() > 0) { CommaSeparatedStringBuilder c = new CommaSeparatedStringBuilder(); for (DateTimeType p : s.getEvent()) { - c.append(p.toHumanDisplay()); + if (p.hasValue()) { + c.append(p.toHumanDisplay()); + } else if (!renderExpression(c, p)) { + c.append("??"); + } } b.append("Events: "+ c.toString()); } @@ -829,6 +835,15 @@ public class DataRenderer extends Renderer { return b.toString(); } + private boolean renderExpression(CommaSeparatedStringBuilder c, PrimitiveType p) { + Extension exp = p.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/cqf-expression"); + if (exp == null) { + return false; + } + c.append(exp.getValueExpression().getExpression()); + return true; + } + private String displayEventCode(EventTiming when) { switch (when) { case C: return "at meals";