use of org.pmiops.workbench.db.model.ParticipantCohortStatusKey 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.db.model.ParticipantCohortStatusKey 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.db.model.ParticipantCohortStatusKey in project workbench by all-of-us.
the class CohortReviewController method createParticipantCohortStatusesList.
/**
* Helper method that builds a list of {@link ParticipantCohortStatus} from BigQuery results.
*
* @param cohortReviewId
* @param result
* @param rm
* @return
*/
private List<ParticipantCohortStatus> createParticipantCohortStatusesList(Long cohortReviewId, QueryResult result, Map<String, Integer> rm) {
List<ParticipantCohortStatus> participantCohortStatuses = new ArrayList<>();
for (List<FieldValue> row : result.iterateAll()) {
String birthDateTimeString = bigQueryService.getString(row, rm.get("birth_datetime"));
if (birthDateTimeString == null) {
throw new BigQueryException(500, "birth_datetime is null at position: " + rm.get("birth_datetime"));
}
java.util.Date birthDate = Date.from(Instant.ofEpochMilli(Double.valueOf(birthDateTimeString).longValue() * 1000));
participantCohortStatuses.add(new ParticipantCohortStatus().participantKey(new ParticipantCohortStatusKey(cohortReviewId, bigQueryService.getLong(row, rm.get("person_id")))).status(CohortStatus.NOT_REVIEWED).birthDate(new java.sql.Date(birthDate.getTime())).genderConceptId(bigQueryService.getLong(row, rm.get("gender_concept_id"))).raceConceptId(bigQueryService.getLong(row, rm.get("race_concept_id"))).ethnicityConceptId(bigQueryService.getLong(row, rm.get("ethnicity_concept_id"))));
}
return participantCohortStatuses;
}
use of org.pmiops.workbench.db.model.ParticipantCohortStatusKey in project workbench by all-of-us.
the class CohortMaterializationServiceTest method makeStatus.
private ParticipantCohortStatus makeStatus(long cohortReviewId, long participantId, CohortStatus status) {
ParticipantCohortStatusKey key = new ParticipantCohortStatusKey();
key.setCohortReviewId(cohortReviewId);
key.setParticipantId(participantId);
ParticipantCohortStatus result = new ParticipantCohortStatus();
result.setStatus(status);
result.setParticipantKey(key);
return result;
}
Aggregations