use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.
the class SparkCqlEvaluatorTest method testGetFilteredRequestsGlobalParametersApplied.
@Test
public void testGetFilteredRequestsGlobalParametersApplied() {
CqlEvaluationRequests requests = new CqlEvaluationRequests();
requests.setGlobalParameters(new HashMap<String, Parameter>() {
{
put("param1", new IntegerParameter(10));
put("param2", new StringParameter("10"));
put("globalParam", new DecimalParameter("10.0"));
}
});
CqlEvaluationRequest request = makeEvaluationRequest("context", "lib1", "1.0.0");
request.setExpressionsByNames(new HashSet<>(Collections.singletonList("cohortOrig")));
request.setParameters(new HashMap<String, Parameter>() {
{
put("param1", new IntegerParameter(1));
put("param2", new StringParameter("1"));
put("param3", new DecimalParameter("1.0"));
}
});
CqlEvaluationRequest request2 = makeEvaluationRequest("context", "lib2", "1.0.0");
request2.setExpressionsByNames(new HashSet<>(Collections.singletonList("cohortOrig")));
List<CqlEvaluationRequest> evaluations = Arrays.asList(request, request2);
requests.setEvaluations(evaluations);
CqlEvaluationRequests actual = evaluator.getFilteredRequests(requests, null, null);
for (CqlEvaluationRequest evaluation : actual.getEvaluations()) {
if (evaluation.getDescriptor().getLibraryId().equals("lib1")) {
assertEquals(4, evaluation.getParameters().size());
assertEquals(new IntegerParameter(1), evaluation.getParameters().get("param1"));
assertEquals(new StringParameter("1"), evaluation.getParameters().get("param2"));
assertEquals(new DecimalParameter("1.0"), evaluation.getParameters().get("param3"));
assertEquals(new DecimalParameter("10.0"), evaluation.getParameters().get("globalParam"));
} else if (evaluation.getDescriptor().getLibraryId().equals("lib2")) {
assertEquals(3, evaluation.getParameters().size());
assertEquals(new IntegerParameter(10), evaluation.getParameters().get("param1"));
assertEquals(new StringParameter("10"), evaluation.getParameters().get("param2"));
assertEquals(new DecimalParameter("10.0"), evaluation.getParameters().get("globalParam"));
} else {
fail("Unexpected library encountered. Expected only lib1 and lib2.");
}
}
}
use of com.ibm.cohort.cql.evaluation.parameters.DecimalParameter in project quality-measure-and-cohort-service by Alvearie.
the class CqlEvaluationRequestsTest method testSetGet.
@Test
public void testSetGet() {
Map<String, Parameter> globalParameters = new HashMap<>();
globalParameters.put("String", new StringParameter("Hello,World"));
globalParameters.put("Integer", new IntegerParameter(10));
Map<String, Parameter> localParameters = new HashMap<>();
localParameters.put("String", new StringParameter("Goodbye, Cruel World"));
localParameters.put("Float", new DecimalParameter("1.29f"));
CqlLibraryDescriptor desc = new CqlLibraryDescriptor().setLibraryId("SampleLibrary").setVersion("1.0.0");
CqlExpressionConfiguration expressionConfiguration = new CqlExpressionConfiguration();
expressionConfiguration.setName("IsFemale");
CqlEvaluationRequest r1 = new CqlEvaluationRequest();
r1.setDescriptor(desc);
r1.setParameters(localParameters);
r1.setExpressions(Collections.singleton(expressionConfiguration));
r1.setContextKey("Patient");
r1.setContextValue("NA");
assertEquals(desc, r1.getDescriptor());
assertEquals(localParameters, r1.getParameters());
assertEquals(Collections.singleton(expressionConfiguration), r1.getExpressions());
assertEquals("Patient", r1.getContextKey());
assertEquals("NA", r1.getContextValue());
CqlEvaluationRequests requests = new CqlEvaluationRequests();
requests.setGlobalParameters(globalParameters);
requests.setEvaluations(Arrays.asList(r1));
assertEquals(globalParameters, requests.getGlobalParameters());
assertEquals(1, requests.getEvaluations().size());
}
Aggregations