diff --git a/1.sources/MyHealth/docroot/error.xhtml b/1.sources/MyHealth/docroot/error.xhtml index c7e1cc7..e961f1d 100644 --- a/1.sources/MyHealth/docroot/error.xhtml +++ b/1.sources/MyHealth/docroot/error.xhtml @@ -1,7 +1,8 @@ - + @@ -9,24 +10,29 @@
- + + + + +
La acción que estaba realizando a causado un error inesperado en el sistema. A continuación podrá ver un descripción detallada del error para que pueda comunicarlo al equipo de soporte.
- Descripción del error -
- -
- + +
-
-
+
+ +
+ +
+
-
+
diff --git a/1.sources/MyHealth/docroot/header.xhtml b/1.sources/MyHealth/docroot/header.xhtml index 45a0088..2e76837 100644 --- a/1.sources/MyHealth/docroot/header.xhtml +++ b/1.sources/MyHealth/docroot/header.xhtml @@ -33,7 +33,7 @@

- +
@@ -156,11 +158,11 @@
- - + diff --git a/1.sources/MyHealth/docroot/profile/UpdateSpecialistDoctor.xhtml b/1.sources/MyHealth/docroot/profile/UpdateSpecialistDoctor.xhtml deleted file mode 100644 index e24bb46..0000000 --- a/1.sources/MyHealth/docroot/profile/UpdateSpecialistDoctor.xhtml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - -
-
- -
-
- -
-
- -
-
-
-
- -
-
- -
-
-
-
-
-
-
-
- diff --git a/1.sources/MyHealth/src/TO/FamilyDoctorTO.java b/1.sources/MyHealth/src/TO/FamilyDoctorTO.java index dd91620..6a7e0f0 100644 --- a/1.sources/MyHealth/src/TO/FamilyDoctorTO.java +++ b/1.sources/MyHealth/src/TO/FamilyDoctorTO.java @@ -86,7 +86,7 @@ public class FamilyDoctorTO implements Serializable { } public String getDisplayName() { - return String.format("[%d] %s %s", this.id, this.name, this.surname); + return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname); } public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() { diff --git a/1.sources/MyHealth/src/TO/PatientTO.java b/1.sources/MyHealth/src/TO/PatientTO.java index e694dcb..7cd78ca 100644 --- a/1.sources/MyHealth/src/TO/PatientTO.java +++ b/1.sources/MyHealth/src/TO/PatientTO.java @@ -90,6 +90,10 @@ public class PatientTO implements Serializable { this.id = id; } + public String getDisplayName() { + return String.format("[%s] %s %s", this.personalIdentificationCode, this.name, this.surname); + } + public FamilyDoctorTO getFamilyDoctor() { return familyDoctor; } diff --git a/1.sources/MyHealth/src/TO/SpecialistDoctorTO.java b/1.sources/MyHealth/src/TO/SpecialistDoctorTO.java index 596745e..d55dcaf 100644 --- a/1.sources/MyHealth/src/TO/SpecialistDoctorTO.java +++ b/1.sources/MyHealth/src/TO/SpecialistDoctorTO.java @@ -85,6 +85,10 @@ public class SpecialistDoctorTO implements Serializable { this.id = id; } + public String getDisplayName() { + return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname); + } + public MedicalSpecialtyTO getMedicalSpecialty() { return medicalSpecialty; } diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java index e150321..47b55db 100644 --- a/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java @@ -161,114 +161,153 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal { public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) { MedicalSpecialtyTO msTO = null; - + if (ms != null) { msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription()); } - + return msTO; } public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) { PrimaryHealthCareCenterTO phcTO = null; - + if (phc != null) { phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation()); } - + return phcTO; } public 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)); + + nestedProps--; + sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), + this.getPOJOforMedicalSpecialtyJPA(ms)); } - + return sdTO; } - + public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) { FamilyDoctorTO fdTO = null; - + if (fd != 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)); + fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), + this.getPOJOforPrimaryHealthCareCenterJPA(phc)); } - + return fdTO; } - + public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) { PatientTO paTO = null; - + if (pat != null) { 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)); + paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), + this.getPOJOforFamilyDoctorJPA(fd, nestedProps)); } - + return paTO; } - + public PatientTO findPatientById(int patientId) { // Recuperamos propiedades anidadas 1 nivel! return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1); } - - public PatientJPA findPatientByCode(String code) { + public PatientTO findPatientByCode(String code) { TypedQuery query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class); - + query.setMaxResults(1); query.setParameter("code", code); - + List results = query.getResultList(); if (results.size() > 0) - return results.get(0); + return this.getPOJOforPatientJPA(results.get(0), 1); else - return null; } + return null; + } + + public PatientTO findPatientByNif(String searchValue) { + TypedQuery query = entman.createQuery("from PatientJPA pat where pat.nif=:nif", PatientJPA.class); + query.setMaxResults(1); + query.setParameter("nif", searchValue); + + List results = query.getResultList(); + if (results.size() > 0) + return this.getPOJOforPatientJPA(results.get(0), 1); + else + return null; + } public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) { return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1); } - public FamilyDoctorJPA findFamilyDoctorByCode(String code) { + public FamilyDoctorTO findFamilyDoctorByCode(String code) { TypedQuery query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class); - + query.setParameter("code", code); - + List results = query.getResultList(); if (results.size() > 0) - return results.get(0); + return this.getPOJOforFamilyDoctorJPA(results.get(0), 1); else return null; } - + + public FamilyDoctorTO findFamilyDoctorByNif(String searchValue) { + TypedQuery query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif", FamilyDoctorJPA.class); + query.setMaxResults(1); + query.setParameter("nif", searchValue); + + List results = query.getResultList(); + if (results.size() > 0) + return this.getPOJOforFamilyDoctorJPA(results.get(0), 1); + else + return null; + } + public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) { return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1); } - public SpecialistDoctorJPA findSpecialistDoctorByCode(String code) { + public SpecialistDoctorTO findSpecialistDoctorByCode(String code) { TypedQuery query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class); - + query.setParameter("code", code); - + List results = query.getResultList(); if (results.size() > 0) - return results.get(0); + return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1); + else + return null; + } + + public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue) { + TypedQuery query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif", SpecialistDoctorJPA.class); + query.setMaxResults(1); + query.setParameter("nif", searchValue); + + List results = query.getResultList(); + if (results.size() > 0) + return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1); else return null; } diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java index bd6a081..72772f2 100644 --- a/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java @@ -44,15 +44,21 @@ public interface CommonFacadeLocal { public PatientTO findPatientById(int patientId); - public PatientJPA findPatientByCode(String code); + public PatientTO findPatientByCode(String code); + + public PatientTO findPatientByNif(String searchValue); public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId); - public FamilyDoctorJPA findFamilyDoctorByCode(String code); + public FamilyDoctorTO findFamilyDoctorByCode(String code); + + public FamilyDoctorTO findFamilyDoctorByNif(String searchValue); public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId); - public SpecialistDoctorJPA findSpecialistDoctorByCode(String code); + public SpecialistDoctorTO findSpecialistDoctorByCode(String code); + + public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue); public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms); diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java index 44f38cc..e386ac8 100644 --- a/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java @@ -42,14 +42,20 @@ public interface CommonFacadeRemote { public PatientTO findPatientById(int patientId); - public PatientJPA findPatientByCode(String code); + public PatientTO findPatientByCode(String code); + + public PatientTO findPatientByNif(String searchValue); public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId); - public FamilyDoctorJPA findFamilyDoctorByCode(String code); + public FamilyDoctorTO findFamilyDoctorByCode(String code); + + public FamilyDoctorTO findFamilyDoctorByNif(String searchValue); public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId); - public SpecialistDoctorJPA findSpecialistDoctorByCode(String code); + public SpecialistDoctorTO findSpecialistDoctorByCode(String code); + + public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue); } diff --git a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java index 5260402..3b59839 100644 --- a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java @@ -41,7 +41,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote { } private String getNextPersonalIdentificationCode() { - Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')"); + Query q = entman.createNativeQuery("select nextval('myhealth.codigoidentificacionpaciente')"); return Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX.concat(String.valueOf(q.getSingleResult())); } diff --git a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java index ea2eccf..37785f3 100644 --- a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java @@ -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); diff --git a/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java b/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java index 84c85f8..945a532 100644 --- a/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java +++ b/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java @@ -2,7 +2,11 @@ package managedbean.common; import java.io.IOException; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.List; +import javax.faces.application.FacesMessage; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -14,6 +18,11 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.primefaces.model.menu.DefaultSeparator; +import org.primefaces.model.menu.DefaultSubMenu; + +import common.UserType; + @WebFilter(filterName = "AuthFilter", urlPatterns = { "*.xhtml" }) public class AuthorizationFilter implements Filter { @@ -34,11 +43,101 @@ public class AuthorizationFilter implements Filter { HttpSession ses = req.getSession(false); String reqURI = req.getRequestURI(); - if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0 - || reqURI.contains("javax.faces.resource") || SessionUtils.isLogedIn(ses) == true) + + // Para recursos publicos permitimos el acceso + if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/profile/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 + || reqURI.indexOf("/error.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0 || reqURI.contains("javax.faces.resource")) { chain.doFilter(request, response); - else - resp.sendRedirect(req.getContextPath() + "/login.xhtml"); + return; + } + + // Si el usuario está logeado comprobamos si está autorizado a ver la página + // solicitada. + if (SessionUtils.isLogedIn(ses) == true) { + UserType tipoUsuario = SessionUtils.getUserType(ses); + boolean authorized = false; + + switch (tipoUsuario) { + case ADMINISTRATOR: + if (reqURI.indexOf("/systemAdmin/ManageSpecialties") > 0) + authorized = true; + if (reqURI.indexOf("/systemAdmin/ManageHealthCareCenters") > 0) + authorized = true; + if (reqURI.indexOf("/systemAdmin/ListDoctorsByCenter") > 0) + authorized = true; + if (reqURI.indexOf("/visit/VisitView") > 0) + authorized = true; + if (reqURI.indexOf("/visit/UpdateVisit") > 0) + authorized = true; + break; + case PATIENT: + if (reqURI.indexOf("/visit/VisitView") > 0) + authorized = true; + if (reqURI.indexOf("/visit/AddVisit") > 0) + authorized = true; + if (reqURI.indexOf("/visit/UpdateVisit") > 0) + authorized = true; + if (reqURI.indexOf("/visit/CancelVisit") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/AddQuestion") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/MedicalTests") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/SearchSpecialistBySpecialty") > 0) + authorized = true; + if (reqURI.indexOf("/profile/UpdateProfile") > 0) + authorized = true; + if (reqURI.indexOf("/profile/ChangeFamilyDoctor") > 0) + authorized = true; + break; + case FAMILY_DOCTOR: + if (reqURI.indexOf("/visit/VisitView") > 0) + authorized = true; + if (reqURI.indexOf("/visit/VisitAddResult") > 0) + authorized = true; + if (reqURI.indexOf("/visit/VisitViewSchedules") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/MedicalTests") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/AnswerQuestion") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/PendingQuestions") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0) + authorized = true; + if (reqURI.indexOf("/profile/UpdateProfile") > 0) + authorized = true; + if (reqURI.indexOf("/profile/ChangePrimaryHealthCareCenter") > 0) + authorized = true; + break; + case SPECIALIST_DOCTOR: + if (reqURI.indexOf("/medicaltest/MedicalTests") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/AddMedicalTest") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0) + authorized = true; + if (reqURI.indexOf("/medicaltest/AddImageToMedicalTest") > 0) + authorized = true; + if (reqURI.indexOf("/profile/UpdateProfile") > 0) + authorized = true; + break; + } + + if (authorized == true) { + chain.doFilter(request, response); + return; + } else { + SessionUtils.addMessage(ses, FacesMessage.SEVERITY_ERROR, "No está autorizado a acceder a la página solicitada. Por favor, utilice el menú principal de la aplicación.", String.format("Se ha producido una expción de autorización, su usuario no está autorizado a acceder a la página: (%s).", reqURI)); + resp.sendRedirect(req.getContextPath() + "/error.xhtml?type=auth"); + return; + } + + } + + resp.sendRedirect(req.getContextPath() + "/login.xhtml"); } catch (Exception e) { System.out.println(e.getMessage()); } diff --git a/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java b/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java index c9d4fb7..74ac0dd 100644 --- a/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java +++ b/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java @@ -95,17 +95,29 @@ public class ManagedBeanBase { protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) { FacesContext context = FacesContext.getCurrentInstance(); - this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail); + this.addFacesMessage(FacesContext.getCurrentInstance(), null, severity, summary, detail); context.getExternalContext().getFlash().setKeepMessages(true); } protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) { - this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail); + this.addFacesMessage(FacesContext.getCurrentInstance(), null, severity, summary, detail); + } + + protected void addFacesMessage(String clientId, FacesMessage.Severity severity, String summary, String detail) { + this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, severity, summary, detail); } - protected void addFacesMessage(FacesContext context, FacesMessage.Severity severity, String summary, String detail) { - context.addMessage(null, new FacesMessage(severity, summary, detail)); + protected void addFacesMessage(FacesContext context, String clientId, FacesMessage.Severity severity, String summary, String detail) { + this.addFacesMessage(context, clientId, new FacesMessage(severity, summary, detail)); + } + + protected void addFacesMessage(FacesMessage facesMsg, String clientId) { + this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, facesMsg); + } + + protected void addFacesMessage(FacesContext context, String clientId, FacesMessage facesMsg) { + context.addMessage(clientId, facesMsg); } protected void manageException(Exception ex) { diff --git a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java index 801de63..35c1b7e 100644 --- a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java @@ -114,9 +114,9 @@ public class MenuMBean implements Serializable { subMenu = new DefaultSubMenu("Gestionar perfil", "fa fa-gears"); if (SessionUtils.isLogedIn() == false) { subMenu.addElement(createMenuItem("Registro de usuario", "fa fa-user-plus", "/profile/RegisterUser", null)); - subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null)); - subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null)); - subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null)); +// subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null)); +// subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null)); +// subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null)); model.addElement(subMenu); } else { diff --git a/1.sources/MyHealth/src/managedbean/common/SessionUtils.java b/1.sources/MyHealth/src/managedbean/common/SessionUtils.java index 80f5eb3..0aa178f 100644 --- a/1.sources/MyHealth/src/managedbean/common/SessionUtils.java +++ b/1.sources/MyHealth/src/managedbean/common/SessionUtils.java @@ -1,6 +1,7 @@ package managedbean.common; +import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; @@ -14,6 +15,7 @@ public class SessionUtils { public static final String SESSION_VAR_USERID = "userId"; public static final String SESSION_VAR_USERTYPE = "userType"; public static final String SESSION_VAR_USER = "loggedOnUser"; + public static final String SESSION_VAR_MESSAGE = "facesMessage"; public static HttpSession getSession() { FacesContext ctx = FacesContext.getCurrentInstance(); @@ -47,7 +49,7 @@ public class SessionUtils { public static boolean isLogedIn() { return isLogedIn(getSession()); } - + public static boolean isLogedIn(HttpSession session) { if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null) return true; @@ -70,15 +72,18 @@ public class SessionUtils { else return ""; } - + public static UserType getUserType() { - HttpSession session = getSession(); + return getUserType(getSession()); + } + + public static UserType getUserType(HttpSession session) { if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE) != null) return UserType.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE)); else return null; - } - + } + public static LoggedUserTO getloggedOnUser() { HttpSession session = getSession(); if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USER) != null) @@ -86,4 +91,24 @@ public class SessionUtils { else return null; } + + public static FacesMessage getMessage() { + HttpSession session = getSession(); + if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE) != null) { + FacesMessage msg = FacesMessage.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE)); + session.removeAttribute(SessionUtils.SESSION_VAR_MESSAGE); + return msg; + } else + return null; + } + + public static void addMessage(FacesMessage.Severity severity, String summary, String detail) { + addMessage(getSession(), severity, summary, detail); + } + + public static void addMessage(HttpSession session, FacesMessage.Severity severity, String summary, String detail) { + if (session != null) + session.setAttribute(SessionUtils.SESSION_VAR_MESSAGE, new FacesMessage(severity, summary, detail)); + } + } diff --git a/1.sources/MyHealth/src/managedbean/common/ValidationUtils.java b/1.sources/MyHealth/src/managedbean/common/ValidationUtils.java index f011bc3..d147b8e 100644 --- a/1.sources/MyHealth/src/managedbean/common/ValidationUtils.java +++ b/1.sources/MyHealth/src/managedbean/common/ValidationUtils.java @@ -1,5 +1,11 @@ package managedbean.common; +import TO.FamilyDoctorTO; +import TO.PatientTO; +import TO.SpecialistDoctorTO; +import common.UserType; +import ejb.common.CommonFacadeRemote; + /*** * * @author Marcos García Núñez (mgarcianun@uoc.edu) @@ -47,4 +53,51 @@ public class ValidationUtils { return false; } + /** + * Comprueba si un NIF existe para un tipo de usuario. * No se permite que el + * mismo NIF esté registrado como médico de familia y como especialista. * Se + * permite que el mismo NIF esté registrado como paciente y como médico (de + * familia o especialista) + * + * @param remoteSvc Servicio Remoto para recuperar datos. + * @param userType Tipo de usuario a comprobar + * @param nif NIF a comprobar. + * @param id Parámetro opcional, id del usuario actual (si encuentra el + * mismo nif y el usuario coincide no se devuelve la + * coincidencia) + * @return true si el NIF ya estaba registrado para un usuario diferente. + */ + public static boolean checkIfNifAlreadyRegistered(CommonFacadeRemote remoteSvc, UserType userType, String nif, Integer id) { + boolean nifExists = false; + + switch (userType) { + case ADMINISTRATOR: + break; + case FAMILY_DOCTOR: + case SPECIALIST_DOCTOR: + FamilyDoctorTO fd = remoteSvc.findFamilyDoctorByNif(nif); + + if (fd == null) { + // Si el nif no está en uso para un médico de familia, reivsamos si está en uso + // para los especialistas + SpecialistDoctorTO sd = remoteSvc.findSpecialistDoctorByNif(nif); + + if (sd != null && (id == null || fd.getId() != id)) + nifExists = true; + } else if (id == null || fd.getId() != id) + // Si se trata de un usuario diferente, entonces está repetido + nifExists = true; + + break; + case PATIENT: + PatientTO pat = remoteSvc.findPatientByNif(nif); + + // Si se trata de un usuario diferente, entonces está repetido + if (pat != null && (id == null || pat.getId() != id)) + nifExists = true; + break; + } + + return nifExists; + } } diff --git a/1.sources/MyHealth/src/managedbean/common/homeMBean.java b/1.sources/MyHealth/src/managedbean/common/homeMBean.java index 4d1dcdc..89a2b55 100644 --- a/1.sources/MyHealth/src/managedbean/common/homeMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/homeMBean.java @@ -5,6 +5,7 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.enterprise.context.RequestScoped; +import javax.faces.application.FacesMessage; import javax.inject.Named; import common.UserType; @@ -16,7 +17,7 @@ import common.UserType; */ @Named("home") @RequestScoped -public class homeMBean implements Serializable { +public class homeMBean extends ManagedBeanBase implements Serializable { private static final long serialVersionUID = 1L; private boolean isLogedIn; @@ -31,6 +32,12 @@ public class homeMBean implements Serializable { userName = SessionUtils.getUserName(); userId = SessionUtils.getUserId(); userType = SessionUtils.getUserType(); + + FacesMessage message = SessionUtils.getMessage(); + + if (message != null) { + this.addFacesMessage(message, null); + } } public List getThemes() { diff --git a/1.sources/MyHealth/src/managedbean/profile/AddFamilyDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/AddFamilyDoctorMBean.java deleted file mode 100644 index 3d859b2..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/AddFamilyDoctorMBean.java +++ /dev/null @@ -1,29 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; - -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named("AddFamilyDoctorMBean") -@RequestScoped -public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public AddFamilyDoctorMBean() { - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/AddPatientMBean.java b/1.sources/MyHealth/src/managedbean/profile/AddPatientMBean.java deleted file mode 100644 index 6310e3b..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/AddPatientMBean.java +++ /dev/null @@ -1,112 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; - -import javax.enterprise.context.RequestScoped; -import javax.faces.application.FacesMessage; -import javax.faces.context.FacesContext; -import javax.inject.Named; - -import managedbean.common.ManagedBeanBase; - -/** - * ManagedBEan que gestiona la edición y actualización de una especialidad - * médica. - * - * @author mark - * - */ -@Named("addPatientMBean") -@RequestScoped -public class AddPatientMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - private String id; - private String nif; - private String name; - private String surname; - private String password; - private String passwordRepeat; - private String email; - private String primaryHealthCareCenter; - private String medicalSpecialty; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public AddPatientMBean() { - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getSurname() { - return surname; - } - - public void setSurname(String surname) { - this.surname = surname; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getNif() { - return nif; - } - - public void setNif(String nif) { - this.nif = nif; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void save() { - FacesMessage msg; - - try { - - - msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada", "El usuario " + name + " " + surname + " se ha registrado correctamente."); - } catch (Exception e) { - msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Se ha producido un error inesperado: " + e.getLocalizedMessage()); - } - - FacesContext.getCurrentInstance().addMessage(null, msg); - } - - public String getPasswordRepeat() { - return passwordRepeat; - } - - public void setPasswordRepeat(String passwordRepeat) { - this.passwordRepeat = passwordRepeat; - } -} diff --git a/1.sources/MyHealth/src/managedbean/profile/AddSpecialistDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/AddSpecialistDoctorMBean.java deleted file mode 100644 index 9086bc3..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/AddSpecialistDoctorMBean.java +++ /dev/null @@ -1,34 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named( "AddSpecialistDoctorMBean") -@RequestScoped -public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public AddSpecialistDoctorMBean() { - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java b/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java index d53a778..60896c1 100644 --- a/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java @@ -127,6 +127,11 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable { } return this.medicalSpecialitiesList; } + + public void hadleNIFValueChange() { + if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true) + this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); + } public boolean isPatient() { return (this.userType == UserType.PATIENT); @@ -199,6 +204,10 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable { this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido."); error++; } + if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true) { + this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); + error++; + } if (error == 0) { try { diff --git a/1.sources/MyHealth/src/managedbean/profile/ShowFamilyDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/ShowFamilyDoctorMBean.java deleted file mode 100644 index 2c80a9c..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/ShowFamilyDoctorMBean.java +++ /dev/null @@ -1,50 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named( "ShowFamilyDoctorMBean") -@RequestScoped -public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public ShowFamilyDoctorMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx - .lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/ShowPatientMBean.java b/1.sources/MyHealth/src/managedbean/profile/ShowPatientMBean.java deleted file mode 100644 index 059c7bc..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/ShowPatientMBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named("ShowPatientMBean") -@RequestScoped -public class ShowPatientMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public ShowPatientMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/ShowSpecialistDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/ShowSpecialistDoctorMBean.java deleted file mode 100644 index 15bddbd..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/ShowSpecialistDoctorMBean.java +++ /dev/null @@ -1,50 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named( "ShowSpecialistDoctorMBean") -@RequestScoped -public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public ShowSpecialistDoctorMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx - .lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdateFamilyDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdateFamilyDoctorMBean.java deleted file mode 100644 index 67e6f61..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/UpdateFamilyDoctorMBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named("UpdateFamilyDoctorMBean") -@RequestScoped -public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public UpdateFamilyDoctorMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdatePatientMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdatePatientMBean.java deleted file mode 100644 index 6173ebc..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/UpdatePatientMBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named("UpdatePatientMBean") -@RequestScoped -public class UpdatePatientMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public UpdatePatientMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java index 9199d59..3434842 100644 --- a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java @@ -172,6 +172,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable return this.medicalSpecialitiesList; } + public void hadleNIFValueChange() { + if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) + this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); + } + public List getFamilyDoctorList() { return familyDoctorList; } @@ -261,6 +266,10 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido."); error++; } + if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) { + this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); + error++; + } if (changePassword == true) { // el usuario queire cambiar el password Comprobamos que el password // especificado coincide con el guardado diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdateSpecialistDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdateSpecialistDoctorMBean.java deleted file mode 100644 index 9327221..0000000 --- a/1.sources/MyHealth/src/managedbean/profile/UpdateSpecialistDoctorMBean.java +++ /dev/null @@ -1,49 +0,0 @@ -package managedbean.profile; - -import java.io.Serializable; -import java.util.Properties; - -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; -import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; - -import ejb.profile.ProfileFacadeRemote; -import managedbean.common.ManagedBeanBase; - -/*** - * - * @author Marcos García Núñez (mgarcianun@uoc.edu) - * - */ -@Named("UpdateSpecialistDoctorMBean") -@RequestScoped -public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable { - - private static final long serialVersionUID = 1L; - - @EJB - private ProfileFacadeRemote remoteManager; - - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public UpdateSpecialistDoctorMBean() throws Exception { - initializeAdminFacadeRemote(); - } - - /** - * Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - private void initializeAdminFacadeRemote() throws Exception { - Properties props = System.getProperties(); - Context ctx = new InitialContext(props); - remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote"); - } - -} diff --git a/2.database/02. Datos_prueba.sql b/2.database/02. Datos_prueba.sql index ccd897e..0e3aaf4 100644 --- a/2.database/02. Datos_prueba.sql +++ b/2.database/02. Datos_prueba.sql @@ -1,61 +1,84 @@ --Inserta usuarios administradores (contraseña Hash MD5 'admin' para todos) -insert into myhealth.administrator (email, password) values ('admin@example.com', '21232F297A57A5A743894A0E4A801FC3'); -insert into myhealth.administrator (email, password) values ('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3'); +insert into myhealth.administrator (email, password) values +('admin@example.com', '21232F297A57A5A743894A0E4A801FC3') +,('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3'); -- Insertar Algunos centros médicos INSERT INTO myhealth.primaryhealthcarecenter(name, location) VALUES -('CENTRO SAUDE A DOBLADA',' CALLE RUA FAISAN S/N '), -('CENTRO SAUDE BEMBRIVE',' CARRETERA BEMBRIVE 259 '), -('CENTRO SAUDE BOLIVIA',' CALLE PIZARRO 22 '), -('CENTRO SAUDE CASCO VELLO',' PLAZA CONSTITUCION 7 '), -('CENTRO SAUDE COIA',' CALLE PONTEAREAS S/N '), -('CENTRO SAUDE COLMEIRO',' CALLE PINTOR COLMEIRO 11 '), -('CENTRO SAUDE CORUXO',' CALLE RUA JOSE RIVAS CARRASQUEIRA S/N '), -('CENTRO SAUDE LAVADORES',' TRAVESIA BARREIRO 1 36 '), -('CENTRO SAUDE LOPEZ MORA',' CALLE LOPEZ MORA 54 '), -('CENTRO SAUDE MATAMA',' CAMINO CAMIÑO BABIO-AS CARNEIRAS S/N '), -('CENTRO SAUDE NICOLAS PEÑA',' CAMINO CAMIÑO REGUEIRO S/N '), -('CENTRO SAUDE ROSALIA DE CASTRO-BEIRAMAR',' CALLE ROSALIA DE CASTRO 21 '), -('CENTRO SAUDE RUA CUBA',' CALLE CUBA 10 '), -('CENTRO SAUDE SAN PAIO DE NAVIA',' CALLE POZA CABALO S/N '), -('CENTRO SAUDE SARDOMA',' CALLE RUA CANTEIRA DE BALIN 76 '), -('CENTRO SAUDE TEIS',' CALLE ANGELA IGLESIAS REBOLLAR S/N '); +('Centro Saude A Doblada',' Calle Rua Faisan S/N') +,('Centro Saude Bembrive',' Carretera Bembrive 259') +,('Centro Saude Bolivia',' Calle Pizarro 22') +,('Centro Saude Casco Vello',' Plaza Constitucion 7') +,('Centro Saude Coia',' Calle Ponteareas S/N') +,('Centro Saude Colmeiro',' Calle Pintor Colmeiro 11') +,('Centro Saude Coruxo',' Calle Rua Jose Rivas Carrasqueira S/N') +,('Centro Saude Lavadores',' Travesia Barreiro 1 36') +,('Centro Saude Lopez Mora',' Calle Lopez Mora 54') +,('Centro Saude Matama',' Camino Camiño Babio-As Carneiras S/N') +,('Centro Saude Nicolas Peña',' Camino Camiño Regueiro S/N') +,('Centro Saude Rosalia De Castro-Beiramar',' Calle Rosalia De Castro 21') +,('Centro Saude Rua Cuba',' Calle Cuba 10') +,('Centro Saude San Paio De Navia',' Calle Poza Cabalo S/N') +,('Centro Saude Sardoma',' Calle Rua Canteira De Balin 76') +,('Centro Saude Teis',' Calle Angela Iglesias Rebollar S/N'); -- Inserta Especialidades médicas -insert into MyHealth.MedicalSpecialty(name, description) -values ('Alergologia','Especialidad médica de Alergologia'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía cardiaca','Especialidad médica de Cirugía cardiaca'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía general','Especialidad médica de Cirugía general'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía plastica','Especialidad médica de Cirugía plastica'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía de mama','Especialidad médica de Cirugía de mama'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía maxilofacial','Especialidad médica de Cirugía maxilofacial'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Cirugía vascular','Especialidad médica de Cirugía vascular'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Dermatología','Especialidad médica de Dermatología'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Endocrinología y nutrición','Especialidad médica de Endocrinología y nutrición'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Gastroenterología- digestivo','Especialidad médica de Gastroenterología- digestivo'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Neurocirugía','Especialidad médica de Neurocirugía'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Oftalmología','Especialidad médica de Oftalmología'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Otorrinolaringologia','Especialidad médica de Otorrinolaringologia'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Oncología','Especialidad médica de Oncología'); -insert into MyHealth.MedicalSpecialty(name, description) -values ('Pediatría','Especialidad médica de Pediatría'); +insert into MyHealth.MedicalSpecialty(name, description) values +('Alergologia','Especialidad médica de Alergologia') +,('Cirugía cardiaca','Especialidad médica de Cirugía cardiaca') +,('Cirugía general','Especialidad médica de Cirugía general') +,('Cirugía plastica','Especialidad médica de Cirugía plastica') +,('Cirugía de mama','Especialidad médica de Cirugía de mama') +,('Cirugía maxilofacial','Especialidad médica de Cirugía maxilofacial') +,('Cirugía vascular','Especialidad médica de Cirugía vascular') +,('Dermatología','Especialidad médica de Dermatología') +,('Endocrinología y nutrición','Especialidad médica de Endocrinología y nutrición') +,('Gastroenterología- digestivo','Especialidad médica de Gastroenterología- digestivo') +,('Neurocirugía','Especialidad médica de Neurocirugía') +,('Oftalmología','Especialidad médica de Oftalmología') +,('Otorrinolaringologia','Especialidad médica de Otorrinolaringologia') +,('Oncología','Especialidad médica de Oncología') +,('Pediatría','Especialidad médica de Pediatría'); + +-- Insertar médicos de familia +INSERT INTO myhealth.familydoctor(professionalnumber, password, nif, surname, email, name, primaryhealthcarecenterid) VALUES +('PRO#100','912EC803B2CE49E4A541068D495AB570','95874388S','Moran Ortiz', 'Xian@example.ecom','Xian', 1) +,('PRO#101','912EC803B2CE49E4A541068D495AB570','59546140Z','Zambrano Rivas', 'Belen@example.ecom','Belen', 2) +,('PRO#102','912EC803B2CE49E4A541068D495AB570','16354100L','Cuevas Luque', 'Fernando@example.ecom','Fernando', 3) +,('PRO#103','912EC803B2CE49E4A541068D495AB570','32662259M','Becerra Muñiz', 'Luis@example.ecom','Luis', 4) +,('PRO#104','912EC803B2CE49E4A541068D495AB570','70600712G','Aznar Silva', 'Ana@example.ecom','Ana', 5) +,('PRO#105','912EC803B2CE49E4A541068D495AB570','08003806J','Galvez Sancho', 'Alfonso@example.ecom','Alfonso', 6) +,('PRO#106','912EC803B2CE49E4A541068D495AB570','19567288S','Criado Marti', 'Jordi@example.ecom','Jordi', 7) +,('PRO#107','912EC803B2CE49E4A541068D495AB570','95413653Q','Estevez Mena', 'Barbara@example.ecom','Barbara', 8) +,('PRO#108','912EC803B2CE49E4A541068D495AB570','90914444K','Godoy Alcaide', 'Amalia@example.ecom','Amalia', 9) +,('PRO#109','912EC803B2CE49E4A541068D495AB570','05709869G','Lucas Wang', 'Carmelo@example.ecom','Carmelo', 10); + +-- Insertar médicos especialistas +INSERT INTO myhealth.specialistdoctor(professionalnumber, password, nif, surname, email, name, medicalspecialtyid) VALUES +('PRO#110','912EC803B2CE49E4A541068D495AB570','87719252N','Vazquez Cruz', 'Luciano@example.ecom','Luciano', 1) +,('PRO#111','912EC803B2CE49E4A541068D495AB570','79412306E','Alcaide Mesa', 'Gregorio@example.ecom','Gregorio', 2) +,('PRO#112','912EC803B2CE49E4A541068D495AB570','45727688P','Herranz Soria', 'Candida@example.ecom','Candida', 3) +,('PRO#113','912EC803B2CE49E4A541068D495AB570','65061962E','Galvez Vives', 'Nora@example.ecom','Nora', 4) +,('PRO#114','912EC803B2CE49E4A541068D495AB570','07359870P','Rojas Alonso', 'Anton@example.ecom','Anton', 5) +,('PRO#115','912EC803B2CE49E4A541068D495AB570','14117403A','Lorente Carmona', 'Sheila@example.ecom','Sheila', 6) +,('PRO#116','912EC803B2CE49E4A541068D495AB570','79864477J','Gonzalo Bonet', 'Nicolas@example.ecom','Nicolas', 7) +,('PRO#117','912EC803B2CE49E4A541068D495AB570','22761129F','Bonet Ariza', 'Aroa@example.ecom','Aroa', 8) +,('PRO#118','912EC803B2CE49E4A541068D495AB570','99693813Z','Soria Singh', 'Cristian@example.ecom','Cristian', 9) +,('PRO#119','912EC803B2CE49E4A541068D495AB570','04431824T','Requena Calderon', 'Ferran@example.ecom','Ferran', 10) +,('PRO#120','912EC803B2CE49E4A541068D495AB570','27476123R','Angulo Zamora', 'Ana@example.ecom','Ana', 11); + +--Insertar Pacientes +INSERT INTO myhealth.patient(personalidentificationcode, password, nif, surname, email, name, familydoctorid) VALUES +('PAT#100','912EC803B2CE49E4A541068D495AB570','97758900E','Singh Vila', 'Soledad@example.ecom','Soledad', 1) +,('PAT#101','912EC803B2CE49E4A541068D495AB570','Z9518183Y','Jimenez Merino', 'Ainhoa@example.ecom','Ainhoa', 2) +,('PAT#102','912EC803B2CE49E4A541068D495AB570','97758900E','Jesus Chen Barba', 'Abel@example.ecom','Abel', 3) +,('PAT#103','912EC803B2CE49E4A541068D495AB570','95014341F','Lorenzo Tapia Navas', 'Francisco@example.ecom','Francisco', 4) +,('PAT#104','912EC803B2CE49E4A541068D495AB570','17873499S','Gimenez Gutierrez', 'Teodora@example.ecom','Teodora', 5) +,('PAT#105','912EC803B2CE49E4A541068D495AB570','07320674G','Escobar Marquez', 'Jorge@example.ecom','Jorge', 6) +,('PAT#106','912EC803B2CE49E4A541068D495AB570','63888801E','Marin Reina', 'Marti@example.ecom','Marti', 7) +,('PAT#107','912EC803B2CE49E4A541068D495AB570','36676167E','Bosch Zapata', 'Abril@example.ecom','Abril', 8) +,('PAT#108','912EC803B2CE49E4A541068D495AB570','73569670F','Bosch Zapata', 'Esperanza@example.ecom','Esperanza', 9) +,('PAT#109','912EC803B2CE49E4A541068D495AB570','53986482P','Carretero Ayala', 'Eduardo@example.ecom','Eduardo', 10); + + -INSERT INTO myhealth.primaryhealthcarecenter(name, location) - VALUES ('Centro A', 'Descripción centro A'); -INSERT INTO myhealth.primaryhealthcarecenter(name, location) - VALUES ('Centro Medico Azul', 'Descripción centro medico azul'); -INSERT INTO myhealth.primaryhealthcarecenter(name, location) - VALUES ('Centro Medico 23', 'Descripción centro medico 23');