Search in sources :

Example 6 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertIntygToListEntries.

@Test
public void testConvertIntygToListEntries() {
    LocalDateTime modfied = LocalDateTime.parse("2014-01-01T10:00:00");
    String id = "123";
    String type = "type";
    String updatedSignedBy = "Dr Dengroth";
    String updatedSignedByHsaId = "HSA1234";
    Personnummer patientId = Personnummer.createPersonnummer("19121212-1212").get();
    List<Utkast> utkastList = Collections.singletonList(TestIntygFactory.createUtkast(id, modfied, type, updatedSignedBy, updatedSignedByHsaId, UtkastStatus.DRAFT_COMPLETE, patientId));
    List<ListIntygEntry> res = IntygDraftsConverter.convertUtkastsToListIntygEntries(utkastList);
    assertNotNull(res);
    assertEquals(1, res.size());
    ListIntygEntry ref = res.get(0);
    assertEquals(id, ref.getIntygId());
    assertEquals(type, ref.getIntygType());
    assertEquals("DRAFT_COMPLETE", ref.getStatus());
    assertEquals(updatedSignedBy, ref.getUpdatedSignedBy());
    assertEquals(modfied, ref.getLastUpdatedSigned());
}
Also used : LocalDateTime(java.time.LocalDateTime) Personnummer(se.inera.intyg.schemas.contract.Personnummer) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 7 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId.

@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId() {
    Signatur signatur = mock(Signatur.class);
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    utkast.setSignatur(signatur);
    when(signatur.getSigneradAv()).thenReturn(utkast.getSenastSparadAv().getNamn());
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(utkast.getSenastSparadAv().getNamn(), res.getUpdatedSignedBy());
}
Also used : Signatur(se.inera.intyg.webcert.persistence.utkast.model.Signatur) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 8 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameFromSenastSparadAv.

@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameFromSenastSparadAv() {
    Utkast utkast = createUtkast();
    utkast.setStatus(UtkastStatus.SIGNED);
    ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
    assertNotNull(res);
    assertEquals(utkast.getSenastSparadAv().getNamn(), res.getUpdatedSignedBy());
}
Also used : Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry) Test(org.junit.Test)

Example 9 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverter method convertIntygToListIntygEntry.

private ListIntygEntry convertIntygToListIntygEntry(Intyg source) {
    ListIntygEntry entry = new ListIntygEntry();
    entry.setIntygId(source.getIntygsId().getExtension());
    entry.setIntygType(moduleRegistry.getModuleIdFromExternalId(source.getTyp().getCode()));
    entry.setSource(IntygSource.IT);
    entry.setStatus(findLatestStatus(source.getStatus()).name());
    entry.setUpdatedSignedBy(source.getSkapadAv().getFullstandigtNamn());
    entry.setLastUpdatedSigned(source.getSigneringstidpunkt());
    entry.setPatientId(createPnr(source.getPatient().getPersonId().getExtension()));
    return entry;
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)

Example 10 with ListIntygEntry

use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.

the class IntygDraftsConverter method convertUtkastToListIntygEntry.

public static ListIntygEntry convertUtkastToListIntygEntry(Utkast utkast) {
    ListIntygEntry entry = new ListIntygEntry();
    entry.setIntygId(utkast.getIntygsId());
    entry.setIntygType(utkast.getIntygsTyp());
    entry.setSource(IntygSource.WC);
    entry.setUpdatedSignedBy(resolvedSignedBy(utkast));
    entry.setLastUpdatedSigned(utkast.getSenastSparadDatum());
    entry.setPatientId(utkast.getPatientPersonnummer());
    entry.setVidarebefordrad(utkast.getVidarebefordrad());
    entry.setStatus(resolveStatus(utkast));
    entry.setVersion(utkast.getVersion());
    return entry;
}
Also used : ListIntygEntry(se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)

Aggregations

ListIntygEntry (se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry)26 Test (org.junit.Test)16 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 Signatur (se.inera.intyg.webcert.persistence.utkast.model.Signatur)5 List (java.util.List)4 Response (javax.ws.rs.core.Response)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 SekretessStatus (se.inera.intyg.webcert.common.model.SekretessStatus)3 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 ListCertificatesForCareType (se.riv.clinicalprocess.healthcond.certificate.listcertificatesforcare.v3.ListCertificatesForCareType)2 LocalDateTime (java.time.LocalDateTime)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 OptimisticLockException (javax.persistence.OptimisticLockException)1 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyBoolean (org.mockito.ArgumentMatchers.anyBoolean)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 OptimisticLockingFailureException (org.springframework.dao.OptimisticLockingFailureException)1 IntygRelations (se.inera.intyg.clinicalprocess.healthcond.certificate.listrelationsforcertificate.v1.IntygRelations)1