Search in sources :

Example 1 with ArendeCount

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) Enhet(se.riv.clinicalprocess.healthcond.certificate.v3.Enhet) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) CertificateStatusUpdateForCareType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType) HandelsekodEnum(se.inera.intyg.common.support.common.enumerations.HandelsekodEnum) Test(org.junit.Test)

Example 2 with ArendeCount

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) CertificateStatusUpdateForCareType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType) HandelsekodEnum(se.inera.intyg.common.support.common.enumerations.HandelsekodEnum) LocalDate(java.time.LocalDate) Amneskod(se.riv.clinicalprocess.healthcond.certificate.types.v3.Amneskod) Test(org.junit.Test)

Example 3 with ArendeCount

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Intyg(se.riv.clinicalprocess.healthcond.certificate.v3.Intyg) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) CertificateStatusUpdateForCareType(se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType) HandelsekodEnum(se.inera.intyg.common.support.common.enumerations.HandelsekodEnum) Test(org.junit.Test)

Example 4 with ArendeCount

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) IntygModule(se.inera.intyg.common.support.modules.registry.IntygModule) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Handelse(se.inera.intyg.webcert.persistence.handelse.model.Handelse) Test(org.junit.Test)

Example 5 with ArendeCount

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());
}
Also used : LocalDateTime(java.time.LocalDateTime) IntygModule(se.inera.intyg.common.support.modules.registry.IntygModule) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Handelse(se.inera.intyg.webcert.persistence.handelse.model.Handelse) Test(org.junit.Test)

Aggregations

ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)12 Test (org.junit.Test)8 LocalDateTime (java.time.LocalDateTime)6 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)5 IntygWithNotificationsResponse (se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse)5 Handelse (se.inera.intyg.webcert.persistence.handelse.model.Handelse)4 Intyg (se.riv.clinicalprocess.healthcond.certificate.v3.Intyg)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)3 HandelsekodEnum (se.inera.intyg.common.support.common.enumerations.HandelsekodEnum)3 IntygModule (se.inera.intyg.common.support.modules.registry.IntygModule)3 CertificateStatusUpdateForCareType (se.riv.clinicalprocess.healthcond.certificate.certificatestatusupdateforcareresponder.v3.CertificateStatusUpdateForCareType)3 LocalDate (java.time.LocalDate)2 Fk7263EntryPoint (se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)2 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1