Search in sources :

Example 16 with CdrVersion

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

the class CohortBuilderControllerMockTest method getCriteriaByTypeAndParentIdCPT.

@Test
public void getCriteriaByTypeAndParentIdCPT() throws Exception {
    org.pmiops.workbench.cdr.model.Criteria expectedCriteria = new org.pmiops.workbench.cdr.model.Criteria().id(1L).type("CPT").name("DIAGNOSIS CODES").group(true).selectable(true).count("0").conceptId("0");
    when(mockCdrVersionDao.findOne(1L)).thenReturn(new CdrVersion());
    when(mockCriteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc("CPT", 0L)).thenReturn(Arrays.asList(expectedCriteria));
    assertCriteria(controller.getCriteriaByTypeAndParentId(1L, "CPT", 0L), new Criteria().id(1L).type("CPT").name("DIAGNOSIS CODES").group(true).selectable(true).count(0L).conceptId(0L));
    verify(mockCdrVersionDao).findOne(1L);
    verify(mockCriteriaDao).findCriteriaByTypeAndParentIdOrderByCodeAsc("CPT", 0L);
    verifyNoMoreInteractions(mockCriteriaDao, mockCdrVersionDao);
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) Criteria(org.pmiops.workbench.model.Criteria) Test(org.junit.Test)

Example 17 with CdrVersion

use of org.pmiops.workbench.db.model.CdrVersion 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)

Example 18 with CdrVersion

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

the class BigQueryService method filterBigQueryConfig.

public QueryJobConfiguration filterBigQueryConfig(QueryJobConfiguration queryJobConfiguration) {
    CdrVersion cdrVersion = CdrVersionContext.getCdrVersion();
    if (cdrVersion == null) {
        throw new ServerErrorException("No CDR version specified");
    }
    String returnSql = queryJobConfiguration.getQuery().replace("${projectId}", cdrVersion.getBigqueryProject());
    returnSql = returnSql.replace("${dataSetId}", cdrVersion.getBigqueryDataset());
    return queryJobConfiguration.toBuilder().setQuery(returnSql).build();
}
Also used : CdrVersion(org.pmiops.workbench.db.model.CdrVersion) ServerErrorException(org.pmiops.workbench.exceptions.ServerErrorException)

Aggregations

CdrVersion (org.pmiops.workbench.db.model.CdrVersion)18 Before (org.junit.Before)8 Test (org.junit.Test)8 Criteria (org.pmiops.workbench.model.Criteria)7 Gson (com.google.gson.Gson)4 User (org.pmiops.workbench.db.model.User)4 CohortReview (org.pmiops.workbench.db.model.CohortReview)2 Workspace (org.pmiops.workbench.db.model.Workspace)2 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)2 ResearchPurpose (org.pmiops.workbench.model.ResearchPurpose)2 Workspace (org.pmiops.workbench.model.Workspace)2 FieldValue (com.google.cloud.bigquery.FieldValue)1 QueryResult (com.google.cloud.bigquery.QueryResult)1 Blob (com.google.cloud.storage.Blob)1 BlobId (com.google.cloud.storage.BlobId)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1