Search in sources :

Example 76 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class WebcertRedirectIntegrationExceptionHandler method handleRuntimeException.

private Response handleRuntimeException(RuntimeException re) {
    if (re instanceof WebCertServiceException) {
        LOG.warn("WebCertServiceException caught", re.getMessage());
        WebCertServiceException we = (WebCertServiceException) re;
        if (we.getErrorCode() == WebCertServiceErrorCodeEnum.MISSING_PARAMETER) {
            return buildErrorRedirectResponse("missing-parameter", we.getMessage());
        } else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM) {
            return buildErrorRedirectResponse("auth-exception", we.getMessage());
        } else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM_SEKRETESSMARKERING) {
            return buildErrorRedirectResponse("auth-exception-sekretessmarkering", we.getMessage());
        } else if (we.getErrorCode() == WebCertServiceErrorCodeEnum.PU_PROBLEM) {
            return buildErrorRedirectResponse("pu-problem", we.getMessage());
        }
    }
    LOG.error("Unhandled RuntimeException occured!", re);
    return buildErrorRedirectResponse("unknown", re.getMessage());
}
Also used : WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 77 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException 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 78 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class FragaSvarServiceImpl method sendFragaSvarToExternalParty.

private void sendFragaSvarToExternalParty(final FragaSvar fragaSvar) {
    // Send to external party (FK)
    SendMedicalCertificateAnswerType sendType = new SendMedicalCertificateAnswerType();
    AnswerToFkType answer = FKAnswerConverter.convert(fragaSvar);
    sendType.setAnswer(answer);
    // Remove ASAP.
    if ("true".equalsIgnoreCase(forceFullstandigtNamn)) {
        answer.getLakarutlatande().getPatient().setFullstandigtNamn("---");
    }
    AttributedURIType logicalAddress = new AttributedURIType();
    logicalAddress.setValue(sendAnswerToFkLogicalAddress);
    SendMedicalCertificateAnswerResponseType response;
    try {
        response = sendAnswerToFKClient.sendMedicalCertificateAnswer(logicalAddress, sendType);
    } catch (SOAPFaultException e) {
        LOGGER.error("Failed to send answer to FK, error was: " + e.getMessage());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getMessage());
    }
    if (!response.getResult().getResultCode().equals(ResultCodeEnum.OK)) {
        LOGGER.error("Failed to send answer to FK, result was " + response.getResult().getErrorText());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, response.getResult().getErrorText());
    }
    monitoringService.logAnswerSent(fragaSvar.getExternReferens(), fragaSvar.getInternReferens(), (fragaSvar.getIntygsReferens() == null) ? null : fragaSvar.getIntygsReferens().getIntygsId(), fragaSvar.getVardAktorHsaId(), fragaSvar.getAmne());
    // Notify stakeholders
    sendNotification(fragaSvar, NotificationEvent.NEW_ANSWER_FROM_CARE);
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) AttributedURIType(org.w3.wsaddressing10.AttributedURIType) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType) SendMedicalCertificateAnswerType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 79 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class IntygServiceImpl method handleAfterSigned.

/**
 * Check if signed certificate is a completion, in that case, send to recipient and close pending completion QA /
 * Arende as handled.
 * <p>
 * Check if signed certificate should be sent directly to default recipient for this intygstyp.
 * <p>
 * Note that the send operation uses the "delay" boolean to allow the signing operation some time to complete
 * in intygstjansten.
 */
@Override
public void handleAfterSigned(Utkast utkast) {
    boolean isKomplettering = RelationKod.KOMPLT == utkast.getRelationKod();
    boolean isSigneraSkickaDirekt = authoritiesHelper.isFeatureActive(AuthoritiesConstants.FEATURE_SIGNERA_SKICKA_DIREKT, utkast.getIntygsTyp());
    if (isKomplettering || isSigneraSkickaDirekt) {
        try {
            LOG.info("Send intyg '{}' directly to recipient", utkast.getIntygsId());
            sendIntyg(utkast.getIntygsId(), utkast.getIntygsTyp(), moduleRegistry.getModuleEntryPoint(utkast.getIntygsTyp()).getDefaultRecipient(), true);
            if (isKomplettering) {
                LOG.info("Set komplettering QAs as handled for {}", utkast.getRelationIntygsId());
                arendeService.closeCompletionsAsHandled(utkast.getRelationIntygsId(), utkast.getIntygsTyp());
            }
        } catch (ModuleNotFoundException e) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, "Could not send intyg directly to recipient", e);
        }
    }
}
Also used : ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 80 with WebCertServiceException

use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.

the class IntygServiceImpl method buildIntygContentHolderForUtkast.

// NOTE! INTYG-4086. This method is used when fetching Intyg/Utkast from WC locally. The question is, should we
// replace the patient on the existing model with a freshly fetched one here or not? In case we're storing patient
// info entered manually for non FK-types here, we may end up overwriting a manually stored name etc...
private IntygContentHolder buildIntygContentHolderForUtkast(Utkast utkast, boolean relations) {
    try {
        // INTYG-4086: Patient object populated according to ruleset for the intygstyp at hand.
        Patient newPatientData = patientDetailsResolver.resolvePatient(utkast.getPatientPersonnummer(), utkast.getIntygsTyp());
        // create an "empty" Patient with personnummer only.
        if (newPatientData == null) {
            newPatientData = new Patient();
            newPatientData.setPersonId(utkast.getPatientPersonnummer());
        }
        // INTYG-5354, INTYG-5380: Don't use incomplete address from external data sources (PU/js).
        Utlatande utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), utkast.getModel());
        if (!completeAddressProvided(newPatientData)) {
            // Use the old address data.
            Patient oldPatientData = utlatande.getGrundData().getPatient();
            copyOldAddressToNewPatientData(oldPatientData, newPatientData);
        }
        String updatedModel = moduleRegistry.getModuleApi(utkast.getIntygsTyp()).updateBeforeSave(utkast.getModel(), newPatientData);
        utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), updatedModel);
        List<Status> statuses = IntygConverterUtil.buildStatusesFromUtkast(utkast);
        Relations certificateRelations = certificateRelationService.getRelations(utkast.getIntygsId());
        final SekretessStatus sekretessStatus = patientDetailsResolver.getSekretessStatus(newPatientData.getPersonId());
        if (SekretessStatus.UNDEFINED.equals(sekretessStatus)) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, "Sekretesstatus could not be fetched from the PU service");
        }
        final boolean sekretessmarkerad = SekretessStatus.TRUE.equals(sekretessStatus);
        boolean patientNameChanged = patientDetailsResolver.isPatientNamedChanged(utlatande.getGrundData().getPatient(), newPatientData);
        boolean patientAddressChanged = patientDetailsResolver.isPatientAddressChanged(utlatande.getGrundData().getPatient(), newPatientData);
        return IntygContentHolder.builder().setContents(updatedModel).setUtlatande(utlatande).setStatuses(statuses).setRevoked(utkast.getAterkalladDatum() != null).setRelations(certificateRelations).setCreated(utkast.getSkapad()).setDeceased(isDeceased(utkast.getPatientPersonnummer())).setSekretessmarkering(sekretessmarkerad).setPatientNameChangedInPU(patientNameChanged).setPatientAddressChangedInPU(patientAddressChanged).build();
    } catch (ModuleException | ModuleNotFoundException e) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    }
}
Also used : UtkastStatus(se.inera.intyg.webcert.common.model.UtkastStatus) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Status(se.inera.intyg.common.support.model.Status) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Aggregations

WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)85 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)35 Test (org.junit.Test)16 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)16 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)14 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)14 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)13 OptimisticLockException (javax.persistence.OptimisticLockException)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)11 Personnummer (se.inera.intyg.schemas.contract.Personnummer)10 SignaturTicket (se.inera.intyg.webcert.web.service.signatur.dto.SignaturTicket)10 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)9 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)7 Transactional (org.springframework.transaction.annotation.Transactional)7 POST (javax.ws.rs.POST)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)6 LocalDateTime (java.time.LocalDateTime)5