Search in sources :

Example 6 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findAllSearchCriteriaIn.

@Test
public void findAllSearchCriteriaIn() 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.IN).values(Arrays.asList("1", "2")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.STATUS).operator(Operator.IN).values(Arrays.asList(CohortStatus.INCLUDED.toString(), CohortStatus.EXCLUDED.toString())));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.BIRTHDATE).operator(Operator.IN).values(Arrays.asList(new Date(System.currentTimeMillis()).toString())));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.GENDER).operator(Operator.IN).values(Arrays.asList("MALE", "FEMALE")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.RACE).operator(Operator.IN).values(Arrays.asList("Asian", "White")));
    filters.add(new Filter().property(ParticipantCohortStatusColumns.ETHNICITY).operator(Operator.IN).values(Arrays.asList("Not Hispanic", "Hispanic")));
    List<ParticipantCohortStatus> results = participantCohortStatusDao.findAll(1L, filters, 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(0).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) 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 7 with ParticipantCohortStatus

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

the class ParticipantCohortStatusDaoTest method findByParticipantKeyCohortReviewIdAndParticipantKeyParticipantId.

@Test
public void findByParticipantKeyCohortReviewIdAndParticipantKeyParticipantId() throws Exception {
    ParticipantCohortStatus participant1 = createExpectedPCS(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
    ParticipantCohortStatus actualParticipant = participantCohortStatusDao.findByParticipantKey_CohortReviewIdAndParticipantKey_ParticipantId(COHORT_REVIEW_ID, participant1.getParticipantKey().getParticipantId());
    participant1.setBirthDate(actualParticipant.getBirthDate());
    assertEquals(participant1, actualParticipant);
}
Also used : 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 8 with ParticipantCohortStatus

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

the class CohortReviewControllerTest method createParticipantCohortStatus.

private ParticipantCohortStatus createParticipantCohortStatus(long cohortReviewId, long participantId, CohortStatus cohortStatus) {
    ParticipantCohortStatusKey key = new ParticipantCohortStatusKey().cohortReviewId(cohortReviewId).participantId(participantId);
    final Date dob = new Date(System.currentTimeMillis());
    return new ParticipantCohortStatus().participantKey(key).status(cohortStatus).birthDate(dob).ethnicityConceptId(1L).genderConceptId(1L).raceConceptId(1L);
}
Also used : ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) Date(java.sql.Date)

Example 9 with ParticipantCohortStatus

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

the class CohortReviewControllerTest method assertCreateParticipantCohortAnnotation.

private void assertCreateParticipantCohortAnnotation(ParticipantCohortAnnotation request, AnnotationType annotationType) throws Exception {
    ParticipantCohortStatusKey key = new ParticipantCohortStatusKey().cohortReviewId(cohortReviewId).participantId(participantId);
    ParticipantCohortStatus participantCohortStatus = new ParticipantCohortStatus().participantKey(key);
    CohortAnnotationDefinition cohortAnnotationDefinition = new CohortAnnotationDefinition().annotationType(annotationType);
    if (request.getAnnotationValueEnum() != null) {
        CohortAnnotationEnumValue cohortAnnotationEnumValue = new CohortAnnotationEnumValue().name(request.getAnnotationValueEnum());
        cohortAnnotationDefinition.setEnumValues(new TreeSet(Arrays.asList(cohortAnnotationEnumValue)));
    }
    when(cohortReviewService.findCohort(cohortId)).thenReturn(createCohort(cohortId, workspaceId, null));
    when(cohortReviewService.validateMatchingWorkspace(namespace, name, workspaceId, WorkspaceAccessLevel.WRITER)).thenReturn(new Workspace());
    when(cohortReviewService.findCohortReview(cohortId, cdrVersionId)).thenReturn(createCohortReview(0, cohortId, cohortReviewId, cdrVersionId, null));
    when(cohortReviewService.saveParticipantCohortAnnotation(isA(Long.class), isA(org.pmiops.workbench.db.model.ParticipantCohortAnnotation.class))).thenReturn(createParticipantCohortAnnotation(request));
    ParticipantCohortAnnotation response = reviewController.createParticipantCohortAnnotation(namespace, name, cohortId, cdrVersionId, participantId, request).getBody();
    assertEquals(request, response);
    verify(cohortReviewService, atLeastOnce()).findCohort(cohortId);
    verify(cohortReviewService, atLeastOnce()).validateMatchingWorkspace(namespace, name, workspaceId, WorkspaceAccessLevel.WRITER);
    verify(cohortReviewService, atLeastOnce()).findCohortReview(cohortId, cdrVersionId);
    verify(cohortReviewService, atLeastOnce()).saveParticipantCohortAnnotation(isA(Long.class), isA(org.pmiops.workbench.db.model.ParticipantCohortAnnotation.class));
    verifyNoMoreMockInteractions();
}
Also used : CohortAnnotationDefinition(org.pmiops.workbench.db.model.CohortAnnotationDefinition) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) TreeSet(java.util.TreeSet) ParticipantCohortStatusKey(org.pmiops.workbench.db.model.ParticipantCohortStatusKey) CohortAnnotationEnumValue(org.pmiops.workbench.db.model.CohortAnnotationEnumValue) Workspace(org.pmiops.workbench.db.model.Workspace)

Example 10 with ParticipantCohortStatus

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

the class CohortReviewServiceImplTest method saveParticipantCohortStatus.

@Test
public void saveParticipantCohortStatus() throws Exception {
    ParticipantCohortStatus pcs = new ParticipantCohortStatus();
    when(participantCohortStatusDao.save(pcs)).thenReturn(pcs);
    ParticipantCohortStatus actualPcs = cohortReviewService.saveParticipantCohortStatus(pcs);
    assertEquals(pcs, actualPcs);
    verify(participantCohortStatusDao).save(pcs);
    verifyNoMoreMockInteractions();
}
Also used : ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) 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