Search in sources :

Example 1 with ClinicalVisitIndexDto

use of de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ClinicalVisitFacadeEjb method getIndexList.

@Override
public List<ClinicalVisitIndexDto> getIndexList(ClinicalVisitCriteria criteria, Integer first, Integer max, List<SortProperty> sortProperties) {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<ClinicalVisitIndexDto> cq = cb.createQuery(ClinicalVisitIndexDto.class);
    Root<ClinicalVisit> visit = cq.from(ClinicalVisit.class);
    ClinicalVisitJoins joins = new ClinicalVisitJoins(visit);
    cq.multiselect(visit.get(ClinicalVisit.UUID), visit.get(ClinicalVisit.VISIT_DATE_TIME), visit.get(ClinicalVisit.VISITING_PERSON), visit.get(ClinicalVisit.VISIT_REMARKS), joins.getSymptoms().get(Symptoms.TEMPERATURE), joins.getSymptoms().get(Symptoms.TEMPERATURE_SOURCE), joins.getSymptoms().get(Symptoms.BLOOD_PRESSURE_SYSTOLIC), joins.getSymptoms().get(Symptoms.BLOOD_PRESSURE_DIASTOLIC), joins.getSymptoms().get(Symptoms.HEART_RATE), joins.getSymptoms().get(Symptoms.ID), JurisdictionHelper.booleanSelector(cb, caseService.inJurisdictionOrOwned(new CaseQueryContext(cb, cq, joins.getCaseJoins()))));
    if (criteria != null) {
        cq.where(service.buildCriteriaFilter(criteria, cb, visit));
    }
    if (CollectionUtils.isNotEmpty(sortProperties)) {
        List<Order> order = new ArrayList<>(sortProperties.size());
        for (SortProperty sortProperty : sortProperties) {
            Expression<?> expression;
            switch(sortProperty.propertyName) {
                case ClinicalVisitDto.UUID:
                case ClinicalVisitDto.DISEASE:
                case ClinicalVisitDto.VISIT_DATE_TIME:
                case ClinicalVisitDto.CLINICAL_COURSE:
                    expression = visit.get(sortProperty.propertyName);
                    break;
                default:
                    throw new IllegalArgumentException(sortProperty.propertyName);
            }
            order.add(sortProperty.ascending ? cb.asc(expression) : cb.desc(expression));
        }
        cq.orderBy(order);
    } else {
        cq.orderBy(cb.desc(visit.get(ClinicalVisit.VISIT_DATE_TIME)));
    }
    List<ClinicalVisitIndexDto> results = QueryHelper.getResultList(em, cq, first, max);
    Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
    pseudonymizer.pseudonymizeDtoCollection(ClinicalVisitIndexDto.class, results, v -> v.getInJurisdiction(), null);
    return results;
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) Order(javax.persistence.criteria.Order) Pseudonymizer(de.symeda.sormas.backend.util.Pseudonymizer) ArrayList(java.util.ArrayList) SortProperty(de.symeda.sormas.api.utils.SortProperty) ClinicalVisitIndexDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto) CaseQueryContext(de.symeda.sormas.backend.caze.CaseQueryContext)

Example 2 with ClinicalVisitIndexDto

use of de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ClinicalCourseFacadeEjbTest method testClinicalVisitIndexListGeneration.

@Test
public void testClinicalVisitIndexListGeneration() {
    RDCFEntities rdcf = creator.createRDCFEntities();
    UserDto user = creator.createUser(rdcf, UserRole.SURVEILLANCE_SUPERVISOR, UserRole.CASE_SUPERVISOR);
    PersonDto casePerson = creator.createPerson("Case", "Person");
    CaseDataDto caze = creator.createCase(user.toReference(), casePerson.toReference(), rdcf);
    creator.createClinicalVisit(caze);
    List<ClinicalVisitIndexDto> results = getClinicalVisitFacade().getIndexList(null, null, null, null);
    assertEquals(1, results.size());
}
Also used : RDCFEntities(de.symeda.sormas.backend.TestDataCreator.RDCFEntities) ClinicalVisitIndexDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) PersonDto(de.symeda.sormas.api.person.PersonDto) UserDto(de.symeda.sormas.api.user.UserDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Example 3 with ClinicalVisitIndexDto

use of de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto in project SORMAS-Project by hzi-braunschweig.

the class ClinicalVisitFacadeEjbPseudonymizationTest method testPseudonymizeIndexList.

@Test
public void testPseudonymizeIndexList() {
    loginWith(user1);
    CaseDataDto case1 = createCase(user1, rdcf1);
    ClinicalVisitDto visit1 = createClinicalVisit(case1);
    // create contact to have access to @case1
    creator.createContact(user2.toReference(), case1.getPerson(), case1);
    loginWith(user2);
    CaseDataDto case2 = createCase(user2, rdcf2);
    ClinicalVisitDto visit2 = createClinicalVisit(case2);
    List<ClinicalVisitIndexDto> indexList = getClinicalVisitFacade().getIndexList(null, null, null, null);
    ClinicalVisitIndexDto export1 = indexList.stream().filter(v -> v.getUuid().equals(visit1.getUuid())).findFirst().get();
    assertThat(export1.getVisitingPerson(), is("Confidential"));
    assertThat(export1.getVisitRemarks(), is("Confidential"));
    ClinicalVisitIndexDto export2 = indexList.stream().filter(v -> v.getUuid().equals(visit2.getUuid())).findFirst().get();
    assertThat(export2.getVisitingPerson(), is("John Smith"));
    assertThat(export2.getVisitRemarks(), is("Test remarks"));
}
Also used : ClinicalVisitIndexDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto) CaseDataDto(de.symeda.sormas.api.caze.CaseDataDto) ClinicalVisitDto(de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto) Test(org.junit.Test) AbstractBeanTest(de.symeda.sormas.backend.AbstractBeanTest)

Aggregations

ClinicalVisitIndexDto (de.symeda.sormas.api.clinicalcourse.ClinicalVisitIndexDto)3 CaseDataDto (de.symeda.sormas.api.caze.CaseDataDto)2 AbstractBeanTest (de.symeda.sormas.backend.AbstractBeanTest)2 Test (org.junit.Test)2 ClinicalVisitDto (de.symeda.sormas.api.clinicalcourse.ClinicalVisitDto)1 PersonDto (de.symeda.sormas.api.person.PersonDto)1 UserDto (de.symeda.sormas.api.user.UserDto)1 SortProperty (de.symeda.sormas.api.utils.SortProperty)1 RDCFEntities (de.symeda.sormas.backend.TestDataCreator.RDCFEntities)1 CaseQueryContext (de.symeda.sormas.backend.caze.CaseQueryContext)1 Pseudonymizer (de.symeda.sormas.backend.util.Pseudonymizer)1 ArrayList (java.util.ArrayList)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Order (javax.persistence.criteria.Order)1