Search in sources :

Example 6 with PersonSvar

use of se.inera.intyg.infra.integration.pu.model.PersonSvar in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifterMissingPerson.

@Test
public void testGetPersonuppgifterMissingPerson() {
    Personnummer personnummer = createPnr("19010101-0101");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(null, PersonSvar.Status.NOT_FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.NOT_FOUND, res.getStatus());
    assertNull(res.getPerson());
    verify(mockMonitoringService).logPULookup(personnummer, "NOT_FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Test(org.junit.Test)

Example 7 with PersonSvar

use of se.inera.intyg.infra.integration.pu.model.PersonSvar in project webcert by sklintyg.

the class PatientDetailsResolverImpl method isAvliden.

@Override
public boolean isAvliden(Personnummer personnummer) {
    PersonSvar personSvar = getPersonSvar(personnummer);
    boolean avlidenPU = personSvar.getStatus() == PersonSvar.Status.FOUND && personSvar.getPerson().isAvliden();
    WebCertUser user = webCertUserService.hasAuthenticationContext() ? webCertUserService.getUser() : null;
    boolean avlidenIntegration = user != null && user.getParameters() != null && user.getParameters().isPatientDeceased();
    return avlidenPU || avlidenIntegration;
}
Also used : PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 8 with PersonSvar

use of se.inera.intyg.infra.integration.pu.model.PersonSvar in project webcert by sklintyg.

the class BaseCreateDraftCertificateValidator method validatePUServiceResponse.

protected void validatePUServiceResponse(ResultValidator errors, Personnummer personnummer) {
    PersonSvar personSvar = patientDetailsResolver.getPersonFromPUService(personnummer);
    switch(personSvar.getStatus()) {
        case ERROR:
            errors.addError("Cannot issue intyg. The PU-service was unreachable. Please try again later.");
            break;
        case NOT_FOUND:
            String msg = "Personnumret du har angivit finns inte i folkbokföringsregistret." + " Observera att det inte går att ange reservnummer." + " Webcert hanterar enbart person- och samordningsnummer.";
            errors.addError(msg);
            break;
        default:
            // Do nothing
            break;
    }
}
Also used : PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar)

Example 9 with PersonSvar

use of se.inera.intyg.infra.integration.pu.model.PersonSvar in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifter.

@Test
public void testGetPersonuppgifter() {
    Personnummer personnummer = createPnr("19121212-1212");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(new Person(personnummer, false, false, "fnamn", "mnamn", "enamn", "paddr", "pnr", "port"), PersonSvar.Status.FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.FOUND, res.getStatus());
    assertEquals(false, res.getPerson().isSekretessmarkering());
    assertEquals("fnamn", res.getPerson().getFornamn());
    assertEquals("mnamn", res.getPerson().getMellannamn());
    assertEquals("enamn", res.getPerson().getEfternamn());
    assertEquals("paddr", res.getPerson().getPostadress());
    assertEquals("pnr", res.getPerson().getPostnummer());
    assertEquals("port", res.getPerson().getPostort());
    verify(mockMonitoringService).logPULookup(personnummer, "FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Example 10 with PersonSvar

use of se.inera.intyg.infra.integration.pu.model.PersonSvar in project webcert by sklintyg.

the class PersonApiControllerTest method testGetPersonuppgifterSekretess.

@Test
public void testGetPersonuppgifterSekretess() {
    Personnummer personnummer = createPnr("19121212-1212");
    when(puService.getPerson(any(Personnummer.class))).thenReturn(new PersonSvar(new Person(personnummer, true, false, "fnamn", "mnamn", "enamn", "paddr", "pnr", "port"), PersonSvar.Status.FOUND));
    Response response = personCtrl.getPersonuppgifter(personnummer.getPersonnummer());
    assertNotNull(response);
    assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
    PersonuppgifterResponse res = (PersonuppgifterResponse) response.getEntity();
    assertEquals(PersonSvar.Status.FOUND, res.getStatus());
    assertEquals(true, res.getPerson().isSekretessmarkering());
    assertEquals("fnamn", res.getPerson().getFornamn());
    assertEquals("mnamn", res.getPerson().getMellannamn());
    assertEquals("enamn", res.getPerson().getEfternamn());
    assertEquals("paddr", res.getPerson().getPostadress());
    assertEquals("pnr", res.getPerson().getPostnummer());
    assertEquals("port", res.getPerson().getPostort());
    verify(mockMonitoringService).logPULookup(personnummer, "FOUND");
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) Response(javax.ws.rs.core.Response) PersonuppgifterResponse(se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Test(org.junit.Test)

Aggregations

PersonSvar (se.inera.intyg.infra.integration.pu.model.PersonSvar)16 Personnummer (se.inera.intyg.schemas.contract.Personnummer)8 Patient (se.inera.intyg.common.support.model.common.internal.Patient)4 Person (se.inera.intyg.infra.integration.pu.model.Person)4 PersonuppgifterResponse (se.inera.intyg.webcert.web.web.controller.api.dto.PersonuppgifterResponse)4 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3 Before (org.junit.Before)2 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 ModuleNotFoundException (se.inera.intyg.common.support.modules.registry.ModuleNotFoundException)1 ModuleApi (se.inera.intyg.common.support.modules.support.api.ModuleApi)1 InvalidPersonNummerException (se.inera.intyg.schemas.contract.InvalidPersonNummerException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1