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