Search in sources :

Example 36 with SearchParameter

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

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

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

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

the class CodesQueryBuilder method getMappedParameters.

protected Map<GroupType, ListMultimap<String, SearchParameter>> getMappedParameters(List<SearchParameter> searchParameters) {
    Map<GroupType, ListMultimap<String, SearchParameter>> fullMap = new LinkedHashMap<>();
    ListMultimap<String, SearchParameter> groupParameters = ArrayListMultimap.create();
    ListMultimap<String, SearchParameter> notGroupParameters = ArrayListMultimap.create();
    for (SearchParameter parameter : searchParameters) {
        if (parameter.getGroup()) {
            groupParameters.put(parameter.getDomain(), parameter);
        } else {
            notGroupParameters.put(parameter.getDomain(), parameter);
        }
    }
    if (!groupParameters.isEmpty()) {
        fullMap.put(GroupType.GROUP, groupParameters);
    }
    if (!notGroupParameters.isEmpty()) {
        fullMap.put(GroupType.NOT_GROUP, notGroupParameters);
    }
    return fullMap;
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) ListMultimap(com.google.common.collect.ListMultimap) SearchParameter(org.pmiops.workbench.model.SearchParameter) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

SearchParameter (org.pmiops.workbench.model.SearchParameter)39 Test (org.junit.Test)34 SearchRequest (org.pmiops.workbench.model.SearchRequest)27 SearchGroupItem (org.pmiops.workbench.model.SearchGroupItem)10 ArrayList (java.util.ArrayList)9 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)8 SearchGroup (org.pmiops.workbench.model.SearchGroup)7 Criteria (org.pmiops.workbench.cdr.model.Criteria)6 Attribute (org.pmiops.workbench.model.Attribute)5 QueryParameterValue (com.google.cloud.bigquery.QueryParameterValue)4 ListMultimap (com.google.common.collect.ListMultimap)3 LocalDate (java.time.LocalDate)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 LinkedHashMap (java.util.LinkedHashMap)2 HashMap (java.util.HashMap)1 List (java.util.List)1 CriteriaDao (org.pmiops.workbench.cdr.dao.CriteriaDao)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1