Fix narrative generation issue

This commit is contained in:
Grahame Grieve 2022-08-10 21:26:48 +10:00
parent 056e41d19d
commit ba2ff9390d
2 changed files with 15 additions and 6 deletions

View File

@ -104,14 +104,19 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
@Override
public boolean render(XhtmlNode x, ResourceWrapper r) throws FHIRFormatError, DefinitionException, IOException {
boolean idDone = false;
XhtmlNode p = x.para();
if (context.isAddGeneratedNarrativeHeader()) {
x.para().b().tx("Generated Narrative: "+r.fhirType());
}
if (!Utilities.noString(r.getId())) {
x.an(r.getId());
p.b().tx("Generated Narrative: "+r.fhirType());
p.an(r.getId());
idDone = true;
}
if (context.isTechnicalMode() && !context.isContained()) {
renderResourceHeader(r, x);
renderResourceHeader(r, x, !idDone);
idDone = true;
}
if (!Utilities.noString(r.getId()) && !idDone) {
x.para().an(r.getId());
}
try {
StructureDefinition sd = r.getDefinition();

View File

@ -398,12 +398,16 @@ public abstract class ResourceRenderer extends DataRenderer {
return true;
}
protected void renderResourceHeader(ResourceWrapper r, XhtmlNode x) throws UnsupportedEncodingException, FHIRException, IOException {
protected void renderResourceHeader(ResourceWrapper r, XhtmlNode x, boolean doId) throws UnsupportedEncodingException, FHIRException, IOException {
XhtmlNode div = x.div().style("display: inline-block").style("background-color: #d9e0e7").style("padding: 6px")
.style("margin: 4px").style("border: 1px solid #8da1b4")
.style("border-radius: 5px").style("line-height: 60%");
String id = getPrimitiveValue(r, "id");
if (doId) {
div.an(id);
}
String lang = getPrimitiveValue(r, "language");
String ir = getPrimitiveValue(r, "implicitRules");
BaseWrapper meta = r.getChildByName("meta").hasValues() ? r.getChildByName("meta").getValues().get(0) : null;