Search in sources :

Example 51 with Expression

use of org.hl7.elm.r1.Expression in project cqf-ruler by DBCG.

the class MeasureBuilder method addSDE.

public MeasureBuilder addSDE(String sdeId, String expression) {
    MeasureSupplementalDataComponent sde = measure.getSupplementalDataFirstRep();
    sde.getCode().setText(sdeId);
    sde.getCriteria().setLanguage("text/cql").setExpression(expression);
    return this;
}
Also used : MeasureSupplementalDataComponent(org.hl7.fhir.r4.model.Measure.MeasureSupplementalDataComponent)

Example 52 with Expression

use of org.hl7.elm.r1.Expression in project cqf-ruler by DBCG.

the class MeasureBuilder method addPopulation.

private MeasureBuilder addPopulation(MeasurePopulationType measurePopulationType, String expression) {
    MeasureGroupPopulationComponent mgpc = this.measure.getGroupFirstRep().addPopulation();
    mgpc.getCode().getCodingFirstRep().setCode(measurePopulationType.toCode());
    mgpc.setCriteria(expression);
    return this;
}
Also used : MeasureGroupPopulationComponent(org.hl7.fhir.dstu3.model.Measure.MeasureGroupPopulationComponent)

Example 53 with Expression

use of org.hl7.elm.r1.Expression in project cqf-ruler by DBCG.

the class CqlExecutionProviderIT method testDataBundleCqlExecutionProviderWithSubject.

@Test
public void testDataBundleCqlExecutionProviderWithSubject() throws Exception {
    Parameters params = new Parameters();
    Parameters libraryParameter = new Parameters();
    params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
    libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
    libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
    params.addParameter().setName("library").setResource(libraryParameter);
    params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
    loadResource(packagePrefix + "SimpleDstu3Library.json");
    loadResource(packagePrefix + "SimplePatient.json");
    Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
    params.addParameter().setName("data").setResource(data);
    params.addParameter().setName("useServerData").setValue(new BooleanType(false));
    Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
    assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
    assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
    assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
    logger.debug("Results: ", results);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 54 with Expression

use of org.hl7.elm.r1.Expression in project cqf-ruler by DBCG.

the class CqlExecutionProviderIT method testDataBundleCqlExecutionProvider.

@Test
public void testDataBundleCqlExecutionProvider() throws Exception {
    Parameters params = new Parameters();
    Parameters libraryParameter = new Parameters();
    libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
    libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
    params.addParameter().setName("library").setResource(libraryParameter);
    params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"observationRetrieve\""));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
    loadResource(packagePrefix + "SimpleDstu3Library.json");
    loadResource(packagePrefix + "SimplePatient.json");
    Bundle data = (Bundle) loadResource(packagePrefix + "SimpleDataBundle.json");
    params.addParameter().setName("data").setResource(data);
    params.addParameter().setName("useServerData").setValue(new BooleanType(false));
    Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
    assertTrue(results.getParameter().get(0).getResource() instanceof Bundle);
    assertTrue(((Bundle) results.getParameter().get(0).getResource()).getEntry().get(0).getResource() instanceof Observation);
    assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("List"));
    logger.debug("Results: ", results);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Bundle(org.hl7.fhir.dstu3.model.Bundle) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Observation(org.hl7.fhir.dstu3.model.Observation) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Example 55 with Expression

use of org.hl7.elm.r1.Expression in project cqf-ruler by DBCG.

the class CqlExecutionProviderIT method testReferencedLibraryCqlExecutionProvider.

@Test
public void testReferencedLibraryCqlExecutionProvider() throws Exception {
    Parameters params = new Parameters();
    params.addParameter().setName("subject").setValue(new StringType("Patient/SimplePatient"));
    Parameters libraryParameter = new Parameters();
    libraryParameter.addParameter().setName("url").setValue(new StringType(this.getClient().getServerBase() + "Library/SimpleDstu3Library"));
    libraryParameter.addParameter().setName("name").setValue(new StringType("SimpleDstu3Library"));
    params.addParameter().setName("library").setResource(libraryParameter);
    params.addParameter().setName("expression").setValue(new StringType("SimpleDstu3Library.\"simpleBooleanExpression\""));
    String packagePrefix = "org/opencds/cqf/ruler/cpg/dstu3/provider/";
    loadResource(packagePrefix + "SimpleDstu3Library.json");
    loadResource(packagePrefix + "SimplePatient.json");
    Parameters results = getClient().operation().onServer().named("$cql").withParameters(params).execute();
    assertTrue(results.getParameter().get(0).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(0).getValue()).asStringValue().equals("true"));
    assertTrue(results.getParameter().get(1).getValue() instanceof StringType);
    assertTrue(((StringType) results.getParameter().get(1).getValue()).asStringValue().equals("Boolean"));
    logger.debug("Results: ", results);
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters) StringType(org.hl7.fhir.dstu3.model.StringType) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Aggregations

Test (org.junit.Test)102 Expression (org.apache.commons.jexl2.Expression)98 TermWeightPosition (datawave.ingest.protobuf.TermWeightPosition)66 Zone (datawave.query.jexl.functions.TermFrequencyList.Zone)66 Test (org.junit.jupiter.api.Test)60 ArrayList (java.util.ArrayList)36 HashMap (java.util.HashMap)35 Patient (org.hl7.fhir.r4.model.Patient)29 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)28 CqlVersionedIdentifier (com.ibm.cohort.cql.library.CqlVersionedIdentifier)28 Expression (io.atlasmap.v2.Expression)26 JexlContext (org.apache.commons.jexl2.JexlContext)26 Expression (org.hl7.elm.r1.Expression)26 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)25 CqlEvaluationResult (com.ibm.cohort.cql.evaluation.CqlEvaluationResult)24 JexlEngine (org.apache.commons.jexl2.JexlEngine)22 MapContext (org.apache.commons.jexl2.MapContext)22 FHIRException (org.hl7.fhir.exceptions.FHIRException)19 FhirServerConfig (com.ibm.cohort.fhir.client.config.FhirServerConfig)16 Coding (org.hl7.fhir.r4.model.Coding)15