Java Code Examples for org.opencds.cqf.cql.execution.Context#enterLibrary()
The following examples show how to use
org.opencds.cqf.cql.execution.Context#enterLibrary() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeEvaluator.java From cql_engine with Apache License 2.0 | 6 votes |
@Override protected Object internalEvaluate(Context context) { org.opencds.cqf.cql.runtime.Code code = new org.opencds.cqf.cql.runtime.Code().withCode(this.getCode()).withDisplay(this.getDisplay()); org.cqframework.cql.elm.execution.CodeSystemRef codeSystemRef = this.getSystem(); if (codeSystemRef != null) { boolean enteredLibrary = context.enterLibrary(codeSystemRef.getLibraryName()); try { org.cqframework.cql.elm.execution.CodeSystemDef codeSystemDef = context.resolveCodeSystemRef(codeSystemRef.getName()); code.setSystem(codeSystemDef.getId()); code.setVersion(codeSystemDef.getVersion()); } finally { context.exitLibrary(enteredLibrary); } } return code; }
Example 2
Source File: FunctionRefEvaluator.java From cql_engine with Apache License 2.0 | 5 votes |
@Override protected Object internalEvaluate(Context context) { ArrayList<Object> arguments = new ArrayList<>(); for (Expression operand : this.getOperand()) { arguments.add(operand.evaluate(context)); } boolean enteredLibrary = context.enterLibrary(this.getLibraryName()); try { // TODO: Use type specifiers from the operands here if they are available FunctionDef functionDef = context.resolveFunctionRef(this.getName(), arguments, this.getLibraryName()); if (Optional.ofNullable(functionDef.isExternal()).orElse(false)) { return context.getExternalFunctionProvider().evaluate(functionDef.getName(), arguments); } else { context.pushWindow(); try { for (int i = 0; i < arguments.size(); i++) { context.push(new Variable().withName(functionDef.getOperand().get(i).getName()).withValue(arguments.get(i))); } return functionDef.getExpression().evaluate(context); } finally { context.popWindow(); } } } finally { context.exitLibrary(enteredLibrary); } }
Example 3
Source File: ExpressionRefEvaluator.java From cql_engine with Apache License 2.0 | 5 votes |
@Override protected Object internalEvaluate(Context context) { boolean enteredLibrary = context.enterLibrary(this.getLibraryName()); try { return context.resolveExpressionRef(this.getName()).evaluate(context); } finally { context.exitLibrary(enteredLibrary); } }
Example 4
Source File: CodeRefEvaluator.java From cql_engine with Apache License 2.0 | 5 votes |
@Override protected Object internalEvaluate(Context context) { boolean enteredLibrary = context.enterLibrary(this.getLibraryName()); try { return context.resolveCodeRef(this.getName()).evaluate(context); } finally { context.exitLibrary(enteredLibrary); } }