Search in sources :

Example 11 with SearchGroupItem

use of org.pmiops.workbench.model.SearchGroupItem 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 12 with SearchGroupItem

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

Aggregations

SearchGroupItem (org.pmiops.workbench.model.SearchGroupItem)12 SearchParameter (org.pmiops.workbench.model.SearchParameter)10 Test (org.junit.Test)8 SearchGroup (org.pmiops.workbench.model.SearchGroup)8 SearchRequest (org.pmiops.workbench.model.SearchRequest)8 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)5 ArrayList (java.util.ArrayList)3 Criteria (org.pmiops.workbench.cdr.model.Criteria)2 ListMultimap (com.google.common.collect.ListMultimap)1 LocalDate (java.time.LocalDate)1 StringJoiner (java.util.StringJoiner)1 QueryParameters (org.pmiops.workbench.cohortbuilder.querybuilder.QueryParameters)1 Attribute (org.pmiops.workbench.model.Attribute)1