use of com.ibm.cohort.datarow.model.SimpleDataRow in project quality-measure-and-cohort-service by Alvearie.
the class DataRowDataProviderTest method testEvaluateSuccess.
@Test
public void testEvaluateSuccess() throws Exception {
CqlLibraryProvider backingProvider = new ClasspathCqlLibraryProvider("cql");
CqlToElmTranslator translator = new CqlToElmTranslator();
try (Reader r = new FileReader(new File("src/test/resources/modelinfo/mock-modelinfo-1.0.0.xml"))) {
translator.registerModelInfo(r);
}
CqlLibraryProvider libraryProvider = new TranslatingCqlLibraryProvider(backingProvider, translator);
CqlVersionedIdentifier topLevelLibraryIdentifier = new CqlVersionedIdentifier("SampleLibrary", "1.0.0");
CqlTerminologyProvider terminologyProvider = new UnsupportedTerminologyProvider();
Map<String, Object> row = new HashMap<>();
row.put("id", "123");
row.put("gender", "female");
row.put("birthDate", new DateTime(OffsetDateTime.now()));
Map<String, Iterable<Object>> data = new HashMap<>();
data.put("Patient", Arrays.asList(new SimpleDataRow(row)));
DataRowRetrieveProvider retrieveProvider = new DataRowRetrieveProvider(data, terminologyProvider);
CqlDataProvider dataProvider = new CompositeCqlDataProvider(new DataRowModelResolver(SimpleDataRow.class), retrieveProvider);
CqlEvaluator evaluator = new CqlEvaluator().setLibraryProvider(libraryProvider).setTerminologyProvider(terminologyProvider).setDataProvider(dataProvider).setCacheContexts(false);
CqlEvaluationResult result = evaluator.evaluate(topLevelLibraryIdentifier);
assertEquals(2, result.getExpressionResults().size());
Object perDefineResult = result.getExpressionResults().get("IsFemale");
assertEquals(Boolean.TRUE, perDefineResult);
}
use of com.ibm.cohort.datarow.model.SimpleDataRow in project quality-measure-and-cohort-service by Alvearie.
the class DataRowModelResolverTest method testResolveTypeIsType.
@Test
public void testResolveTypeIsType() {
DataRow row = new SimpleDataRow(Collections.emptyMap());
assertEquals(row.getClass(), resolver.resolveType(row));
}
use of com.ibm.cohort.datarow.model.SimpleDataRow in project quality-measure-and-cohort-service by Alvearie.
the class DataRowModelResolverTest method testResolvePathForMissingFieldIsNull.
@Test
public void testResolvePathForMissingFieldIsNull() {
DataRow row = new SimpleDataRow(Collections.emptyMap());
assertNull(resolver.resolvePath(row, String.valueOf("does-not-exist")));
}
use of com.ibm.cohort.datarow.model.SimpleDataRow in project quality-measure-and-cohort-service by Alvearie.
the class DataRowModelResolverTest method testInvalidObjectAsTypeNonStrict.
@Test
public void testInvalidObjectAsTypeNonStrict() {
DataRow row = new SimpleDataRow(Collections.emptyMap());
assertNull(resolver.as(row, String.class, false));
}
use of com.ibm.cohort.datarow.model.SimpleDataRow in project quality-measure-and-cohort-service by Alvearie.
the class DataRowModelResolverTest method testObjectAsTypeStrict.
@Test
public void testObjectAsTypeStrict() {
DataRow row = new SimpleDataRow(Collections.emptyMap());
assertTrue(resolver.as(row, DataRow.class, true) instanceof DataRow);
}
Aggregations