Fix #131 - Narrative generator incorrectly sets the Resource.text.status

to 'generated' even if the given resource type does not have a template
(and therefore no narrative is actually generated).
This commit is contained in:
James Agnew 2015-03-24 17:18:34 -04:00
parent cffda7539f
commit c7558c7780
5 changed files with 112 additions and 0 deletions

View File

@ -148,6 +148,10 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
ourLog.trace("Post-whitespace cleaning: ", result);
}
if (isBlank(result)) {
return;
}
theNarrative.getDiv().setValueAsString(result);
theNarrative.getStatus().setValueAsString("generated");
return;

View File

@ -50,6 +50,7 @@ import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu.resource.AllergyIntolerance;
import ca.uhn.fhir.model.dstu.resource.Binary;
import ca.uhn.fhir.model.dstu.resource.Composition;
import ca.uhn.fhir.model.dstu.resource.Condition;
import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Conformance.RestResource;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
@ -73,6 +74,7 @@ import ca.uhn.fhir.model.primitive.DecimalDt;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.model.primitive.InstantDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.parser.JsonParserTest.MyPatientWithOneDeclaredAddressExtension;
import ca.uhn.fhir.parser.JsonParserTest.MyPatientWithOneDeclaredExtension;
@ -97,6 +99,22 @@ public class XmlParserTest {
}
/**
* See #131
*/
@Test
public void testParseAndReencodeCondition() {
FhirContext ctx = FhirContext.forDstu1();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
InputStreamReader reader = new InputStreamReader(XmlParserTest.class.getResourceAsStream("/condition.xml"));
Condition cond = ctx.newXmlParser().parseResource(Condition.class, reader);
String enc = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(cond);
ourLog.info(enc);
assertThat(enc, not(containsString("generated")));
}
@Test
public void testEncodeOmitsVersionAndBase() {
Patient p = new Patient();

View File

@ -0,0 +1,85 @@
<Condition
xmlns="http://hl7.org/fhir">
<extension url="http://www.dmix.gov/fhir/Profile/commonextensions#id">
<valueString value="site2957-pat226-prb-159"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/metadata#Metadata">
<extension url="http://www.dmix.gov/fhir/Profile/metadata#ImplementationVersion">
<valueString value="0.2.dstu1"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/metadata#JenkinsBuildInfo">
<valueString value="Build Tag: [jenkins-FHIR DSTU1 Branch Development Build-40] Built At: [2015-03-18_16-25-36] GIT Branch: [origin/DSTU1] GIT Commit: [e0e7cfba1f74b4b49f8769d9078beaf90c681264]"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/metadata#BuildUser">
<valueString value="Built by: [jenkins@null]"/>
</extension>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/commonextensions#Domain">
<valueString value="ProblemLists"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/commonextensions#sourceEnterprise">
<valueString value="VA"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/commonextensions#sourceDataSystem">
<valueString value="VistA - VDS"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/commonextensions#sourceSite">
<valueCodeableConcept>
<coding>
<system value="http://www.dmix.gov/vaSiteCode"/>
<code value="2957"/>
<display value="VistA Site 2957"/>
</coding>
<coding>
<system value="http://www.dmix.gov/dmisId"/>
<code value="7001"/>
</coding>
<coding>
<system value="http://www.dmix.gov/moniker"/>
<code value="SMS1"/>
</coding>
<text value="VistA Site 2957"/>
</valueCodeableConcept>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/dmixcondition#acuity">
<valueString value="ACUTE"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/dmixcondition#last-modified">
<valueDate value="1999-08-17"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/dmixcondition#problem-id">
<valueString value="159"/>
</extension>
<extension url="http://www.dmix.gov/fhir/Profile/dmixcondition#service-connected">
<valueBoolean value="false"/>
</extension>
<identifier>
<use value="official"/>
<label value="VistA Problem Id at Site 2957 - 159"/>
<system value="http://www.dmix.gov/vaProblemId/2957"/>
<value value="159"/>
</identifier>
<subject>
<reference value="Patient/site2957-pat226"/>
</subject>
<asserter>
<reference value="Practitioner/..Condition..site2957-pat226-prb-159..vapvdr-11817"/>
</asserter>
<dateAsserted value="1999-08-17"/>
<code>
<coding>
<system value="http://hl7.org/fhir/sid/icd-9-cm"/>
<code value="787.91"/>
<display value="Diarrhea"/>
<primary value="true"/>
</coding>
<coding>
<system value="http://snomed.info/sct"/>
<code value="62315008"/>
<display value="Diarrhea"/>
</coding>
<text value="Diarrhea"/>
</code>
<status value="confirmed"/>
<notes value="--------------------&#xa;Date: 1999-08-17T00:00:00-04:00&#xa;Entered By: RADTECH,FORTYONE&#xa;&#xa;PATIENT SOMEWHAT DEHYDRATED&#xa;"/>
</Condition>

View File

@ -64,6 +64,11 @@
reference if the base matches the base for the server giving
the response.
</action>
<action type="fix" fix="131">
Narrative generator incorrectly sets the Resource.text.status to 'generated' even if the
given resource type does not have a template (and therefore no narrative is actually generated).
Thanks to Bill de Beaubien for reporting!
</action>
</release>
<release version="0.9" date="2015-Mar-14">
<action type="add">