use of se.inera.intyg.webcert.web.converter.ArendeListItemConverter in project webcert by sklintyg.
the class FragaSvarServiceImpl method filterFragaSvar.
@Override
@Transactional(value = "jpaTransactionManager", readOnly = true)
public QueryFragaSvarResponse filterFragaSvar(Filter filter) {
List<ArendeListItem> results = fragaSvarRepository.filterFragaSvar(filter).stream().map(ArendeListItemConverter::convert).filter(Objects::nonNull).collect(Collectors.toList());
int totalResultsCount = fragaSvarRepository.filterCountFragaSvar(filter);
QueryFragaSvarResponse response = new QueryFragaSvarResponse();
response.setResults(results);
response.setTotalCount(totalResultsCount);
return response;
}
use of se.inera.intyg.webcert.web.converter.ArendeListItemConverter in project webcert by sklintyg.
the class ArendeServiceImpl method filterArende.
@Override
@Transactional(value = "jpaTransactionManager", readOnly = true)
public QueryFragaSvarResponse filterArende(QueryFragaSvarParameter filterParameters) {
WebCertUser user = webcertUserService.getUser();
Set<String> intygstyperForPrivilege = authoritiesHelper.getIntygstyperForPrivilege(user, AuthoritiesConstants.PRIVILEGE_VISA_INTYG);
Filter filter;
if (!Strings.isNullOrEmpty(filterParameters.getEnhetId())) {
verifyEnhetsAuth(filterParameters.getEnhetId(), true);
filter = FilterConverter.convert(filterParameters, Arrays.asList(filterParameters.getEnhetId()), intygstyperForPrivilege);
} else {
filter = FilterConverter.convert(filterParameters, user.getIdsOfSelectedVardenhet(), intygstyperForPrivilege);
}
int originalStartFrom = filter.getStartFrom();
int originalPageSize = filter.getPageSize();
// INTYG-4086: Do NOT perform any paging. We must first load all applicable QA / ärenden, then apply
// sekretessmarkering filtering. THEN - we can do paging stuff in-memory. Very inefficient...
filter.setStartFrom(null);
filter.setPageSize(null);
List<ArendeListItem> results = arendeRepository.filterArende(filter).stream().map(ArendeListItemConverter::convert).filter(Objects::nonNull).peek(item -> item.setPaminnelse(!arendeRepository.findByPaminnelseMeddelandeId(item.getMeddelandeId()).isEmpty())).collect(Collectors.toList());
QueryFragaSvarResponse fsResults = fragaSvarService.filterFragaSvar(filter);
results.addAll(fsResults.getResults());
results.sort(Comparator.comparing(ArendeListItem::getReceivedDate).reversed());
QueryFragaSvarResponse response = new QueryFragaSvarResponse();
Map<Personnummer, SekretessStatus> sekretessStatusMap = patientDetailsResolver.getSekretessStatusForList(results.stream().map(ali -> Personnummer.createPersonnummer(ali.getPatientId()).get()).collect(Collectors.toList()));
// INTYG-4086, INTYG-4486: Filter out any items that doesn't pass sekretessmarkering rules
results = results.stream().filter(ali -> this.passesSekretessCheck(ali.getPatientId(), ali.getIntygTyp(), user, sekretessStatusMap)).collect(Collectors.toList());
// We must mark all items having patient with sekretessmarkering
results.stream().filter(ali -> hasSekretessStatus(ali, SekretessStatus.TRUE, sekretessStatusMap)).forEach(ali -> ali.setSekretessmarkering(true));
response.setTotalCount(results.size());
if (originalStartFrom >= results.size()) {
response.setResults(new ArrayList<>());
} else {
response.setResults(results.subList(originalStartFrom, Math.min(originalPageSize + originalStartFrom, results.size())));
}
return response;
}
Aggregations