Search in sources :

Example 6 with FragorOchSvar

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

the class NotificationServiceImplTest method createNotificationMessage.

private NotificationMessage createNotificationMessage(HandelsekodEnum handelse, String utkastJson) {
    FragorOchSvar fs = FragorOchSvar.getEmpty();
    LocalDateTime time = LocalDateTime.of(2001, 12, 31, 12, 34, 56, 789);
    NotificationMessage notMsg = new NotificationMessage(INTYG_ID, INTYG_TYP_FK, time, handelse, LOGISK_ADDR, utkastJson, fs, null, null, SchemaVersion.VERSION_1, null);
    return notMsg;
}
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)

Example 7 with FragorOchSvar

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

the class FragorOchSvarCreatorImpl method performCount.

private FragorOchSvar performCount(List<FragaSvarStatus> fsStatuses) {
    int antalFragor = 0;
    int antalSvar = 0;
    int antalHanteradeFragor = 0;
    int antalHanteradeSvar = 0;
    for (FragaSvarStatus fsStatus : fsStatuses) {
        // faktiska svar från FK.
        if (isFromWebcert(fsStatus)) {
            if (fsStatus.hasAnswerSet()) {
                antalSvar++;
                if (fsStatus.isClosed()) {
                    antalHanteradeSvar++;
                }
            }
        } else if (isFromFK(fsStatus)) {
            antalFragor++;
            if (fsStatus.isClosed()) {
                antalHanteradeFragor++;
            }
        }
    }
    return new FragorOchSvar(antalFragor, antalSvar, antalHanteradeFragor, antalHanteradeSvar);
}
Also used : FragorOchSvar(se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar) FragaSvarStatus(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvarStatus) Fk7263EntryPoint(se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)

Example 8 with FragorOchSvar

use of se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar 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 9 with FragorOchSvar

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

the class FragorOchSvarCreatorTest method testPerformCountHan9NotAnswered.

@Test
public void testPerformCountHan9NotAnswered() {
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Collections.singletonList(new FragaSvarStatus(1L, FRAGESTALLARE_FK, null, Status.CLOSED)));
    FragorOchSvar fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(1, fos.getAntalFragor());
    assertEquals(1, fos.getAntalHanteradeFragor());
    assertEquals(0, fos.getAntalSvar());
    assertEquals(0, fos.getAntalHanteradeSvar());
    verify(fragaSvarRepository).findFragaSvarStatusesForIntyg(INTYG_ID);
    verifyNoMoreInteractions(fragaSvarRepository);
    verifyNoMoreInteractions(arendeRepository);
}
Also used : FragorOchSvar(se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar) FragaSvarStatus(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvarStatus) Test(org.junit.Test)

Example 10 with FragorOchSvar

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

the class FragorOchSvarCreatorTest method testAll.

@Test
public void testAll() {
    // 1. Skickar fråga från WC till FK
    // Förväntad statusuppdatering: HAN8 0,0,0,0
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Collections.singletonList(new FragaSvarStatus(1L, FRAGESTALLARE_WEBCERT, null, Status.PENDING_EXTERNAL_ACTION)));
    FragorOchSvar fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(0, fos.getAntalFragor());
    assertEquals(0, fos.getAntalHanteradeFragor());
    assertEquals(0, fos.getAntalSvar());
    assertEquals(0, fos.getAntalHanteradeSvar());
    // 2. FK svarar på frågan
    // Förväntad statusuppdatering: HAN7 0,0,1,0
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Collections.singletonList(new FragaSvarStatus(1L, FRAGESTALLARE_WEBCERT, "Ett svar kom in", Status.ANSWERED)));
    fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(0, fos.getAntalFragor());
    assertEquals(0, fos.getAntalHanteradeFragor());
    assertEquals(1, fos.getAntalSvar());
    assertEquals(0, fos.getAntalHanteradeSvar());
    // 3. Markerar svaret som hanterat
    // Förväntad statusuppdatering: HAN10 0,0,1,1
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Collections.singletonList(new FragaSvarStatus(1L, FRAGESTALLARE_WEBCERT, "Ett svar kom in", Status.CLOSED)));
    fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(0, fos.getAntalFragor());
    assertEquals(0, fos.getAntalHanteradeFragor());
    assertEquals(1, fos.getAntalSvar());
    assertEquals(1, fos.getAntalHanteradeSvar());
    // 4. FK skickar fråga till WC
    // Förväntad statusuppdatering: HAN6 1,0,1,1
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Arrays.asList(new FragaSvarStatus(1L, FRAGESTALLARE_WEBCERT, "Ett svar kom in", Status.CLOSED), new FragaSvarStatus(1L, FRAGESTALLARE_FK, null, Status.PENDING_INTERNAL_ACTION)));
    fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(1, fos.getAntalFragor());
    assertEquals(0, fos.getAntalHanteradeFragor());
    assertEquals(1, fos.getAntalSvar());
    assertEquals(1, fos.getAntalHanteradeSvar());
    // 5. WC svarar på frågan från FK
    // Förväntad statusuppdatering: HAN9 1,1,1,1
    when(fragaSvarRepository.findFragaSvarStatusesForIntyg(INTYG_ID)).thenReturn(Arrays.asList(new FragaSvarStatus(1L, FRAGESTALLARE_WEBCERT, "Ett svar kom in", Status.CLOSED), new FragaSvarStatus(1L, FRAGESTALLARE_FK, "Ett svar kom in", Status.CLOSED)));
    fos = fsCreator.createFragorOchSvar(INTYG_ID);
    assertNotNull(fos);
    assertEquals(1, fos.getAntalFragor());
    assertEquals(1, fos.getAntalHanteradeFragor());
    assertEquals(1, fos.getAntalSvar());
    assertEquals(1, fos.getAntalHanteradeSvar());
}
Also used : FragorOchSvar(se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar) FragaSvarStatus(se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvarStatus) Test(org.junit.Test)

Aggregations

FragorOchSvar (se.inera.intyg.common.support.modules.support.api.notification.FragorOchSvar)12 Test (org.junit.Test)8 FragaSvarStatus (se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvarStatus)8 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)3 LocalDateTime (java.time.LocalDateTime)2 Fk7263EntryPoint (se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)1 ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1