Search in sources :

Example 56 with Patient

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

the class IntygServiceTest method buildPatient.

private Patient buildPatient(boolean sekretessMarkering, boolean avliden) {
    Patient patient = new Patient();
    patient.setPersonId(PERSNR);
    patient.setFornamn("fornamn");
    patient.setMellannamn("mellannamn");
    patient.setEfternamn("efternamn");
    patient.setSekretessmarkering(sekretessMarkering);
    patient.setAvliden(avliden);
    return patient;
}
Also used : Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Example 57 with Patient

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

the class IntygServiceImpl method buildIntygContentHolderForUtkast.

// NOTE! INTYG-4086. This method is used when fetching Intyg/Utkast from WC locally. The question is, should we
// replace the patient on the existing model with a freshly fetched one here or not? In case we're storing patient
// info entered manually for non FK-types here, we may end up overwriting a manually stored name etc...
private IntygContentHolder buildIntygContentHolderForUtkast(Utkast utkast, boolean relations) {
    try {
        // INTYG-4086: Patient object populated according to ruleset for the intygstyp at hand.
        Patient newPatientData = patientDetailsResolver.resolvePatient(utkast.getPatientPersonnummer(), utkast.getIntygsTyp());
        // create an "empty" Patient with personnummer only.
        if (newPatientData == null) {
            newPatientData = new Patient();
            newPatientData.setPersonId(utkast.getPatientPersonnummer());
        }
        // INTYG-5354, INTYG-5380: Don't use incomplete address from external data sources (PU/js).
        Utlatande utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), utkast.getModel());
        if (!completeAddressProvided(newPatientData)) {
            // Use the old address data.
            Patient oldPatientData = utlatande.getGrundData().getPatient();
            copyOldAddressToNewPatientData(oldPatientData, newPatientData);
        }
        String updatedModel = moduleRegistry.getModuleApi(utkast.getIntygsTyp()).updateBeforeSave(utkast.getModel(), newPatientData);
        utlatande = modelFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), updatedModel);
        List<Status> statuses = IntygConverterUtil.buildStatusesFromUtkast(utkast);
        Relations certificateRelations = certificateRelationService.getRelations(utkast.getIntygsId());
        final SekretessStatus sekretessStatus = patientDetailsResolver.getSekretessStatus(newPatientData.getPersonId());
        if (SekretessStatus.UNDEFINED.equals(sekretessStatus)) {
            throw new WebCertServiceException(WebCertServiceErrorCodeEnum.PU_PROBLEM, "Sekretesstatus could not be fetched from the PU service");
        }
        final boolean sekretessmarkerad = SekretessStatus.TRUE.equals(sekretessStatus);
        boolean patientNameChanged = patientDetailsResolver.isPatientNamedChanged(utlatande.getGrundData().getPatient(), newPatientData);
        boolean patientAddressChanged = patientDetailsResolver.isPatientAddressChanged(utlatande.getGrundData().getPatient(), newPatientData);
        return IntygContentHolder.builder().setContents(updatedModel).setUtlatande(utlatande).setStatuses(statuses).setRevoked(utkast.getAterkalladDatum() != null).setRelations(certificateRelations).setCreated(utkast.getSkapad()).setDeceased(isDeceased(utkast.getPatientPersonnummer())).setSekretessmarkering(sekretessmarkerad).setPatientNameChangedInPU(patientNameChanged).setPatientAddressChangedInPU(patientAddressChanged).build();
    } catch (ModuleException | ModuleNotFoundException e) {
        throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
    }
}
Also used : UtkastStatus(se.inera.intyg.webcert.common.model.UtkastStatus) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Status(se.inera.intyg.common.support.model.Status) ModuleNotFoundException(se.inera.intyg.common.support.modules.registry.ModuleNotFoundException) SekretessStatus(se.inera.intyg.webcert.common.model.SekretessStatus) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) Patient(se.inera.intyg.common.support.model.common.internal.Patient) Relations(se.inera.intyg.webcert.web.web.controller.api.dto.Relations) ModuleException(se.inera.intyg.common.support.modules.support.api.exception.ModuleException) WebCertServiceException(se.inera.intyg.webcert.common.service.exception.WebCertServiceException)

Example 58 with Patient

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

the class PatientDetailsResolverImpl method buildBasePatientFromParameters.

private Patient buildBasePatientFromParameters(Personnummer personnummer, IntegrationParameters parameters) {
    Patient patient = new Patient();
    patient.setPersonId(personnummer);
    patient.setFornamn(parameters.getFornamn());
    patient.setEfternamn(parameters.getEfternamn());
    patient.setMellannamn(parameters.getMellannamn());
    patient.setFullstandigtNamn(Joiner.on(' ').skipNulls().join(parameters.getFornamn(), parameters.getMellannamn(), parameters.getEfternamn()));
    patient.setAvliden(parameters.isPatientDeceased());
    return patient;
}
Also used : Patient(se.inera.intyg.common.support.model.common.internal.Patient)

Example 59 with Patient

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

the class PatientDetailsResolverImpl method resolveFkPatient.

/*
     * I: Info om avliden från både PU-tjänst och journalsystem.
     */
private Patient resolveFkPatient(Personnummer personnummer, WebCertUser user) {
    PersonSvar personSvar = getPersonSvar(personnummer);
    Patient patient = personSvar.getStatus() == PersonSvar.Status.FOUND ? toPatientFromPersonSvarNameOnly(personnummer, personSvar) : resolveFkPatientPuUnavailable(personnummer, user);
    if (patient != null) {
        patient.setAvliden(patient.isAvliden() || Optional.ofNullable(user.getParameters()).map(IntegrationParameters::isPatientDeceased).orElse(false));
    }
    return patient;
}
Also used : Patient(se.inera.intyg.common.support.model.common.internal.Patient) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar)

Example 60 with Patient

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

the class PatientDetailsResolverImpl method resolveDbPatient.

/**
 * Integration: Namn, s-markering från PU-tjänst & info om avliden. Journalsystem för adress.
 * Free: PU-tjänsten (alla uppgifter)
 */
private Patient resolveDbPatient(Personnummer personnummer, WebCertUser user) {
    PersonSvar personSvar = getPersonSvar(personnummer);
    Patient patient = null;
    // NORMAL and DJUPINTEGRATION uses only PU for db
    if (personSvar.getStatus() == PersonSvar.Status.FOUND) {
        patient = toPatientFromPersonSvar(personnummer, personSvar);
    }
    return patient;
}
Also used : Patient(se.inera.intyg.common.support.model.common.internal.Patient) PersonSvar(se.inera.intyg.infra.integration.pu.model.PersonSvar)

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