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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations