Search in sources :

Example 6 with Criteria

use of org.pmiops.workbench.cdr.model.Criteria in project workbench by all-of-us.

the class CohortBuilderControllerTest method countSubjectsDemoGenderAndAge.

@Test
public void countSubjectsDemoGenderAndAge() throws Exception {
    Criteria demoGender = createDemoCriteria("DEMO", "GEN", "8507");
    SearchParameter demoGenderSearchParam = createSearchParameter(demoGender, null);
    LocalDate birthdate = LocalDate.of(1980, 8, 01);
    LocalDate now = LocalDate.now();
    Integer age = Period.between(birthdate, now).getYears();
    Criteria demoAge = createDemoCriteria("DEMO", "AGE", null);
    SearchParameter demoAgeSearchParam = createSearchParameter(demoAge, null);
    demoAgeSearchParam.attribute(new Attribute().operator("=").operands(Arrays.asList(age.toString())));
    SearchRequest searchRequests = createSearchRequests(demoAge.getType(), Arrays.asList(demoGenderSearchParam, demoAgeSearchParam));
    assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequests), 1);
}
Also used : SearchRequest(org.pmiops.workbench.model.SearchRequest) Attribute(org.pmiops.workbench.model.Attribute) Criteria(org.pmiops.workbench.cdr.model.Criteria) SearchParameter(org.pmiops.workbench.model.SearchParameter) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 7 with Criteria

use of org.pmiops.workbench.cdr.model.Criteria in project workbench by all-of-us.

the class CohortBuilderControllerTest method countSubjectsDemoExcluded.

@Test
public void countSubjectsDemoExcluded() throws Exception {
    Criteria demoGender = createDemoCriteria("DEMO", "GEN", "8507");
    SearchParameter demoGenderSearchParam = createSearchParameter(demoGender, null);
    SearchParameter demoGenderSearchParamExclude = createSearchParameter(demoGender, null);
    SearchGroupItem excludeSearchGroupItem = new SearchGroupItem().type(demoGender.getType()).searchParameters(Arrays.asList(demoGenderSearchParamExclude));
    SearchGroup excludeSearchGroup = new SearchGroup().addItemsItem(excludeSearchGroupItem);
    SearchRequest searchRequests = createSearchRequests(demoGender.getType(), Arrays.asList(demoGenderSearchParam));
    searchRequests.getExcludes().add(excludeSearchGroup);
    assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequests), 0);
}
Also used : SearchRequest(org.pmiops.workbench.model.SearchRequest) SearchGroup(org.pmiops.workbench.model.SearchGroup) Criteria(org.pmiops.workbench.cdr.model.Criteria) SearchParameter(org.pmiops.workbench.model.SearchParameter) SearchGroupItem(org.pmiops.workbench.model.SearchGroupItem) Test(org.junit.Test)

Example 8 with Criteria

use of org.pmiops.workbench.cdr.model.Criteria in project workbench by all-of-us.

the class CohortBuilderControllerTest method countSubjectsDemoGender.

@Test
public void countSubjectsDemoGender() throws Exception {
    Criteria demoGender = createDemoCriteria("DEMO", "GEN", "8507");
    SearchParameter demo = createSearchParameter(demoGender, null);
    SearchRequest searchRequest = createSearchRequests(demoGender.getType(), Arrays.asList(demo));
    assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequest), 1);
}
Also used : SearchRequest(org.pmiops.workbench.model.SearchRequest) Criteria(org.pmiops.workbench.cdr.model.Criteria) SearchParameter(org.pmiops.workbench.model.SearchParameter) Test(org.junit.Test)

Example 9 with Criteria

use of org.pmiops.workbench.cdr.model.Criteria in project workbench by all-of-us.

the class CohortBuilderControllerTest method countSubjectsICD9AndDemo.

@Test
public void countSubjectsICD9AndDemo() throws Exception {
    Criteria demoGender = createDemoCriteria("DEMO", "GEN", "8507");
    SearchParameter demoGenderSearchParam = createSearchParameter(demoGender, null);
    LocalDate birthdate = LocalDate.of(1980, 8, 01);
    LocalDate now = LocalDate.now();
    Integer age = Period.between(birthdate, now).getYears();
    Criteria demoAge = createDemoCriteria("DEMO", "AGE", null);
    SearchParameter demoAgeSearchParam = createSearchParameter(demoAge, null);
    demoAgeSearchParam.attribute(new Attribute().operator("=").operands(Arrays.asList(age.toString())));
    SearchRequest searchRequests = createSearchRequests(demoAge.getType(), Arrays.asList(demoGenderSearchParam, demoAgeSearchParam));
    SearchParameter icd9 = createSearchParameter(icd9MeasurementChild, "003.1");
    SearchGroupItem anotherSearchGroupItem = new SearchGroupItem().type(icd9.getType()).searchParameters(Arrays.asList(icd9));
    searchRequests.getIncludes().get(0).addItemsItem(anotherSearchGroupItem);
    assertParticipants(controller.countParticipants(cdrVersion.getCdrVersionId(), searchRequests), 1);
}
Also used : SearchRequest(org.pmiops.workbench.model.SearchRequest) Attribute(org.pmiops.workbench.model.Attribute) Criteria(org.pmiops.workbench.cdr.model.Criteria) SearchParameter(org.pmiops.workbench.model.SearchParameter) LocalDate(java.time.LocalDate) SearchGroupItem(org.pmiops.workbench.model.SearchGroupItem) Test(org.junit.Test)

Example 10 with Criteria

use of org.pmiops.workbench.cdr.model.Criteria 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

Criteria (org.pmiops.workbench.cdr.model.Criteria)10 Test (org.junit.Test)6 SearchParameter (org.pmiops.workbench.model.SearchParameter)6 SearchRequest (org.pmiops.workbench.model.SearchRequest)6 LocalDate (java.time.LocalDate)3 ParticipantCriteria (org.pmiops.workbench.cohortbuilder.ParticipantCriteria)3 Attribute (org.pmiops.workbench.model.Attribute)3 CriteriaListResponse (org.pmiops.workbench.model.CriteriaListResponse)3 SearchGroupItem (org.pmiops.workbench.model.SearchGroupItem)2 Gson (com.google.gson.Gson)1 Before (org.junit.Before)1 CdrVersion (org.pmiops.workbench.db.model.CdrVersion)1 Cohort (org.pmiops.workbench.db.model.Cohort)1 CohortReview (org.pmiops.workbench.db.model.CohortReview)1 Workspace (org.pmiops.workbench.db.model.Workspace)1 SearchGroup (org.pmiops.workbench.model.SearchGroup)1