@Test
public void testEncodeBundle() throws InterruptedException {
Bundle b = new Bundle();
b.getMeta().addTag().setSystem("http://hl7.org/fhir/tag").setCode("http://hl7.org/fhir/tag/message")
.setDisplay("Message");
InstantType pub = InstantType.withCurrentTime();
b.getMeta().setLastUpdatedElement(pub);
Patient p1 = new Patient();
p1.addName().addFamily("Family1");
BundleEntryComponent entry = b.addEntry();
p1.getIdElement().setValue("1");
entry.setResource(p1);
Patient p2 = new Patient();
p2.addName().addFamily("Family2");
entry = b.addEntry();
p2.getIdElement().setValue("2");
entry.setResource(p2);
String bundleString = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(b);
ourLog.info(bundleString);
// @formatter:on
String[] strings = { "<Bundle xmlns=\"http://hl7.org/fhir\">",
"<lastUpdated value=\"" + pub.getValueAsString() + "\"/>", "<Patient xmlns=\"http://hl7.org/fhir\">",
"<id value=\"1\"/>", "<Patient xmlns=\"http://hl7.org/fhir\">", "<id value=\"2\"/>" };
// @formatter:off
assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));
}
XmlParserHl7OrgDstu2Test.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:hapi-fhir
作者:
评论列表
文章目录