Search in sources :

Example 1 with CqlVersionedIdentifier

use of com.ibm.cohort.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testUsingUSCoreWithTranslation.

@Test
public void testUsingUSCoreWithTranslation() throws Exception {
    Patient patient = getPatient("123", AdministrativeGender.MALE, "1983-12-02");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.uscore");
    String expression = "QueryByGender";
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestUSCore", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
    Assert.assertEquals(1, actual.getExpressionResults().size());
    List<Object> value = (List) actual.getExpressionResults().get(expression);
    Assert.assertEquals(1, value.size());
    assertFhirEquals(patient, (IBaseResource) value.get(0));
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) CqlEvaluationResult(com.ibm.cohort.cql.evaluation.CqlEvaluationResult) List(java.util.List) CqlEvaluator(com.ibm.cohort.cql.evaluation.CqlEvaluator) CqlVersionedIdentifier(com.ibm.cohort.cql.library.CqlVersionedIdentifier) Test(org.junit.Test)

Example 2 with CqlVersionedIdentifier

use of com.ibm.cohort.cql.library.CqlVersionedIdentifier 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 3 with CqlVersionedIdentifier

use of com.ibm.cohort.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testUOMEquivalence_demonstrateConversionOfBothSides.

@Test
public void testUOMEquivalence_demonstrateConversionOfBothSides() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1983-12-02");
    CqlEvaluator evaluator = setupTestFor(patient, "cql.uomequivalence");
    String expression = "UpConvert";
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("TestUOMCompare", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    // The safest thing to do is convert the left and right
    // values to a known, fixed unit
    expected.put(expression, true);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) 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 4 with CqlVersionedIdentifier

use of com.ibm.cohort.cql.library.CqlVersionedIdentifier 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)

Example 5 with CqlVersionedIdentifier

use of com.ibm.cohort.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.

the class CqlEvaluatorIntegrationTest method testPatientIsFemaleFalse.

@Test
public void testPatientIsFemaleFalse() throws Exception {
    Patient patient = getPatient("123", Enumerations.AdministrativeGender.MALE, null);
    CqlEvaluator evaluator = setupTestFor(patient, "cql.basic");
    String expression = "Female";
    CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
    Map<String, Object> expected = new HashMap<>();
    expected.put(expression, false);
    Assert.assertEquals(expected, actual.getExpressionResults());
}
Also used : HashMap(java.util.HashMap) Patient(org.hl7.fhir.r4.model.Patient) 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

CqlVersionedIdentifier (com.ibm.cohort.cql.library.CqlVersionedIdentifier)33 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)31 Test (org.junit.Test)31 Patient (org.hl7.fhir.r4.model.Patient)29 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)27 HashMap (java.util.HashMap)27 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)14 Date (java.util.Date)7 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)6 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)6 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)6 Observation (org.hl7.fhir.r4.model.Observation)6 DatetimeParameter (com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter)4 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)4 ClasspathCqlLibraryProvider (com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider)4 CqlTerminologyProvider (com.ibm.cohort.cql.terminology.CqlTerminologyProvider)4 TranslatingCqlLibraryProvider (com.ibm.cohort.cql.translation.TranslatingCqlLibraryProvider)4 Bundle (org.hl7.fhir.r4.model.Bundle)4 Condition (org.hl7.fhir.r4.model.Condition)4 Reference (org.hl7.fhir.r4.model.Reference)4