use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetYearOfBirthOrPersonIdFilters.
@Test
public void testMaterializeCohortPersonFieldSetYearOfBirthOrPersonIdFilters() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("person");
tableQuery.setColumns(ImmutableList.of("person_id"));
ColumnFilter filter1 = new ColumnFilter();
filter1.setColumnName("year_of_birth");
filter1.setValueNumber(new BigDecimal(1980));
ColumnFilter filter2 = new ColumnFilter();
filter2.setColumnName("person_id");
filter2.setValueNumber(new BigDecimal(2L));
tableQuery.addFiltersItem(ImmutableList.of(filter1));
tableQuery.addFiltersItem(ImmutableList.of(filter2));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
assertPersonIds(response, 1L, 2L);
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewNullStatusFilter.
@Test
public void testMaterializeCohortWithReviewNullStatusFilter() {
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), makeRequest(2));
// With a null status filter, everyone is returned.
assertPersonIds(response, 1L, 2L);
assertThat(response.getNextPageToken()).isNotNull();
MaterializeCohortRequest request = makeRequest(2);
request.setPageToken(response.getNextPageToken());
MaterializeCohortResponse response2 = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), request);
assertPersonIds(response2, 102246L);
assertThat(response2.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithStringLikeFilterNoMatch.
@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithStringLikeFilterNoMatch() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("person");
tableQuery.setColumns(ImmutableList.of("person_id"));
ColumnFilter filter = new ColumnFilter();
filter.setColumnName("person_source_value");
filter.setOperator(Operator.LIKE);
filter.setValue("p");
tableQuery.addFiltersItem(ImmutableList.of(filter));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
assertPersonIds(response);
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortObservationFieldSetAllColumns.
@Test
public void testMaterializeCohortObservationFieldSetAllColumns() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("observation");
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.males(), makeRequest(fieldSet, 1000));
ImmutableMap<String, Object> p1Map = ImmutableMap.<String, Object>builder().put("observation_id", 5L).put("person_id", 1L).put("observation_concept_id", 5L).put("observation_date", "2009-12-03").put("observation_datetime", "2009-12-03 05:00:00 UTC").put("observation_type_concept_id", 5L).put("value_as_number", 5.0).put("value_as_string", "5").put("value_as_concept_id", 5L).put("qualifier_concept_id", 5L).put("unit_concept_id", 5L).put("provider_id", 5L).put("visit_occurrence_id", 5L).put("observation_source_value", "5").put("observation_source_concept_id", 5L).put("unit_source_value", "5").put("qualifier_source_value", "5").build();
assertResults(response, p1Map);
assertThat(response.getNextPageToken()).isNull();
}
use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.
the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetOrderByGenderConceptId.
@Test
public void testMaterializeCohortPersonFieldSetOrderByGenderConceptId() {
TableQuery tableQuery = new TableQuery();
tableQuery.setTableName("person");
tableQuery.setColumns(ImmutableList.of("person_id", "gender_concept_id"));
tableQuery.setOrderBy(ImmutableList.of("gender_concept_id"));
FieldSet fieldSet = new FieldSet();
fieldSet.setTableQuery(tableQuery);
MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
ImmutableMap<String, Object> p1Map = ImmutableMap.of("person_id", 1L, "gender_concept_id", 8507L);
ImmutableMap<String, Object> p2Map = ImmutableMap.of("person_id", 2L, "gender_concept_id", 2L);
ImmutableMap<String, Object> p3Map = ImmutableMap.of("person_id", 102246L, "gender_concept_id", 8532L);
assertResults(response, p2Map, p1Map, p3Map);
assertThat(response.getNextPageToken()).isNull();
}
Aggregations