use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformerTest method testSituationanpassatCertificateOnSchemaVersion1.
@Test(expected = IllegalArgumentException.class)
public void testSituationanpassatCertificateOnSchemaVersion1() throws Exception {
NotificationMessage notificationMessage = new NotificationMessage(INTYGS_ID, LUSE, LocalDateTime.now(), HandelsekodEnum.SKAPAT, LOGISK_ADRESS, "{ }", FragorOchSvar.getEmpty(), null, null, SchemaVersion.VERSION_1, "ref");
Message message = new DefaultMessage();
message.setBody(notificationMessage);
transformer.process(message);
verifyZeroInteractions(notificationPatientEnricher);
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformerTest method testSchemaVersion2Transformation.
@Test
public void testSchemaVersion2Transformation() throws Exception {
NotificationMessage notificationMessage = new NotificationMessage(INTYGS_ID, LUSE, LocalDateTime.now(), HandelsekodEnum.SKAPAT, LOGISK_ADRESS, "{ }", null, ArendeCount.getEmpty(), ArendeCount.getEmpty(), SchemaVersion.VERSION_3, "ref");
Message message = spy(new DefaultMessage());
message.setBody(notificationMessage);
ModuleApi moduleApi = mock(ModuleApi.class);
when(moduleRegistry.getModuleApi(eq(LUSE))).thenReturn(moduleApi);
Intyg intyg = new Intyg();
IntygId intygsId = new IntygId();
intygsId.setExtension(INTYGS_ID);
intyg.setIntygsId(intygsId);
HosPersonal hosPersonal = new HosPersonal();
Enhet enhet = new Enhet();
enhet.setArbetsplatskod(new ArbetsplatsKod());
enhet.setVardgivare(new Vardgivare());
hosPersonal.setEnhet(enhet);
intyg.setSkapadAv(hosPersonal);
when(moduleApi.getIntygFromUtlatande(any())).thenReturn(intyg);
transformer.process(message);
assertEquals(INTYGS_ID, ((se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType) message.getBody()).getIntyg().getIntygsId().getExtension());
assertEquals(HandelsekodEnum.SKAPAT.value(), message.getHeader(NotificationRouteHeaders.HANDELSE));
assertEquals(INTYGS_ID, message.getHeader(NotificationRouteHeaders.INTYGS_ID));
assertEquals(LOGISK_ADRESS, message.getHeader(NotificationRouteHeaders.LOGISK_ADRESS));
assertEquals(SchemaVersion.VERSION_3.name(), message.getHeader(NotificationRouteHeaders.VERSION));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.LOGISK_ADRESS), eq(LOGISK_ADRESS));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.INTYGS_ID), eq(INTYGS_ID));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.HANDELSE), eq(HandelsekodEnum.SKAPAT.value()));
verify(message, times(1)).setHeader(eq(NotificationRouteHeaders.VERSION), eq(SchemaVersion.VERSION_3.name()));
verify(moduleRegistry, times(1)).getModuleApi(eq(LUSE));
verify(moduleApi, times(1)).getUtlatandeFromJson(any());
verify(moduleApi, times(1)).getIntygFromUtlatande(any());
verify(notificationPatientEnricher, times(1)).enrichWithPatient(any());
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTransformerTest method setupInternalToNotification.
private void setupInternalToNotification() throws ModuleException {
when(internalToNotification.createCertificateStatusUpdateForCareType(any())).thenAnswer(invocation -> {
NotificationMessage msg = (NotificationMessage) invocation.getArguments()[0];
if (msg == null) {
return null;
}
CertificateStatusUpdateForCareType request = new CertificateStatusUpdateForCareType();
UtlatandeType utlatande = new UtlatandeType();
UtlatandeId utlatandeId = new UtlatandeId();
utlatandeId.setExtension(msg.getIntygsId());
utlatande.setUtlatandeId(utlatandeId);
request.setUtlatande(utlatande);
return request;
});
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTypeConverterTest method testNotUpdatingExistingValues.
@Test
public void testNotUpdatingExistingValues() {
final String intygsId = "intygsid";
final String arbetsplatskod = "ARBETSPLATSKOD";
final String epost = "EPOST";
final LocalDateTime handelsetid = LocalDateTime.now().minusDays(1);
final HandelsekodEnum handelsetyp = HandelsekodEnum.ANDRAT;
Intyg intyg = buildIntyg();
Enhet enhet = intyg.getSkapadAv().getEnhet();
enhet.getArbetsplatskod().setExtension(arbetsplatskod);
enhet.setEpost(epost);
NotificationMessage msg = new NotificationMessage(intygsId, "luse", handelsetid, handelsetyp, "address", "", null, new ArendeCount(4, 3, 2, 1), new ArendeCount(4, 3, 2, 1), SchemaVersion.VERSION_3, "ref");
CertificateStatusUpdateForCareType res = NotificationTypeConverter.convert(msg, intyg);
assertEquals(arbetsplatskod, res.getIntyg().getSkapadAv().getEnhet().getArbetsplatskod().getExtension());
assertEquals(epost, res.getIntyg().getSkapadAv().getEnhet().getEpost());
}
use of se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage in project webcert by sklintyg.
the class NotificationTypeConverterTest method testConvertWhenHandelsekodIsNYFRFM.
@Test
public void testConvertWhenHandelsekodIsNYFRFM() throws Exception {
final String intygsId = "intygsid";
final LocalDateTime handelsetid = LocalDateTime.now().minusDays(1);
final LocalDate sistaSvarsDatum = LocalDate.now().plusWeeks(3);
final HandelsekodEnum handelsetyp = HandelsekodEnum.NYFRFM;
final Amneskod amneskod = AmneskodCreator.create("KOMPLT", "Komplettering");
final int skickadeFragorTotalt = 8;
final int skickadeFragorHanterade = 7;
final int skickadeFragorBesvarade = 6;
final int skickadeFragorEjBesvarade = 5;
final int mottagnaFragorTotalt = 4;
final int mottagnaFragorHanterade = 3;
final int mottagnaFragorBesvarade = 2;
final int mottagnaFragorEjBesvarade = 1;
final Intyg intyg = buildIntyg();
ArendeCount skickadeFragor = new ArendeCount(skickadeFragorTotalt, skickadeFragorEjBesvarade, skickadeFragorBesvarade, skickadeFragorHanterade);
ArendeCount mottagnaFragor = new ArendeCount(mottagnaFragorTotalt, mottagnaFragorEjBesvarade, mottagnaFragorBesvarade, mottagnaFragorHanterade);
NotificationMessage msg = new NotificationMessage(intygsId, "luse", handelsetid, handelsetyp, "address", "", null, skickadeFragor, mottagnaFragor, SchemaVersion.VERSION_3, "ref", amneskod, sistaSvarsDatum);
CertificateStatusUpdateForCareType res = NotificationTypeConverter.convert(msg, intyg);
assertEquals(intyg, res.getIntyg());
assertEquals(HandelsekodEnum.NYFRFM.value(), res.getHandelse().getHandelsekod().getCode());
assertEquals(HandelsekodEnum.NYFRFM.description(), res.getHandelse().getHandelsekod().getDisplayName());
assertEquals(handelsetid, res.getHandelse().getTidpunkt());
assertEquals(sistaSvarsDatum, res.getHandelse().getSistaDatumForSvar());
assertEquals(amneskod.getCode(), res.getHandelse().getAmne().getCode());
assertEquals(amneskod.getCodeSystem(), res.getHandelse().getAmne().getCodeSystem());
assertEquals(amneskod.getDisplayName(), res.getHandelse().getAmne().getDisplayName());
assertSkickadeFrågor(skickadeFragorTotalt, skickadeFragorHanterade, skickadeFragorBesvarade, skickadeFragorEjBesvarade, res);
assertMottagnaFragor(mottagnaFragorTotalt, mottagnaFragorHanterade, mottagnaFragorBesvarade, mottagnaFragorEjBesvarade, res);
// Make sure we have a valid Intyg according to service contract
assertEquals(NotificationTypeConverter.TEMPORARY_ARBETSPLATSKOD, res.getIntyg().getSkapadAv().getEnhet().getArbetsplatskod().getExtension());
assertNull(res.getIntyg().getSkapadAv().getEnhet().getEpost());
}
Aggregations