mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-07 21:38:15 +00:00
fix bug in Definition mode - support ofType()
This commit is contained in:
parent
e8c6a9112f
commit
5485a048b0
@ -4433,6 +4433,7 @@ public class FHIRPathEngine {
|
||||
public ElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
||||
StructureDefinition sd = profile;
|
||||
ElementDefinition focus = null;
|
||||
boolean okToNotResolve = false;
|
||||
|
||||
if (expr.getKind() == Kind.Name) {
|
||||
if (element.hasSlicing()) {
|
||||
@ -4493,6 +4494,19 @@ public class FHIRPathEngine {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("ofType".equals(expr.getName())) {
|
||||
if (!element.hasType())
|
||||
throw new DefinitionException("illegal use of ofType() in discriminator - no type on element "+element.getId());
|
||||
if (element.getType().size() > 1)
|
||||
throw new DefinitionException("illegal use of ofType() in discriminator - Multiple possible types on "+element.getId());
|
||||
if (!element.getType().get(0).hasCode())
|
||||
throw new DefinitionException("illegal use of ofType() in discriminator - Type has no code on "+element.getId());
|
||||
String atn = element.getType().get(0).getCode();
|
||||
String stn = expr.getParameters().get(0).getName();
|
||||
okToNotResolve = true;
|
||||
if ((atn.equals(stn))) {
|
||||
focus = element;
|
||||
}
|
||||
} else
|
||||
throw new DefinitionException("illegal function name "+expr.getName()+"() in discriminator");
|
||||
} else if (expr.getKind() == Kind.Group) {
|
||||
@ -4501,9 +4515,13 @@ public class FHIRPathEngine {
|
||||
throw new DefinitionException("illegal expression syntax in discriminator (const)");
|
||||
}
|
||||
|
||||
if (focus == null)
|
||||
throw new DefinitionException("Unable to resolve discriminator in definitions: "+expr.toString());
|
||||
else if (expr.getInner() == null)
|
||||
if (focus == null) {
|
||||
if (okToNotResolve) {
|
||||
return null;
|
||||
} else {
|
||||
throw new DefinitionException("Unable to resolve discriminator in definitions: "+expr.toString());
|
||||
}
|
||||
} else if (expr.getInner() == null)
|
||||
return focus;
|
||||
else {
|
||||
return evaluateDefinition(expr.getInner(), sd, focus);
|
||||
|
Loading…
x
Reference in New Issue
Block a user