render comments

This commit is contained in:
Grahame Grieve 2022-08-26 20:59:11 +10:00
parent 58017176fe
commit bdb5a46621
2 changed files with 47 additions and 13 deletions

View File

@ -77,6 +77,7 @@ import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.NodeType;
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
@ -306,6 +307,9 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
return;
Base e = ew.getBase();
if (context.isShowComments()) {
x = renderCommentsSpan(x, e);
}
if (e instanceof StringType)
x.addText(((StringType) e).getValue());
@ -436,6 +440,14 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
}
private XhtmlNode renderCommentsSpan(XhtmlNode x, Base e) {
if (e.hasFormatComment()) {
return x.span(null, CommaSeparatedStringBuilder.join("
", e.getFormatCommentsPost()));
} else {
return x;
}
}
private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
return displayLeaf(res, ew, defn, x, name, showCodeDetails, true);
}

View File

@ -122,6 +122,7 @@ public class RenderingContext {
private QuestionnaireRendererMode questionnaireMode = QuestionnaireRendererMode.FORM;
private boolean addGeneratedNarrativeHeader = true;
private boolean showComments = false;
private FhirPublication targetVersion;
private Locale locale;
@ -188,6 +189,7 @@ public class RenderingContext {
res.dateYearMonthFormat = dateYearMonthFormat;
res.targetVersion = targetVersion;
res.locale = locale;
res.showComments = showComments;
res.terminologyServiceOptions = terminologyServiceOptions.copy();
return res;
@ -453,8 +455,9 @@ public class RenderingContext {
return targetVersion;
}
public void setTargetVersion(FhirPublication targetVersion) {
public RenderingContext setTargetVersion(FhirPublication targetVersion) {
this.targetVersion = targetVersion;
return this;
}
public boolean isTechnicalMode() {
@ -473,8 +476,9 @@ public class RenderingContext {
}
}
public void setLocale(Locale locale) {
public RenderingContext setLocale(Locale locale) {
this.locale = locale;
return this;
}
@ -494,8 +498,9 @@ public class RenderingContext {
return timeZoneId;
}
public void setTimeZoneId(ZoneId timeZoneId) {
public RenderingContext setTimeZoneId(ZoneId timeZoneId) {
this.timeZoneId = timeZoneId;
return this;
}
@ -509,12 +514,14 @@ public class RenderingContext {
return this.dateTimeFormat;
}
public void setDateTimeFormat(DateTimeFormatter dateTimeFormat) {
public RenderingContext setDateTimeFormat(DateTimeFormatter dateTimeFormat) {
this.dateTimeFormat = dateTimeFormat;
return this;
}
public void setDateTimeFormatString(String dateTimeFormat) {
public RenderingContext setDateTimeFormatString(String dateTimeFormat) {
this.dateTimeFormat = DateTimeFormatter.ofPattern(dateTimeFormat);
return this;
}
/**
@ -527,52 +534,67 @@ public class RenderingContext {
return this.dateFormat;
}
public void setDateFormat(DateTimeFormatter dateFormat) {
public RenderingContext setDateFormat(DateTimeFormatter dateFormat) {
this.dateFormat = dateFormat;
return this;
}
public void setDateFormatString(String dateFormat) {
public RenderingContext setDateFormatString(String dateFormat) {
this.dateFormat = DateTimeFormatter.ofPattern(dateFormat);
return this;
}
public DateTimeFormatter getDateYearFormat() {
return dateYearFormat;
}
public void setDateYearFormat(DateTimeFormatter dateYearFormat) {
public RenderingContext setDateYearFormat(DateTimeFormatter dateYearFormat) {
this.dateYearFormat = dateYearFormat;
return this;
}
public void setDateYearFormatString(String dateYearFormat) {
public RenderingContext setDateYearFormatString(String dateYearFormat) {
this.dateYearFormat = DateTimeFormatter.ofPattern(dateYearFormat);
return this;
}
public DateTimeFormatter getDateYearMonthFormat() {
return dateYearMonthFormat;
}
public void setDateYearMonthFormat(DateTimeFormatter dateYearMonthFormat) {
public RenderingContext setDateYearMonthFormat(DateTimeFormatter dateYearMonthFormat) {
this.dateYearMonthFormat = dateYearMonthFormat;
return this;
}
public void setDateYearMonthFormatString(String dateYearMonthFormat) {
public RenderingContext setDateYearMonthFormatString(String dateYearMonthFormat) {
this.dateYearMonthFormat = DateTimeFormatter.ofPattern(dateYearMonthFormat);
return this;
}
public ResourceRendererMode getMode() {
return mode;
}
public void setMode(ResourceRendererMode mode) {
public RenderingContext setMode(ResourceRendererMode mode) {
this.mode = mode;
return this;
}
public boolean isContained() {
return contained;
}
public void setContained(boolean contained) {
public RenderingContext setContained(boolean contained) {
this.contained = contained;
return this;
}
public boolean isShowComments() {
return showComments;
}
public RenderingContext setShowComments(boolean showComments) {
this.showComments = showComments;
return this;
}