Search in sources :

Example 26 with CqlLibraryProvider

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

the class CqlTranslationIntegrationTest method multipleFilesInZip__translatedSuccessfully.

@Test
public void multipleFilesInZip__translatedSuccessfully() throws Exception {
    Path zipFile = Paths.get("src/test/resources/cql/multiple-files/packaged-cqls.zip");
    MapCqlLibraryProviderFactory providerFactory = new MapCqlLibraryProviderFactory();
    CqlLibraryProvider backingLibraryProvider = providerFactory.fromZipFile(zipFile);
    runMultipleFilesTest(backingLibraryProvider);
}
Also used : Path(java.nio.file.Path) MapCqlLibraryProviderFactory(com.ibm.cohort.cql.library.MapCqlLibraryProviderFactory) ClasspathCqlLibraryProvider(com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider) CqlLibraryProvider(com.ibm.cohort.cql.library.CqlLibraryProvider) Test(org.junit.Test)

Example 27 with CqlLibraryProvider

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

the class CqlTranslationIntegrationTest method errorCausedByInvalidContent.

@Test
public void errorCausedByInvalidContent() {
    CqlLibraryProvider backingLibraryProvider = cqlResourceDescriptor -> {
        CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("Junk").setLibraryId("1.0.0").setFormat(Format.CQL);
        String content = "this is a junk cql";
        return new CqlLibrary().setContent(content).setDescriptor(descriptor);
    };
    CqlToElmTranslator translator = new CqlToElmTranslator();
    CqlLibraryProvider translatingLibraryProvider = new TranslatingCqlLibraryProvider(backingLibraryProvider, translator, true);
    CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("Junk").setLibraryId("1.0.0").setFormat(Format.ELM);
    boolean failed = false;
    try {
        translatingLibraryProvider.getLibrary(descriptor);
    } catch (Exception e) {
        failed = true;
        Assert.assertTrue("Unexpected exception message: " + e.getMessage(), e.getMessage().startsWith("There were errors during cql translation:"));
    }
    if (!failed) {
        Assert.fail("Did not fail translation");
    }
}
Also used : ClasspathCqlLibraryProvider(com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider) Arrays(java.util.Arrays) MapCqlLibraryProviderFactory(com.ibm.cohort.cql.library.MapCqlLibraryProviderFactory) CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) CqlLibraryProvider(com.ibm.cohort.cql.library.CqlLibraryProvider) Test(org.junit.Test) Format(com.ibm.cohort.cql.library.Format) CqlLibraryDescriptor(com.ibm.cohort.cql.library.CqlLibraryDescriptor) LibraryLoader(org.opencds.cqf.cql.engine.execution.LibraryLoader) ProviderBasedLibraryLoader(com.ibm.cohort.cql.library.ProviderBasedLibraryLoader) List(java.util.List) VersionedIdentifier(org.cqframework.cql.elm.execution.VersionedIdentifier) Paths(java.nio.file.Paths) Library(org.cqframework.cql.elm.execution.Library) Assert(org.junit.Assert) Path(java.nio.file.Path) CqlLibrary(com.ibm.cohort.cql.library.CqlLibrary) ClasspathCqlLibraryProvider(com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider) CqlLibraryProvider(com.ibm.cohort.cql.library.CqlLibraryProvider) CqlLibraryDescriptor(com.ibm.cohort.cql.library.CqlLibraryDescriptor) Test(org.junit.Test)

Aggregations

CqlLibraryProvider (com.ibm.cohort.cql.library.CqlLibraryProvider)27 ClasspathCqlLibraryProvider (com.ibm.cohort.cql.library.ClasspathCqlLibraryProvider)23 TranslatingCqlLibraryProvider (com.ibm.cohort.cql.translation.TranslatingCqlLibraryProvider)18 Test (org.junit.Test)15 CqlToElmTranslator (com.ibm.cohort.cql.translation.CqlToElmTranslator)13 CqlLibraryDescriptor (com.ibm.cohort.cql.library.CqlLibraryDescriptor)11 PriorityCqlLibraryProvider (com.ibm.cohort.cql.library.PriorityCqlLibraryProvider)10 CqlTerminologyProvider (com.ibm.cohort.cql.terminology.CqlTerminologyProvider)10 CqlLibrary (com.ibm.cohort.cql.library.CqlLibrary)9 HashMap (java.util.HashMap)9 Path (java.nio.file.Path)8 CqlDataProvider (com.ibm.cohort.cql.data.CqlDataProvider)7 MapCqlLibraryProviderFactory (com.ibm.cohort.cql.library.MapCqlLibraryProviderFactory)7 File (java.io.File)4 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 CqlEvaluationRequests (com.ibm.cohort.cql.evaluation.CqlEvaluationRequests)3 CqlEvaluator (com.ibm.cohort.cql.evaluation.CqlEvaluator)3 IntegerParameter (com.ibm.cohort.cql.evaluation.parameters.IntegerParameter)3 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)3