Implementada comprobación de NIFs duplicados para pacientes y todos los

médicos.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-15 19:32:30 +01:00
parent 7193ffd250
commit 5a3ed35c16
9 changed files with 110 additions and 31 deletions

View File

@@ -5,15 +5,15 @@ import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PatientTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.HashUtils;
import common.UserType;
import ejb.common.CommonFacadeLocal;
import jpa.AdministratorJPA;
import jpa.FamilyDoctorJPA;
import jpa.PatientJPA;
import jpa.SpecialistDoctorJPA;
/**
*
@@ -29,7 +29,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
@EJB
CommonFacadeLocal commonServices;
/**
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
* datos del usuario logeado.
@@ -61,20 +61,20 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
if (userCode.startsWith(Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX)) {
// Si el identificador de usuario es de tipo paciente, intentamos realizar el
// login.
PatientJPA pat = this.commonServices.findPatientByCode(userCode);
PatientTO pat = this.commonServices.findPatientByCode(userCode);
if (pat != null) {
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
}
} else if (userCode.startsWith(Constants.PROFESSIONAL_NUMBER_PREFIX)) {
// Si el identificador de usuario es de tipo profesional, intentamos realizar el
// login, primero como médico de familia, después como especialista
FamilyDoctorJPA fd = this.commonServices.findFamilyDoctorByCode(userCode);
FamilyDoctorTO fd = this.commonServices.findFamilyDoctorByCode(userCode);
if (fd != null) {
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR);
} else {
// No era un código de médico de familia, intenamos logearlo como especialista
SpecialistDoctorJPA sd = this.commonServices.findSpecialistDoctorByCode(userCode);
SpecialistDoctorTO sd = this.commonServices.findSpecialistDoctorByCode(userCode);
if (sd != null) {
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);