Search in sources :

Example 16 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSosDoiIntygIntegrationWithNoDBIntygAndPuOk.

/**
 * DOI - Integration. DB saknas, PU finns == allt från PU
 */
@Test
public void testSosDoiIntygIntegrationWithNoDBIntygAndPuOk() throws ModuleNotFoundException, IOException {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    when(integratedWebCertUser.getValdVardgivare()).thenReturn(new Vardgivare("vg-1", "vardgivare-1"));
    List<Utkast> drafts = new ArrayList<>();
    when(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(anyString(), anyString(), anyList(), anySet())).thenReturn(drafts);
    Patient patient = testee.resolvePatient(PNR, "doi");
    assertEquals(PNR.getPersonnummer(), patient.getPersonId().getPersonnummer());
    assertEquals(FNAMN, patient.getFornamn());
    assertEquals(MNAMN, patient.getMellannamn());
    assertEquals(LNAMN, patient.getEfternamn());
    assertEquals(POST_ADDR, patient.getPostadress());
    assertEquals(POST_NR, patient.getPostnummer());
    assertEquals(POST_ORT, patient.getPostort());
    assertEquals(PU_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArrayList(java.util.ArrayList) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Test(org.junit.Test)

Example 17 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testFKIntygIntegrationWithPuUnavailable.

/**
 * För FK + integration + UTAN PU vill vi ha namn etc från Integrations-parametrar.
 */
@Test
public void testFKIntygIntegrationWithPuUnavailable() {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildErrorPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    Patient patient = testee.resolvePatient(PNR, "luae_fs");
    assertEquals(PNR, patient.getPersonId());
    assertEquals(INTEGR_FNAMN, patient.getFornamn());
    assertEquals(INTEGR_MNAMN, patient.getMellannamn());
    assertEquals(INTEGR_LNAMN, patient.getEfternamn());
    assertNull(patient.getPostadress());
    assertNull(patient.getPostnummer());
    assertNull(patient.getPostort());
    assertEquals(INTEGR_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Example 18 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSosDoiIntygFristaendeWithNoDBIntygAndPuUnavailable.

/**
 * DOI - Fristående. DB saknas, PU saknas. Rubbet från Integration
 */
@Test
public void testSosDoiIntygFristaendeWithNoDBIntygAndPuUnavailable() throws ModuleNotFoundException, IOException {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildErrorPersonSvar());
    when(webCertUserService.getUser()).thenReturn(freeWebCertUser);
    when(freeWebCertUser.getValdVardenhet()).thenReturn(buildVardenhet());
    List<Utkast> drafts = new ArrayList<>();
    when(utkastRepository.findDraftsByPatientAndEnhetAndStatus(anyString(), anyList(), anyList(), anySet())).thenReturn(drafts);
    Patient patient = testee.resolvePatient(PNR, "doi");
    assertNull(patient);
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) ArrayList(java.util.ArrayList) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Example 19 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testFKIntygFristaendeWithPuUnavailable.

/**
 * FK - fristående, EJ PU.
 */
@Test
public void testFKIntygFristaendeWithPuUnavailable() {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildErrorPersonSvar());
    when(webCertUserService.getUser()).thenReturn(freeWebCertUser);
    Patient patient = testee.resolvePatient(PNR, "luae_fs");
    assertNull(patient);
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Test(org.junit.Test)

Example 20 with Patient

use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.

the class PatientDetailsResolverTest method testSosDoiIntygIntegrationWithExistingDBIntygAndPuUnavailable.

/**
 * DOI - Integration. DB finns, PU saknas. Namn och adress från DB-intyget, avliden från integrationsparam.
 */
@Test
public void testSosDoiIntygIntegrationWithExistingDBIntygAndPuUnavailable() throws ModuleNotFoundException, IOException {
    when(puService.getPerson(any(Personnummer.class))).thenReturn(buildErrorPersonSvar());
    when(webCertUserService.getUser()).thenReturn(integratedWebCertUser);
    when(integratedWebCertUser.getValdVardgivare()).thenReturn(new Vardgivare("vg-1", "vardgivare-1"));
    List<Utkast> drafts = buildSosDBDrafts();
    when(utkastRepository.findDraftsByPatientAndVardgivareAndStatus(anyString(), anyString(), anyList(), anySet())).thenReturn(drafts);
    ModuleApi moduleApi = mock(ModuleApi.class);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(buildSosDoiUtlatande());
    when(moduleRegistry.getModuleApi("db")).thenReturn(moduleApi);
    Patient patient = testee.resolvePatient(PNR, "doi");
    assertEquals(PNR.getPersonnummer(), patient.getPersonId().getPersonnummer());
    assertEquals(DB_FNAMN, patient.getFornamn());
    assertEquals(DB_MNAMN, patient.getMellannamn());
    assertEquals(DB_ENAMN, patient.getEfternamn());
    assertEquals(DB_POST_ADDR, patient.getPostadress());
    assertEquals(DB_POST_NR, patient.getPostnummer());
    assertEquals(DB_POST_ORT, patient.getPostort());
    assertEquals(INTEGR_AVLIDEN, patient.isAvliden());
    assertEquals(false, patient.isSekretessmarkering());
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) ModuleApi(se.inera.intyg.common.support.modules.support.api.ModuleApi) Utkast(se.inera.intyg.webcert.persistence.utkast.model.Utkast) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Test(org.junit.Test)

Aggregations

Patient (se.inera.intyg.common.support.model.common.internal.Patient)62 Test (org.junit.Test)28 Personnummer (se.inera.intyg.schemas.contract.Personnummer)28 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)12 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)11 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)7 Vardenhet (se.inera.intyg.common.support.model.common.internal.Vardenhet)6 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)6 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)5 Vardgivare (se.inera.intyg.common.support.model.common.internal.Vardgivare)5 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)5 IntygContentHolder (se.inera.intyg.webcert.web.service.intyg.dto.IntygContentHolder)5 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)5 IOException (java.io.IOException)4 GrundData (se.inera.intyg.common.support.model.common.internal.GrundData)4 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)4 ModuleException (se.inera.intyg.common.support.modules.support.api.exception.ModuleException)4 PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)4