use of org.pmiops.workbench.cohortreview.util.PageRequest 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());
}
use of org.pmiops.workbench.cohortreview.util.PageRequest 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));
}
use of org.pmiops.workbench.cohortreview.util.PageRequest in project workbench by all-of-us.
the class ParticipantCohortStatusDaoTest method findAllStatusSorting.
@Test
public void findAllStatusSorting() throws Exception {
PageRequest pageRequest = new PageRequest(page, 2, SortOrder.ASC, ParticipantCohortStatusColumns.STATUS.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(2), CohortStatus.EXCLUDED);
expectedPCS1.setBirthDate(results.get(0).getBirthDate());
ParticipantCohortStatus 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));
pageRequest = new PageRequest(page, 2, SortOrder.DESC, ParticipantCohortStatusColumns.STATUS.toString());
results = participantCohortStatusDao.findAll(1L, Collections.<Filter>emptyList(), pageRequest);
assertEquals(2, results.size());
expectedPCS1 = createExpectedPCSWithConceptValues(new ParticipantCohortStatusKey().cohortReviewId(COHORT_REVIEW_ID).participantId(1), CohortStatus.INCLUDED);
expectedPCS1.setBirthDate(results.get(0).getBirthDate());
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));
}
use of org.pmiops.workbench.cohortreview.util.PageRequest in project workbench by all-of-us.
the class CohortReviewController method getParticipantCohortStatuses.
/**
* Get all participants for the specified cohortId and cdrVersionId. This endpoint does pagination
* based on page, pageSize, sortOrder and sortColumn.
*/
@Override
public ResponseEntity<org.pmiops.workbench.model.CohortReview> getParticipantCohortStatuses(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, PageFilterRequest request) {
CohortReview cohortReview = null;
Cohort cohort = cohortReviewService.findCohort(cohortId);
Workspace workspace = cohortReviewService.validateMatchingWorkspace(workspaceNamespace, workspaceId, cohort.getWorkspaceId(), WorkspaceAccessLevel.READER);
CdrVersionContext.setCdrVersion(workspace.getCdrVersion());
try {
cohortReview = cohortReviewService.findCohortReview(cohortId, cdrVersionId);
} catch (NotFoundException nfe) {
cohortReview = initializeCohortReview(cdrVersionId, cohort);
}
PageRequest pageRequest = createPageRequest(request);
List<Filter> filters = request.getFilters() == null ? Collections.<Filter>emptyList() : request.getFilters().getItems();
List<ParticipantCohortStatus> participantCohortStatuses = cohortReviewService.findAll(cohortReview.getCohortReviewId(), filters, pageRequest);
org.pmiops.workbench.model.CohortReview responseReview = TO_CLIENT_COHORTREVIEW.apply(cohortReview, pageRequest);
responseReview.setParticipantCohortStatuses(participantCohortStatuses.stream().map(TO_CLIENT_PARTICIPANT).collect(Collectors.toList()));
return ResponseEntity.ok(responseReview);
}
Aggregations