Search in sources :

Example 31 with SearchRequest

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

SearchRequest (org.pmiops.workbench.model.SearchRequest)31 Test (org.junit.Test)27 SearchParameter (org.pmiops.workbench.model.SearchParameter)27 SearchGroup (org.pmiops.workbench.model.SearchGroup)8 SearchGroupItem (org.pmiops.workbench.model.SearchGroupItem)8 Criteria (org.pmiops.workbench.cdr.model.Criteria)6 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)4 LocalDate (java.time.LocalDate)3 Attribute (org.pmiops.workbench.model.Attribute)3 ArrayList (java.util.ArrayList)2 BadRequestException (org.pmiops.workbench.exceptions.BadRequestException)2 Gson (com.google.gson.Gson)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 StringJoiner (java.util.StringJoiner)1 CdrVersion (org.pmiops.workbench.db.model.CdrVersion)1 CohortReview (org.pmiops.workbench.db.model.CohortReview)1 Workspace (org.pmiops.workbench.db.model.Workspace)1 NotFoundException (org.pmiops.workbench.exceptions.NotFoundException)1 MaterializeCohortResponse (org.pmiops.workbench.model.MaterializeCohortResponse)1