Checking parameter type for where() and all()
This commit is contained in:
parent
289ab6b29c
commit
31ffd84667
|
@ -44,6 +44,7 @@ import org.hl7.fhir.exceptions.DefinitionException;
|
|||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.TypeDetails.ProfiledTypeSorter;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
@ -253,6 +254,14 @@ public class TypeDetails {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
t = ProfiledType.ns(n);
|
||||
StructureDefinition sd = context.fetchTypeDefinition(t);
|
||||
if (sd != null && sd.getKind() != StructureDefinitionKind.LOGICAL && Utilities.existsInList(sd.getType(), "boolean", "string", "integer", "decimal", "Quantity", "dateTime", "time")) {
|
||||
t = FP_NS+"System."+Utilities.capitalize(sd.getType());
|
||||
if (typesContains(t)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String n: tn) {
|
||||
String id = n.contains("#") ? n.substring(0, n.indexOf("#")) : n;
|
||||
|
|
|
@ -3272,6 +3272,7 @@ public class FHIRPathEngine {
|
|||
case Count :
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer);
|
||||
case Where :
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean));
|
||||
// special case: where the focus is Reference, and the parameter to where is resolve() "is", we will suck up the target types
|
||||
if (focus.hasType("Reference")) {
|
||||
boolean canRestrictTargets = !exp.getParameters().isEmpty();
|
||||
|
@ -3298,6 +3299,7 @@ public class FHIRPathEngine {
|
|||
case Select :
|
||||
return paramTypes.get(0);
|
||||
case All :
|
||||
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean));
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Repeat :
|
||||
return paramTypes.get(0);
|
||||
|
@ -3681,7 +3683,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
|
||||
private void checkParamTypes(ExpressionNode expr, String funcName, List<TypeDetails> paramTypes, TypeDetails... typeSet) throws PathEngineException {
|
||||
private void checkParamTypes(ExpressionNode expr, String funcName,List<TypeDetails> paramTypes, TypeDetails... typeSet) throws PathEngineException {
|
||||
int i = 0;
|
||||
for (TypeDetails pt : typeSet) {
|
||||
if (i == paramTypes.size()) {
|
||||
|
|
Loading…
Reference in New Issue