overwritten section text in composition  #402
This commit is contained in:
James Agnew 2019-09-30 20:19:55 -04:00 committed by GitHub
commit 62ae8f85cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 73 additions and 0 deletions

View File

@ -447,6 +447,34 @@ public class JsonParserR4Test {
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);
}
/**
* 2019-09-19 - Pre #1489

View File

@ -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);
}
}