fix questionnaire rendering to create valid resources
This commit is contained in:
parent
b4a65d1825
commit
c70c43271a
|
@ -62,7 +62,7 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
|
|||
boolean hasFlags = checkForFlags(q.getItem());
|
||||
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(context.getDestDir(), context.isInlineGraphics(), true);
|
||||
TableModel model = gen.new TableModel("qtree="+q.getId(), true);
|
||||
TableModel model = gen.new TableModel("qtree="+q.getId(), !forResource);
|
||||
model.setAlternating(true);
|
||||
model.setDocoImg(context.getSpecificationLink() +"help16.png");
|
||||
model.setDocoRef(context.getSpecificationLink()+"formats.html#table");
|
||||
|
|
|
@ -38,6 +38,7 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
|
||||
protected ResourceContext rcontext;
|
||||
protected XVerExtensionManager xverManager;
|
||||
protected boolean forResource;
|
||||
|
||||
|
||||
public ResourceRenderer(RenderingContext context) {
|
||||
|
@ -53,7 +54,6 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
||||
render(x, dr);
|
||||
return x;
|
||||
|
||||
}
|
||||
/**
|
||||
* given a resource, update it's narrative with the best rendering available
|
||||
|
@ -67,7 +67,14 @@ public abstract class ResourceRenderer extends DataRenderer {
|
|||
|
||||
public void render(DomainResource r) throws IOException, FHIRException, EOperationOutcome {
|
||||
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
|
||||
boolean hasExtensions = render(x, r);
|
||||
boolean ofr = forResource;
|
||||
boolean hasExtensions;
|
||||
try {
|
||||
forResource = true;
|
||||
hasExtensions = render(x, r);
|
||||
} finally {
|
||||
forResource = ofr;
|
||||
}
|
||||
inject(r, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.apache.commons.lang3.SystemUtils;
|
|||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.Questionnaire;
|
||||
|
@ -107,7 +108,12 @@ public class NarrativeGenerationTests {
|
|||
rc.setDefinitionsTarget("test.html");
|
||||
rc.setTerminologyServiceOptions(TerminologyServiceOptions.defaults());
|
||||
IOUtils.copy(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-expected.xml"), new FileOutputStream(TestingUtilities.tempFile("narrative", test.getId() + "-expected.xml")));
|
||||
DomainResource source = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-input.xml"));
|
||||
DomainResource source;
|
||||
if (TestingUtilities.findTestResource("r5", "narrative", test.getId() + "-input.json")) {
|
||||
source = (DomainResource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-input.json"));
|
||||
} else {
|
||||
source = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-input.xml"));
|
||||
}
|
||||
DomainResource target = (DomainResource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-expected.xml"));
|
||||
RendererFactory.factory(source, rc).render(source);
|
||||
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(TestingUtilities.tempFile("narrative", test.getId() + "-actual.xml")), source);
|
||||
|
|
|
@ -1308,6 +1308,19 @@ public class Utilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static String describeSize(int length) {
|
||||
if (length > 1024 * 1024 * 1024) {
|
||||
return ""+length / (1024 * 1024 * 1024)+"Gb";
|
||||
}
|
||||
if (length > 1024 * 1024) {
|
||||
return ""+length / (1024 * 1024)+"Mb";
|
||||
}
|
||||
if (length > 1024) {
|
||||
return ""+length / (1024)+"kb";
|
||||
}
|
||||
return ""+length +"b";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue