Search in sources :

Example 1 with IntegerParameter

use of com.ibm.cohort.cql.evaluation.parameters.IntegerParameter in project quality-measure-and-cohort-service by Alvearie.

the class ParameterHelperTest method testResolveIntegerParameter.

@Test
public void testResolveIntegerParameter() {
    Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:integer:40"));
    assertEquals(1, params.size());
    IntegerParameter p = (IntegerParameter) params.get("test");
    assertNotNull("Parameter with expected name not found", p);
    assertEquals("Unexpected value", 40, p.getValue());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Test(org.junit.Test)

Example 2 with IntegerParameter

use of com.ibm.cohort.cql.evaluation.parameters.IntegerParameter in project quality-measure-and-cohort-service by Alvearie.

the class ParameterHelperTest method testResolveIntervalIntegerParameter.

@Test
public void testResolveIntervalIntegerParameter() {
    Map<String, Parameter> params = ParameterHelper.parseParameterArguments(Arrays.asList("test:interval:integer,10,20"));
    assertEquals(1, params.size());
    IntervalParameter p = (IntervalParameter) params.get("test");
    assertEquals(10, ((IntegerParameter) p.getStart()).getValue());
    assertEquals(20, ((IntegerParameter) p.getEnd()).getValue());
}
Also used : DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Test(org.junit.Test)

Example 3 with IntegerParameter

use of com.ibm.cohort.cql.evaluation.parameters.IntegerParameter in project quality-measure-and-cohort-service by Alvearie.

the class R4ParameterDefinitionWithDefaultToCohortParameterConverterTest method testInteger__shouldReturnIntegerParameter.

@Test
public void testInteger__shouldReturnIntegerParameter() {
    ParameterDefinition parameterDefinition = getBaseParameterDefinition("integer");
    int expectedValue = 10;
    IntegerType fhirValue = new IntegerType(expectedValue);
    parameterDefinition.addExtension(CDMConstants.PARAMETER_DEFAULT_URL, fhirValue);
    assertEquals(new IntegerParameter(expectedValue), R4ParameterDefinitionWithDefaultToCohortParameterConverter.toCohortParameter(parameterDefinition));
}
Also used : IntegerType(org.hl7.fhir.r4.model.IntegerType) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Test(org.junit.Test)

Example 4 with IntegerParameter

use of com.ibm.cohort.cql.evaluation.parameters.IntegerParameter in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testRequiredCQLParameterSpecifiedPatientInRange.

@Test
public void testRequiredCQLParameterSpecifiedPatientInRange() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.parameters");
    String expression = "Female";
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("MaxAge", new IntegerParameter(50));
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestWithParams", "1.0.0"), parameters, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, true);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 5 with IntegerParameter

use of com.ibm.cohort.cql.evaluation.parameters.IntegerParameter in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testRequiredCQLParameterSpecifiedPatientOutOfRange.

@Test
public void testRequiredCQLParameterSpecifiedPatientOutOfRange() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.parameters");
    String expression = "Female";
    Map<String, Parameter> parameters = new HashMap<>();
    parameters.put("MaxAge", new IntegerParameter(40));
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestWithParams", "1.0.0"), parameters, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, false);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Aggregations

IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)19 Test (org.junit.Test)18 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)17 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)14 HashMap (java.util.HashMap)13 StringParameter (com.ibm.cohort.cql.evaluation.parameters.StringParameter)12 DecimalParameter (com.ibm.cohort.cql.evaluation.parameters.DecimalParameter)11 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)9 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)8 CqlLibraryDescriptor (com.ibm.cohort.cql.library.CqlLibraryDescriptor)7 CqlEvaluationRequests (com.ibm.cohort.cql.evaluation.CqlEvaluationRequests)6 CqlEvaluationRequest (com.ibm.cohort.cql.evaluation.CqlEvaluationRequest)5 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)5 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)5 QuantityParameter (com.ibm.cohort.cql.evaluation.parameters.QuantityParameter)5 TimeParameter (com.ibm.cohort.cql.evaluation.parameters.TimeParameter)5 IntegerType (org.hl7.fhir.r4.model.IntegerType)4 CqlDataProvider (com.ibm.cohort.cql.data.CqlDataProvider)3 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)3 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)3