Search in sources :

Example 1 with IntygsStatus

use of se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus in project webcert by sklintyg.

the class IntygDraftsConverterTest method testFindLatestStatus.

@Test
public void testFindLatestStatus() {
    LocalDateTime defaultTime = LocalDateTime.now();
    CertificateState res;
    List<IntygsStatus> statuses;
    // test with empty list
    statuses = new ArrayList<>();
    res = IntygDraftsConverter.findLatestStatus(statuses);
    assertEquals(CertificateState.UNHANDLED, res);
    // test with just some statuses
    statuses = new ArrayList<>();
    statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(2)));
    statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(1)));
    res = IntygDraftsConverter.findLatestStatus(statuses);
    assertEquals(CertificateState.SENT, res);
    // test with DELETED in the list, which should be removed
    statuses = new ArrayList<>();
    statuses.add(buildIntygsStatus(StatusKod.CANCEL.name(), defaultTime.minusHours(2)));
    statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(3)));
    statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1)));
    statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(4)));
    res = IntygDraftsConverter.findLatestStatus(statuses);
    assertEquals(CertificateState.CANCELLED, res);
    // test with DELETED and RESTORED in the list, which should be removed
    statuses = new ArrayList<>();
    statuses.add(buildIntygsStatus(StatusKod.CANCEL.name(), defaultTime.minusHours(2)));
    statuses.add(buildIntygsStatus(StatusKod.SENTTO.name(), defaultTime.minusHours(3)));
    statuses.add(buildIntygsStatus(StatusKod.RESTOR.name(), defaultTime.minusMinutes(30)));
    statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1)));
    statuses.add(buildIntygsStatus(StatusKod.RECEIV.name(), defaultTime.minusHours(4)));
    res = IntygDraftsConverter.findLatestStatus(statuses);
    assertEquals(CertificateState.CANCELLED, res);
    // test with just DELETED, which will be removed and result in an empty list
    statuses = new ArrayList<>();
    statuses.add(buildIntygsStatus(StatusKod.DELETE.name(), defaultTime.minusHours(1)));
    res = IntygDraftsConverter.findLatestStatus(statuses);
    assertEquals(CertificateState.UNHANDLED, res);
}
Also used : LocalDateTime(java.time.LocalDateTime) CertificateState(se.inera.intyg.common.support.model.CertificateState) IntygsStatus(se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus) Test(org.junit.Test)

Example 2 with IntygsStatus

use of se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus in project webcert by sklintyg.

the class IntygDraftsConverterTest method buildIntygsStatus.

private IntygsStatus buildIntygsStatus(String statuskod, LocalDateTime timestamp) {
    IntygsStatus status = new IntygsStatus();
    status.setStatus(new Statuskod());
    status.getStatus().setCode(statuskod);
    status.setTidpunkt(timestamp);
    return status;
}
Also used : Statuskod(se.riv.clinicalprocess.healthcond.certificate.types.v3.Statuskod) IntygsStatus(se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus)

Aggregations

IntygsStatus (se.riv.clinicalprocess.healthcond.certificate.v3.IntygsStatus)2 LocalDateTime (java.time.LocalDateTime)1 Test (org.junit.Test)1 CertificateState (se.inera.intyg.common.support.model.CertificateState)1 Statuskod (se.riv.clinicalprocess.healthcond.certificate.types.v3.Statuskod)1