Search in sources :

Example 1 with NotificationEvent

use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.

the class ArendeServiceImpl method openArendeAsUnhandled.

@Override
public ArendeConversationView openArendeAsUnhandled(String meddelandeId) {
    Arende arende = lookupArende(meddelandeId);
    boolean arendeIsAnswered = !arendeRepository.findBySvarPaId(meddelandeId).isEmpty();
    // Enforce business rule FS-011, from FK + answer should remain closed
    if (!FrageStallare.WEBCERT.isKodEqual(arende.getSkickatAv()) && arendeIsAnswered) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + meddelandeId);
    }
    NotificationEvent notificationEvent = determineNotificationEvent(arende, arendeIsAnswered);
    if (arendeIsAnswered) {
        arende.setStatus(Status.ANSWERED);
    } else {
        if (FrageStallare.WEBCERT.isKodEqual(arende.getSkickatAv())) {
            arende.setStatus(Status.PENDING_EXTERNAL_ACTION);
        } else {
            arende.setStatus(Status.PENDING_INTERNAL_ACTION);
        }
    }
    Arende openedArende = arendeRepository.save(arende);
    sendNotification(openedArende, notificationEvent);
    return arendeViewConverter.convertToArendeConversationView(openedArende, arendeRepository.findBySvarPaId(meddelandeId).stream().findFirst().orElse(null), null, arendeRepository.findByPaminnelseMeddelandeId(meddelandeId), null);
}
Also used : MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 2 with NotificationEvent

use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.

the class ArendeServiceImpl method closeArendeAsHandled.

private Arende closeArendeAsHandled(Arende arendeToClose) {
    NotificationEvent notificationEvent = determineNotificationEvent(arendeToClose, false);
    arendeToClose.setStatus(Status.CLOSED);
    arendeToClose.setSenasteHandelse(LocalDateTime.now(systemClock));
    Arende closedArende = arendeRepository.save(arendeToClose);
    sendNotification(closedArende, notificationEvent);
    arendeDraftService.delete(closedArende.getIntygsId(), closedArende.getMeddelandeId());
    return closedArende;
}
Also used : NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende)

Example 3 with NotificationEvent

use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.

the class FragaSvarServiceImpl method openQuestionAsUnhandled.

@Override
public FragaSvar openQuestionAsUnhandled(Long frageSvarId) {
    FragaSvar fragaSvar = lookupFragaSvar(frageSvarId);
    // Enforce business rule FS-011, from FK + answer should remain closed
    if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId);
    }
    NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
    if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
        fragaSvar.setStatus(Status.ANSWERED);
    } else {
        if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) {
            fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION);
        } else {
            fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION);
        }
    }
    FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar);
    sendNotification(openedFragaSvar, notificationEvent);
    return openedFragaSvar;
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 4 with NotificationEvent

use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.

the class FragaSvarServiceImpl method closeQuestionAsHandled.

private FragaSvar closeQuestionAsHandled(FragaSvar fragaSvar) {
    NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
    fragaSvar.setStatus(Status.CLOSED);
    FragaSvar closedFragaSvar = fragaSvarRepository.save(fragaSvar);
    sendNotification(closedFragaSvar, notificationEvent);
    if (!fragaSvar.getFrageStallare().equals(FrageStallare.WEBCERT.getKod())) {
        arendeDraftService.delete(fragaSvar.getIntygsReferens().getIntygsId(), Long.toString(fragaSvar.getInternReferens()));
    }
    return closedFragaSvar;
}
Also used : FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) NotificationEvent(se.inera.intyg.webcert.web.service.notification.NotificationEvent)

Aggregations

NotificationEvent (se.inera.intyg.webcert.web.service.notification.NotificationEvent)4 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)2 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)2 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)2