Search in sources :

Example 16 with CohortReview

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

the class CohortReviewController method updateParticipantCohortStatus.

@Override
public ResponseEntity<org.pmiops.workbench.model.ParticipantCohortStatus> updateParticipantCohortStatus(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId, ModifyCohortStatusRequest cohortStatusRequest) {
    CohortReview cohortReview = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.WRITER);
    ParticipantCohortStatus participantCohortStatus = cohortReviewService.findParticipantCohortStatus(cohortReview.getCohortReviewId(), participantId);
    participantCohortStatus.setStatus(cohortStatusRequest.getStatus());
    cohortReviewService.saveParticipantCohortStatus(participantCohortStatus);
    lookupGenderRaceEthnicityValues(Arrays.asList(participantCohortStatus));
    cohortReview.lastModifiedTime(new Timestamp(System.currentTimeMillis()));
    cohortReview.incrementReviewedCount();
    cohortReviewService.saveCohortReview(cohortReview);
    return ResponseEntity.ok(TO_CLIENT_PARTICIPANT.apply(participantCohortStatus));
}
Also used : ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) CohortReview(org.pmiops.workbench.db.model.CohortReview) Timestamp(java.sql.Timestamp)

Example 17 with CohortReview

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

the class CohortReviewController method createParticipantCohortAnnotation.

@Override
public ResponseEntity<ParticipantCohortAnnotation> createParticipantCohortAnnotation(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId, ParticipantCohortAnnotation request) {
    if (request.getCohortAnnotationDefinitionId() == null) {
        throw new BadRequestException("Invalid Request: Please provide a valid cohort annotation definition id.");
    }
    CohortReview cohortReview = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.WRITER);
    org.pmiops.workbench.db.model.ParticipantCohortAnnotation participantCohortAnnotation = FROM_CLIENT_PARTICIPANT_COHORT_ANNOTATION.apply(request);
    participantCohortAnnotation = cohortReviewService.saveParticipantCohortAnnotation(cohortReview.getCohortReviewId(), participantCohortAnnotation);
    return ResponseEntity.ok(TO_CLIENT_PARTICIPANT_COHORT_ANNOTATION.apply(participantCohortAnnotation));
}
Also used : BadRequestException(org.pmiops.workbench.exceptions.BadRequestException) org.pmiops.workbench.model(org.pmiops.workbench.model) CohortReview(org.pmiops.workbench.db.model.CohortReview)

Example 18 with CohortReview

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

the class CohortReviewController method getParticipantCohortStatus.

@Override
public ResponseEntity<org.pmiops.workbench.model.ParticipantCohortStatus> getParticipantCohortStatus(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId) {
    CohortReview review = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.READER);
    ParticipantCohortStatus status = cohortReviewService.findParticipantCohortStatus(review.getCohortReviewId(), participantId);
    lookupGenderRaceEthnicityValues(Arrays.asList(status));
    return ResponseEntity.ok(TO_CLIENT_PARTICIPANT.apply(status));
}
Also used : ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) CohortReview(org.pmiops.workbench.db.model.CohortReview)

Example 19 with CohortReview

use of org.pmiops.workbench.db.model.CohortReview 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);
}
Also used : PageRequest(org.pmiops.workbench.cohortreview.util.PageRequest) Cohort(org.pmiops.workbench.db.model.Cohort) ParticipantCohortStatus(org.pmiops.workbench.db.model.ParticipantCohortStatus) NotFoundException(org.pmiops.workbench.exceptions.NotFoundException) org.pmiops.workbench.model(org.pmiops.workbench.model) CohortReview(org.pmiops.workbench.db.model.CohortReview) Workspace(org.pmiops.workbench.db.model.Workspace)

Example 20 with CohortReview

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

the class CohortReviewController method createNewCohortReview.

/**
 * Helper method that constructs a {@link CohortReview} with the specified ids and count.
 *
 * @param cohortId
 * @param cdrVersionId
 * @param cohortCount
 * @return
 */
private CohortReview createNewCohortReview(Long cohortId, Long cdrVersionId, long cohortCount) {
    CohortReview cohortReview = new CohortReview();
    cohortReview.setCohortId(cohortId);
    cohortReview.setCdrVersionId(cdrVersionId);
    cohortReview.matchedParticipantCount(cohortCount);
    cohortReview.setCreationTime(new Timestamp(System.currentTimeMillis()));
    cohortReview.reviewedCount(0L);
    cohortReview.reviewStatus(ReviewStatus.NONE);
    return cohortReview;
}
Also used : CohortReview(org.pmiops.workbench.db.model.CohortReview) Timestamp(java.sql.Timestamp)

Aggregations

CohortReview (org.pmiops.workbench.db.model.CohortReview)23 org.pmiops.workbench.model (org.pmiops.workbench.model)7 Test (org.junit.Test)6 Cohort (org.pmiops.workbench.db.model.Cohort)6 ParticipantCohortStatus (org.pmiops.workbench.db.model.ParticipantCohortStatus)6 Workspace (org.pmiops.workbench.db.model.Workspace)6 Gson (com.google.gson.Gson)4 Timestamp (java.sql.Timestamp)4 PageRequest (org.pmiops.workbench.cohortreview.util.PageRequest)4 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)4 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)4 QueryResult (com.google.cloud.bigquery.QueryResult)3 CdrVersion (org.pmiops.workbench.db.model.CdrVersion)3 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)3 FieldValue (com.google.cloud.bigquery.FieldValue)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Before (org.junit.Before)2 ParticipantCohortStatusKey (org.pmiops.workbench.db.model.ParticipantCohortStatusKey)2 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)1