Improve error handling in narrative generator
This commit is contained in:
parent
c4d302df8d
commit
9f5d672133
|
@ -184,7 +184,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
|
|||
name = theContext.getResourceDefinition(theResource).getName().toLowerCase();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
if (name == null || !myNameToNarrativeTemplate.containsKey(name)) {
|
||||
if (myIgnoreMissingTemplates) {
|
||||
ourLog.debug("No narrative template available for resorce: {}", name);
|
||||
try {
|
||||
|
|
|
@ -27,6 +27,7 @@ import ca.uhn.fhir.model.dstu2.resource.Medication;
|
|||
import ca.uhn.fhir.model.dstu2.resource.MedicationOrder;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.DiagnosticReportStatusEnum;
|
||||
import ca.uhn.fhir.model.dstu2.valueset.EncounterClassEnum;
|
||||
|
@ -77,6 +78,32 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnsupportedType() throws DataFormatException {
|
||||
myGen.setIgnoreMissingTemplates(true);
|
||||
|
||||
Parameters value = new Parameters();
|
||||
value.setId("123");
|
||||
|
||||
NarrativeDt narrative = new NarrativeDt();
|
||||
myGen.generateNarrative(ourCtx, value, narrative);
|
||||
String output = narrative.getDiv().getValueAsString();
|
||||
ourLog.info(output);
|
||||
assertThat(output, StringContains.containsString("No narrative template available"));
|
||||
|
||||
}
|
||||
|
||||
@Test(expected=DataFormatException.class)
|
||||
public void testUnsupportedTypeDontIgnore() throws DataFormatException {
|
||||
myGen.setIgnoreMissingTemplates(false);
|
||||
|
||||
Parameters value = new Parameters();
|
||||
value.setId("123");
|
||||
|
||||
NarrativeDt narrative = new NarrativeDt();
|
||||
myGen.generateNarrative(ourCtx, value, narrative);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGenerateEncounter() throws DataFormatException {
|
||||
|
|
Loading…
Reference in New Issue