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());
}
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());
}
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());
}
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;
}
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;
}
Aggregations