use of au.csiro.pathling.fhirpath.operator.OperatorInput in project pathling by aehrc.
the class Visitor method visitBinaryOperator.
@Nonnull
private FhirPath visitBinaryOperator(@Nullable final ParseTree leftContext, @Nullable final ParseTree rightContext, @Nullable final String operatorName) {
checkNotNull(operatorName);
// Parse the left and right expressions.
final FhirPath left = new Visitor(context).visit(leftContext);
final FhirPath right = new Visitor(context).visit(rightContext);
// Retrieve an Operator instance based upon the operator string.
final Operator operator = Operator.getInstance(operatorName);
final OperatorInput operatorInput = new OperatorInput(context, left, right);
return operator.invoke(operatorInput);
}
use of au.csiro.pathling.fhirpath.operator.OperatorInput in project pathling by aehrc.
the class ExtensionFunction method invoke.
@Nonnull
@Override
public FhirPath invoke(@Nonnull final NamedFunctionInput input) {
final String expression = NamedFunction.expressionFromInput(input, NAME);
checkUserInput(input.getArguments().size() == 1, "extension function must have one argument: " + expression);
final FhirPath urlArgument = input.getArguments().get(0);
checkUserInput(urlArgument instanceof StringLiteralPath, "extension function must have argument of type String literal: " + expression);
final NonLiteralPath inputPath = input.getInput();
final ElementPath extensionPath = new PathTraversalOperator().invoke(new PathTraversalInput(input.getContext(), inputPath, ExtensionSupport.EXTENSION_ELEMENT_NAME()));
// Now we need to create a correct argument context for the `where` call.
final ParserContext argumentContext = input.getContext();
final FhirPath extensionUrlPath = new PathTraversalOperator().invoke(new PathTraversalInput(argumentContext, extensionPath.toThisPath(), "url"));
final FhirPath extensionUrCondition = new ComparisonOperator(ComparisonOperation.EQUALS).invoke(new OperatorInput(argumentContext, extensionUrlPath, urlArgument));
// Override the expression in the function input.
return new WhereFunction().invoke(new NamedFunctionInput(input.getContext(), extensionPath, Collections.singletonList(extensionUrCondition), expression));
}
Aggregations