Search in sources :

Example 26 with FieldSet

use of org.pmiops.workbench.model.FieldSet 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();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 27 with FieldSet

use of org.pmiops.workbench.model.FieldSet 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();
}
Also used : FieldSet(org.pmiops.workbench.model.FieldSet) TableQuery(org.pmiops.workbench.model.TableQuery) MaterializeCohortResponse(org.pmiops.workbench.model.MaterializeCohortResponse) BigQueryBaseTest(org.pmiops.workbench.api.BigQueryBaseTest) Test(org.junit.Test)

Example 28 with FieldSet

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

the class CohortMaterializationServiceTest method testMaterializeCohortObservationFilterObservationDatetimeGreaterThanOrEqualTo.

@Test
public void testMaterializeCohortObservationFilterObservationDatetimeGreaterThanOrEqualTo() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("observation");
    tableQuery.setColumns(ImmutableList.of("observation_id"));
    ColumnFilter columnFilter = new ColumnFilter();
    columnFilter.setColumnName("observation_datetime");
    columnFilter.setOperator(Operator.GREATER_THAN_OR_EQUAL_TO);
    columnFilter.setValueDate("2009-12-03 05:00:00 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 29 with FieldSet

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

the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithNumberLessThanOrEqualToFilter.

@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithNumberLessThanOrEqualToFilter() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("person");
    tableQuery.setColumns(ImmutableList.of("person_id"));
    ColumnFilter filter = new ColumnFilter();
    filter.setColumnName("person_id");
    filter.setOperator(Operator.LESS_THAN_OR_EQUAL_TO);
    filter.setValueNumber(new BigDecimal(2L));
    tableQuery.addFiltersItem(ImmutableList.of(filter));
    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();
}
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 30 with FieldSet

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

the class CohortMaterializationServiceTest method testMaterializeCohortPersonFieldSetPersonIdWithNumbersFilter.

@Test
public void testMaterializeCohortPersonFieldSetPersonIdWithNumbersFilter() {
    TableQuery tableQuery = new TableQuery();
    tableQuery.setTableName("person");
    tableQuery.setColumns(ImmutableList.of("person_id"));
    ColumnFilter filter = new ColumnFilter();
    filter.setColumnName("person_id");
    filter.setOperator(Operator.IN);
    filter.setValueNumbers(ImmutableList.of(new BigDecimal(1L), new BigDecimal(2L)));
    tableQuery.addFiltersItem(ImmutableList.of(filter));
    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();
}
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)

Aggregations

FieldSet (org.pmiops.workbench.model.FieldSet)36 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)36 Test (org.junit.Test)35 BigQueryBaseTest (org.pmiops.workbench.api.BigQueryBaseTest)35 TableQuery (org.pmiops.workbench.model.TableQuery)35 ColumnFilter (org.pmiops.workbench.model.ColumnFilter)29 BigDecimal (java.math.BigDecimal)8 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 ArrayList (java.util.ArrayList)1 ParticipantCriteria (org.pmiops.workbench.cohortbuilder.ParticipantCriteria)1 TableQueryAndConfig (org.pmiops.workbench.cohortbuilder.TableQueryAndConfig)1 ParticipantIdAndCohortStatus (org.pmiops.workbench.db.model.ParticipantIdAndCohortStatus)1 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)1 ForbiddenException (org.pmiops.workbench.exceptions.ForbiddenException)1 ServerErrorException (org.pmiops.workbench.exceptions.ServerErrorException)1 ServerUnavailableException (org.pmiops.workbench.exceptions.ServerUnavailableException)1 CohortStatus (org.pmiops.workbench.model.CohortStatus)1