Search in sources :

Example 16 with Fk7263Utlatande

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

the class IntygServiceTest method testHandleSignedCompletion.

@Test
public void testHandleSignedCompletion() throws Exception {
    final String intygId = "intygId";
    final String intygTyp = "intygTyp";
    final String relationIntygId = "relationIntygId";
    final String recipient = new Fk7263EntryPoint().getDefaultRecipient();
    final Personnummer personnummer = PERSNR;
    Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    utlatande.setId(intygId);
    utlatande.setTyp(intygTyp);
    utlatande.getGrundData().getPatient().setPersonId(personnummer);
    Utkast utkast = new Utkast();
    utkast.setIntygsId(intygId);
    utkast.setIntygsTyp(intygTyp);
    utkast.setRelationKod(RelationKod.KOMPLT);
    utkast.setRelationIntygsId(relationIntygId);
    utkast.setModel(json);
    when(utkastRepository.findOne(intygId)).thenReturn(utkast);
    when(moduleFacade.getUtlatandeFromInternalModel(eq(intygTyp), anyString())).thenReturn(utlatande);
    when(certificateRelationService.getNewestRelationOfType(eq(intygId), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.empty());
    when(moduleRegistry.getModuleEntryPoint(intygTyp)).thenReturn(new Fk7263EntryPoint());
    intygService.handleAfterSigned(utkast);
    verify(certificateSenderService).sendCertificate(eq(intygId), eq(personnummer), anyString(), eq(recipient), eq(true));
    verify(mockMonitoringService).logIntygSent(intygId, recipient);
    verify(logservice).logSendIntygToRecipient(any(LogRequest.class));
    verify(arendeService).closeCompletionsAsHandled(relationIntygId, intygTyp);
    verify(notificationService).sendNotificationForIntygSent(intygId);
    ArgumentCaptor<Utkast> utkastCaptor = ArgumentCaptor.forClass(Utkast.class);
    verify(utkastRepository).save(utkastCaptor.capture());
    assertNotNull(utkastCaptor.getValue().getSkickadTillMottagareDatum());
    assertEquals(recipient, utkastCaptor.getValue().getSkickadTillMottagare());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) 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) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Fk7263EntryPoint(se.inera.intyg.common.fk7263.support.Fk7263EntryPoint) Test(org.junit.Test)

Example 17 with Fk7263Utlatande

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

the class IntygServiceTest method setupIntygstjanstResponse.

@Before
public void setupIntygstjanstResponse() throws Exception {
    vardpersonReferens = new VardpersonReferens();
    vardpersonReferens.setHsaId(HSA_ID);
    vardpersonReferens.setNamn(CREATED_BY_NAME);
    json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
    Fk7263Utlatande utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    CertificateMetaData metaData = new CertificateMetaData();
    metaData.setStatus(new ArrayList<>());
    CertificateResponse certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
    when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(certificateResponse);
    when(moduleFacade.getUtlatandeFromInternalModel(anyString(), anyString())).thenReturn(utlatande);
}
Also used : Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ClassPathResource(org.springframework.core.io.ClassPathResource) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) VardpersonReferens(se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens) Before(org.junit.Before)

Example 18 with Fk7263Utlatande

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

the class IntygConverterUtilTest method testBuildSendTypeFromUtlatande.

@Test
public void testBuildSendTypeFromUtlatande() throws Exception {
    Fk7263Utlatande utlatande = createUtlatandeFromJson();
    SendType res = IntygConverterUtil.buildSendTypeFromUtlatande(utlatande);
    assertNotNull(res);
    assertNotNull(res.getAvsantTidpunkt());
    assertTrue(res.getVardReferensId().contains("SEND-123-"));
    assertEquals("123", res.getLakarutlatande().getLakarutlatandeId());
    assertNull(res.getLakarutlatande().getPatient().getFullstandigtNamn());
    assertEquals("19121212-1212", res.getLakarutlatande().getPatient().getPersonId().getExtension());
    assertNotNull(res.getLakarutlatande().getSigneringsTidpunkt());
    assertNull(res.getAdressVard().getHosPersonal().getForskrivarkod());
    assertEquals("En Läkare", res.getAdressVard().getHosPersonal().getFullstandigtNamn());
    assertEquals("Personal HSA-ID", res.getAdressVard().getHosPersonal().getPersonalId().getExtension());
    assertEquals("Kir mott", res.getAdressVard().getHosPersonal().getEnhet().getEnhetsnamn());
    assertEquals("VardenhetY", res.getAdressVard().getHosPersonal().getEnhet().getEnhetsId().getExtension());
    assertEquals("123456789011", res.getAdressVard().getHosPersonal().getEnhet().getArbetsplatskod().getExtension());
    assertEquals("Landstinget Norrland", res.getAdressVard().getHosPersonal().getEnhet().getVardgivare().getVardgivarnamn());
    assertEquals("VardgivarId", res.getAdressVard().getHosPersonal().getEnhet().getVardgivare().getVardgivareId().getExtension());
}
Also used : Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) SendType(se.inera.ifv.insuranceprocess.healthreporting.sendmedicalcertificateresponder.v1.SendType) 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