Search in sources :

Example 1 with SendMedicalCertificateAnswerResponseType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType in project webcert by sklintyg.

the class SendAnswerStub method sendMedicalCertificateAnswer.

@Override
public SendMedicalCertificateAnswerResponseType sendMedicalCertificateAnswer(AttributedURIType logicalAddress, SendMedicalCertificateAnswerType parameters) {
    SendMedicalCertificateAnswerResponseType response = new SendMedicalCertificateAnswerResponseType();
    if (logicalAddress == null) {
        response.setResult(ResultOfCallUtil.failResult("Ingen LogicalAddress är satt"));
    } else if (!LOGICAL_ADDRESS.equals(logicalAddress.getValue())) {
        response.setResult(ResultOfCallUtil.failResult("LogicalAddress '" + logicalAddress.getValue() + "' är inte samma som '" + LOGICAL_ADDRESS + "'"));
    } else if ("error".equalsIgnoreCase(parameters.getAnswer().getSvar().getMeddelandeText())) {
        response.setResult(ResultOfCallUtil.failResult("Du ville ju få ett fel"));
    } else {
        AnswerToFkType answerType = parameters.getAnswer();
        SendMedicalCertificateAnswerValidator validator = new SendMedicalCertificateAnswerValidator(answerType);
        try {
            validator.validateAndCorrect();
            response.setResult(ResultOfCallUtil.okResult());
        } catch (ValidationException e) {
            response.setResult(ResultOfCallUtil.failResult(e.getMessage()));
        }
        questionAnswerStore.addAnswer(parameters.getAnswer());
    }
    return response;
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) ValidationException(se.inera.intyg.webcert.fkstub.validation.ValidationException) SendMedicalCertificateAnswerValidator(se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateAnswerValidator) AnswerToFkType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)

Example 2 with SendMedicalCertificateAnswerResponseType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType in project webcert by sklintyg.

the class FragaSvarServiceImplTest method testSaveSvarOK.

@Test
public void testSaveSvarOK() {
    FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
    when(webCertUserService.getUser()).thenReturn(createUser());
    when(fragasvarRepositoryMock.findOne(1L)).thenReturn(fragaSvar);
    when(webCertUserService.getUser()).thenReturn(createUser());
    when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
    when(fragasvarRepositoryMock.save(fragaSvar)).thenReturn(fragaSvar);
    // mock ws ok response
    SendMedicalCertificateAnswerResponseType wsResponse = new SendMedicalCertificateAnswerResponseType();
    wsResponse.setResult(ResultOfCallUtil.okResult());
    when(sendAnswerToFKClientMock.sendMedicalCertificateAnswer(any(AttributedURIType.class), any(SendMedicalCertificateAnswerType.class))).thenReturn(wsResponse);
    FragaSvar result = service.saveSvar(1L, "svarsText");
    verify(fragasvarRepositoryMock).findOne(1L);
    verify(webCertUserService).getUser();
    verify(webCertUserService).isAuthorizedForUnit(anyString(), eq(false));
    verify(fragasvarRepositoryMock).save(fragaSvar);
    verify(sendAnswerToFKClientMock).sendMedicalCertificateAnswer(any(AttributedURIType.class), any(SendMedicalCertificateAnswerType.class));
    verify(notificationServiceMock).sendNotificationForQAs(INTYG_ID, NotificationEvent.NEW_ANSWER_FROM_CARE);
    verify(monitoringServiceMock).logAnswerSent(anyString(), any(Long.class), anyString(), anyString(), any(Amne.class));
    assertEquals("svarsText", result.getSvarsText());
    assertEquals(Status.CLOSED, result.getStatus());
    assertNotNull(result.getSvarSkickadDatum());
    verify(arendeDraftService).delete(INTYG_ID, Long.toString(1L));
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) AttributedURIType(org.w3.wsaddressing10.AttributedURIType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) SendMedicalCertificateAnswerType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Amne(se.inera.intyg.webcert.persistence.fragasvar.model.Amne) Test(org.junit.Test)

Example 3 with SendMedicalCertificateAnswerResponseType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType in project webcert by sklintyg.

the class FragaSvarServiceImplTest method testAnswerKomplNotPermitted.

@Test(expected = WebCertServiceException.class)
public void testAnswerKomplNotPermitted() {
    FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
    fragaSvar.setAmne(Amne.KOMPLETTERING_AV_LAKARINTYG);
    fragaSvar.setFrageStallare(FrageStallare.FORSAKRINGSKASSAN.getKod());
    SendMedicalCertificateAnswerResponseType wsResponse = new SendMedicalCertificateAnswerResponseType();
    wsResponse.setResult(ResultOfCallUtil.okResult());
    when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
    when(fragasvarRepositoryMock.findOne(eq(1L))).thenReturn(fragaSvar);
    service.saveSvar(fragaSvar.getInternReferens(), "svarsText");
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 4 with SendMedicalCertificateAnswerResponseType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType in project webcert by sklintyg.

the class FragaSvarServiceImplTest method testSaveSvarWsError.

@Test(expected = WebCertServiceException.class)
public void testSaveSvarWsError() {
    FragaSvar fragaSvar = buildFragaSvar(1L, LocalDateTime.now(), LocalDateTime.now());
    when(fragasvarRepositoryMock.findOne(1L)).thenReturn(fragaSvar);
    when(webCertUserService.getUser()).thenReturn(createUser());
    when(webCertUserService.isAuthorizedForUnit(any(String.class), eq(false))).thenReturn(true);
    when(fragasvarRepositoryMock.save(fragaSvar)).thenReturn(fragaSvar);
    // mock ws error response
    SendMedicalCertificateAnswerResponseType wsResponse = new SendMedicalCertificateAnswerResponseType();
    wsResponse.setResult(ResultOfCallUtil.failResult("some error"));
    when(sendAnswerToFKClientMock.sendMedicalCertificateAnswer(any(AttributedURIType.class), any(SendMedicalCertificateAnswerType.class))).thenReturn(wsResponse);
    try {
        service.saveSvar(1L, "svarsText");
    } finally {
        verifyZeroInteractions(notificationServiceMock);
    }
}
Also used : SendMedicalCertificateAnswerResponseType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType) AttributedURIType(org.w3.wsaddressing10.AttributedURIType) FragaSvar(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar) SendMedicalCertificateAnswerType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with SendMedicalCertificateAnswerResponseType

use of se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType 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)

Aggregations

SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)5 Test (org.junit.Test)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)3 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)3 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)3 AnswerToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 SendMedicalCertificateAnswerValidator (se.inera.intyg.webcert.fkstub.validation.SendMedicalCertificateAnswerValidator)1 ValidationException (se.inera.intyg.webcert.fkstub.validation.ValidationException)1 Amne (se.inera.intyg.webcert.persistence.fragasvar.model.Amne)1