mirror of
https://github.com/hapifhir/org.hl7.fhir.core.git
synced 2025-02-14 16:54:54 +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 {
|
public ElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
||||||
StructureDefinition sd = profile;
|
StructureDefinition sd = profile;
|
||||||
ElementDefinition focus = null;
|
ElementDefinition focus = null;
|
||||||
|
boolean okToNotResolve = false;
|
||||||
|
|
||||||
if (expr.getKind() == Kind.Name) {
|
if (expr.getKind() == Kind.Name) {
|
||||||
if (element.hasSlicing()) {
|
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
|
} else
|
||||||
throw new DefinitionException("illegal function name "+expr.getName()+"() in discriminator");
|
throw new DefinitionException("illegal function name "+expr.getName()+"() in discriminator");
|
||||||
} else if (expr.getKind() == Kind.Group) {
|
} else if (expr.getKind() == Kind.Group) {
|
||||||
@ -4501,9 +4515,13 @@ public class FHIRPathEngine {
|
|||||||
throw new DefinitionException("illegal expression syntax in discriminator (const)");
|
throw new DefinitionException("illegal expression syntax in discriminator (const)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (focus == null)
|
if (focus == null) {
|
||||||
|
if (okToNotResolve) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
throw new DefinitionException("Unable to resolve discriminator in definitions: "+expr.toString());
|
throw new DefinitionException("Unable to resolve discriminator in definitions: "+expr.toString());
|
||||||
else if (expr.getInner() == null)
|
}
|
||||||
|
} else if (expr.getInner() == null)
|
||||||
return focus;
|
return focus;
|
||||||
else {
|
else {
|
||||||
return evaluateDefinition(expr.getInner(), sd, focus);
|
return evaluateDefinition(expr.getInner(), sd, focus);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user