Start working on rendering expressions

This commit is contained in:
Grahame Grieve 2020-08-10 15:53:08 +10:00
parent 74c11cfec1
commit bc11ac5c5b
1 changed files with 16 additions and 1 deletions

View File

@ -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";