Search in sources :

Example 11 with Fk7263Utlatande

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

the class IntygModuleApiControllerTest method setupCertificateData.

@BeforeClass
public static void setupCertificateData() {
    utlatande = new Fk7263Utlatande();
    utlatande.setId(CERTIFICATE_ID);
    utlatande.setTyp(CERTIFICATE_TYPE);
    GrundData grundData = new GrundData();
    patient = new Patient();
    patient.setPersonId(createPnr(PERSON_ID));
    patient.setFornamn("Fornamn");
    patient.setEfternamn("Efternamn");
    grundData.setPatient(patient);
    utlatande.setGrundData(grundData);
    List<Status> status = new ArrayList<>();
    status.add(new Status(CertificateState.RECEIVED, "HSVARD", LocalDateTime.now()));
    status.add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
}
Also used : Status(se.inera.intyg.common.support.model.Status) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) ArrayList(java.util.ArrayList) Patient(se.inera.intyg.common.support.model.common.internal.Patient) GrundData(se.inera.intyg.common.support.model.common.internal.GrundData) BeforeClass(org.junit.BeforeClass)

Example 12 with Fk7263Utlatande

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

the class AbstractIntygServiceTest method setupMocks.

@Before
public void setupMocks() throws Exception {
    json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
    utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    CertificateMetaData metaData = buildCertificateMetaData();
    certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
    when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
    when(certificateRelationService.getNewestRelationOfType(anyString(), any(RelationKod.class), any(List.class))).thenReturn(Optional.empty());
    when(intygRelationHelper.getRelationsForIntyg(anyString())).thenReturn(new Relations());
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(buildPatient(false, false));
    when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
    when(moduleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("MODEL");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) ArrayList(java.util.ArrayList) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClassPathResource(org.springframework.core.io.ClassPathResource) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) RelationKod(se.inera.intyg.common.support.common.enumerations.RelationKod) Before(org.junit.Before)

Example 13 with Fk7263Utlatande

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

the class IntygServiceRevokeTest method setupMocks.

@Override
@Before
public void setupMocks() throws Exception {
    json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
    utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    CertificateMetaData metaData = buildCertificateMetaData();
    certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
    when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
    when(intygRelationHelper.getRelationsForIntyg(anyString())).thenReturn(new Relations());
    when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(buildPatient(false, false));
    when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
    when(moduleApi.updateBeforeSave(anyString(), any(Patient.class))).thenReturn("MODEL");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClassPathResource(org.springframework.core.io.ClassPathResource) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) Before(org.junit.Before)

Example 14 with Fk7263Utlatande

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

the class IntygServiceTest method testListCertificatesForCareWithQANoNotifications.

@Test
public void testListCertificatesForCareWithQANoNotifications() throws Exception {
    final List<String> enhetList = Arrays.asList("enhet");
    final String intygType = "intygType";
    final String intygId = "intygId";
    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.findDraftsByPatientAndEnhetAndStatus(eq(PERSON_ID), eq(enhetList), eq(Arrays.asList(UtkastStatus.values())), eq(Collections.singleton(intygType)))).thenReturn(Arrays.asList(getDraft(intygId)));
    when(notificationService.getNotifications(eq(intygId))).thenReturn(Collections.emptyList());
    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).setEnhetId(enhetList).build());
    assertNotNull(res);
    assertEquals(1, res.size());
    assertTrue(res.get(0).getNotifications().isEmpty());
    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 : 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) Test(org.junit.Test)

Example 15 with Fk7263Utlatande

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

the class IntygServiceTest method testLoggingFetchIntygAsPdfWithSJF.

@Test
public void testLoggingFetchIntygAsPdfWithSJF() throws IOException, IntygModuleFacadeException {
    // Set up user
    IntegrationParameters parameters = new IntegrationParameters(null, null, null, null, null, null, null, null, null, true, false, false, false);
    when(webcertUser.getOrigin()).thenReturn(UserOriginType.DJUPINTEGRATION.name());
    when(webcertUser.getParameters()).thenReturn(parameters);
    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());
    intygService.fetchIntygAsPdf(CERTIFICATE_ID, CERTIFICATE_TYPE, false);
    // Verify that the isAuthorized check wasn't run (since SJF=true and DJUPINTEGRATION)
    verify(webCertUserService, times(0)).isAuthorizedForUnit(anyString(), anyString(), anyBoolean());
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Test(org.junit.Test)

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