Support for rendering contained resources in IG Publisher

This commit is contained in:
Grahame Grieve 2020-06-02 13:52:28 +10:00
parent c5634c012e
commit f1d901a842
3 changed files with 82 additions and 0 deletions

View File

@ -79,6 +79,15 @@ private Map<String, Object> userData;
return (Integer) getUserData(name); return (Integer) getUserData(name);
} }
public void copyUserData(Base other) {
if (other.userData != null) {
if (userData == null) {
userData = new HashMap<>();
}
userData.putAll(other.userData);
}
}
public boolean hasFormatComment() { public boolean hasFormatComment() {
return (formatCommentsPre != null && !formatCommentsPre.isEmpty()) || (formatCommentsPost != null && !formatCommentsPost.isEmpty()); return (formatCommentsPre != null && !formatCommentsPre.isEmpty()) || (formatCommentsPost != null && !formatCommentsPost.isEmpty());
} }

View File

@ -0,0 +1,65 @@
package org.hl7.fhir.r5.test;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.Manager;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.utilities.cache.PackageCacheManager;
import org.hl7.fhir.utilities.cache.ToolsVersion;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class XmlParserTests {
private static SimpleWorkerContext context;
private static FHIRPathEngine fp;
@BeforeAll
public static void setUp() throws Exception {
PackageCacheManager pcm = new PackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
context = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
fp = new FHIRPathEngine(context);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "any.xml"), "any.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ii.xml"), "ii.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cd.xml"), "cd.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ce.xml"), "ce.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "ed.xml"), "ed.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "st.xml"), "st.xml", null);
context.loadFromFile(TestingUtilities.loadTestResourceStream("validator", "cda", "cda.xml"), "cda.xml", null);
for (StructureDefinition sd : context.getStructures()) {
if (!sd.hasSnapshot()) {
System.out.println("generate snapshot for " + sd.getUrl());
context.generateSnapshot(sd, true);
}
}
}
@Test
/**
* Deserializes a simplified CDA example into the logical model and checks that
* xml deserialization works for the xsi:type
*
* @throws IOException
*/
public void testXsiDeserialiserXmlParser() throws IOException {
Element cda = Manager.parse(context, TestingUtilities.loadTestResourceStream("validator", "cda", "example-xsi.xml"),
FhirFormat.XML);
ByteArrayOutputStream baosXml = new ByteArrayOutputStream();
Manager.compose(context, cda, baosXml, FhirFormat.XML, OutputStyle.PRETTY, null);
String cdaSerialised = baosXml.toString();
assertTrue(cdaSerialised.indexOf("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"")>0);
assertTrue(cdaSerialised.indexOf("xsi:type=\"CD\"")>0);
}
}

View File

@ -917,4 +917,12 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
if (!check) if (!check)
throw new FHIRException(message); throw new FHIRException(message);
} }
public void emptyRow(TableModel model, int cellCount) {
Row r = new Row();
model.rows.add(r);
for (int i = 0; i < cellCount; i++) {
r.getCells().add(new Cell());
}
}
} }