Properly handle bundle entry summary element

This commit is contained in:
James Agnew 2014-09-17 11:35:57 -04:00
parent b316d556b7
commit 62bf2620f1
5 changed files with 26 additions and 3 deletions

View File

@ -28,6 +28,10 @@
XHTML (in narratives) containing escapable characters (e.g. < or ") will now always have those characters
escaped properly in encoded messages.
</action>
<action type="fix">
Summary (in the bundle entry) is now encoded by the XML and JSON parsers if supplied. Thanks to David Hay of
Orion Health for reporting this!
</action>
</release>
<release version="0.6" date="2014-Sep-08" description="This release brings a number of new features and bug fixes!">
<!--

View File

@ -203,6 +203,10 @@ public class JsonParser extends BaseParser implements IParser {
encodeResourceToJsonStreamWriter(resDef, resource, eventWriter, "content", false);
}
if (nextEntry.getSummary().isEmpty()==false) {
eventWriter.write("summary", nextEntry.getSummary().getValueAsString());
}
eventWriter.writeEnd(); // entry object
}
eventWriter.writeEnd(); // entry array

View File

@ -208,6 +208,14 @@ public class XmlParser extends BaseParser implements IParser {
ourLog.debug("Bundle entry contains null resource");
}
if (!nextEntry.getSummary().isEmpty()) {
eventWriter.writeStartElement("summary");
eventWriter.writeAttribute("type", "xhtml");
encodeXhtml(nextEntry.getSummary(), eventWriter);
eventWriter.writeEndElement();
}
eventWriter.writeEndElement(); // entry
}

View File

@ -764,6 +764,8 @@ public class JsonParserTest {
DiagnosticReport res = (DiagnosticReport) entry.getResource();
assertEquals("Complete Blood Count", res.getName().getText().getValue());
assertThat(entry.getSummary().getValueAsString(), containsString("CBC Report for Wile"));
}
@Test
@ -874,6 +876,7 @@ public class JsonParserTest {
BundleEntry entry = b.addEntry();
entry.getId().setValue("1");
entry.setResource(p1);
entry.getSummary().setValueAsString("this is the summary");
Patient p2 = new Patient();
p2.addName().addFamily("Family2");
@ -893,6 +896,7 @@ public class JsonParserTest {
List<String> strings = new ArrayList<String>();
strings.addAll(Arrays.asList("\"published\":\""+pub.getValueAsString()+"\""));
strings.addAll(Arrays.asList("\"id\":\"1\""));
strings.addAll(Arrays.asList("this is the summary"));
strings.addAll(Arrays.asList("\"id\":\"2\"", "\"rel\":\"alternate\"", "\"href\":\"http://foo/bar\""));
strings.addAll(Arrays.asList("\"deleted\":\""+nowDt.getValueAsString()+"\"", "\"id\":\"Patient/3\""));
assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));

View File

@ -117,6 +117,7 @@ public class XmlParserTest {
BundleEntry entry = b.addEntry();
entry.getId().setValue("1");
entry.setResource(p1);
entry.getSummary().setValueAsString("this is the summary");
Patient p2 = new Patient();
p2.addName().addFamily("Family2");
@ -136,7 +137,7 @@ public class XmlParserTest {
List<String> strings = new ArrayList<String>();
strings.addAll(Arrays.asList("<published>", pub.getValueAsString(), "</published>"));
strings.add("<category term=\"http://hl7.org/fhir/tag/message\" label=\"Message\" scheme=\"http://hl7.org/fhir/tag\"/>");
strings.addAll(Arrays.asList("<entry>", "<id>1</id>", "</entry>"));
strings.addAll(Arrays.asList("<entry>", "<id>1</id>", "</Patient>","<summary type=\"xhtml\">", "<div", "</entry>"));
strings.addAll(Arrays.asList("<entry>", "<id>2</id>", "<link rel=\"alternate\" href=\"http://foo/bar\"/>", "<link rel=\"search\" href=\"http://foo/bar/search\"/>", "</entry>"));
strings.addAll(Arrays.asList("<at:deleted-entry", "ref=\"Patient/3", "/>"));
assertThat(bundleString, StringContainsInOrder.stringContainsInOrder(strings));
@ -941,6 +942,8 @@ public class XmlParserTest {
assertEquals("12345", resource.getId().getVersionIdPart());
assertEquals("12345", ((IdDt) resource.getResourceMetadata().get(ResourceMetadataKeyEnum.VERSION_ID)).getVersionIdPart());
assertThat(entry.getSummary().getValueAsString(), containsString("LOINC Codes for Cholesterol"));
}
@SuppressWarnings("deprecation")