Search in sources :

Example 11 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllPaging.

@Test
public void findAllPaging() throws Exception {
    PageRequest pageRequest = new PageRequest(page, 1, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(1, results.size());
    ParticipantCohortStatus expectedPCS = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    expectedPCS.setBirthDate(results.get(0).getBirthDate());
    assertEquals(expectedPCS, results.get(0));
    pageRequest = new PageRequest(1, 1, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(1, results.size());
    expectedPCS = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(2), CohortStatus.EXCLUDED);
    expectedPCS.setBirthDate(results.get(0).getBirthDate());
    assertEquals(expectedPCS, results.get(0));
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) Filter(org.pmiops.workbench.model.Filter) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 12 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllNoSearchCriteria.

@Test
public void findAllNoSearchCriteria() throws Exception {
    PageRequest pageRequest = new PageRequest(page, pageSize, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(2, results.size());
    ParticipantCohortStatus participant1 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    participant1.setBirthDate(results.get(0).getBirthDate());
    ParticipantCohortStatus participant2 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.EXCLUDED);
    participant2.setBirthDate(results.get(1).getBirthDate());
    assertEquals(participant1, results.get(0));
    assertEquals(participant2, results.get(1));
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 13 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllSearchCriteriaEqual.

@Test
public void findAllSearchCriteriaEqual() throws Exception {
    PageRequest pageRequest = new PageRequest(page, pageSize, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    List<Filter> filters = new ArrayList<>();
    filters.add(new Filter().property(ParticipantCohortStatusColumns.PARTICIPANTID).operator(Operator.EQUAL).values(Arrays.asList("1")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.STATUS).operator(Operator.EQUAL).values(Arrays.asList(CohortStatus.INCLUDED.toString())));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.BIRTHDATE).operator(Operator.EQUAL).values(Arrays.asList(new Date(System.currentTimeMillis()).toString())));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.GENDER).operator(Operator.EQUAL).values(Arrays.asList("MALE")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.RACE).operator(Operator.EQUAL).values(Arrays.asList("Asian")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.ETHNICITY).operator(Operator.EQUAL).values(Arrays.asList("Not Hispanic")));
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, filters, pageRequest);
    assertEquals(1, results.size());
    ParticipantCohortStatus expectedPCS = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    expectedPCS.setBirthDate(results.get(0).getBirthDate());
    assertEquals(expectedPCS, results.get(0));
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) Filter(org.pmiops.workbench.model.Filter) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) ArrayList(java.util.ArrayList) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) Date(java.sql.Date) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 14 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllNoMatchingConcept.

@Test
public void findAllNoMatchingConcept() throws Exception {
    jdbcTemplate.execute("delete from concept");
    PageRequest pageRequest = new PageRequest(page, pageSize, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(2, results.size());
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Example 15 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllParticipantIdSorting.

@Test
public void findAllParticipantIdSorting() throws Exception {
    PageRequest pageRequest = new PageRequest(page, 2, SortOrder.ASC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(2, results.size());
    ParticipantCohortStatus expectedPCS1 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    expectedPCS1.setBirthDate(results.get(0).getBirthDate());
    ParticipantCohortStatus expectedPCS2 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(2), CohortStatus.EXCLUDED);
    expectedPCS2.setBirthDate(results.get(1).getBirthDate());
    assertEquals(expectedPCS1, results.get(0));
    assertEquals(expectedPCS2, results.get(1));
    pageRequest = new PageRequest(page, 2, SortOrder.DESC, ParticipantCohortStatusColumns.PARTICIPANTID.toString());
    results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
    assertEquals(2, results.size());
    expectedPCS1 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(2), CohortStatus.EXCLUDED);
    expectedPCS1.setBirthDate(results.get(0).getBirthDate());
    expectedPCS2 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    expectedPCS2.setBirthDate(results.get(1).getBirthDate());
    assertEquals(expectedPCS1, results.get(0));
    assertEquals(expectedPCS2, results.get(1));
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) Filter(org.pmiops.workbench.model.Filter) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest) Test(org.junit.Test)

Aggregations

ParticipantCohortStatus (org.pmiops.workbench.db.model.ParticipantCohortStatus)23 ParticipantCohortStatusKey (org.pmiops.workbench.db.model.ParticipantCohortStatusKey)14 Test (org.junit.Test)12 PageRequest (org.pmiops.workbench.cohortreview.util.PageRequest)9 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)9 Date (java.sql.Date)6 CohortReview (org.pmiops.workbench.db.model.CohortReview)6 Workspace (org.pmiops.workbench.db.model.Workspace)6 Filter (org.pmiops.workbench.model.Filter)5 ArrayList (java.util.ArrayList)4 Cohort (org.pmiops.workbench.db.model.Cohort)4 org.pmiops.workbench.model (org.pmiops.workbench.model)3 Timestamp (java.sql.Timestamp)2 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)2 BigQueryException (com.google.cloud.bigquery.BigQueryException)1 FieldValue (com.google.cloud.bigquery.FieldValue)1 QueryResult (com.google.cloud.bigquery.QueryResult)1 Gson (com.google.gson.Gson)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1