Search in sources :

Example 21 with CohortReview

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

the class CohortReviewController method updateParticipantCohortAnnotation.

@Override
public ResponseEntity<ParticipantCohortAnnotation> updateParticipantCohortAnnotation(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId, Long annotationId, ModifyParticipantCohortAnnotationRequest request) {
    CohortReview cohortReview = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.WRITER);
    org.pmiops.workbench.db.model.ParticipantCohortAnnotation participantCohortAnnotation = cohortReviewService.updateParticipantCohortAnnotation(annotationId, cohortReview.getCohortReviewId(), participantId, request);
    return ResponseEntity.ok(TO_CLIENT_PARTICIPANT_COHORT_ANNOTATION.apply(participantCohortAnnotation));
}
Also used : org.pmiops.workbench.model(org.pmiops.workbench.model) CohortReview(org.pmiops.workbench.db.model.CohortReview)

Example 22 with CohortReview

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

the class CohortReviewController method deleteParticipantCohortAnnotation.

@Override
public ResponseEntity<EmptyResponse> deleteParticipantCohortAnnotation(String workspaceNamespace, String workspaceId, Long cohortId, Long cdrVersionId, Long participantId, Long annotationId) {
    if (annotationId == null) {
        throw new BadRequestException("Invalid Request: Please provide a valid cohort annotation definition id.");
    }
    CohortReview cohortReview = validateRequestAndSetCdrVersion(workspaceNamespace, workspaceId, cohortId, cdrVersionId, WorkspaceAccessLevel.WRITER);
    // will throw a NotFoundException if participant does not exist
    cohortReviewService.findParticipantCohortStatus(cohortReview.getCohortReviewId(), participantId);
    // will throw a NotFoundException if participant cohort annotation does not exist
    cohortReviewService.deleteParticipantCohortAnnotation(annotationId, cohortReview.getCohortReviewId(), participantId);
    return ResponseEntity.ok(new EmptyResponse());
}
Also used : BadRequestException(org.pmiops.workbench.exceptions.BadRequestException) CohortReview(org.pmiops.workbench.db.model.CohortReview)

Example 23 with CohortReview

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

the class CohortMaterializationServiceTest method setUp.

@Before
public void setUp() {
    cdrVersion = new CdrVersion();
    cdrVersion.setBigqueryDataset(testWorkbenchConfig.bigquery.dataSetId);
    cdrVersion.setBigqueryProject(testWorkbenchConfig.bigquery.projectId);
    cdrVersionDao.save(cdrVersion);
    CdrVersionContext.setCdrVersion(cdrVersion);
    Criteria icd9CriteriaGroup = new Criteria().group(true).name("group").selectable(true).code(SearchRequests.ICD9_GROUP_CODE).type(SearchRequests.ICD9_TYPE).parentId(0);
    criteriaDao.save(icd9CriteriaGroup);
    Criteria icd9CriteriaChild = new Criteria().group(false).name("child").selectable(true).code(SearchRequests.ICD9_GROUP_CODE + ".1").type(SearchRequests.ICD9_TYPE).domainId("Condition").parentId(icd9CriteriaGroup.getId());
    criteriaDao.save(icd9CriteriaChild);
    Workspace workspace = new Workspace();
    workspace.setCdrVersion(cdrVersion);
    workspace.setName("name");
    workspace.setDataAccessLevel(DataAccessLevel.PROTECTED);
    workspaceDao.save(workspace);
    Cohort cohort = new Cohort();
    cohort.setWorkspaceId(workspace.getWorkspaceId());
    cohort.setName("males");
    cohort.setType("AOU");
    Gson gson = new Gson();
    cohort.setCriteria(gson.toJson(SearchRequests.males()));
    cohortDao.save(cohort);
    Cohort cohort2 = new Cohort();
    cohort2.setWorkspaceId(workspace.getWorkspaceId());
    cohort2.setName("all genders");
    cohort2.setType("AOU");
    cohort2.setCriteria(gson.toJson(SearchRequests.allGenders()));
    cohortDao.save(cohort2);
    cohortReview = new CohortReview();
    cohortReview.setCdrVersionId(cdrVersion.getCdrVersionId());
    cohortReview.setCohortId(cohort2.getCohortId());
    cohortReview.setMatchedParticipantCount(3);
    cohortReview.setReviewedCount(2);
    cohortReview.setReviewSize(3);
    cohortReviewDao.save(cohortReview);
    participantCohortStatusDao.save(makeStatus(cohortReview.getCohortReviewId(), 1L, CohortStatus.INCLUDED));
    participantCohortStatusDao.save(makeStatus(cohortReview.getCohortReviewId(), 2L, CohortStatus.EXCLUDED));
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Cohort(org.pmiops.workbench.db.model.Cohort) Gson(com.google.gson.Gson) Criteria(org.pmiops.workbench.cdr.model.Criteria) CohortReview(org.pmiops.workbench.db.model.CohortReview) Workspace(org.pmiops.workbench.db.model.Workspace) Before(org.junit.Before)

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