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.context.IWorkerContext;
|
||||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||||
import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus;
|
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.r5.model.TypeDetails.ProfiledTypeSorter;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
@ -253,6 +254,14 @@ public class TypeDetails {
|
||||||
return true;
|
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) {
|
for (String n: tn) {
|
||||||
String id = n.contains("#") ? n.substring(0, n.indexOf("#")) : n;
|
String id = n.contains("#") ? n.substring(0, n.indexOf("#")) : n;
|
||||||
|
|
|
@ -3272,6 +3272,7 @@ public class FHIRPathEngine {
|
||||||
case Count :
|
case Count :
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer);
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer);
|
||||||
case Where :
|
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
|
// 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")) {
|
if (focus.hasType("Reference")) {
|
||||||
boolean canRestrictTargets = !exp.getParameters().isEmpty();
|
boolean canRestrictTargets = !exp.getParameters().isEmpty();
|
||||||
|
@ -3298,6 +3299,7 @@ public class FHIRPathEngine {
|
||||||
case Select :
|
case Select :
|
||||||
return paramTypes.get(0);
|
return paramTypes.get(0);
|
||||||
case All :
|
case All :
|
||||||
|
checkParamTypes(exp, exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean));
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||||
case Repeat :
|
case Repeat :
|
||||||
return paramTypes.get(0);
|
return paramTypes.get(0);
|
||||||
|
|
Loading…
Reference in New Issue