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;
}
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());
}
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"));
}
Aggregations