Search in sources :

Example 1 with SendMessageToRecipientType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType in project webcert by sklintyg.

the class SendMessageToRecipientTypeConverterTest method buildSendMessageToRecipientType.

private SendMessageToRecipientType buildSendMessageToRecipientType() {
    SendMessageToRecipientType res = new SendMessageToRecipientType();
    res.setAmne(new Amneskod());
    res.getAmne().setCode("OVRIGT");
    res.getAmne().setCodeSystem("ffa59d8f-8d7e-46ae-ac9e-31804e8e8499");
    res.getAmne().setDisplayName("Övrigt");
    res.setIntygsId(new IntygId());
    res.getIntygsId().setRoot("TSTNMT2321000156-1039");
    res.getIntygsId().setExtension("79d77cad-0c19-4278-8212-b23c82a7e33c");
    res.setLogiskAdressMottagare("SendMessageStub");
    res.setMeddelande("svarstext meddelande");
    res.setMeddelandeId("b7360a70-80a3-4d24-b10e-621c3c0c826a");
    res.setPatientPersonId(new PersonId());
    res.getPatientPersonId().setRoot("1.2.752.129.2.1.3.1");
    res.getPatientPersonId().setExtension("19121212-1212");
    res.setReferensId("referensId");
    res.setRubrik("en fråga");
    res.setSkickatAv(new HosPersonal());
    res.getSkickatAv().setEnhet(new Enhet());
    res.getSkickatAv().getEnhet().setArbetsplatskod(new ArbetsplatsKod());
    res.getSkickatAv().getEnhet().getArbetsplatskod().setRoot("1.2.752.29.4.71");
    res.getSkickatAv().getEnhet().getArbetsplatskod().setExtension("1234567890");
    res.getSkickatAv().getEnhet().setEnhetsId(new HsaId());
    res.getSkickatAv().getEnhet().getEnhetsId().setRoot("1.2.752.129.2.1.4.1");
    res.getSkickatAv().getEnhet().getEnhetsId().setExtension("TSTNMT2321000156-1039");
    res.getSkickatAv().getEnhet().setEnhetsnamn("NMT vg1 ve2");
    res.getSkickatAv().getEnhet().setVardgivare(new Vardgivare());
    res.getSkickatAv().getEnhet().getVardgivare().setVardgivareId(new HsaId());
    res.getSkickatAv().getEnhet().getVardgivare().getVardgivareId().setRoot("1.2.752.129.2.1.4.1");
    res.getSkickatAv().getEnhet().getVardgivare().getVardgivareId().setExtension("TSTNMT2321000156-1002");
    res.getSkickatAv().getEnhet().getVardgivare().setVardgivarnamn("NMT vg1");
    res.getSkickatAv().setForskrivarkod("0000000");
    res.getSkickatAv().setFullstandigtNamn("Leonie Koehl");
    res.getSkickatAv().setPersonalId(new HsaId());
    res.getSkickatAv().getPersonalId().setRoot("1.2.752.129.2.1.4.1");
    res.getSkickatAv().getPersonalId().setExtension("TSTNMT2321000156-103F");
    res.setSkickatTidpunkt(LocalDateTime.now());
    res.setSvarPa(new MeddelandeReferens());
    res.getSvarPa().setMeddelandeId("5d665d73-7029-4619-9a91-3225a90d81c8");
    res.getSvarPa().setReferensId("referensid2");
    return res;
}
Also used : HosPersonal(se.riv.clinicalprocess.healthcond.certificate.v3.HosPersonal) Enhet(se.riv.clinicalprocess.healthcond.certificate.v3.Enhet) ArbetsplatsKod(se.riv.clinicalprocess.healthcond.certificate.types.v3.ArbetsplatsKod) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) Vardgivare(se.riv.clinicalprocess.healthcond.certificate.v3.Vardgivare) Amneskod(se.riv.clinicalprocess.healthcond.certificate.types.v3.Amneskod) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId) MeddelandeReferens(se.riv.clinicalprocess.healthcond.certificate.v3.MeddelandeReferens) IntygId(se.riv.clinicalprocess.healthcond.certificate.types.v3.IntygId)

Example 2 with SendMessageToRecipientType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType in project webcert by sklintyg.

the class SendMessageToRecipientTypeConverterTest method convertTest.

@Test
public void convertTest() throws JAXBException {
    SendMessageToRecipientType request = buildSendMessageToRecipientType();
    String xmlString = SendMessageToRecipientTypeConverter.toXml(request);
    SendMessageToRecipientType requestRes = SendMessageToRecipientTypeConverter.fromXml(xmlString);
    assertEquals(request.getAmne().getCode(), requestRes.getAmne().getCode());
    assertEquals(request.getIntygsId().getExtension(), requestRes.getIntygsId().getExtension());
    assertEquals(request.getLogiskAdressMottagare(), requestRes.getLogiskAdressMottagare());
    assertEquals(request.getMeddelandeId(), requestRes.getMeddelandeId());
    assertEquals(request.getPatientPersonId().getExtension(), requestRes.getPatientPersonId().getExtension());
    assertEquals(request.getSkickatAv().getPersonalId().getExtension(), requestRes.getSkickatAv().getPersonalId().getExtension());
}
Also used : SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) Test(org.junit.Test)

Example 3 with SendMessageToRecipientType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType in project webcert by sklintyg.

the class SendMessageToRecipientProcessor method process.

public void process(@Body String xmlBody, @Header(Constants.INTYGS_ID) String intygsId, @Header(Constants.LOGICAL_ADDRESS) String logicalAddress) throws TemporaryException, PermanentException {
    try {
        SendMessageToRecipientType parameters = SendMessageToRecipientTypeConverter.fromXml(xmlBody);
        SendMessageToRecipientResponseType response = sendMessageToRecipientResponder.sendMessageToRecipient(logicalAddress, parameters);
        ResultType result = response.getResult();
        switch(result.getResultCode()) {
            case OK:
            case INFO:
                return;
            case ERROR:
                switch(result.getErrorId()) {
                    case REVOKED:
                    case VALIDATION_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as PermanentException", intygsId, result.getResultText(), result.getErrorId());
                        throw new PermanentException(result.getResultText());
                    case APPLICATION_ERROR:
                    case TECHNICAL_ERROR:
                        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}, ErrorId: {}." + " Rethrowing as TemporaryException", intygsId, result.getResultText(), result.getErrorId());
                        throw new TemporaryException(result.getResultText());
                }
        }
    } catch (JAXBException e) {
        LOG.error("Call to sendMessageToRecipient for intyg {} caused an error: {}. Rethrowing as PermanentException", intygsId, e.getMessage());
        throw new PermanentException(e.getMessage());
    } catch (WebServiceException e) {
        LOG.error("Call to sendMessageToRecipient for 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) WebServiceException(javax.xml.ws.WebServiceException) PermanentException(se.inera.intyg.webcert.common.sender.exception.PermanentException) JAXBException(javax.xml.bind.JAXBException) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) SendMessageToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)

Example 4 with SendMessageToRecipientType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType in project webcert by sklintyg.

the class SendMessageToRecipientTypeConverter method toXml.

public static String toXml(SendMessageToRecipientType request) throws JAXBException {
    StringWriter stringWriter = new StringWriter();
    JAXBElement<SendMessageToRecipientType> requestElement = new ObjectFactory().createSendMessageToRecipient(request);
    JAXBContext.newInstance(SendMessageToRecipientType.class).createMarshaller().marshal(requestElement, stringWriter);
    return stringWriter.toString();
}
Also used : StringWriter(java.io.StringWriter) ObjectFactory(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.ObjectFactory) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)

Example 5 with SendMessageToRecipientType

use of se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType in project webcert by sklintyg.

the class ArendeServiceImpl method processOutgoingMessage.

private Arende processOutgoingMessage(Arende arende, NotificationEvent notificationEvent) {
    Arende saved = arendeRepository.save(arende);
    monitoringLog.logArendeCreated(arende.getIntygsId(), arende.getIntygTyp(), arende.getEnhetId(), arende.getAmne(), arende.getSvarPaId() != null);
    updateRelated(arende);
    SendMessageToRecipientType request = SendMessageToRecipientTypeBuilder.build(arende, webcertUserService.getUser(), sendMessageToFKLogicalAddress);
    // Send to recipient
    try {
        certificateSenderService.sendMessageToRecipient(arende.getIntygsId(), SendMessageToRecipientTypeConverter.toXml(request));
    } catch (JAXBException | CertificateSenderException e) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, e.getMessage());
    }
    sendNotification(saved, notificationEvent);
    return saved;
}
Also used : JAXBException(javax.xml.bind.JAXBException) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) SendMessageToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException) CertificateSenderException(se.inera.intyg.webcert.web.service.certificatesender.CertificateSenderException)

Aggregations

SendMessageToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientType)9 Test (org.junit.Test)4 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)4 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)3 JAXBException (javax.xml.bind.JAXBException)2 StringWriter (java.io.StringWriter)1 WebServiceException (javax.xml.ws.WebServiceException)1 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)1 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)1 CertificateSenderException (se.inera.intyg.webcert.web.service.certificatesender.CertificateSenderException)1 ObjectFactory (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.ObjectFactory)1 SendMessageToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendMessageToRecipient.v2.SendMessageToRecipientResponseType)1 Amneskod (se.riv.clinicalprocess.healthcond.certificate.types.v3.Amneskod)1 ArbetsplatsKod (se.riv.clinicalprocess.healthcond.certificate.types.v3.ArbetsplatsKod)1 HsaId (se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId)1 IntygId (se.riv.clinicalprocess.healthcond.certificate.types.v3.IntygId)1 PersonId (se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId)1 Enhet (se.riv.clinicalprocess.healthcond.certificate.v3.Enhet)1