use of org.opencds.cqf.cql.engine.execution.InMemoryLibraryLoader in project quality-measure-and-cohort-service by Alvearie.
the class CQLParameterTests method runTest.
public void runTest(String type, Object expectedOutput, String defaultValue) throws Exception {
String cql = "library \"Test\" version '1.0.0'\n";
cql += "codesystem \"DUMMY\": 'urn:mysystem'\n";
cql += "parameter Input " + type;
if (defaultValue != null) {
cql += " default ";
cql += defaultValue;
}
cql += "\n";
cql += "define Output:\n\tInput\n";
Map<String, Object> parameters = null;
if (defaultValue == null) {
parameters = new HashMap<>();
parameters.put("Input", expectedOutput);
}
TerminologyProvider tp = new TerminologyProvider() {
@Override
public boolean in(Code code, ValueSetInfo valueSet) {
return false;
}
@Override
public Iterable<Code> expand(ValueSetInfo valueSet) {
return null;
}
@Override
public Code lookup(Code code, CodeSystemInfo codeSystem) {
return code;
}
};
LibraryLoader ll = new InMemoryLibraryLoader(Arrays.asList(toLibrary(cql)));
CqlEngine engine = new CqlEngine(ll, Collections.<String, DataProvider>emptyMap(), tp);
EvaluationResult result = engine.evaluate("Test", parameters);
assertEquals(1, result.expressionResults.size());
Object actual = result.forExpression("Output");
assertEquals(expectedOutput.toString(), actual.toString());
}
Aggregations