Search in sources :

Example 6 with AnswerToFkType

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

AnswerToFkType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.AnswerToFkType)5 JAXBContext (javax.xml.bind.JAXBContext)2 SendMedicalCertificateAnswerResponseType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerResponseType)2 StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 Marshaller (javax.xml.bind.Marshaller)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 StreamSource (javax.xml.transform.stream.StreamSource)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 Test (org.junit.Test)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1 AttributedURIType (org.w3.wsaddressing10.AttributedURIType)1 KompletteringType (se.inera.ifv.insuranceprocess.healthreporting.medcertqa.v1.KompletteringType)1 QuestionFromFkType (se.inera.ifv.insuranceprocess.healthreporting.receivemedicalcertificatequestionsponder.v1.QuestionFromFkType)1 ObjectFactory (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.ObjectFactory)1 SendMedicalCertificateAnswerType (se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateanswerresponder.v1.SendMedicalCertificateAnswerType)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 FragaSvar (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar)1