Search in sources :

Example 6 with ArendeCount

use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.

the class FragorOchSvarCreatorImpl method performFragorCount.

private Pair<ArendeCount, ArendeCount> performFragorCount(List<FragaSvarStatus> fsStatuses) {
    int skickadeFragorTotalt = 0;
    int skickadeFragorBesvarade = 0;
    int skickadeFragorEjBesvarade = 0;
    int skickadeFragorHanterade = 0;
    int mottagnaFragorTotalt = 0;
    int mottagnaFragorBesvarade = 0;
    int mottagnaFragorEjBesvarade = 0;
    int mottagnaFragorHanterade = 0;
    for (FragaSvarStatus fsStatus : fsStatuses) {
        if (isFromWebcert(fsStatus)) {
            skickadeFragorTotalt++;
            if (fsStatus.isClosed()) {
                skickadeFragorHanterade++;
            } else if (fsStatus.hasAnswerSet()) {
                skickadeFragorBesvarade++;
            } else {
                skickadeFragorEjBesvarade++;
            }
        } else if (isFromFK(fsStatus)) {
            mottagnaFragorTotalt++;
            if (fsStatus.isClosed()) {
                mottagnaFragorHanterade++;
            } else if (fsStatus.hasAnswerSet()) {
                mottagnaFragorBesvarade++;
            } else {
                mottagnaFragorEjBesvarade++;
            }
        }
    }
    return Pair.of(new ArendeCount(skickadeFragorTotalt, skickadeFragorEjBesvarade, skickadeFragorBesvarade, skickadeFragorHanterade), new ArendeCount(mottagnaFragorTotalt, mottagnaFragorEjBesvarade, mottagnaFragorBesvarade, mottagnaFragorHanterade));
}
Also used : ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) FragaSvarStatus(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvarStatus) Fk7263EntryPoint(se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)

Example 7 with ArendeCount

use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.

the class NotificationMessageFactoryImpl method createNotificationMessage.

@Override
public NotificationMessage createNotificationMessage(Utkast utkast, HandelsekodEnum handelse, SchemaVersion version, String reference, Amneskod amne, LocalDate sistaSvarsDatum) {
    String intygsId = utkast.getIntygsId();
    String intygsTyp = utkast.getIntygsTyp();
    LocalDateTime handelseTid = LocalDateTime.now();
    String logiskAdress = utkast.getEnhetsId();
    String utkastJson = utkast.getModel();
    FragorOchSvar fragaSvar = null;
    ArendeCount skickadeFragor = null;
    ArendeCount mottagnaFragor = null;
    if (SchemaVersion.VERSION_3 == version) {
        Pair<ArendeCount, ArendeCount> arenden = Pair.of(ArendeCount.getEmpty(), ArendeCount.getEmpty());
        // Add a count of questions to the message
        if (USES_FRAGOR_OCH_SVAR.contains(handelse)) {
            arenden = fragorOchSvarCreator.createArenden(intygsId, intygsTyp);
        }
        skickadeFragor = arenden.getLeft();
        mottagnaFragor = arenden.getRight();
    } else {
        fragaSvar = FragorOchSvar.getEmpty();
        // Add a count of questions to the message
        if (USES_FRAGOR_OCH_SVAR.contains(handelse)) {
            fragaSvar = fragorOchSvarCreator.createFragorOchSvar(intygsId);
        }
    }
    return new NotificationMessage(intygsId, intygsTyp, handelseTid, handelse, logiskAdress, utkastJson, fragaSvar, skickadeFragor, mottagnaFragor, version, reference, amne, sistaSvarsDatum);
}
Also used : LocalDateTime(java.time.LocalDateTime) FragorOchSvar(se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar) NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)

Example 8 with ArendeCount

use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.

the class NotificationMessageFactoryTest method testCreateNotificationMessageForUsesFragorOchSvarSchemaVersion3.

@Test
public void testCreateNotificationMessageForUsesFragorOchSvarSchemaVersion3() {
    when(mockFragorOchSvarCreator.createArenden(INTYGS_ID, INTYGS_TYP)).thenReturn(Pair.of(new ArendeCount(1, 1, 1, 1), new ArendeCount(2, 2, 2, 2)));
    Utkast utkast = createUtkast(INTYGS_ID);
    final String reference = "ref";
    NotificationMessage msg = notificationMessageFactory.createNotificationMessage(utkast, HandelsekodEnum.NYFRFV, SchemaVersion.VERSION_3, reference, null, null);
    assertNotNull(msg);
    assertNotNull(msg.getHandelse());
    assertEquals(HandelsekodEnum.NYFRFV, msg.getHandelse());
    assertNotNull(msg.getHandelseTid());
    assertEquals(INTYGS_ID, msg.getIntygsId());
    assertEquals(INTYGS_TYP, msg.getIntygsTyp());
    assertEquals("SE12345678-1000", msg.getLogiskAdress());
    assertEquals("{model}", msg.getUtkast());
    assertEquals(SchemaVersion.VERSION_3, msg.getVersion());
    assertEquals(reference, msg.getReference());
    assertNull(msg.getFragaSvar());
    assertNotNull(msg.getSkickadeFragor());
    assertEquals(1, msg.getSkickadeFragor().getTotalt());
    assertEquals(1, msg.getSkickadeFragor().getBesvarade());
    assertEquals(1, msg.getSkickadeFragor().getEjBesvarade());
    assertEquals(1, msg.getSkickadeFragor().getHanterade());
    assertNotNull(msg.getMottagnaFragor());
    assertEquals(2, msg.getMottagnaFragor().getTotalt());
    assertEquals(2, msg.getMottagnaFragor().getBesvarade());
    assertEquals(2, msg.getMottagnaFragor().getEjBesvarade());
    assertEquals(2, msg.getMottagnaFragor().getHanterade());
    verify(mockFragorOchSvarCreator).createArenden(INTYGS_ID, INTYGS_TYP);
    verifyNoMoreInteractions(mockFragorOchSvarCreator);
}
Also used : NotificationMessage(se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) Test(org.junit.Test)

Example 9 with ArendeCount

use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.

the class IntygServiceTest method testListCertificatesForCareWithQANoNotifications.

@Test
public void testListCertificatesForCareWithQANoNotifications() throws Exception {
    final List<String> enhetList = Arrays.asList("enhet");
    final String intygType = "intygType";
    final String intygId = "intygId";
    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(Collections.emptyList());
    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());
    assertTrue(res.get(0).getNotifications().isEmpty());
    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 : 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) Test(org.junit.Test)

Example 10 with ArendeCount

use of se.inera.intyg.common.support.modules.support.api.notification.ArendeCount in project webcert by sklintyg.

the class ListCertificatesForCareWithQAResponderImplTest method testListCertificatesForCareWithQA.

@Test
public void testListCertificatesForCareWithQA() {
    final Personnummer personnummer = Personnummer.createPersonnummer("191212121212").get();
    final String enhet = "enhetHsaId";
    final LocalDate deadline = LocalDate.of(2017, 1, 1);
    final String reference = "ref";
    Handelse handelse = new Handelse();
    handelse.setCode(HandelsekodEnum.SKAPAT);
    handelse.setTimestamp(LocalDateTime.now());
    handelse.setAmne(ArendeAmne.AVSTMN);
    handelse.setSistaDatumForSvar(deadline);
    when(intygService.listCertificatesForCareWithQA(any(IntygWithNotificationsRequest.class))).thenReturn(Arrays.asList(new IntygWithNotificationsResponse(null, Arrays.asList(handelse), new ArendeCount(1, 1, 1, 1), new ArendeCount(2, 2, 2, 2), reference)));
    ListCertificatesForCareWithQAType request = new ListCertificatesForCareWithQAType();
    PersonId personId = new PersonId();
    personId.setExtension(personnummer.getPersonnummer());
    request.setPersonId(personId);
    HsaId hsaId = new HsaId();
    hsaId.setExtension(enhet);
    request.getEnhetsId().add(hsaId);
    ListCertificatesForCareWithQAResponseType response = responder.listCertificatesForCareWithQA("logicalAdress", request);
    assertNotNull(response);
    assertNotNull(response.getList());
    assertNotNull(response.getList().getItem());
    assertEquals(1, response.getList().getItem().size());
    assertEquals(1, response.getList().getItem().get(0).getHandelser().getHandelse().size());
    assertEquals(reference, response.getList().getItem().get(0).getRef());
    assertEquals(deadline, response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getSistaDatumForSvar());
    assertEquals(HandelsekodEnum.SKAPAT.name(), response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getHandelsekod().getCode());
    assertEquals(ArendeAmne.AVSTMN.name(), response.getList().getItem().get(0).getHandelser().getHandelse().get(0).getAmne().getCode());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ListCertificatesForCareWithQAResponseType(se.riv.clinicalprocess.healthcond.certificate.listCertificatesForCareWithQA.v3.ListCertificatesForCareWithQAResponseType) PersonId(se.riv.clinicalprocess.healthcond.certificate.types.v3.PersonId) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) IntygWithNotificationsRequest(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsRequest) ListCertificatesForCareWithQAType(se.riv.clinicalprocess.healthcond.certificate.listCertificatesForCareWithQA.v3.ListCertificatesForCareWithQAType) LocalDate(java.time.LocalDate) HsaId(se.riv.clinicalprocess.healthcond.certificate.types.v3.HsaId) 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