overwritten section text in composition #402
This commit is contained in:
parent
43a8499bf6
commit
24c9c27abb
|
@ -369,8 +369,7 @@ public class XmlParser extends BaseParser /* implements IParser */ {
|
||||||
} else {
|
} else {
|
||||||
narr = null;
|
narr = null;
|
||||||
}
|
}
|
||||||
// FIXME potential null access on narr see line 623
|
if (gen != null && (narr==null || narr.isEmpty())) {
|
||||||
if (gen != null && narr.isEmpty()) {
|
|
||||||
gen.populateResourceNarrative(myContext, theResource);
|
gen.populateResourceNarrative(myContext, theResource);
|
||||||
}
|
}
|
||||||
if (narr != null && narr.isEmpty() == false) {
|
if (narr != null && narr.isEmpty() == false) {
|
||||||
|
|
|
@ -374,6 +374,34 @@ public class JsonParserR4Test {
|
||||||
assertEquals("535", ((StringType) houseNumberExt.getValue()).getValue());
|
assertEquals("535", ((StringType) houseNumberExt.getValue()).getValue());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Composition createComposition(String sectionText) {
|
||||||
|
Composition c = new Composition();
|
||||||
|
Narrative compositionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED);
|
||||||
|
compositionText.setDivAsString("Composition");
|
||||||
|
Narrative compositionSectionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED);
|
||||||
|
compositionSectionText.setDivAsString(sectionText);
|
||||||
|
c.setText(compositionText);
|
||||||
|
c.addSection().setText(compositionSectionText);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #402 (however JSON is fine)
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEncodingTextSection() {
|
||||||
|
|
||||||
|
String sectionText = "sectionText";
|
||||||
|
Composition composition = createComposition(sectionText);
|
||||||
|
|
||||||
|
String encoded = ourCtx.newJsonParser().encodeResourceToString(composition);
|
||||||
|
ourLog.info(encoded);
|
||||||
|
|
||||||
|
int idx = encoded.indexOf(sectionText);
|
||||||
|
assertNotEquals(-1, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterClassClearContext() {
|
public static void afterClassClearContext() {
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package ca.uhn.fhir.parser;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
|
import org.hl7.fhir.r4.model.Composition;
|
||||||
|
import org.hl7.fhir.r4.model.Narrative;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
|
||||||
|
public class XmlParserR4Test {
|
||||||
|
private static final Logger ourLog = LoggerFactory.getLogger(XmlParserR4Test.class);
|
||||||
|
private static FhirContext ourCtx = FhirContext.forR4();
|
||||||
|
|
||||||
|
|
||||||
|
private Composition createComposition(String sectionText) {
|
||||||
|
Composition c = new Composition();
|
||||||
|
Narrative compositionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED);
|
||||||
|
compositionText.setDivAsString("Composition");
|
||||||
|
Narrative compositionSectionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED);
|
||||||
|
compositionSectionText.setDivAsString(sectionText);
|
||||||
|
c.setText(compositionText);
|
||||||
|
c.addSection().setText(compositionSectionText);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #402 section.text is overwritten by composition.text
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEncodingTextSection() {
|
||||||
|
|
||||||
|
String sectionText = "sectionText";
|
||||||
|
Composition composition = createComposition(sectionText);
|
||||||
|
|
||||||
|
String encoded = ourCtx.newXmlParser().encodeResourceToString(composition);
|
||||||
|
ourLog.info(encoded);
|
||||||
|
|
||||||
|
int idx = encoded.indexOf(sectionText);
|
||||||
|
assertNotEquals(-1, idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue