Search in sources :

Example 11 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class CertificateSendProcessor method process.

public void process(@Body String skickatAv, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.PERSON_ID) String personId, @Header(Constants.RECIPIENT) String recipient, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException {
    SendCertificateToRecipientResponseType response;
    try {
        response = sendServiceClient.sendCertificate(intygsId, personId, skickatAv, recipient, logicalAddress);
        final ResultType result = response.getResult();
        final String resultText = result.getResultText();
        if (ResultCodeType.ERROR == result.getResultCode()) {
            LOG.warn("Error occured when trying to send intyg '{}'; {}", intygsId, resultText);
            switch(result.getErrorId()) {
                case APPLICATION_ERROR:
                case TECHNICAL_ERROR:
                    throw new TemporaryException(resultText);
                case REVOKED:
                case VALIDATION_ERROR:
                    throw new PermanentException(resultText);
            }
        } else {
            if (ResultCodeType.INFO.equals(result.getResultCode())) {
                LOG.warn("Warning occured when trying to send intyg '{}'; {}. Will not requeue.", intygsId, resultText);
            }
        }
    } catch (WebServiceException e) {
        LOG.warn("Call to send intyg {} caused an error: {}. Will retry", intygsId, e.getMessage());
        throw new TemporaryException(e.getMessage());
    }
}
Also used : TemporaryException(se.inera.intyg.webcert.common.sender.exception.TemporaryException) SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Example 12 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class MockSendCertificateServiceClientImpl method createResponse.

private SendCertificateToRecipientResponseType createResponse(ResultCodeType resultCodeType, ErrorIdType errorType) {
    ResultType resultType = new ResultType();
    resultType.setResultCode(resultCodeType);
    if (errorType != null) {
        resultType.setErrorId(errorType);
    }
    SendCertificateToRecipientResponseType responseType = new SendCertificateToRecipientResponseType();
    responseType.setResult(resultType);
    return responseType;
}
Also used : SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)

Example 13 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class IntygServiceSendTest method testSendIntygReturnsInfo.

@Test
public void testSendIntygReturnsInfo() throws Exception {
    final String completionMeddelandeId = "meddelandeId";
    SendCertificateToRecipientResponseType response = new SendCertificateToRecipientResponseType();
    response.setResult(ResultTypeUtil.infoResult("Info text"));
    WebCertUser webCertUser = createUser();
    Utlatande completionUtlatande = utlatande;
    completionUtlatande.getGrundData().setRelation(new Relation());
    completionUtlatande.getGrundData().getRelation().setRelationKod(RelationKod.KOMPLT);
    completionUtlatande.getGrundData().getRelation().setMeddelandeId(completionMeddelandeId);
    when(moduleFacade.getUtlatandeFromInternalModel(isNull(), anyString())).thenReturn(completionUtlatande);
    when(webCertUserService.isAuthorizedForUnit(anyString(), anyString(), anyBoolean())).thenReturn(true);
    when(patientDetailsResolver.getSekretessStatus(any(Personnummer.class))).thenReturn(SekretessStatus.FALSE);
    when(webCertUserService.getUser()).thenReturn(webCertUser);
    when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
    IntygServiceResult res = intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
    assertEquals(IntygServiceResult.OK, res);
    verify(logService).logSendIntygToRecipient(any(LogRequest.class));
    verify(certificateSenderService).sendCertificate(anyString(), any(Personnummer.class), anyString(), anyString(), eq(false));
    verify(intygRepository, times(2)).findOne(INTYG_ID);
    verify(intygRepository).save(any(Utkast.class));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) Relation(se.inera.intyg.common.support.model.common.internal.Relation) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) IntygServiceResult(se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Aggregations

SendCertificateToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType)12 Test (org.junit.Test)8 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)4 SendCertificateToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientType)2 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)1 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 CertificateHolder (se.inera.intyg.common.support.modules.support.api.CertificateHolder)1 CertificateStateHolder (se.inera.intyg.common.support.modules.support.api.CertificateStateHolder)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)1 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1 StubLatencyAware (se.inera.intyg.webcert.intygstjanststub.mode.StubLatencyAware)1 StubModeAware (se.inera.intyg.webcert.intygstjanststub.mode.StubModeAware)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 IntygServiceResult (se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult)1