Search in sources :

Example 6 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class CertificateRevokeProcessor method process.

public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress, @Header(Constants.INTYGS_TYP) String intygsTyp) throws TemporaryException, PermanentException {
    checkArgument(!Strings.isNullOrEmpty(intygsId), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.INTYGS_ID);
    checkArgument(!Strings.isNullOrEmpty(logicalAddress), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.LOGICAL_ADDRESS);
    checkArgument(!Strings.isNullOrEmpty(intygsTyp), "Message of type %s does not have a %s header.", Constants.REVOKE_MESSAGE, Constants.INTYGS_TYP);
    try {
        ModuleApi moduleApi = registry.getModuleApi(intygsTyp);
        moduleApi.revokeCertificate(xmlBody, logicalAddress);
    } catch (ExternalServiceCallException e) {
        switch(e.getErroIdEnum()) {
            case TECHNICAL_ERROR:
            case APPLICATION_ERROR:
                throw new TemporaryException(e.getMessage());
            default:
                throw new PermanentException(e.getMessage());
        }
    } catch (ModuleException e) {
        throw new PermanentException(e.getMessage());
    } catch (WebServiceException e) {
        throw new TemporaryException(e.getMessage());
    } catch (Exception e) {
        throw new PermanentException(e.getMessage());
    }
}
Also used : ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) WebServiceException(javax.xml.ws.WebServiceException) ExternalServiceCallException(se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException)

Example 7 with TemporaryException

use of se.inera.intyg.webcert.common.sender.exception.TemporaryException in project webcert by sklintyg.

the class NotificationPatientEnricher method enrichWithPatient.

public void enrichWithPatient(Intyg intyg) throws TemporaryException {
    // INTYG-4190, hämta patientens uppgifter från PU-tjänsten och klistra in i utlåtandet.
    String intygsTyp = intyg.getTyp().getCode();
    switch(intygsTyp.toLowerCase()) {
        case "luse":
        case "luae_na":
        case "luae_fs":
        case "lisjp":
            String personId = intyg.getPatient().getPersonId().getExtension();
            Personnummer personnummer = Personnummer.createPersonnummer(personId).orElseThrow(() -> new IllegalArgumentException("Cannot create Personummer object from personId: " + personId));
            PersonSvar personSvar = puService.getPerson(personnummer);
            if (personSvar.getStatus() == PersonSvar.Status.FOUND) {
                if (!personSvar.getPerson().isSekretessmarkering()) {
                    intyg.setPatient(buildPatientFromPersonSvar(personSvar.getPerson()));
                } else {
                    intyg.getPatient().setEfternamn(SEKRETESSMARKERING);
                    intyg.getPatient().setFornamn(EMPTY_STRING);
                    intyg.getPatient().setMellannamn(EMPTY_STRING);
                    intyg.getPatient().setPostadress(EMPTY_STRING);
                    intyg.getPatient().setPostnummer(EMPTY_STRING);
                    intyg.getPatient().setPostort(EMPTY_STRING);
                }
            } else if (personSvar.getStatus() == PersonSvar.Status.ERROR) {
                throw new TemporaryException(new IllegalStateException("Could not query PU-service for enriching notification with patient data."));
            } else {
                LOG.warn("PU-service returned NOT_FOUND for personnummer: {}, not enriching notification.", personnummer.getPersonnummerHash());
            }
            break;
        default:
            // Do nothing
            break;
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar)

Aggregations

TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)7 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)6 WebServiceException (javax.xml.ws.WebServiceException)3 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)3 JAXBException (javax.xml.bind.JAXBException)1 Test (org.junit.Test)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 ExternalServiceCallException (se.inera.intyg.common.support.modules.support.api.exception.ExternalServiceCallException)1 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)1 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 CertificateStatusUpdateForCareResponseType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareResponseType)1 SendCertificateToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType)1 SendMessageToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)1 SendMessageToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)1 ResultType (se.riv.clinicalprocess.healthcond.certificate.v1.ResultType)1