Search in sources :

Example 36 with IntegrationParameters

use of se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters 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

IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)36 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)32 Test (org.junit.Test)25 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CreateRenewalCopyRequest (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyRequest)9 CreateRenewalCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateRenewalCopyResponse)9 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)8 Response (javax.ws.rs.core.Response)7 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)7 Personnummer (se.inera.intyg.schemas.contract.Personnummer)6 CreateReplacementCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateReplacementCopyResponse)6 CreateCompletionCopyResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateCompletionCopyResponse)5 Person (se.inera.intyg.infra.integration.pu.model.Person)4 LogRequest (se.inera.intyg.webcert.web.service.log.dto.LogRequest)4 CreateUtkastFromTemplateResponse (se.inera.intyg.webcert.web.service.utkast.dto.CreateUtkastFromTemplateResponse)4 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)4 CopyIntygResponse (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygResponse)4 Patient (se.inera.intyg.common.support.model.common.internal.Patient)3 Privilege (se.inera.intyg.infra.security.common.model.Privilege)3 Role (se.inera.intyg.infra.security.common.model.Role)3