Search in sources :

Example 16 with PersonSvar

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

the class PatientDetailsResolverImpl method resolveTsPatient.

/*
     * I: Namn, s-markering från PU-tjänst.
     * I: Info om avliden från både PU-tjänst och journalsystem.
     * I: Adress från journalsystem.
     * F: PU-tjänsten (alla uppgifter).
     */
private Patient resolveTsPatient(Personnummer personnummer, WebCertUser user) {
    PersonSvar personSvar = getPersonSvar(personnummer);
    if (personSvar.getStatus() == PersonSvar.Status.FOUND) {
        Patient patient = toPatientFromPersonSvar(personnummer, personSvar);
        // Get address if djupintegration from params, fallback to PU for address if unavailable.
        if (user.getOrigin().equals(UserOriginType.DJUPINTEGRATION.name())) {
            IntegrationParameters parameters = user.getParameters();
            // Loading utkast without uthoppslänk would fail during end-to-end tests, thus the line below
            if (parameters == null) {
                parameters = new IntegrationParameters(null, null, null, null, null, null, null, null, null, false, false, false, false);
            }
            // Update avliden with integrationparameters
            patient.setAvliden(patient.isAvliden() || parameters.isPatientDeceased());
            // All address fields needs to be present from integration parameters, otherwise use PU instead.
            if (isNotNullOrEmpty(parameters.getPostadress()) && isNotNullOrEmpty(parameters.getPostnummer()) && isNotNullOrEmpty(parameters.getPostort())) {
                patient.setPostadress(parameters.getPostadress());
                patient.setPostnummer(parameters.getPostnummer());
                patient.setPostort(parameters.getPostort());
            } else {
                patient.setPostadress(personSvar.getPerson().getPostadress());
                patient.setPostnummer(personSvar.getPerson().getPostnummer());
                patient.setPostort(personSvar.getPerson().getPostort());
            }
        }
        return patient;
    } else {
        // No PU means only use integration parameters
        if (user.getOrigin().equals(UserOriginType.DJUPINTEGRATION.name())) {
            return toPatientFromParameters(personnummer, user.getParameters());
        } else {
            return null;
        }
    }
}
Also used : IntegrationParameters(se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters) Patient(se.inera.intyg.common.support.model.common.internal.Patient) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar)

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