Search in sources :

Example 6 with Fk7263Utlatande

use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.

the class IntygServiceTest method testListCertificatesForCareWithQAVardgivare.

@Test
public void testListCertificatesForCareWithQAVardgivare() throws Exception {
    final String vardgivarId = "vardgivarId";
    final String intygType = "intygType";
    final String intygId = "intygId";
    final LocalDateTime localDateTime = LocalDateTime.of(2017, Month.JANUARY, 1, 1, 1);
    Handelse handelse = new Handelse();
    handelse.setTimestamp(localDateTime);
    handelse.setCode(HandelsekodEnum.SKAPAT);
    Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    ArendeCount sent = new ArendeCount(1, 2, 3, 4);
    ArendeCount received = new ArendeCount(5, 6, 7, 8);
    when(moduleRegistry.listAllModules()).thenReturn(Arrays.asList(new IntygModule(intygType, "", "", "", "", "", "", "", "", false)));
    when(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(eq(PERSON_ID), eq(vardgivarId), eq(Arrays.asList(UtkastStatus.values())), eq(Collections.singleton(intygType)))).thenReturn(Arrays.asList(getDraft(intygId)));
    when(notificationService.getNotifications(eq(intygId))).thenReturn(Arrays.asList(handelse));
    when(moduleRegistry.getModuleApi(any(String.class))).thenReturn(moduleApi);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(utlatande);
    when(fragorOchSvarCreator.createArenden(eq(intygId), anyString())).thenReturn(Pair.of(sent, received));
    List<IntygWithNotificationsResponse> res = intygService.listCertificatesForCareWithQA(new IntygWithNotificationsRequest.Builder().setPersonnummer(PERSNR).setVardgivarId(vardgivarId).build());
    assertNotNull(res);
    assertEquals(1, res.size());
    assertEquals(1, res.get(0).getNotifications().size());
    assertEquals(HandelsekodEnum.SKAPAT, res.get(0).getNotifications().get(0).getCode());
    assertEquals(localDateTime, res.get(0).getNotifications().get(0).getTimestamp());
    assertEquals(1, res.get(0).getSentQuestions().getTotalt());
    assertEquals(2, res.get(0).getSentQuestions().getEjBesvarade());
    assertEquals(3, res.get(0).getSentQuestions().getBesvarade());
    assertEquals(4, res.get(0).getSentQuestions().getHanterade());
    assertEquals(5, res.get(0).getReceivedQuestions().getTotalt());
    assertEquals(6, res.get(0).getReceivedQuestions().getEjBesvarade());
    assertEquals(7, res.get(0).getReceivedQuestions().getBesvarade());
    assertEquals(8, res.get(0).getReceivedQuestions().getHanterade());
}
Also used : LocalDateTime(java.time.LocalDateTime) IntygModule(se.inera.intyg.common.support.modules.registry.IntygModule) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) ArendeCount(se.inera.intyg.common.support.modules.support.api.notification.ArendeCount) IntygWithNotificationsResponse(se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Handelse(se.inera.intyg.webcert.persistence.handelse.model.Handelse) Test(org.junit.Test)

Example 7 with Fk7263Utlatande

use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.

the class IntygServiceTest method testLoggingFetchIntygAsPdfWithDraft.

@SuppressWarnings("unchecked")
@Test
public void testLoggingFetchIntygAsPdfWithDraft() throws IOException, IntygModuleFacadeException {
    final Utkast draft = getDraft(CERTIFICATE_ID);
    when(utkastRepository.findOne(CERTIFICATE_ID)).thenReturn(draft);
    Fk7263Utlatande utlatande = objectMapper.readValue(draft.getModel(), Fk7263Utlatande.class);
    when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
    when(moduleFacade.convertFromInternalToPdfDocument(anyString(), anyString(), anyList(), anyBoolean())).thenReturn(buildPdfDocument());
    IntygPdf intygPdf = intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
    assertNotNull(intygPdf);
    verify(utkastRepository).findOne(anyString());
    verify(logservice).logPrintIntygAsDraft(any(LogRequest.class));
    verifyNoMoreInteractions(logservice);
    verify(moduleFacade, times(0)).getCertificate(CERTIFICATE_ID, CERTIFICATE_TYPE);
}
Also used : LogRequest(se.inera.intyg.webcert.web.service.log.dto.LogRequest) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) IntygPdf(se.inera.intyg.webcert.web.service.intyg.dto.IntygPdf) Test(org.junit.Test)

Example 8 with Fk7263Utlatande

use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.

the class UtkastModuleApiControllerTest method setup.

@Before
public void setup() throws ModuleNotFoundException, ModuleException, IOException {
    session = mock(HttpSession.class);
    request = mock(HttpServletRequest.class);
    Mockito.doNothing().when(session).removeAttribute("lastSavedDraft");
    when(request.getSession(true)).thenReturn(session);
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(buildPatient());
    when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
    when(moduleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("MODEL");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Personnummer(se.inera.intyg.schemas.contract.Personnummer) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) HttpSession(javax.servlet.http.HttpSession) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Before(org.junit.Before)

Example 9 with Fk7263Utlatande

use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.

the class CopyCompletionUtkastBuilderTest method createIntygContentHolder.

private IntygContentHolder createIntygContentHolder() throws Exception {
    List<Status> status = new ArrayList<>();
    status.add(new Status(CertificateState.RECEIVED, "HSVARD", LocalDateTime.now()));
    status.add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
    Fk7263Utlatande utlatande = new CustomObjectMapper().readValue(new ClassPathResource("IntygDraftServiceImplTest/utlatande.json").getFile(), Fk7263Utlatande.class);
    return IntygContentHolder.builder().setContents("<external-json/>").setUtlatande(utlatande).setStatuses(status).setRevoked(false).setRelations(new Relations()).setDeceased(false).setSekretessmarkering(false).setPatientNameChangedInPU(false).setPatientAddressChangedInPU(false).build();
}
Also used : ValidationStatus(se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus) Status(se.inera.intyg.common.support.model.Status) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CustomObjectMapper(se.inera.intyg.common.util.integration.json.CustomObjectMapper) ArrayList(java.util.ArrayList) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 10 with Fk7263Utlatande

use of se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande in project webcert by sklintyg.

the class CreateRenewalCopyUtkastBuilderImplTest method createIntygContentHolder.

private IntygContentHolder createIntygContentHolder() throws Exception {
    List<Status> status = new ArrayList<>();
    status.add(new Status(CertificateState.RECEIVED, "HSVARD", LocalDateTime.now()));
    status.add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
    Fk7263Utlatande utlatande = new CustomObjectMapper().readValue(new ClassPathResource("IntygDraftServiceImplTest/utlatande.json").getFile(), Fk7263Utlatande.class);
    return IntygContentHolder.builder().setContents("<external-json/>").setUtlatande(utlatande).setStatuses(status).setRevoked(false).setRelations(new Relations()).setDeceased(false).setSekretessmarkering(false).setPatientNameChangedInPU(false).setPatientAddressChangedInPU(false).build();
}
Also used : ValidationStatus(se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus) Status(se.inera.intyg.common.support.model.Status) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CustomObjectMapper(se.inera.intyg.common.util.integration.json.CustomObjectMapper) ArrayList(java.util.ArrayList) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 Test (org.junit.Test)8 Before (org.junit.Before)7 ClassPathResource (org.springframework.core.io.ClassPathResource)6 Patient (se.inera.intyg.common.support.model.common.internal.Patient)5 Personnummer (se.inera.intyg.schemas.contract.Personnummer)5 ArrayList (java.util.ArrayList)4 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)4 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)4 Status (se.inera.intyg.common.support.model.Status)3 IntygModule (se.inera.intyg.common.support.modules.registry.IntygModule)3 CertificateMetaData (se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData)3 CertificateResponse (se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse)3 ArendeCount (se.inera.intyg.common.support.modules.support.api.notification.ArendeCount)3 IntygWithNotificationsResponse (se.inera.intyg.webcert.web.service.intyg.dto.IntygWithNotificationsResponse)3 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)3 LocalDateTime (java.time.LocalDateTime)2 Fk7263EntryPoint (se.inera.intyg.common.fk7263.support.Fk7263EntryPoint)2 ValidationStatus (se.inera.intyg.common.support.modules.support.api.dto.ValidationStatus)2