Prevent NPE when auto-generating narrative and an illegal resource type is encountered

This commit is contained in:
Grahame Grieve 2020-09-17 15:41:32 +10:00
parent 8ce405cc4d
commit 3464643921
1 changed files with 7 additions and 6 deletions

View File

@ -106,13 +106,14 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
}
try {
StructureDefinition sd = r.getDefinition();
ElementDefinition ed = sd.getSnapshot().getElement().get(0);
if (sd.getType().equals("NamingSystem") && "icd10".equals(r.getId())) {
System.out.println("hah!");
if (sd == null) {
throw new FHIRException("Cannot find definition for "+r.fhirType());
} else {
ElementDefinition ed = sd.getSnapshot().getElement().get(0);
containedIds.clear();
hasExtensions = false;
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), false, 0);
}
containedIds.clear();
hasExtensions = false;
generateByProfile(r, sd, r.root(), sd.getSnapshot().getElement(), ed, context.getProfileUtilities().getChildList(sd, ed), x, r.fhirType(), false, 0);
} catch (Exception e) {
e.printStackTrace();
x.para().b().style("color: maroon").tx("Exception generating Narrative: "+e.getMessage());