Multiples cambios para soportar la utilización de códigos de usuario
únicos para (Pacientes, medicos de familia, medicos especialista y administradores). Nuevos métodos en EJB común para consultar Entidades por Id y por código (Para el login).
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;">
|
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;">
|
||||||
<p:outputLabel value="#{RegisterUser.id}" />
|
<p:outputLabel value="#{RegisterUser.cipCode}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-3"></div>
|
<div class="ui-g-3"></div>
|
||||||
|
|||||||
@@ -27,14 +27,14 @@
|
|||||||
<p:panel id="DatosPersonales" header="Actualizar datos personales">
|
<p:panel id="DatosPersonales" header="Actualizar datos personales">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
<p:outputLabel value="Código de Identificación Personal (CIP):" rendered="#{UpdateProfile.userTypePatient}" for="id" />
|
<p:outputLabel value="Código de Identificación Personal (CIP):" rendered="#{UpdateProfile.userTypePatient}" for="cipCode" />
|
||||||
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.userTypeDoctor}" for="id" />
|
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.userTypeDoctor}" for="cipCode" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-4 ui-md-4">
|
||||||
<p:inputText id="id" value="#{UpdateProfile.id}" disabled="true" required="true" requiredMessage="Por favor, indque su identificador" />
|
<p:inputText id="cipCode" value="#{UpdateProfile.cipCode}" disabled="true" required="true" requiredMessage="Es necesario un código de identificación" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-6 ui-md-6">
|
<div class="ui-g-6 ui-md-6">
|
||||||
<p:message for="id" display="text" />
|
<p:message for="cipCode" display="text" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
private String professionalNumber;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -25,8 +26,9 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
|
public FamilyDoctorTO(Integer id, String pic, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.professionalNumber = pic;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -95,4 +97,11 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
this.primaryHealthCareCenter = primaryHealthCareCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfessionalNumber() {
|
||||||
|
return professionalNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfessionalNumber(String professionalNumber) {
|
||||||
|
this.professionalNumber = professionalNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class PatientTO implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
private String personalIdentificationCode;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -30,8 +31,9 @@ public class PatientTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO(Integer id, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
|
public PatientTO(Integer id, String pic, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.personalIdentificationCode = pic;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -96,5 +98,11 @@ public class PatientTO implements Serializable {
|
|||||||
this.familyDoctor = familyDoctor;
|
this.familyDoctor = familyDoctor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPersonalIdentificationCode() {
|
||||||
|
return personalIdentificationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonalIdentificationCode(String personalIdentificationCode) {
|
||||||
|
this.personalIdentificationCode = personalIdentificationCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class SpecialistDoctorTO implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
private String professionalNumber;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -25,8 +26,9 @@ public class SpecialistDoctorTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
|
public SpecialistDoctorTO(Integer id, String pic, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.professionalNumber = pic;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -91,4 +93,11 @@ public class SpecialistDoctorTO implements Serializable {
|
|||||||
this.medicalSpecialty = medicalSpecialty;
|
this.medicalSpecialty = medicalSpecialty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfessionalNumber() {
|
||||||
|
return professionalNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfessionalNumber(String professionalNumber) {
|
||||||
|
this.professionalNumber = professionalNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,6 @@ package common;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
public static final int MAX_ITEMS_AUTOCOMPLETE_SEARCH = 200;
|
public static final int MAX_ITEMS_AUTOCOMPLETE_SEARCH = 200;
|
||||||
|
public static final String PROFESSIONAL_NUMBER_PREFIX= "PRO#";
|
||||||
|
public static final String PERSONAL_IDENTIFICATION_CODE_PREFIX= "PAT#";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package ejb.common;
|
package ejb.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
@@ -10,6 +9,8 @@ import javax.persistence.PersistenceContext;
|
|||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
import org.jboss.security.auth.spi.Users.User;
|
||||||
|
|
||||||
import TO.FamilyDoctorTO;
|
import TO.FamilyDoctorTO;
|
||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
@@ -71,8 +72,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
|||||||
List<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
List<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
||||||
List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
||||||
|
|
||||||
for (MedicalSpecialtyJPA cap : allJPA) {
|
for (MedicalSpecialtyJPA item : allJPA) {
|
||||||
allSpecialities.add(new MedicalSpecialtyTO(cap.getId(), cap.getName(), cap.getDescription()));
|
allSpecialities.add(this.getPOJOforMedicalSpecialtyJPA(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
return allSpecialities;
|
return allSpecialities;
|
||||||
@@ -111,8 +112,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
|||||||
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||||
List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||||
|
|
||||||
for (PrimaryHealthCareCenterJPA cap : allJPA) {
|
for (PrimaryHealthCareCenterJPA item : allJPA) {
|
||||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getId(), cap.getName(), cap.getLocation()));
|
allCAPs.add(this.getPOJOforPrimaryHealthCareCenterJPA(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
return allCAPs;
|
return allCAPs;
|
||||||
@@ -148,60 +149,127 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
|||||||
query.setMaxResults(pageSize);
|
query.setMaxResults(pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
|
List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
|
||||||
List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
|
List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
|
||||||
|
|
||||||
for (FamilyDoctorJPA item : allFDsJPA) {
|
for (FamilyDoctorJPA item : allFDsJPA) {
|
||||||
allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null));
|
allFDTOs.add(this.getPOJOforFamilyDoctorJPA(item, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return allFDTOs;
|
return allFDTOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO retrievePatient(int patientId) throws Exception {
|
private MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
|
||||||
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
MedicalSpecialtyTO msTO = null;
|
||||||
|
|
||||||
if (pat == null) {
|
if (ms != null) {
|
||||||
throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId));
|
msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return msTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
|
||||||
|
PrimaryHealthCareCenterTO phcTO = null;
|
||||||
|
|
||||||
|
if (phc != null) {
|
||||||
|
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
return phcTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) {
|
||||||
|
SpecialistDoctorTO sdTO = null;
|
||||||
|
|
||||||
|
if (sd != null) {
|
||||||
|
MedicalSpecialtyJPA ms = null;
|
||||||
|
if (nestedProps > 0)
|
||||||
|
ms = sd.getMedicalSpecialty();
|
||||||
|
|
||||||
|
nestedProps--;
|
||||||
|
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
return sdTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) {
|
||||||
FamilyDoctorTO fdTO = null;
|
FamilyDoctorTO fdTO = null;
|
||||||
if (pat.getFamilyDoctor() != null) {
|
|
||||||
FamilyDoctorJPA fd = pat.getFamilyDoctor();
|
if (fd != null) {
|
||||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), null);
|
PrimaryHealthCareCenterJPA phc = null;
|
||||||
|
if (nestedProps > 0)
|
||||||
|
phc = fd.getPrimaryHealthCareCenter();
|
||||||
|
|
||||||
|
nestedProps--;
|
||||||
|
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||||
}
|
}
|
||||||
|
|
||||||
PatientTO paTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), fdTO);
|
|
||||||
return paTO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception {
|
|
||||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
|
||||||
if (fd == null) {
|
|
||||||
throw new Exception("No se encuentra en la base de datos ningún médico de familia con id: " + String.valueOf(ProfessionalNumberId));
|
|
||||||
}
|
|
||||||
|
|
||||||
PrimaryHealthCareCenterTO phc = null;
|
|
||||||
if (fd.getPrimaryHealthCareCenter() != null)
|
|
||||||
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getId(), fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
|
|
||||||
|
|
||||||
FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
|
|
||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorTO retrieveSpecialistDoctor(int professionalId) throws Exception {
|
private PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
|
||||||
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, professionalId);
|
PatientTO paTO = null;
|
||||||
if (sd == null) {
|
|
||||||
throw new Exception(
|
if (pat != null) {
|
||||||
"No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(professionalId));
|
FamilyDoctorJPA fd = null;
|
||||||
|
if (nestedProps > 0)
|
||||||
|
fd = pat.getFamilyDoctor();
|
||||||
|
|
||||||
|
nestedProps--;
|
||||||
|
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||||
}
|
}
|
||||||
|
|
||||||
MedicalSpecialtyTO ms = null;
|
return paTO;
|
||||||
if (sd.getMedicalSpecialty() != null)
|
}
|
||||||
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getId(), sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
|
|
||||||
|
|
||||||
SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms);
|
public PatientTO findPatientById(int patientId) {
|
||||||
return sdTO;
|
// Recuperamos propiedades anidadas 1 nivel!
|
||||||
|
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PatientJPA findPatientByCode(String code) {
|
||||||
|
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
|
||||||
|
|
||||||
|
query.setParameter("code", code);
|
||||||
|
|
||||||
|
List<PatientJPA> results = query.getResultList();
|
||||||
|
if (results.size() > 0)
|
||||||
|
return results.get(0);
|
||||||
|
else
|
||||||
|
return null; }
|
||||||
|
|
||||||
|
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
|
||||||
|
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FamilyDoctorJPA findFamilyDoctorByCode(String code) {
|
||||||
|
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
|
||||||
|
|
||||||
|
query.setParameter("code", code);
|
||||||
|
|
||||||
|
List<FamilyDoctorJPA> results = query.getResultList();
|
||||||
|
if (results.size() > 0)
|
||||||
|
return results.get(0);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
|
||||||
|
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code) {
|
||||||
|
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
|
||||||
|
|
||||||
|
query.setParameter("code", code);
|
||||||
|
|
||||||
|
List<SpecialistDoctorJPA> results = query.getResultList();
|
||||||
|
if (results.size() > 0)
|
||||||
|
return results.get(0);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import TO.MedicalSpecialtyTO;
|
|||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
import TO.PrimaryHealthCareCenterTO;
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
import TO.SpecialistDoctorTO;
|
import TO.SpecialistDoctorTO;
|
||||||
|
import jpa.FamilyDoctorJPA;
|
||||||
|
import jpa.PatientJPA;
|
||||||
|
import jpa.SpecialistDoctorJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -37,9 +40,16 @@ public interface CommonFacadeLocal {
|
|||||||
|
|
||||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||||
|
|
||||||
public PatientTO retrievePatient(int patientId) throws Exception;
|
public PatientTO findPatientById(int patientId);
|
||||||
|
|
||||||
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;
|
public PatientJPA findPatientByCode(String code);
|
||||||
|
|
||||||
|
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||||
|
|
||||||
|
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||||
|
|
||||||
|
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||||
|
|
||||||
|
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||||
|
|
||||||
public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import TO.MedicalSpecialtyTO;
|
|||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
import TO.PrimaryHealthCareCenterTO;
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
import TO.SpecialistDoctorTO;
|
import TO.SpecialistDoctorTO;
|
||||||
|
import jpa.FamilyDoctorJPA;
|
||||||
|
import jpa.PatientJPA;
|
||||||
|
import jpa.SpecialistDoctorJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -37,9 +40,16 @@ public interface CommonFacadeRemote {
|
|||||||
|
|
||||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||||
|
|
||||||
public PatientTO retrievePatient(int patientId) throws Exception;
|
public PatientTO findPatientById(int patientId);
|
||||||
|
|
||||||
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception;
|
public PatientJPA findPatientByCode(String code);
|
||||||
|
|
||||||
|
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||||
|
|
||||||
|
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
|
||||||
|
|
||||||
|
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||||
|
|
||||||
|
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
|
||||||
|
|
||||||
public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ import javax.ejb.EJB;
|
|||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import TO.FamilyDoctorTO;
|
import TO.FamilyDoctorTO;
|
||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
import TO.PrimaryHealthCareCenterTO;
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
import TO.SpecialistDoctorTO;
|
import TO.SpecialistDoctorTO;
|
||||||
|
import common.Constants;
|
||||||
import common.HashUtils;
|
import common.HashUtils;
|
||||||
import ejb.common.CommonFacadeBean;
|
|
||||||
import ejb.common.CommonFacadeLocal;
|
import ejb.common.CommonFacadeLocal;
|
||||||
import ejb.common.CommonFacadeRemote;
|
|
||||||
import jpa.FamilyDoctorJPA;
|
import jpa.FamilyDoctorJPA;
|
||||||
import jpa.MedicalSpecialtyJPA;
|
import jpa.MedicalSpecialtyJPA;
|
||||||
import jpa.PatientJPA;
|
import jpa.PatientJPA;
|
||||||
@@ -35,32 +35,42 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
@EJB
|
@EJB
|
||||||
CommonFacadeLocal commonServices;
|
CommonFacadeLocal commonServices;
|
||||||
|
|
||||||
public PatientTO changeFamilyDoctor(int patientId, int ProfessionalNumberId) throws Exception {
|
private String getNextProfessionalNumber() {
|
||||||
|
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
|
||||||
|
return Constants.PROFESSIONAL_NUMBER_PREFIX.concat(String.valueOf(q.getSingleResult()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getNextPersonalIdentificationCode() {
|
||||||
|
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
|
||||||
|
return Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX.concat(String.valueOf(q.getSingleResult()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatientTO changeFamilyDoctor(int patientId, int newDoctor) throws Exception {
|
||||||
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
||||||
if (pat == null) {
|
if (pat == null) {
|
||||||
throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId));
|
throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId));
|
||||||
}
|
}
|
||||||
|
|
||||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, newDoctor);
|
||||||
if (fd == null) {
|
if (fd == null) {
|
||||||
throw new Exception("No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: "
|
throw new Exception(
|
||||||
+ String.valueOf(ProfessionalNumberId));
|
"No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(newDoctor));
|
||||||
}
|
}
|
||||||
|
|
||||||
PatientTO paTO = null;
|
PatientTO paTO = null;
|
||||||
pat.setFamilyDoctor(fd);
|
pat.setFamilyDoctor(fd);
|
||||||
entman.persist(pat);
|
entman.persist(pat);
|
||||||
|
|
||||||
//CommonFacadeRemote common = new CommonFacadeBean();
|
// CommonFacadeRemote common = new CommonFacadeBean();
|
||||||
return commonServices.retrievePatient(pat.getId());
|
return commonServices.findPatientById(pat.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email) {
|
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email) {
|
||||||
PatientTO paTO = null;
|
PatientTO paTO = null;
|
||||||
|
|
||||||
PatientJPA pat = new PatientJPA(nif, name, surname, HashUtils.hashMD5(password), email, null);
|
PatientJPA pat = new PatientJPA(this.getNextPersonalIdentificationCode(), nif, name, surname, HashUtils.hashMD5(password), email, null);
|
||||||
entman.persist(pat);
|
entman.persist(pat);
|
||||||
paTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
|
paTO = new PatientTO(pat.getId(), this.getNextPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
|
||||||
|
|
||||||
return paTO;
|
return paTO;
|
||||||
}
|
}
|
||||||
@@ -72,11 +82,11 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
|
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, ms);
|
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(this.getNextProfessionalNumber(), nif, name, surname, HashUtils.hashMD5(password), email, ms);
|
||||||
entman.persist(sd);
|
entman.persist(sd);
|
||||||
|
|
||||||
SpecialistDoctorTO sdTO = null;
|
SpecialistDoctorTO sdTO = null;
|
||||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
|
sdTO = new SpecialistDoctorTO(sd.getId(), this.getNextProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
|
||||||
|
|
||||||
return sdTO;
|
return sdTO;
|
||||||
}
|
}
|
||||||
@@ -89,10 +99,10 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + cap.getName());
|
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + cap.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
FamilyDoctorJPA fd = new FamilyDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, phcC);
|
FamilyDoctorJPA fd = new FamilyDoctorJPA(this.getNextProfessionalNumber(), nif, name, surname, HashUtils.hashMD5(password), email, phcC);
|
||||||
entman.persist(fd);
|
entman.persist(fd);
|
||||||
|
|
||||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), cap);
|
fdTO = new FamilyDoctorTO(fd.getId(), this.getNextProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), cap);
|
||||||
|
|
||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
@@ -115,7 +125,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
entman.persist(pat);
|
entman.persist(pat);
|
||||||
|
|
||||||
PatientTO patTO = null;
|
PatientTO patTO = null;
|
||||||
patTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
|
patTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
|
||||||
|
|
||||||
return patTO;
|
return patTO;
|
||||||
}
|
}
|
||||||
@@ -144,7 +154,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
entman.persist(sd);
|
entman.persist(sd);
|
||||||
|
|
||||||
SpecialistDoctorTO sdTO = null;
|
SpecialistDoctorTO sdTO = null;
|
||||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
|
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
|
||||||
|
|
||||||
return sdTO;
|
return sdTO;
|
||||||
}
|
}
|
||||||
@@ -172,7 +182,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
entman.persist(fd);
|
entman.persist(fd);
|
||||||
|
|
||||||
FamilyDoctorTO fdTO = null;
|
FamilyDoctorTO fdTO = null;
|
||||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phcTO);
|
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phcTO);
|
||||||
|
|
||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
@@ -192,7 +202,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
|
|
||||||
fd.setPrimaryHealthCareCenter(phcC);
|
fd.setPrimaryHealthCareCenter(phcC);
|
||||||
entman.persist(fd);
|
entman.persist(fd);
|
||||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), newCenter);
|
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), newCenter);
|
||||||
|
|
||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import TO.SpecialistDoctorTO;
|
|||||||
@Remote
|
@Remote
|
||||||
public interface ProfileFacadeRemote {
|
public interface ProfileFacadeRemote {
|
||||||
|
|
||||||
public PatientTO changeFamilyDoctor(int id, int ProfessionalNumberId) throws Exception;
|
public PatientTO changeFamilyDoctor(int id, int newDoctor) throws Exception;
|
||||||
|
|
||||||
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email);
|
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email);
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
package ejb.systemAdmin;
|
package ejb.systemAdmin;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.ejb.EJB;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.Query;
|
|
||||||
|
|
||||||
import TO.LoggedUserTO;
|
import TO.LoggedUserTO;
|
||||||
import TO.MedicalSpecialtyTO;
|
import common.Constants;
|
||||||
import TO.PrimaryHealthCareCenterTO;
|
|
||||||
import common.HashUtils;
|
import common.HashUtils;
|
||||||
import common.UserType;
|
import common.UserType;
|
||||||
|
import ejb.common.CommonFacadeLocal;
|
||||||
import jpa.AdministratorJPA;
|
import jpa.AdministratorJPA;
|
||||||
import jpa.FamilyDoctorJPA;
|
import jpa.FamilyDoctorJPA;
|
||||||
import jpa.MedicalSpecialtyJPA;
|
|
||||||
import jpa.PatientJPA;
|
import jpa.PatientJPA;
|
||||||
import jpa.PrimaryHealthCareCenterJPA;
|
|
||||||
import jpa.SpecialistDoctorJPA;
|
import jpa.SpecialistDoctorJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,49 +27,80 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
@PersistenceContext(unitName = "MyHealth")
|
@PersistenceContext(unitName = "MyHealth")
|
||||||
private EntityManager entman;
|
private EntityManager entman;
|
||||||
|
|
||||||
public LoggedUserTO login(String id, String pwd) {
|
@EJB
|
||||||
|
CommonFacadeLocal commonServices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
|
||||||
|
* datos del usuario logeado.
|
||||||
|
*
|
||||||
|
* La autenticación se realiza en 2 pasos:
|
||||||
|
*
|
||||||
|
* Paso 1. Se intenta localizar un registro de usuario, por orden:
|
||||||
|
*
|
||||||
|
* a. Primero Paciente, si el identificador comienza por los caracteres
|
||||||
|
* correctos.
|
||||||
|
*
|
||||||
|
* b.Después médico de familia, si el identificador es de profesional
|
||||||
|
*
|
||||||
|
* c. Si no lo localizamos buscamos el identificador en la tabla de médicos
|
||||||
|
* especialistas (el identificador es de profesional)
|
||||||
|
*
|
||||||
|
* d. Si no hemos localizado aún al usuario, lo buscamos en la tabla de
|
||||||
|
* administradores, aún cuando el identificador comience por cualquier carácter
|
||||||
|
* (podría ser una dirección de email que comienza por caracteres del
|
||||||
|
* identificaodr de paciente o profesional)
|
||||||
|
*
|
||||||
|
* Paso 2. Si hemos localizado un registro de usuario, verificamos si el
|
||||||
|
* password recibido coincide con el de la base de datos, en tal caso la
|
||||||
|
* autenticación se compelta y es correcta.
|
||||||
|
*/
|
||||||
|
public LoggedUserTO login(String userCode, String pwd) {
|
||||||
LoggedUserTO usr = null;
|
LoggedUserTO usr = null;
|
||||||
|
|
||||||
// First try to login as Admin
|
if (userCode.startsWith(Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX)) {
|
||||||
AdministratorJPA adm = entman.find(AdministratorJPA.class, id);
|
// Si el identificador de usuario es de tipo paciente, intentamos realizar el
|
||||||
if (adm != null) {
|
// login.
|
||||||
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR);
|
PatientJPA pat = this.commonServices.findPatientByCode(userCode);
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
int iId = Integer.parseInt(id);
|
|
||||||
|
|
||||||
// Try to login Patient, FamilyDoctor or SpecialistDoctor
|
|
||||||
// TODO: Si Patient, FamilyDoctor o Specialist Doctor tienen el mismo id, solo
|
|
||||||
// el paciente se puede logear. ¿Deberíamos cambiar esto permitiendo seleccionar
|
|
||||||
// el perfil a logearse?
|
|
||||||
PatientJPA pat = entman.find(PatientJPA.class, iId);
|
|
||||||
|
|
||||||
if (pat != null) {
|
if (pat != null) {
|
||||||
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
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);
|
||||||
|
|
||||||
|
if (fd != null) {
|
||||||
|
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR);
|
||||||
} else {
|
} else {
|
||||||
FamilyDoctorJPA fdoc = entman.find(FamilyDoctorJPA.class, iId);
|
// No era un código de médico de familia, intenamos logearlo como especialista
|
||||||
|
SpecialistDoctorJPA sd = this.commonServices.findSpecialistDoctorByCode(userCode);
|
||||||
|
|
||||||
if (fdoc != null) {
|
if (sd != null) {
|
||||||
usr = new LoggedUserTO(String.valueOf(fdoc.getId()), fdoc.getName(), fdoc.getPassword(), UserType.FAMILY_DOCTOR);
|
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);
|
||||||
} else {
|
|
||||||
SpecialistDoctorJPA sdoc = entman.find(SpecialistDoctorJPA.class, iId);
|
|
||||||
|
|
||||||
if (sdoc != null) {
|
|
||||||
usr = new LoggedUserTO(String.valueOf(sdoc.getId()), sdoc.getName(), sdoc.getPassword(), UserType.SPECIALIST_DOCTOR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException nf) {
|
|
||||||
// id is not an intenger, so, login fails
|
|
||||||
usr = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Si todavía no hemos conseguido autenticar al usuario, podría tratarse de una
|
||||||
|
// dirección de email de un administrador que empiece por
|
||||||
|
// PERSONAL_IDENTIFICATION_CODE_PREFIX o por PROFESSIONAL_NUMBER_PREFIX, por lo
|
||||||
|
// cual intentamos login contra la tabla de administradores
|
||||||
|
if (usr == null) {
|
||||||
|
// Intentamos recuperar un registro de administrador
|
||||||
|
AdministratorJPA adm = entman.find(AdministratorJPA.class, userCode);
|
||||||
|
|
||||||
|
if (adm != null) {
|
||||||
|
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si el objeto usr, es que hemos localizado un registro de usuario, verificamos
|
||||||
|
// la contraseña.
|
||||||
if (usr != null) {
|
if (usr != null) {
|
||||||
// Comprobamos el password
|
// Comprobamos el password
|
||||||
if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) {
|
if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) {
|
||||||
// Bad Password, devolvemos null!
|
// Bad Password, devolvemos null! La autenticación falla.
|
||||||
usr = null;
|
usr = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
@Column(updatable = false)
|
@Column(updatable = false)
|
||||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
@Column(nullable = false, unique = true)
|
||||||
|
private String professionalNumber;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -49,7 +51,8 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorJPA(String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
|
public FamilyDoctorJPA(String pin, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
|
||||||
|
this.setProfessionalNumber(pin);
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -124,4 +127,12 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
|
||||||
this.primaryHealthCareCenter = center;
|
this.primaryHealthCareCenter = center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfessionalNumber() {
|
||||||
|
return professionalNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfessionalNumber(String professionalNumber) {
|
||||||
|
this.professionalNumber = professionalNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,8 @@ public class PatientJPA implements Serializable {
|
|||||||
@Column(updatable = false)
|
@Column(updatable = false)
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
@Column(nullable = false, unique = true)
|
||||||
|
private String personalIdentificationCode;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -42,7 +44,8 @@ public class PatientJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientJPA(String nif, String name, String surname, String password, String email, FamilyDoctorJPA familyDoc) {
|
public PatientJPA(String pic, String nif, String name, String surname, String password, String email, FamilyDoctorJPA familyDoc) {
|
||||||
|
this.personalIdentificationCode = pic;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -106,4 +109,12 @@ public class PatientJPA implements Serializable {
|
|||||||
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
|
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
|
||||||
this.familyDoctor = familyDoc;
|
this.familyDoctor = familyDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPersonalIdentificationCode() {
|
||||||
|
return personalIdentificationCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPersonalIdentificationCode(String personalIdentificationCode) {
|
||||||
|
this.personalIdentificationCode = personalIdentificationCode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
@Column(updatable = false)
|
@Column(updatable = false)
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
@Column(nullable = false, unique = true)
|
||||||
|
private String professionalNumber;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -42,7 +44,8 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorJPA(String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
|
public SpecialistDoctorJPA(String pic, String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
|
||||||
|
this.setProfessionalNumber(pic);
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.surname = surname;
|
this.surname = surname;
|
||||||
@@ -106,4 +109,12 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
public void setMedicalSpecialty(MedicalSpecialtyJPA specialty) {
|
public void setMedicalSpecialty(MedicalSpecialtyJPA specialty) {
|
||||||
this.medicalSpecialty = specialty;
|
this.medicalSpecialty = specialty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfessionalNumber() {
|
||||||
|
return professionalNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProfessionalNumber(String professionalNumber) {
|
||||||
|
this.professionalNumber = professionalNumber;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
|
|||||||
if (usr.getUserType() == UserType.PATIENT) {
|
if (usr.getUserType() == UserType.PATIENT) {
|
||||||
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
|
|
||||||
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
|
PatientTO pat = this.getRemoteManagerCommon().findPatientById(this.id);
|
||||||
this.setCurrentFamilyDoctor(pat.getFamilyDoctor());
|
this.setCurrentFamilyDoctor(pat.getFamilyDoctor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
|||||||
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
|
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
|
||||||
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
|
|
||||||
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
|
FamilyDoctorTO fd = this.getRemoteManagerCommon().findFamilyDoctorById(this.id);
|
||||||
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
|
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import managedbean.common.ValidationUtils;
|
|||||||
public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
private String cipCode;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -185,14 +185,6 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
|||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNewUser() {
|
public void addNewUser() {
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
@@ -214,17 +206,17 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
|||||||
switch (UserType.valueOf(this.userType)) {
|
switch (UserType.valueOf(this.userType)) {
|
||||||
case PATIENT:
|
case PATIENT:
|
||||||
PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
|
PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
|
||||||
this.id = pat.getId();
|
this.cipCode = pat.getPersonalIdentificationCode();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case FAMILY_DOCTOR:
|
||||||
FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||||
this.id = fd.getId();
|
this.cipCode = fd.getProfessionalNumber();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||||
this.id = sd.getId();
|
this.cipCode = sd.getProfessionalNumber();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ADMINISTRATOR:
|
case ADMINISTRATOR:
|
||||||
@@ -268,4 +260,12 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
|||||||
return registered;
|
return registered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCipCode() {
|
||||||
|
return cipCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCipCode(String cipCode) {
|
||||||
|
this.cipCode = cipCode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
private String cipCode;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -88,35 +89,15 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
switch (usr.getUserType()) {
|
switch (usr.getUserType()) {
|
||||||
case PATIENT:
|
case PATIENT:
|
||||||
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
|
this.setPatientData(this.getRemoteManagerCommon().findPatientById(this.id));
|
||||||
|
|
||||||
this.name = pat.getName();
|
|
||||||
this.surname = pat.getName();
|
|
||||||
this.nif = pat.getNif();
|
|
||||||
this.email = pat.getEmail();
|
|
||||||
this.currentPassword = pat.getPassword();
|
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
SpecialistDoctorTO sd = this.getRemoteManagerCommon().retrieveSpecialistDoctor(this.id);
|
this.setSpecialistDoctorData(this.getRemoteManagerCommon().findSpecialistDoctorById(this.id));
|
||||||
|
|
||||||
this.name = sd.getName();
|
|
||||||
this.surname = sd.getName();
|
|
||||||
this.nif = sd.getNif();
|
|
||||||
this.email = sd.getEmail();
|
|
||||||
this.currentPassword = sd.getPassword();
|
|
||||||
this.medicalSpecialty = sd.getMedicalSpecialty();
|
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case FAMILY_DOCTOR:
|
||||||
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
|
this.setFamilyDoctorData(this.getRemoteManagerCommon().findFamilyDoctorById(this.id));
|
||||||
|
|
||||||
this.name = fd.getName();
|
|
||||||
this.surname = fd.getName();
|
|
||||||
this.nif = fd.getNif();
|
|
||||||
this.email = fd.getEmail();
|
|
||||||
this.currentPassword = fd.getPassword();
|
|
||||||
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
|
|
||||||
break;
|
break;
|
||||||
case ADMINISTRATOR:
|
case ADMINISTRATOR:
|
||||||
// TODO: Recuperar usuario administrador para editar su perfil ¿?
|
// TODO: Recuperar usuario administrador para editar su perfil ¿?
|
||||||
@@ -127,7 +108,39 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.manageException(e);
|
this.manageException(e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setPatientData(PatientTO pat) {
|
||||||
|
this.id = pat.getId();
|
||||||
|
this.cipCode = pat.getPersonalIdentificationCode();
|
||||||
|
this.name = pat.getName();
|
||||||
|
this.surname = pat.getName();
|
||||||
|
this.nif = pat.getNif();
|
||||||
|
this.email = pat.getEmail();
|
||||||
|
this.currentPassword = pat.getPassword();
|
||||||
|
this.familyDoctor = pat.getFamilyDoctor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFamilyDoctorData(FamilyDoctorTO fd) {
|
||||||
|
this.id = fd.getId();
|
||||||
|
this.cipCode = fd.getProfessionalNumber();
|
||||||
|
this.name = fd.getName();
|
||||||
|
this.surname = fd.getName();
|
||||||
|
this.nif = fd.getNif();
|
||||||
|
this.email = fd.getEmail();
|
||||||
|
this.currentPassword = fd.getPassword();
|
||||||
|
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSpecialistDoctorData(SpecialistDoctorTO sd) {
|
||||||
|
this.id = sd.getId();
|
||||||
|
this.cipCode = sd.getProfessionalNumber();
|
||||||
|
this.name = sd.getName();
|
||||||
|
this.surname = sd.getName();
|
||||||
|
this.nif = sd.getNif();
|
||||||
|
this.email = sd.getEmail();
|
||||||
|
this.currentPassword = sd.getPassword();
|
||||||
|
this.medicalSpecialty = sd.getMedicalSpecialty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserType> getUserTypes() {
|
public List<UserType> getUserTypes() {
|
||||||
@@ -290,17 +303,17 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
switch (UserType.valueOf(this.userType)) {
|
switch (UserType.valueOf(this.userType)) {
|
||||||
case PATIENT:
|
case PATIENT:
|
||||||
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
|
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
|
||||||
this.id = pat.getId();
|
this.setPatientData(pat);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case FAMILY_DOCTOR:
|
||||||
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
|
||||||
this.id = fd.getId();
|
this.setFamilyDoctorData(fd);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
|
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
|
||||||
this.id = sd.getId();
|
this.setSpecialistDoctorData(sd);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ADMINISTRATOR:
|
case ADMINISTRATOR:
|
||||||
@@ -360,4 +373,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
this.familyDoctor = familyDoctor;
|
this.familyDoctor = familyDoctor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCipCode() {
|
||||||
|
return cipCode;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user