Search in sources :

Example 1 with Criteria

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

the class CohortBuilderController method getCriteriaByTypeAndSubtype.

@Override
public ResponseEntity<CriteriaListResponse> getCriteriaByTypeAndSubtype(Long cdrVersionId, String type, String subtype) {
    CdrVersionContext.setCdrVersion(cdrVersionDao.findOne(cdrVersionId));
    final List<Criteria> criteriaList = criteriaDao.findCriteriaByTypeAndSubtypeOrderByNameAsc(type, subtype);
    CriteriaListResponse criteriaResponse = new CriteriaListResponse();
    criteriaResponse.setItems(criteriaList.stream().map(TO_CLIENT_CRITERIA).collect(Collectors.toList()));
    return ResponseEntity.ok(criteriaResponse);
}
Also used : Criteria(org.pmiops.workbench.cdr.model.Criteria) ParticipantCriteria(org.pmiops.workbench.cohortbuilder.ParticipantCriteria) CriteriaListResponse(org.pmiops.workbench.model.CriteriaListResponse)

Example 2 with Criteria

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

the class CohortBuilderControllerTest method countSubjectsDemoAge.

@Test
public void countSubjectsDemoAge() throws Exception {
    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 demo = createSearchParameter(demoAge, null);
    demo.attribute(new Attribute().operator("=").operands(Arrays.asList(age.toString())));
    SearchRequest searchRequests = createSearchRequests(demoAge.getType(), Arrays.asList(demo));
    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 3 with Criteria

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

the class CohortBuilderController method getCriteriaByTypeAndParentId.

/**
 * This method list any of the criteria trees.
 */
@Override
public ResponseEntity<CriteriaListResponse> getCriteriaByTypeAndParentId(Long cdrVersionId, String type, Long parentId) {
    CdrVersionContext.setCdrVersion(cdrVersionDao.findOne(cdrVersionId));
    final List<Criteria> criteriaList = criteriaDao.findCriteriaByTypeAndParentIdOrderByCodeAsc(type, parentId);
    CriteriaListResponse criteriaResponse = new CriteriaListResponse();
    criteriaResponse.setItems(criteriaList.stream().map(TO_CLIENT_CRITERIA).collect(Collectors.toList()));
    return ResponseEntity.ok(criteriaResponse);
}
Also used : Criteria(org.pmiops.workbench.cdr.model.Criteria) ParticipantCriteria(org.pmiops.workbench.cohortbuilder.ParticipantCriteria) CriteriaListResponse(org.pmiops.workbench.model.CriteriaListResponse)

Example 4 with Criteria

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

the class CohortBuilderController method getCriteriaTreeQuickSearch.

@Override
public ResponseEntity<CriteriaListResponse> getCriteriaTreeQuickSearch(Long cdrVersionId, String type, String value) {
    CdrVersionContext.setCdrVersion(cdrVersionDao.findOne(cdrVersionId));
    String nameOrCode = value + "*";
    final List<Criteria> criteriaList = criteriaDao.findCriteriaByTypeAndNameOrCode(type, nameOrCode);
    CriteriaListResponse criteriaResponse = new CriteriaListResponse();
    criteriaResponse.setItems(criteriaList.stream().map(TO_CLIENT_CRITERIA).collect(Collectors.toList()));
    return ResponseEntity.ok(criteriaResponse);
}
Also used : Criteria(org.pmiops.workbench.cdr.model.Criteria) ParticipantCriteria(org.pmiops.workbench.cohortbuilder.ParticipantCriteria) CriteriaListResponse(org.pmiops.workbench.model.CriteriaListResponse)

Example 5 with Criteria

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

the class CohortBuilderControllerTest method countSubjectsDemoDec.

@Test
public void countSubjectsDemoDec() throws Exception {
    Criteria demoGender = createDemoCriteria("DEMO", "DEC", null);
    SearchParameter demo = createSearchParameter(demoGender, "Deceased");
    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)

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