use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem 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;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem in project webcert by sklintyg.
the class ArendeListItemConverter method convert.
public static ArendeListItem convert(FragaSvar fragaSvar) {
if (fragaSvar.getIntygsReferens() == null || fragaSvar.getVardperson() == null) {
return null;
}
ArendeListItem res = new ArendeListItem();
res.setFragestallare(fragaSvar.getFrageStallare());
res.setIntygId(fragaSvar.getIntygsReferens().getIntygsId());
res.setIntygTyp(fragaSvar.getIntygsReferens().getIntygsTyp());
res.setMeddelandeId(Long.toString(fragaSvar.getInternReferens()));
res.setReceivedDate(fragaSvar.getSenasteHandelseDatum());
res.setPatientId(fragaSvar.getIntygsReferens().getPatientId().getPersonnummer());
res.setSigneratAvNamn(fragaSvar.getVardperson().getNamn());
res.setStatus(fragaSvar.getStatus());
res.setVidarebefordrad(fragaSvar.getVidarebefordrad());
res.setAmne(ArendeAmne.fromAmne(fragaSvar.getAmne()).map(ArendeAmne::name).orElse(fragaSvar.getAmne().name()));
res.setEnhetsnamn(fragaSvar.getVardperson().getEnhetsnamn());
res.setVardgivarnamn(fragaSvar.getVardperson().getVardgivarnamn());
return res;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem in project webcert by sklintyg.
the class ArendeServiceTest method buildArendeListItem.
private ArendeListItem buildArendeListItem(String INTYG_ID, LocalDateTime receivedDate) {
ArendeListItem arende = new ArendeListItem();
arende.setIntygId(INTYG_ID);
arende.setReceivedDate(receivedDate);
arende.setPatientId(PNR.getPersonnummer());
return arende;
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem in project webcert by sklintyg.
the class ArendeListItemConverterTest method testConvertArende.
@Test
public void testConvertArende() {
final ArendeAmne amne = ArendeAmne.KONTKT;
final String intygsId = "intygsId";
final String intygTyp = "luse";
final String meddelandeId = "meddelandeId";
final String patientPersonId = "patientPersonId";
final String signeratAvName = "signeratAvName";
final String skickatAv = "skickatAv";
final LocalDateTime skickatTidpunkt = LocalDateTime.now();
final Status status = Status.ANSWERED;
final Boolean vidarebefordrad = Boolean.TRUE;
final String enhetsnamn = "enhetsnamn";
final String vardgivarnamn = "vardgivarnamn";
Arende arende = createArende(amne, intygsId, intygTyp, meddelandeId, patientPersonId, signeratAvName, skickatAv, skickatTidpunkt, status, vidarebefordrad, enhetsnamn, vardgivarnamn);
ArendeListItem result = ArendeListItemConverter.convert(arende);
assertEquals(amne.name(), result.getAmne());
assertEquals(intygsId, result.getIntygId());
assertEquals(intygTyp, result.getIntygTyp());
assertEquals(meddelandeId, result.getMeddelandeId());
assertEquals(patientPersonId, result.getPatientId());
assertEquals(signeratAvName, result.getSigneratAvNamn());
assertEquals(skickatAv, result.getFragestallare());
assertEquals(skickatTidpunkt, result.getReceivedDate());
assertEquals(status, result.getStatus());
assertEquals(true, result.isVidarebefordrad());
assertEquals(enhetsnamn, result.getEnhetsnamn());
assertEquals(vardgivarnamn, result.getVardgivarnamn());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeListItem in project webcert by sklintyg.
the class ArendeListItemConverterTest method testConvert.
@Test
public void testConvert() {
final String fragestallare = "fragestallare";
final String intygId = "intygId";
final String intygTyp = "intygTyp";
final long internReferens = 13;
final LocalDateTime senasteHandelse = LocalDateTime.now();
final String signeratAv = "signeratAv";
final String enhetsnamn = "enhetsnamn";
final String vardgivarnamn = "vardgivarnamn";
final Amne amne = Amne.AVSTAMNINGSMOTE;
final boolean vidarebefordrad = false;
final Status status = Status.PENDING_INTERNAL_ACTION;
FragaSvar fs = createFragaSvar(fragestallare, intygId, intygTyp, patientId, internReferens, senasteHandelse, signeratAv, enhetsnamn, vardgivarnamn, amne, vidarebefordrad, status);
ArendeListItem arende = ArendeListItemConverter.convert(fs);
assertNotNull(arende);
assertEquals(fragestallare, arende.getFragestallare());
assertEquals(intygId, arende.getIntygId());
assertEquals(intygTyp, arende.getIntygTyp());
assertEquals(patientId, arende.getPatientId());
assertEquals(Long.toString(internReferens), arende.getMeddelandeId());
assertEquals(senasteHandelse, arende.getReceivedDate());
assertEquals(signeratAv, arende.getSigneratAvNamn());
assertEquals(enhetsnamn, arende.getEnhetsnamn());
assertEquals(vardgivarnamn, arende.getVardgivarnamn());
assertEquals(ArendeAmne.AVSTMN.name(), arende.getAmne());
assertEquals(vidarebefordrad, arende.isVidarebefordrad());
assertEquals(status, arende.getStatus());
}
Aggregations