encode narratives of contained resources (#3402)
* encode narratives of contained resources fixes #1466 * encode narratives of contained resources fixes #1466
This commit is contained in:
parent
631391819b
commit
0c5d868f44
|
@ -199,8 +199,6 @@ public abstract class BaseParser implements IParser {
|
|||
} else if (myNext.getDef() instanceof RuntimeChildNarrativeDefinition) {
|
||||
if (isSuppressNarratives() || isSummaryMode()) {
|
||||
continue;
|
||||
} else if (theContainedResource) {
|
||||
continue;
|
||||
}
|
||||
} else if (myNext.getDef() instanceof RuntimeChildContainedResources) {
|
||||
if (theContainedResource) {
|
||||
|
|
|
@ -534,8 +534,6 @@ public class JsonParser extends BaseParser implements IJsonLikeParser {
|
|||
beginArray(theEventWriter, nextChildSpecificName);
|
||||
inArray = true;
|
||||
encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, nextValue, childDef, null, theContainedResource, nextChildElem, force, theEncodeContext);
|
||||
} else if (nextChild instanceof RuntimeChildNarrativeDefinition && theContainedResource) {
|
||||
// suppress narratives from contained resources
|
||||
} else {
|
||||
encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, nextValue, childDef, nextChildSpecificName, theContainedResource, nextChildElem, false, theEncodeContext);
|
||||
}
|
||||
|
|
|
@ -446,8 +446,6 @@ public class XmlParser extends BaseParser {
|
|||
}
|
||||
}
|
||||
encodeChildElementToStreamWriter(theResource, theEventWriter, nextChild, nextValue, childName, childDef, getExtensionUrl(extension.getUrl()), theContainedResource, nextChildElem, theEncodeContext);
|
||||
} else if (nextChild instanceof RuntimeChildNarrativeDefinition && theContainedResource) {
|
||||
// suppress narratives from contained resources
|
||||
} else {
|
||||
encodeChildElementToStreamWriter(theResource, theEventWriter, nextChild, nextValue, childName, childDef, extensionUrl, theContainedResource, nextChildElem, theEncodeContext);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 1466
|
||||
title: "The XML and JSON Parsers are now encoding narratives of contained resources.
|
||||
Narratives were skipped before for contained resources. This was a rule which was only valid in STU1 (https://www.hl7.org/fhir/DSTU1/narrative.html), and was removed in DSTU2+ "
|
|
@ -971,7 +971,7 @@ public class XmlParserDstu2_1Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -990,9 +990,9 @@ public class XmlParserDstu2_1Test {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded, not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -1370,7 +1370,7 @@ public class XmlParserDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -1389,9 +1389,9 @@ public class XmlParserDstu2Test {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded, not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -1414,7 +1414,7 @@ public class XmlParserDstu3Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -1433,9 +1433,9 @@ public class XmlParserDstu3Test {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded, not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, containsString("FOOBAR"));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newJsonParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -532,7 +532,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
|
||||
String encoded = parser.encodeResourceToString(patient);
|
||||
ourLog.info(encoded);
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -14,13 +14,39 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.hamcrest.core.IsNot;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu2.model.*;
|
||||
import org.hl7.fhir.dstu2.model.Address;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUse;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory;
|
||||
import org.hl7.fhir.dstu2.model.Binary;
|
||||
import org.hl7.fhir.dstu2.model.Bundle;
|
||||
import org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent;
|
||||
import org.hl7.fhir.dstu2.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu2.model.Composition;
|
||||
import org.hl7.fhir.dstu2.model.Condition;
|
||||
import org.hl7.fhir.dstu2.model.DateTimeType;
|
||||
import org.hl7.fhir.dstu2.model.DateType;
|
||||
import org.hl7.fhir.dstu2.model.DecimalType;
|
||||
import org.hl7.fhir.dstu2.model.DiagnosticReport;
|
||||
import org.hl7.fhir.dstu2.model.DocumentManifest;
|
||||
import org.hl7.fhir.dstu2.model.EnumFactory;
|
||||
import org.hl7.fhir.dstu2.model.Enumeration;
|
||||
import org.hl7.fhir.dstu2.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.dstu2.model.Extension;
|
||||
import org.hl7.fhir.dstu2.model.HumanName;
|
||||
import org.hl7.fhir.dstu2.model.Identifier;
|
||||
import org.hl7.fhir.dstu2.model.Identifier.IdentifierUse;
|
||||
import org.hl7.fhir.dstu2.model.InstantType;
|
||||
import org.hl7.fhir.dstu2.model.MedicationStatement;
|
||||
import org.hl7.fhir.dstu2.model.Narrative.NarrativeStatus;
|
||||
import org.hl7.fhir.dstu2.model.Observation;
|
||||
import org.hl7.fhir.dstu2.model.Organization;
|
||||
import org.hl7.fhir.dstu2.model.Patient;
|
||||
import org.hl7.fhir.dstu2.model.PrimitiveType;
|
||||
import org.hl7.fhir.dstu2.model.Reference;
|
||||
import org.hl7.fhir.dstu2.model.Resource;
|
||||
import org.hl7.fhir.dstu2.model.SimpleQuantity;
|
||||
import org.hl7.fhir.dstu2.model.Specimen;
|
||||
import org.hl7.fhir.dstu2.model.StringType;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
@ -343,7 +369,7 @@ public class XmlParserHl7OrgDstu2Test {
|
|||
/**
|
||||
* See #216 - Profiled datatypes should use their unprofiled parent type as
|
||||
* the choice[x] name
|
||||
*
|
||||
* <p>
|
||||
* Disabled after conversation with Grahame
|
||||
*/
|
||||
@Test
|
||||
|
@ -763,7 +789,7 @@ public class XmlParserHl7OrgDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -784,9 +810,9 @@ public class XmlParserHl7OrgDstu2Test {
|
|||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>",
|
||||
"<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded,
|
||||
not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -1013,7 +1013,7 @@ public class XmlParserDstu2_1Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -1032,9 +1032,9 @@ public class XmlParserDstu2_1Test {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded, not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -532,7 +532,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newJsonParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -549,7 +549,7 @@ public class JsonParserHl7OrgDstu2Test {
|
|||
|
||||
String encoded = parser.encodeResourceToString(patient);
|
||||
ourLog.info(encoded);
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
|
@ -510,7 +510,7 @@ public class XmlParserHl7OrgDstu2Test {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
|
|
@ -1233,7 +1233,7 @@ public class Dstu3XmlParserTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEncodeContainedWithNarrativeIsSuppresed() throws Exception {
|
||||
public void testEncodeContainedWithNarrative() throws Exception {
|
||||
IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
|
||||
|
||||
// Create an organization, note that the organization does not have an ID
|
||||
|
@ -1252,9 +1252,9 @@ public class Dstu3XmlParserTest {
|
|||
ourLog.info(encoded);
|
||||
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<div xmlns=\"http://www.w3.org/1999/xhtml\">BARFOO</div>", "<contained>", "<Organization", "</Organization"));
|
||||
assertThat(encoded, not(stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization")));
|
||||
assertThat(encoded, stringContainsInOrder("<Patient", "<text>", "<contained>", "<Organization", "<text", "</Organization"));
|
||||
|
||||
assertThat(encoded, not(containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("FOOBAR")));
|
||||
assertThat(encoded, (containsString("BARFOO")));
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue