use of com.ibm.cohort.cql.provider.CqlLibrarySourceProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlToElmTranslatorTest method testTranslationWithIncludes.
@Test
public void testTranslationWithIncludes() throws Exception {
CqlLibraryProvider provider = new ClasspathCqlLibraryProvider("cql");
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("SampleLibrary").setVersion("1.0.0").setFormat(Format.CQL);
CqlLibrary primaryLibrary = provider.getLibrary(descriptor);
CqlLibrarySourceProvider sourceProvider = vid -> {
CqlLibraryDescriptor d = new CqlLibraryDescriptor().setLibraryId(vid.getId()).setVersion(vid.getVersion()).setFormat(Format.CQL);
return provider.getLibrary(d).getContentAsStream();
};
CqlToElmTranslator translator = new CqlToElmTranslator();
try (Reader modelInfoXML = new FileReader(new File("src/test/resources/modelinfo/mock-modelinfo-1.0.0.xml"))) {
translator.registerModelInfo(modelInfoXML);
}
CqlTranslationResult result = translator.translate(primaryLibrary, sourceProvider);
assertEquals(1, result.getDependencies().size());
}
use of com.ibm.cohort.cql.provider.CqlLibrarySourceProvider in project quality-measure-and-cohort-service by Alvearie.
the class R4TranslatingLibraryLoader method translateLibrary.
private String translateLibrary(String content, VersionedIdentifier libraryIdentifier) {
LibraryResolutionProvider<org.hl7.fhir.r4.model.Library> libraryResolutionProvider = new ResolverLibraryResolutionProvider<>(resolver);
LibrarySourceProvider<org.hl7.fhir.r4.model.Library, Attachment> librarySourceProvider = new LibrarySourceProvider<>(libraryResolutionProvider, org.hl7.fhir.r4.model.Library::getContent, Attachment::getContentType, Attachment::getData);
CqlLibrarySourceProvider cqlLibrarySourceProvider = new SourceProviderBasedCqlLibrarySourceProvider(librarySourceProvider);
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setFormat(Format.CQL).setLibraryId(libraryIdentifier.getId()).setVersion(libraryIdentifier.getVersion());
CqlLibrary library = new CqlLibrary().setDescriptor(descriptor).setContent(content);
return translator.translate(library, cqlLibrarySourceProvider).getMainLibrary().getContent();
}
use of com.ibm.cohort.cql.provider.CqlLibrarySourceProvider in project quality-measure-and-cohort-service by Alvearie.
the class CqlToElmTranslatorTest method testTranslationWithErrors.
@Test
public void testTranslationWithErrors() {
CqlLibraryDescriptor descriptor = new CqlLibraryDescriptor().setLibraryId("GobbledyGook").setVersion("1.0.0").setFormat(Format.CQL);
CqlLibrary primaryLibrary = new CqlLibrary().setDescriptor(descriptor).setContent("GobbledyGook");
CqlLibrarySourceProvider sourceProvider = vid -> primaryLibrary.getContentAsStream();
CqlToElmTranslator translator = new CqlToElmTranslator();
assertThrows(CqlTranslatorException.class, () -> translator.translate(primaryLibrary, sourceProvider));
}
Aggregations