use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount 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.ArendeCount 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());
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class NotificationTypeConverterTest method testConvert.
@Test
public void testConvert() throws Exception {
final String intygsId = "intygsid";
final LocalDateTime handelsetid = LocalDateTime.now().minusDays(1);
final HandelsekodEnum handelsetyp = HandelsekodEnum.ANDRAT;
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");
CertificateStatusUpdateForCareType res = NotificationTypeConverter.convert(msg, intyg);
assertEquals(intyg, res.getIntyg());
assertEquals(HandelsekodEnum.ANDRAT.value(), res.getHandelse().getHandelsekod().getCode());
assertEquals(HandelsekodEnum.ANDRAT.description(), res.getHandelse().getHandelsekod().getDisplayName());
assertEquals(handelsetid, res.getHandelse().getTidpunkt());
assertNotNull(res.getHandelse().getHandelsekod().getCodeSystem());
// handelsekod -> codeSystemName is not valid in schema but incorrectly generated in java class
// therefore we should not populate this field
assertNull(res.getHandelse().getHandelsekod().getCodeSystemName());
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());
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class IntygServiceTest method testListCertificatesForCareWithQAOk.
@Test
public void testListCertificatesForCareWithQAOk() throws Exception {
final List<String> enhetList = Arrays.asList("enhet");
final String intygType = "intygType";
final String intygId = "intygId";
final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.JANUARY, 1, 1, 1);
Handelse handelse = new Handelse();
handelse.setTimestamp(localDateTime);
handelse.setCode(HandelsekodEnum.SKAPAT);
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
ArendeCount sent = new ArendeCount(1, 2, 3, 4);
ArendeCount received = new ArendeCount(5, 6, 7, 8);
when(moduleRegistry.listAllModules()).thenReturn(Arrays.asList(new IntygModule(intygType, "", "", "", "", "", "", "", "", false)));
when(utkastRepository.findDraftsByPatientAndEnhetAndStatus(eq(PERSON_ID), eq(enhetList), eq(Arrays.asList(UtkastStatus.values())), eq(Collections.singleton(intygType)))).thenReturn(Arrays.asList(getDraft(intygId)));
when(notificationService.getNotifications(eq(intygId))).thenReturn(Arrays.asList(handelse));
when(moduleRegistry.getModuleApi(any(String.class))).thenReturn(moduleApi);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
when(fragorOchSvarCreator.createArenden(eq(intygId), anyString())).thenReturn(Pair.of(sent, received));
List<IntygWithNotificationsResponse> res = intygService.listCertificatesForCareWithQA(new IntygWithNotificationsRequest.Builder().setPersonnummer(PERSNR).setEnhetId(enhetList).build());
assertNotNull(res);
assertEquals(1, res.size());
assertEquals(1, res.get(0).getNotifications().size());
assertEquals(HandelsekodEnum.SKAPAT, res.get(0).getNotifications().get(0).getCode());
assertEquals(localDateTime, res.get(0).getNotifications().get(0).getTimestamp());
assertEquals(1, res.get(0).getSentQuestions().getTotalt());
assertEquals(2, res.get(0).getSentQuestions().getEjBesvarade());
assertEquals(3, res.get(0).getSentQuestions().getBesvarade());
assertEquals(4, res.get(0).getSentQuestions().getHanterade());
assertEquals(5, res.get(0).getReceivedQuestions().getTotalt());
assertEquals(6, res.get(0).getReceivedQuestions().getEjBesvarade());
assertEquals(7, res.get(0).getReceivedQuestions().getBesvarade());
assertEquals(8, res.get(0).getReceivedQuestions().getHanterade());
assertEquals(REFERENCE, res.get(0).getRef());
}
use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.
the class IntygServiceTest method testListCertificatesForCareWithQAVardgivare.
@Test
public void testListCertificatesForCareWithQAVardgivare() throws Exception {
final String vardgivarId = "vardgivarId";
final String intygType = "intygType";
final String intygId = "intygId";
final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.JANUARY, 1, 1, 1);
Handelse handelse = new Handelse();
handelse.setTimestamp(localDateTime);
handelse.setCode(HandelsekodEnum.SKAPAT);
Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
ArendeCount sent = new ArendeCount(1, 2, 3, 4);
ArendeCount received = new ArendeCount(5, 6, 7, 8);
when(moduleRegistry.listAllModules()).thenReturn(Arrays.asList(new IntygModule(intygType, "", "", "", "", "", "", "", "", false)));
when(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(eq(PERSON_ID), eq(vardgivarId), eq(Arrays.asList(UtkastStatus.values())), eq(Collections.singleton(intygType)))).thenReturn(Arrays.asList(getDraft(intygId)));
when(notificationService.getNotifications(eq(intygId))).thenReturn(Arrays.asList(handelse));
when(moduleRegistry.getModuleApi(any(String.class))).thenReturn(moduleApi);
when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
when(fragorOchSvarCreator.createArenden(eq(intygId), anyString())).thenReturn(Pair.of(sent, received));
List<IntygWithNotificationsResponse> res = intygService.listCertificatesForCareWithQA(new IntygWithNotificationsRequest.Builder().setPersonnummer(PERSNR).setVardgivarId(vardgivarId).build());
assertNotNull(res);
assertEquals(1, res.size());
assertEquals(1, res.get(0).getNotifications().size());
assertEquals(HandelsekodEnum.SKAPAT, res.get(0).getNotifications().get(0).getCode());
assertEquals(localDateTime, res.get(0).getNotifications().get(0).getTimestamp());
assertEquals(1, res.get(0).getSentQuestions().getTotalt());
assertEquals(2, res.get(0).getSentQuestions().getEjBesvarade());
assertEquals(3, res.get(0).getSentQuestions().getBesvarade());
assertEquals(4, res.get(0).getSentQuestions().getHanterade());
assertEquals(5, res.get(0).getReceivedQuestions().getTotalt());
assertEquals(6, res.get(0).getReceivedQuestions().getEjBesvarade());
assertEquals(7, res.get(0).getReceivedQuestions().getBesvarade());
assertEquals(8, res.get(0).getReceivedQuestions().getHanterade());
}
Aggregations