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());
}
}
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;
}
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));
}
Aggregations