Search in sources :

Example 11 with MaterializeCohortResponse

use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.

the class CohortMaterializationServiceTest method testMaterializeCohortWithReviewNotReviewedAndNeedsFurtherReviewFilter.

@Test
public void testMaterializeCohortWithReviewNotReviewedAndNeedsFurtherReviewFilter() {
    MaterializeCohortRequest request = makeRequest(2);
    request.setStatusFilter(ImmutableList.of(CohortStatus.NEEDS_FURTHER_REVIEW, CohortStatus.NOT_REVIEWED));
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(cohortReview, SearchRequests.allGenders(), request);
    assertPersonIds(response, 102246L);
    assertThat(response.getNextPageToken()).isNull();
}
Also used : MaterializeCohortRequest(org.pmiops.workbench.model.MaterializeCohortRequest) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 12 with MaterializeCohortResponse

use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.

the class CohortMaterializationServiceTest method testMaterializeCohortObservationFilterObservationDateLessThanOrEqualTo.

@Test
public void testMaterializeCohortObservationFilterObservationDateLessThanOrEqualTo() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("observation");
    tableQuery.setColumns(ImmutableList.of("observation_id"));
    ColumnFilter columnFilter = new ColumnFilter();
    columnFilter.setColumnName("observation_date");
    columnFilter.setOperator(Operator.LESS_THAN_OR_EQUAL_TO);
    columnFilter.setValueDate("2009-12-03");
    tableQuery.addFiltersItem(ImmutableList.of(columnFilter));
    FieldSet fieldSet = new FieldSet();
    fieldSet.setTableQuery(tableQuery);
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.males(), makeRequest(fieldSet, 1000));
    assertResults(response, ImmutableMap.of("observation_id", 5L));
    assertThat(response.getNextPageToken()).isNull();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) ColumnFilter(org.pmiops.workbench.model.ColumnFilter) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 13 with MaterializeCohortResponse

use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.

the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithStringAndPersonIdFilter.

@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithStringAndPersonIdFilter() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("person");
    tableQuery.setColumns(ImmutableList.of("person_id"));
    ColumnFilter filter1 = new ColumnFilter();
    filter1.setColumnName("person_source_value");
    filter1.setValue("psv");
    ColumnFilter filter2 = new ColumnFilter();
    filter2.setColumnName("person_id");
    filter2.setValueNumber(new BigDecimal(2L));
    tableQuery.addFiltersItem(ImmutableList.of(filter1, filter2));
    FieldSet fieldSet = new FieldSet();
    fieldSet.setTableQuery(tableQuery);
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.allGenders(), makeRequest(fieldSet, 1000));
    assertPersonIds(response, 2L);
    assertThat(response.getNextPageToken()).isNull();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) ColumnFilter(org.pmiops.workbench.model.ColumnFilter) BigDecimal(java.math.BigDecimal) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 14 with MaterializeCohortResponse

use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.

the class CohortMaterializationServiceTest method testMaterializeCohortObservationFilterObservationDatetimeLessThan.

@Test
public void testMaterializeCohortObservationFilterObservationDatetimeLessThan() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("observation");
    tableQuery.setColumns(ImmutableList.of("observation_id"));
    ColumnFilter columnFilter = new ColumnFilter();
    columnFilter.setColumnName("observation_datetime");
    columnFilter.setOperator(Operator.LESS_THAN);
    columnFilter.setValueDate("2009-12-03 05:00:01 UTC");
    tableQuery.addFiltersItem(ImmutableList.of(columnFilter));
    FieldSet fieldSet = new FieldSet();
    fieldSet.setTableQuery(tableQuery);
    MaterializeCohortResponse response = cohortMaterializationService.materializeCohort(null, SearchRequests.males(), makeRequest(fieldSet, 1000));
    assertResults(response, ImmutableMap.of("observation_id", 5L));
    assertThat(response.getNextPageToken()).isNull();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) ColumnFilter(org.pmiops.workbench.model.ColumnFilter) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 15 with MaterializeCohortResponse

use of org.pmiops.workbench.model.MaterializeCohortResponse in project workbench by all-of-us.

the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithStringNonMatchFilter.

@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithStringNonMatchFilter() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("person");
    tableQuery.setColumns(ImmutableList.of("person_id"));
    ColumnFilter filter = new ColumnFilter();
    filter.setColumnName("person_source_value");
    filter.setValue("foobar");
    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();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) ColumnFilter(org.pmiops.workbench.model.ColumnFilter) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Aggregations

MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)56 Test (org.junit.Test)52 BigQueryBaseTest (org.pmiops.workbench.api.BigQueryBaseTest)48 FieldSet (org.pmiops.workbench.model.FieldSet)36 TableQuery (org.pmiops.workbench.model.TableQuery)35 ColumnFilter (org.pmiops.workbench.model.ColumnFilter)29 MaterializeCohortRequest (org.pmiops.workbench.model.MaterializeCohortRequest)17 BigDecimal (java.math.BigDecimal)8 Cohort (org.pmiops.workbench.model.Cohort)6 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)4 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)3 CohortReview (org.pmiops.workbench.db.model.CohortReview)2 CohortStatus (org.pmiops.workbench.model.CohortStatus)2 PaginationToken (org.pmiops.workbench.utils.PaginationToken)2 BigQueryException (com.google.cloud.bigquery.BigQueryException)1 FieldValue (com.google.cloud.bigquery.FieldValue)1 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)1 QueryResult (com.google.cloud.bigquery.QueryResult)1 Gson (com.google.gson.Gson)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1