Search in sources :

Example 1 with PersonSvar

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

the class ElegWebCertUserDetailsServiceTest method buildPersonSvar.

private PersonSvar buildPersonSvar(boolean sekretessMarkerad, PersonSvar.Status status) {
    Personnummer personnummer = Personnummer.createPersonnummer(PERSON_ID).get();
    Person person = new Person(personnummer, sekretessMarkerad, false, "fornamn", "", "Efternamn", "gatan", "12345", "postort");
    return new PersonSvar(person, status);
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person)

Example 2 with PersonSvar

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

the class RouteTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    MockEndpoint.resetMocks(camelContext);
    when(moduleRegistry.getModuleApi(anyString())).thenReturn(moduleApi);
    when(moduleApi.getUtlatandeFromJson(anyString())).thenReturn(new Fk7263Utlatande());
    when(moduleApi.getIntygFromUtlatande(any())).thenReturn(NotificationTestHelper.createIntyg("fk7263"));
    when(mockedPuService.getPerson(any())).thenReturn(new PersonSvar(NotificationTestHelper.buildPerson(false), PersonSvar.Status.FOUND));
}
Also used : Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Before(org.junit.Before)

Example 3 with PersonSvar

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

the class CopyUtkastServiceImpl method refreshPatientDetailsFromPUService.

private Person refreshPatientDetailsFromPUService(AbstractCreateCopyRequest copyRequest) {
    Personnummer personnummer;
    if (copyRequest.containsNyttPatientPersonnummer()) {
        LOG.debug("Request contained a new personnummer to use for the copy");
        personnummer = copyRequest.getNyttPatientPersonnummer();
    } else {
        personnummer = copyRequest.getPatient().getPersonId();
    }
    LOG.debug("Refreshing person data to use for the copy");
    PersonSvar personSvar = getPersonSvar(personnummer);
    if (PersonSvar.Status.ERROR.equals(personSvar.getStatus())) {
        LOG.error("An error occured when using '{}' to lookup person data", personnummer.getPersonnummerHash());
        return null;
    } else if (PersonSvar.Status.NOT_FOUND.equals(personSvar.getStatus())) {
        LOG.error("No person data was found using '{}' to lookup person data", personnummer.getPersonnummerHash());
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, "No person data found using '" + personnummer.getPersonnummerHash() + "'");
    }
    return personSvar.getPerson();
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 4 with PersonSvar

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

the class ElegWebCertUserDetailsService method decorateWebcertUserWithSekretessMarkering.

private void decorateWebcertUserWithSekretessMarkering(WebCertUser webCertUser, HoSPersonType hosPerson) {
    // Make sure we have a valid personnr to work with..
    Personnummer personNummer = Personnummer.createPersonnummer(hosPerson.getPersonId().getExtension()).orElseThrow(() -> new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, String.format("Can't determine sekretesstatus for invalid personId %s", hosPerson.getPersonId().getExtension())));
    PersonSvar person = puService.getPerson(personNummer);
    if (person.getStatus() == PersonSvar.Status.FOUND) {
        webCertUser.setSekretessMarkerad(person.getPerson().isSekretessmarkering());
    } else {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, String.format("PU replied with %s - Sekretesstatus cannot be determined for person %s", person.getStatus(), personNummer.getPersonnummerWithDash()));
    }
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 5 with PersonSvar

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

the class CopyUtkastServiceImplTest method expectCallToPUService.

@Before
public void expectCallToPUService() throws Exception {
    PersonSvar personSvar = new PersonSvar(new Person(PATIENT_SSN, false, false, "Adam", "Bertilsson", "Cedergren", "Testgatan 12", "12345", "Testberga"), PersonSvar.Status.FOUND);
    when(mockPUService.getPerson(PATIENT_SSN)).thenReturn(personSvar);
}
Also used : PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar) Person(se.inera.intyg.infra.integration.pu.model.Person) Before(org.junit.Before)

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