use of de.symeda.sormas.backend.util.Pseudonymizer in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjb method convertToReferenceDto.
private ContactReferenceDto convertToReferenceDto(Contact source) {
ContactReferenceDto dto = toReferenceDto(source);
if (source != null && dto != null) {
final ContactJurisdictionFlagsDto contactJurisdictionFlagsDto = service.inJurisdictionOrOwned(source);
boolean isInJurisdiction = contactJurisdictionFlagsDto.getInJurisdiction();
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
pseudonymizer.pseudonymizeDto(ContactReferenceDto.class, dto, isInJurisdiction, (c) -> {
if (source.getCaze() != null) {
pseudonymizer.pseudonymizeDto(ContactReferenceDto.PersonName.class, c.getCaseName(), contactJurisdictionFlagsDto.getCaseInJurisdiction(), null);
}
pseudonymizer.pseudonymizeDto(ContactReferenceDto.PersonName.class, c.getContactName(), isInJurisdiction, null);
});
}
return dto;
}
use of de.symeda.sormas.backend.util.Pseudonymizer in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjb method getIndexDetailedList.
@Override
public List<ContactIndexDetailedDto> getIndexDetailedList(ContactCriteria contactCriteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaQuery<ContactIndexDetailedDto> query = listCriteriaBuilder.buildIndexDetailedCriteria(contactCriteria, sortProperties);
List<ContactIndexDetailedDto> dtos = QueryHelper.getResultList(em, query, first, max);
// Load event count and latest events info per contact
Map<String, List<ContactEventSummaryDetails>> eventSummaries = eventService.getEventSummaryDetailsByContacts(dtos.stream().map(ContactIndexDetailedDto::getUuid).collect(Collectors.toList())).stream().collect(Collectors.groupingBy(ContactEventSummaryDetails::getContactUuid, Collectors.toList()));
for (ContactIndexDetailedDto contact : dtos) {
List<ContactEventSummaryDetails> contactEvents = eventSummaries.getOrDefault(contact.getUuid(), Collections.emptyList());
contact.setEventCount((long) contactEvents.size());
contactEvents.stream().max(Comparator.comparing(ContactEventSummaryDetails::getEventDate)).ifPresent(eventSummary -> {
contact.setLatestEventId(eventSummary.getEventUuid());
contact.setLatestEventTitle(eventSummary.getEventTitle());
});
}
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
User currentUser = userService.getCurrentUser();
pseudonymizer.pseudonymizeDtoCollection(ContactIndexDetailedDto.class, dtos, c -> c.getInJurisdiction(), (c, isInJurisdiction) -> {
pseudonymizer.pseudonymizeUser(userService.getByUuid(c.getReportingUser().getUuid()), currentUser, c::setReportingUser);
if (c.getCaze() != null) {
pseudonymizer.pseudonymizeDto(CaseReferenceDto.class, c.getCaze(), c.getCaseInJurisdiction(), null);
}
});
return dtos;
}
use of de.symeda.sormas.backend.util.Pseudonymizer in project SORMAS-Project by hzi-braunschweig.
the class ContactFacadeEjb method getIndexList.
@Override
public List<ContactIndexDto> getIndexList(ContactCriteria contactCriteria, Integer first, Integer max, List<SortProperty> sortProperties) {
CriteriaQuery<ContactIndexDto> query = listCriteriaBuilder.buildIndexCriteria(contactCriteria, sortProperties);
List<ContactIndexDto> dtos = QueryHelper.getResultList(em, query, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
pseudonymizer.pseudonymizeDtoCollection(ContactIndexDto.class, dtos, ContactIndexDto::getInJurisdiction, (c, isInJurisdiction) -> {
if (c.getCaze() != null) {
pseudonymizer.pseudonymizeDto(CaseReferenceDto.class, c.getCaze(), c.getCaseInJurisdiction(), null);
}
});
return dtos;
}
use of de.symeda.sormas.backend.util.Pseudonymizer in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitFacadeEjb method restorePseudonymizedDto.
private void restorePseudonymizedDto(ClinicalVisitDto clinicalVisit, ClinicalVisit existingClinicalVisit) {
if (existingClinicalVisit != null) {
Boolean inJurisdiction = caseService.inJurisdictionOrOwned(existingClinicalVisit.getClinicalCourse().getCaze());
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight);
ClinicalVisitDto existingDto = toDto(existingClinicalVisit);
pseudonymizer.restorePseudonymizedValues(ClinicalVisitDto.class, clinicalVisit, existingDto, inJurisdiction);
pseudonymizer.restorePseudonymizedValues(SymptomsDto.class, clinicalVisit.getSymptoms(), existingDto.getSymptoms(), inJurisdiction);
}
}
use of de.symeda.sormas.backend.util.Pseudonymizer in project SORMAS-Project by hzi-braunschweig.
the class ClinicalVisitFacadeEjb method getExportList.
@Override
public List<ClinicalVisitExportDto> getExportList(CaseCriteria criteria, Collection<String> selectedRows, int first, int max) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<ClinicalVisitExportDto> cq = cb.createQuery(ClinicalVisitExportDto.class);
Root<ClinicalVisit> clinicalVisit = cq.from(ClinicalVisit.class);
ClinicalVisitJoins joins = new ClinicalVisitJoins(clinicalVisit);
CaseQueryContext caseQueryContext = new CaseQueryContext(cb, cq, joins.getCaze());
cq.multiselect(joins.getCaze().get(Case.UUID), joins.getCasePerson().get(Person.FIRST_NAME), joins.getCasePerson().get(Person.LAST_NAME), clinicalVisit.get(ClinicalVisit.DISEASE), clinicalVisit.get(ClinicalVisit.VISIT_DATE_TIME), clinicalVisit.get(ClinicalVisit.VISIT_REMARKS), clinicalVisit.get(ClinicalVisit.VISITING_PERSON), joins.getSymptoms().get(Symptoms.ID), JurisdictionHelper.booleanSelector(cb, caseService.inJurisdictionOrOwned(caseQueryContext)));
Predicate filter = service.createUserFilter(cb, cq, clinicalVisit);
Predicate criteriaFilter = caseService.createCriteriaFilter(criteria, caseQueryContext);
filter = CriteriaBuilderHelper.and(cb, filter, criteriaFilter);
filter = CriteriaBuilderHelper.andInValues(selectedRows, filter, cb, joins.getCaze().get(Case.UUID));
cq.where(filter);
cq.orderBy(cb.desc(joins.getCaze().get(Case.UUID)), cb.desc(clinicalVisit.get(ClinicalVisit.VISIT_DATE_TIME)));
List<ClinicalVisitExportDto> resultList = QueryHelper.getResultList(em, cq, first, max);
Pseudonymizer pseudonymizer = Pseudonymizer.getDefault(userService::hasRight, I18nProperties.getCaption(Captions.inaccessibleValue));
for (ClinicalVisitExportDto exportDto : resultList) {
exportDto.setSymptoms(SymptomsFacadeEjb.toDto(symptomsService.getById(exportDto.getSymptomsId())));
Boolean inJurisdiction = exportDto.getInJurisdiction();
pseudonymizer.pseudonymizeDto(ClinicalVisitExportDto.class, exportDto, inJurisdiction, (v) -> {
pseudonymizer.pseudonymizeDto(SymptomsDto.class, v.getSymptoms(), inJurisdiction, null);
});
}
return resultList;
}
Aggregations