fix issue with FHIRPath engine throwing exception for an invalid path

This commit is contained in:
Grahame Grieve 2024-11-22 16:10:50 +11:00
parent 8a34a90cee
commit 4544c8762a

View File

@ -6522,15 +6522,15 @@ public class FHIRPathEngine {
}
if (ed.hasContentReference() && path.startsWith(ed.getPath()+".")) {
ElementDefinitionMatch m = getElementDefinitionById(sd, ed.getContentReference());
List<ElementDefinitionMatch> res = getElementDefinition(sd, m.definition.getPath()+path.substring(ed.getPath().length()), allowTypedName, expr);
if (res.size() == 0) {
throw new Error("Unable to find "+ed.getContentReference());
if (m == null) {
throw new Error("Unable to find path "+path+" with a content reference of "+ed.getContentReference());
} else {
List<ElementDefinitionMatch> res = getElementDefinition(sd, m.definition.getPath()+path.substring(ed.getPath().length()), allowTypedName, expr);
for (ElementDefinitionMatch item : res) {
item.sourceDefinition = ed;
}
return res;
}
return res;
}
}
return ml(null);