use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv.
@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv() {
Signatur signatur = mock(Signatur.class);
final String skapadAvName = "Bengt Bengtsson";
final String skapadAvHsaId = "BengtsHsaId";
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.getSkapadAv().setNamn(skapadAvName);
utkast.setSignatur(signatur);
when(signatur.getSigneradAv()).thenReturn(skapadAvHsaId);
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(skapadAvHsaId, res.getUpdatedSignedBy());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable.
@Test
public void testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.RECEIVED.name(), res.getStatus());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsStatusCancelledIfApplicable.
@Test
public void testConvertUtkastToListIntygEntrySetsStatusCancelledIfApplicable() {
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setAterkalladDatum(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.CANCELLED.name(), res.getStatus());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsSentBeforeReceived.
@Test
public void testConvertUtkastToListIntygEntrySetsSentBeforeReceived() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.SENT.name(), res.getStatus());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ListIntygEntry in project webcert by sklintyg.
the class IntygServiceImpl method listIntyg.
@Override
public Pair<List<ListIntygEntry>, Boolean> listIntyg(List<String> enhetId, Personnummer personnummer) {
ListCertificatesForCareType request = new ListCertificatesForCareType();
request.setPersonId(InternalConverterUtil.getPersonId(personnummer));
SekretessStatus sekretessmarkering = patientDetailsResolver.getSekretessStatus(personnummer);
for (String id : enhetId) {
request.getEnhetsId().add(InternalConverterUtil.getHsaId(id));
}
try {
ListCertificatesForCareResponseType response = listCertificateService.listCertificatesForCare(logicalAddress, request);
List<ListIntygEntry> fullIntygItemList = intygConverter.convertIntygToListIntygEntries(response.getIntygsLista().getIntyg());
intygRelationHelper.decorateIntygListWithRelations(fullIntygItemList);
fullIntygItemList = filterByIntygTypeForUser(fullIntygItemList, sekretessmarkering);
addDraftsToListForIntygNotSavedInIntygstjansten(fullIntygItemList, enhetId, personnummer);
return Pair.of(fullIntygItemList, Boolean.FALSE);
} catch (WebServiceException wse) {
LOG.warn("Error when connecting to intygstjÀnsten: {}", wse.getMessage());
}
// If intygstjansten was unavailable, we return whatever certificates we can find and clearly inform
// the caller that the set of certificates are only those that have been issued by WebCert.
List<ListIntygEntry> intygItems = buildIntygItemListFromDrafts(enhetId, personnummer);
for (ListIntygEntry lie : intygItems) {
lie.setRelations(certificateRelationService.getRelations(lie.getIntygId()));
}
return Pair.of(intygItems, Boolean.TRUE);
}
Aggregations