diff --git a/1.sources/MyHealth/docroot/header.xhtml b/1.sources/MyHealth/docroot/header.xhtml index 093c715..45a0088 100644 --- a/1.sources/MyHealth/docroot/header.xhtml +++ b/1.sources/MyHealth/docroot/header.xhtml @@ -45,7 +45,6 @@ -
@@ -81,8 +80,6 @@ - -
diff --git a/1.sources/MyHealth/docroot/medicaltest/MedicalTests.xhtml b/1.sources/MyHealth/docroot/medicaltest/MedicalTests.xhtml index 15133ec..16b990f 100644 --- a/1.sources/MyHealth/docroot/medicaltest/MedicalTests.xhtml +++ b/1.sources/MyHealth/docroot/medicaltest/MedicalTests.xhtml @@ -1,24 +1,59 @@ - + - + - -
-

Medical Tests

-
-
Medical Tests TestPage:
-
- Medical Tests content + + + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
-
-

- -

- + + - + diff --git a/1.sources/MyHealth/docroot/profile/ChangeFamilyDoctor.xhtml b/1.sources/MyHealth/docroot/profile/ChangeFamilyDoctor.xhtml index 8cca1b8..160536f 100644 --- a/1.sources/MyHealth/docroot/profile/ChangeFamilyDoctor.xhtml +++ b/1.sources/MyHealth/docroot/profile/ChangeFamilyDoctor.xhtml @@ -1,39 +1,75 @@ - - + + +
+
+ +
+
+ Su perfil de usuario no permite que pueda cambiar su Médico de Familia asignado.
Si cree que no debería estar viendo esta página y que se trata de un + error, por favor, contacte con el soporte de la aplicación para obtener asistencia tecnica. +
+
+
+ +
+
+
+
+
+
+ - +
-
- + +
+
- +
-
- +
+ +
+
+
+ + + + + + + +
+
+ +
+
-
+
- +
- +
-
+
+ - + diff --git a/1.sources/MyHealth/docroot/profile/ChangePrimaryHealthCareCenter.xhtml b/1.sources/MyHealth/docroot/profile/ChangePrimaryHealthCareCenter.xhtml index ecd68a5..1841a57 100644 --- a/1.sources/MyHealth/docroot/profile/ChangePrimaryHealthCareCenter.xhtml +++ b/1.sources/MyHealth/docroot/profile/ChangePrimaryHealthCareCenter.xhtml @@ -35,7 +35,7 @@
- +
diff --git a/1.sources/MyHealth/docroot/profile/RegisterUser.xhtml b/1.sources/MyHealth/docroot/profile/RegisterUser.xhtml index 0e3dd35..668e6c0 100644 --- a/1.sources/MyHealth/docroot/profile/RegisterUser.xhtml +++ b/1.sources/MyHealth/docroot/profile/RegisterUser.xhtml @@ -175,7 +175,7 @@
- +
diff --git a/1.sources/MyHealth/docroot/systemAdmin/ManageSpecialties.xhtml b/1.sources/MyHealth/docroot/systemAdmin/ManageSpecialties.xhtml index f41089e..e3891a3 100644 --- a/1.sources/MyHealth/docroot/systemAdmin/ManageSpecialties.xhtml +++ b/1.sources/MyHealth/docroot/systemAdmin/ManageSpecialties.xhtml @@ -1,24 +1,59 @@ - + - + - -
-

System Admin Page

-
-
System Admin TestPage:
-
- System Admin page content + + + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
-
-

- -

- + + - + diff --git a/1.sources/MyHealth/docroot/visit/VisitView.xhtml b/1.sources/MyHealth/docroot/visit/VisitView.xhtml index 2f35662..2d2e95b 100644 --- a/1.sources/MyHealth/docroot/visit/VisitView.xhtml +++ b/1.sources/MyHealth/docroot/visit/VisitView.xhtml @@ -1,24 +1,59 @@ - + - + - -
-

Visit Page

-
-
Visit TestPage:
-
- Visit page content + + + +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+
+
-
-

- -

- + + - + diff --git a/1.sources/MyHealth/src/TO/FamilyDoctorTO.java b/1.sources/MyHealth/src/TO/FamilyDoctorTO.java index c37fef8..30e00cf 100644 --- a/1.sources/MyHealth/src/TO/FamilyDoctorTO.java +++ b/1.sources/MyHealth/src/TO/FamilyDoctorTO.java @@ -82,6 +82,10 @@ public class FamilyDoctorTO implements Serializable { public void setId(Integer id) { this.id = id; } + + public String getDisplayDescription() { + return String.format("[%d] %s %s", this.id, this.name, this.surname); + } public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() { return primaryHealthCareCenter; diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java new file mode 100644 index 0000000..44fdb1e --- /dev/null +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java @@ -0,0 +1,152 @@ +package ejb.common; + +import java.util.ArrayList; +import java.util.Collection; + +import javax.ejb.Stateless; +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; + +import TO.FamilyDoctorTO; +import TO.MedicalSpecialtyTO; +import TO.PatientTO; +import TO.PrimaryHealthCareCenterTO; +import TO.SpecialistDoctorTO; +import jpa.FamilyDoctorJPA; +import jpa.MedicalSpecialtyJPA; +import jpa.PatientJPA; +import jpa.PrimaryHealthCareCenterJPA; +import jpa.SpecialistDoctorJPA; + +@Stateless +public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal { + // Persistence Unit Context + @PersistenceContext(unitName = "MyHealth") + private EntityManager entman; + + /** + * Metodo que devuelve todas las especialidades medicas + */ + public Collection listAllMedicalSpecialities() { + return this.listPagedMedicalSpecialities(0, 0); + } + + /** + * Metodo que devuelve las especialidades médicas de forma paginada + * + * Acepta como parametro la página (comenzando en 0) y el número de elementos de + * cada página + * + */ + public Collection listPagedMedicalSpecialities(int pageNumber, int pageSize) { + Query query = entman.createQuery("from MedicalSpecialtyJPA order by name"); + + if (pageSize > 0) { + query.setFirstResult(pageNumber * pageSize); + query.setMaxResults(pageSize); + } + + @SuppressWarnings("unchecked") + Collection allJPA = query.getResultList(); + Collection allSpecialities = new ArrayList(); + + for (MedicalSpecialtyJPA ms : allJPA) { + allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription())); + } + + return allSpecialities; + } + + public Collection listAllCAPs() { + return this.listPagedAllCAPs(0, 0); + } + + public Collection listPagedAllCAPs(int pageNumber, int pageSize) { + Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name"); + + if (pageSize > 0) { + query.setFirstResult(pageNumber * pageSize); + query.setMaxResults(pageSize); + } + + @SuppressWarnings("unchecked") + Collection allJPA = query.getResultList(); + Collection allCAPs = new ArrayList(); + + for (PrimaryHealthCareCenterJPA cap : allJPA) { + allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation())); + } + + return allCAPs; + } + + public Collection listAllFamilyDoctors() { + return this.listAllFamilyDoctors(0, 0); + } + + public Collection listAllFamilyDoctors(int pageNumber, int pageSize) { + Query query = entman.createQuery("from FamilyDoctorJPA order by name, surname"); + + if (pageSize > 0) { + query.setFirstResult(pageNumber * pageSize); + query.setMaxResults(pageSize); + } + + @SuppressWarnings("unchecked") + Collection allFDsJPA = query.getResultList(); + Collection allFDTOs = new ArrayList(); + + for (FamilyDoctorJPA item : allFDsJPA) { + allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null)); + } + + return allFDTOs; + } + + public PatientTO retrievePatient(int patientId) throws Exception { + PatientJPA pat = entman.find(PatientJPA.class, patientId); + + 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)); + } + + FamilyDoctorTO fdTO = null; + if (pat.getFamilyDoctor() != null) { + FamilyDoctorJPA fd = pat.getFamilyDoctor(); + fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), null); + } + + 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().getName(), fd.getPrimaryHealthCareCenter().getLocation()); + + FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc); + return fdTO; + } + + public SpecialistDoctorTO retrieveSpecialistDoctor(int professionalId) throws Exception { + SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, professionalId); + if (sd == 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: " + String.valueOf(professionalId)); + } + + MedicalSpecialtyTO ms = null; + if (sd.getMedicalSpecialty() != null) + ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription()); + + SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms); + return sdTO; + } +} diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java new file mode 100644 index 0000000..3ec40c9 --- /dev/null +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeLocal.java @@ -0,0 +1,38 @@ +package ejb.common; + +import java.util.Collection; + +import javax.ejb.Local; + +import TO.FamilyDoctorTO; +import TO.MedicalSpecialtyTO; +import TO.PatientTO; +import TO.PrimaryHealthCareCenterTO; +import TO.SpecialistDoctorTO; + +/** + * + * @author Marcos García Núñez (mgarcianun@uoc.edu) + * + */ +@Local +public interface CommonFacadeLocal { + + public Collection listAllMedicalSpecialities(); + + public Collection listPagedMedicalSpecialities(int pageNumber, int pageSize); + + public Collection listAllCAPs(); + + public Collection listPagedAllCAPs(int pageNumber, int pageSize); + + public Collection listAllFamilyDoctors(); + + public Collection listAllFamilyDoctors(int pageNumber, int pageSize); + + public PatientTO retrievePatient(int patientId) throws Exception; + + public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception; + + public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception; +} diff --git a/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java b/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java new file mode 100644 index 0000000..6a9732b --- /dev/null +++ b/1.sources/MyHealth/src/ejb/common/CommonFacadeRemote.java @@ -0,0 +1,38 @@ +package ejb.common; + +import java.util.Collection; + +import javax.ejb.Remote; + +import TO.FamilyDoctorTO; +import TO.MedicalSpecialtyTO; +import TO.PatientTO; +import TO.PrimaryHealthCareCenterTO; +import TO.SpecialistDoctorTO; + +/** + * + * @author Marcos García Núñez (mgarcianun@uoc.edu) + * + */ +@Remote +public interface CommonFacadeRemote { + + public Collection listAllMedicalSpecialities(); + + public Collection listPagedMedicalSpecialities(int pageNumber, int pageSize); + + public Collection listAllCAPs(); + + public Collection listPagedAllCAPs(int pageNumber, int pageSize); + + public Collection listAllFamilyDoctors(); + + public Collection listAllFamilyDoctors(int pageNumber, int pageSize); + + public PatientTO retrievePatient(int patientId) throws Exception; + + public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception; + + public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception; +} diff --git a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java index 3a70733..e6c34b7 100644 --- a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeBean.java @@ -1,5 +1,6 @@ package ejb.profile; +import javax.ejb.EJB; import javax.ejb.Stateless; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @@ -10,6 +11,9 @@ import TO.PatientTO; import TO.PrimaryHealthCareCenterTO; import TO.SpecialistDoctorTO; import common.HashUtils; +import ejb.common.CommonFacadeBean; +import ejb.common.CommonFacadeLocal; +import ejb.common.CommonFacadeRemote; import jpa.FamilyDoctorJPA; import jpa.MedicalSpecialtyJPA; import jpa.PatientJPA; @@ -27,6 +31,9 @@ public class ProfileFacadeBean implements ProfileFacadeRemote { // Persistence Unit Context @PersistenceContext(unitName = "MyHealth") private EntityManager entman; + + @EJB + CommonFacadeLocal commonServices; public PatientTO changeFamilyDoctor(int patientId, int ProfessionalNumberId) throws Exception { PatientJPA pat = entman.find(PatientJPA.class, patientId); @@ -44,7 +51,8 @@ public class ProfileFacadeBean implements ProfileFacadeRemote { pat.setFamilyDoctor(fd); entman.persist(pat); - return this.retrievePatient(pat.getId()); + //CommonFacadeRemote common = new CommonFacadeBean(); + return commonServices.retrievePatient(pat.getId()); } public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email) { @@ -188,50 +196,4 @@ public class ProfileFacadeBean implements ProfileFacadeRemote { return fdTO; } - - public PatientTO retrievePatient(int patientId) throws Exception { - PatientJPA pat = entman.find(PatientJPA.class, patientId); - - 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)); - } - - FamilyDoctorTO fdTO = null; - if (pat.getFamilyDoctor() != null) { - FamilyDoctorJPA fd = pat.getFamilyDoctor(); - fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), null); - } - - 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().getName(), fd.getPrimaryHealthCareCenter().getLocation()); - - FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc); - return fdTO; - } - - public SpecialistDoctorTO retrieveSpecialistDoctor(int professionalId) throws Exception { - SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, professionalId); - if (sd == 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: " + String.valueOf(professionalId)); - } - - MedicalSpecialtyTO ms = null; - if (sd.getMedicalSpecialty() != null) - ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription()); - - SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms); - return sdTO; - } } diff --git a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java index 21919b0..d75674c 100644 --- a/1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java +++ b/1.sources/MyHealth/src/ejb/profile/ProfileFacadeRemote.java @@ -31,10 +31,5 @@ public interface ProfileFacadeRemote { public FamilyDoctorTO updateFamilyDoctorData(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) throws Exception; public FamilyDoctorTO changePrimaryHealthCareCenter(int ProfessionalNumberId, PrimaryHealthCareCenterTO newCenter) throws Exception; - - public PatientTO retrievePatient(int patientId) throws Exception; - public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception; - - public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception; } \ No newline at end of file diff --git a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java index fd35ab6..ba4469c 100644 --- a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeBean.java @@ -32,62 +32,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote { @PersistenceContext(unitName = "MyHealth") private EntityManager entman; - /** - * Metodo que devuelve todas las especialidades medicas - */ - public Collection listAllMedicalSpecialities() { - return this.listPagedMedicalSpecialities(0, 0); - } - - /** - * Metodo que devuelve las especialidades médicas de forma paginada - * - * Acepta como parametro la página (comenzando en 0) y el número de elementos de - * cada página - * - */ - public Collection listPagedMedicalSpecialities(int pageNumber, int pageSize) { - Query query = entman.createQuery("from MedicalSpecialtyJPA order by name"); - - if (pageSize > 0) { - query.setFirstResult(pageNumber * pageSize); - query.setMaxResults(pageSize); - } - - @SuppressWarnings("unchecked") - Collection allJPA = query.getResultList(); - Collection allSpecialities = new ArrayList(); - - for (MedicalSpecialtyJPA ms : allJPA) { - allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription())); - } - - return allSpecialities; - } - - public Collection listAllCAPs() { - return this.listPagedAllCAPs(0, 0); - } - - public Collection listPagedAllCAPs(int pageNumber, int pageSize) { - Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name"); - - if (pageSize > 0) { - query.setFirstResult(pageNumber * pageSize); - query.setMaxResults(pageSize); - } - - @SuppressWarnings("unchecked") - Collection allJPA = query.getResultList(); - Collection allCAPs = new ArrayList(); - - for (PrimaryHealthCareCenterJPA cap : allJPA) { - allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation())); - } - - return allCAPs; - } - public LoggedUserTO login(String id, String pwd) { LoggedUserTO usr = null; diff --git a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeRemote.java b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeRemote.java index 98bbf18..7c275b5 100644 --- a/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeRemote.java +++ b/1.sources/MyHealth/src/ejb/systemAdmin/SystemAdminFacadeRemote.java @@ -18,9 +18,7 @@ public interface SystemAdminFacadeRemote { /** * Definimos la interfaz remota */ - public Collection listAllMedicalSpecialities(); - public Collection listAllCAPs(); public LoggedUserTO login(String id, String pwd); } \ No newline at end of file diff --git a/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java b/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java index 74fa16f..c9d4fb7 100644 --- a/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java +++ b/1.sources/MyHealth/src/managedbean/common/ManagedBeanBase.java @@ -9,6 +9,7 @@ import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; +import ejb.common.CommonFacadeRemote; import ejb.medicalTest.MedicalTestFacadeRemote; import ejb.profile.ProfileFacadeRemote; import ejb.systemAdmin.SystemAdminFacadeRemote; @@ -20,6 +21,8 @@ import ejb.visit.VisitFacadeRemote; * */ public class ManagedBeanBase { + @EJB + protected CommonFacadeRemote remoteManagerCommon; @EJB protected ProfileFacadeRemote remoteManagerProfile; @EJB @@ -49,6 +52,14 @@ public class ManagedBeanBase { return retObj; } + protected CommonFacadeRemote getRemoteManagerCommon() { + if (remoteManagerCommon == null) { + remoteManagerCommon = this.getContext("java:app/MyHealth.jar/CommonFacadeBean!ejb.common.CommonFacadeRemote", CommonFacadeRemote.class); + } + + return remoteManagerCommon; + } + protected ProfileFacadeRemote getRemoteManagerProfile() { if (remoteManagerProfile == null) { remoteManagerProfile = this.getContext("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote", ProfileFacadeRemote.class); @@ -67,7 +78,7 @@ public class ManagedBeanBase { protected VisitFacadeRemote getRemoteManagerVisit() { if (remoteManagerVisit == null) { - remoteManagerVisit = this.getContext("java:app/MyHealth.jar/VisitFacadeBean!ejb.systemAdmin.VisitFacadeRemote", VisitFacadeRemote.class); + remoteManagerVisit = this.getContext("java:app/MyHealth.jar/VisitFacadeBean!ejb.visit.VisitFacadeRemote", VisitFacadeRemote.class); } return remoteManagerVisit; @@ -75,7 +86,7 @@ public class ManagedBeanBase { protected MedicalTestFacadeRemote getRemoteManagerMedicalTest() { if (remoteManagerMedicalTest == null) { - remoteManagerMedicalTest = this.getContext("java:app/MyHealth.jar/MedicalTestFacadeBean!ejb.systemAdmin.MedicalTestFacadeRemote", MedicalTestFacadeRemote.class); + remoteManagerMedicalTest = this.getContext("java:app/MyHealth.jar/MedicalTestFacadeBean!ejb.medicalTest.MedicalTestFacadeRemote", MedicalTestFacadeRemote.class); } return remoteManagerMedicalTest; diff --git a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java index c51f876..801de63 100644 --- a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java @@ -31,7 +31,6 @@ public class MenuMBean implements Serializable { @PostConstruct public void init() { model = new DefaultMenuModel(); - DefaultMenuItem item; DefaultSubMenu subMenu; UserType tipoUsuario = null; @@ -42,91 +41,91 @@ public class MenuMBean implements Serializable { // Administracion Sistema if (tipoUsuario == UserType.ADMINISTRATOR) { - subMenu = new DefaultSubMenu("Administración del sistema", "pi pi-cog"); + subMenu = new DefaultSubMenu("Administración del sistema", "fa-wrench"); - subMenu.addElement(createMenuItem("Gestionar especialidades", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null)); - subMenu.addElement(createMenuItem("Centros At. Primaria", "pi pi-briefcase", "/systemAdmin/ManageSpecialties", null)); + subMenu.addElement(createMenuItem("Gestionar especialidades", "fa fa-file-text-o", "/systemAdmin/ManageSpecialties", null)); + subMenu.addElement(createMenuItem("Centros At. Primaria", "fa fa-hospital-o", "/systemAdmin/ManageSpecialties", null)); subMenu.addElement(new DefaultSeparator()); - subMenu.addElement(createMenuItem("Ver médicos de un CAP", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null)); + subMenu.addElement(createMenuItem("Ver médicos de un CAP", "fa fa-medkit", "/systemAdmin/ManageSpecialties", null)); subMenu.addElement(new DefaultSeparator()); - subMenu.addElement(createMenuItem("Añadir usuario Admin", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null)); + subMenu.addElement(createMenuItem("Añadir usuario Admin", "fa fa-user-secret", "/systemAdmin/ManageSpecialties", null)); model.addElement(subMenu); } // Visitas if (tipoUsuario == UserType.PATIENT || tipoUsuario == UserType.ADMINISTRATOR || tipoUsuario == UserType.FAMILY_DOCTOR) { - subMenu = new DefaultSubMenu("Visitas", "pi pi-calendar"); + subMenu = new DefaultSubMenu("Visitas", "fa fa-calendar"); if (tipoUsuario == UserType.PATIENT) - subMenu.addElement(createMenuItem("Solicitar nueva", "pi pi-calendar", "/visit/VisitView", null)); + subMenu.addElement(createMenuItem("Solicitar nueva", "fa fa-calendar-o", "/visit/VisitView", null)); if (tipoUsuario == UserType.PATIENT || tipoUsuario == UserType.ADMINISTRATOR) - subMenu.addElement(createMenuItem("Modificar fecha/hora", "pi pi-calendar", "/visit/VisitView", null)); + subMenu.addElement(createMenuItem("Modificar fecha/hora", "fa fa-briefcase", "/visit/VisitView", null)); if (tipoUsuario == UserType.PATIENT) - subMenu.addElement(createMenuItem("Anular visita", "pi pi-calendar", "/visit/VisitView", null)); + subMenu.addElement(createMenuItem("Anular visita", "fa fa-remove", "/visit/VisitView", null)); if (tipoUsuario == UserType.FAMILY_DOCTOR) - subMenu.addElement(createMenuItem("Añadir resultado", "pi pi-briefcase", "/visit/VisitView", null)); + subMenu.addElement(createMenuItem("Añadir resultado", "fa fa-align-left", "/visit/VisitView", null)); if (tipoUsuario == UserType.FAMILY_DOCTOR) - subMenu.addElement(createMenuItem("Ver agenda del día", "pi pi-calendar", "/visit/VisitView", null)); + subMenu.addElement(createMenuItem("Ver agenda del día", "fa fa-repeat", "/visit/VisitView", null)); model.addElement(subMenu); } // Pruebas médicas if (tipoUsuario == UserType.PATIENT || tipoUsuario == UserType.SPECIALIST_DOCTOR || tipoUsuario == UserType.FAMILY_DOCTOR) { - subMenu = new DefaultSubMenu("Especialista", "pi pi-clone"); + subMenu = new DefaultSubMenu("Especialista", "fa fa-heartbeat"); if (tipoUsuario == UserType.SPECIALIST_DOCTOR) - subMenu.addElement(createMenuItem("Añadir prueba", "pi pi-clone", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Añadir prueba", "fa fa-server", "/medicaltest/MedicalTests", null)); // Todos pueden consultar (P S F) - subMenu.addElement(createMenuItem("Consultar prueba", "pi pi-briefcase", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Consultar prueba", "fa fa-search", "/medicaltest/MedicalTests", null)); subMenu.addElement(new DefaultSeparator()); if (tipoUsuario == UserType.SPECIALIST_DOCTOR) { subMenu.addElement(new DefaultSeparator()); - subMenu.addElement(createMenuItem("Gestionar imagen de una prueba", "pi pi-search", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Gestionar imagen de una prueba", "fa fa-briefcase", "/medicaltest/MedicalTests", null)); } if (tipoUsuario == UserType.PATIENT) - subMenu.addElement(createMenuItem("Buscar especialista...", "pi pi-list", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Buscar especialista...", "fa fa-heartbeat", "/medicaltest/MedicalTests", null)); model.addElement(subMenu); } // Preguntas médicas if (tipoUsuario == UserType.PATIENT || tipoUsuario == UserType.FAMILY_DOCTOR) { - subMenu = new DefaultSubMenu("Preguntas", "pi pi-clone"); + subMenu = new DefaultSubMenu("Preguntas", "fa fa-question-circle"); if (tipoUsuario == UserType.PATIENT) - subMenu.addElement(createMenuItem("Hacer pregunta", "pi pi-clone", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Hacer pregunta", "fa fa-comment-o", "/medicaltest/MedicalTests", null)); if (tipoUsuario == UserType.FAMILY_DOCTOR) - subMenu.addElement(createMenuItem("Responder pregunta", "pi pi-question", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Responder pregunta", "fa fa-comments", "/medicaltest/MedicalTests", null)); if (tipoUsuario == UserType.FAMILY_DOCTOR) - subMenu.addElement(createMenuItem("Ver preguntas pendientes", "pi pi-question", "/medicaltest/MedicalTests", null)); + subMenu.addElement(createMenuItem("Ver preguntas pendientes", "fa fa-comments-o", "/medicaltest/MedicalTests", null)); model.addElement(subMenu); } } // Perfil - subMenu = new DefaultSubMenu("Gestionar perfil", "pi pi-id-card"); + subMenu = new DefaultSubMenu("Gestionar perfil", "fa fa-gears"); if (SessionUtils.isLogedIn() == false) { - subMenu.addElement(createMenuItem("Registro de usuario", "pi pi-users", "/profile/RegisterUser", null)); - subMenu.addElement(createMenuItem("Registro de paciente", "pi pi-user-plus", "/profile/AddPatient", null)); - subMenu.addElement(createMenuItem("Registro de médico", "pi pi-user-plus", "/profile/AddFamilyDoctor", null)); - subMenu.addElement(createMenuItem("Registro de especialista", "pi pi-user-plus", "/profile/AddSpecialistDoctor", null)); + 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)); model.addElement(subMenu); } else { if (tipoUsuario != UserType.ADMINISTRATOR) { - subMenu.addElement(createMenuItem("Modificar datos personales", "pi pi-user-edit", "/profile/UpdateProfile", null)); + subMenu.addElement(createMenuItem("Modificar datos personales", "fa fa-user", "/profile/UpdateProfile", null)); subMenu.addElement(new DefaultSeparator()); if (tipoUsuario == UserType.PATIENT) { - subMenu.addElement(createMenuItem("Cambiar médico de familia", "pi pi-chevron-circle-right", "/profile/ChangeFamilyDoctor", null)); + subMenu.addElement(createMenuItem("Cambiar médico de familia", "fa fa-user-md", "/profile/ChangeFamilyDoctor", null)); subMenu.addElement(new DefaultSeparator()); } @@ -152,58 +151,4 @@ public class MenuMBean implements Serializable { public MenuModel getModel() { return model; } - - public void save() { - addMessage("Success", "Data saved"); - } - - public void update() { - addMessage("Success", "Data updated"); - } - - public void delete() { - addMessage("Success", "Data deleted"); - } - - public String goManageSpecialties() { - - return "ManageSpecialties"; - } - - public String goVisit() { - return "VisitView"; - } - - public String goMedicalTests() { - return "MedicalTests"; - } - - public String goListSpecialistDoctors() { - return "header"; - } - - public String goListSpecialistDoctorsBySpecialty() { - return "header"; - } - - public String goListaFamilyDoctors() { - return "header"; - } - - public String goChangeDoctor() { - return "header"; - } - - public String goChangeCAP() { - return "header"; - } - - public String goAddPatient() { - return "profile/AddPaciente"; - } - - public void addMessage(String summary, String detail) { - FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, detail); - FacesContext.getCurrentInstance().addMessage(null, message); - } } \ No newline at end of file diff --git a/1.sources/MyHealth/src/managedbean/profile/ChangeFamilyDoctorMBean.java b/1.sources/MyHealth/src/managedbean/profile/ChangeFamilyDoctorMBean.java index 960a88c..77996c8 100644 --- a/1.sources/MyHealth/src/managedbean/profile/ChangeFamilyDoctorMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/ChangeFamilyDoctorMBean.java @@ -1,50 +1,114 @@ package managedbean.profile; import java.io.Serializable; -import java.util.Properties; +import java.util.Collection; -import javax.ejb.EJB; -import javax.enterprise.context.RequestScoped; +import javax.annotation.PostConstruct; +import javax.faces.application.FacesMessage; +import javax.faces.view.ViewScoped; import javax.inject.Named; -import javax.naming.Context; -import javax.naming.InitialContext; -import ejb.profile.ProfileFacadeRemote; +import TO.FamilyDoctorTO; +import TO.LoggedUserTO; +import TO.PatientTO; +import common.UserType; import managedbean.common.ManagedBeanBase; +import managedbean.common.SessionUtils; /*** * * @author Marcos García Núñez (mgarcianun@uoc.edu) * */ -@Named( "ChangeFamilyDoctorMBean") -@RequestScoped +@Named("ChangeFD") +@ViewScoped public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable { - private static final long serialVersionUID = 1L; - @EJB - private ProfileFacadeRemote remoteManager; + private int id; + private FamilyDoctorTO currentFamilyDoctor; + private FamilyDoctorTO newFamilyDoctor; + private Collection familyDoctorList; + + public ChangeFamilyDoctorMBean() { - /** - * Constructor. Inicializa la conexión con el EJB Remoto - * - * @throws Exception - */ - public ChangeFamilyDoctorMBean() 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"); + @PostConstruct + public void init() { + // Recuperamos el usuario logeado actual + LoggedUserTO usr = null; + try { + usr = SessionUtils.getloggedOnUser(); + + if (usr == null) + this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida", + "Su sesión actual no es válida, por favor cierre su sesión y vuelva a logearse en el sistema."); + else { + this.id = Integer.valueOf(usr.getId()); + + if (usr.getUserType() == UserType.PATIENT) { + this.familyDoctorList = this.getRemoteManagerCommon().listAllFamilyDoctors(); + + PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id); + this.setCurrentFamilyDoctor(pat.getFamilyDoctor()); + } + } + } catch (Exception e) { + this.manageException(e); + } + + } + + public Collection getFamilyDoctorList() { + return familyDoctorList; + } + + public int getId() { + return id; + } + + public void saveData() { + int error = 0; + + if (this.getNewFamilyDoctor() == null) { + this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Nuevo médico de familia no seleccionado", "Por favor, especifique un nuevvo médico de familia."); + error++; + } + + if (this.getCurrentFamilyDoctor() != null && this.getNewFamilyDoctor().getId() == this.getCurrentFamilyDoctor().getId()) { + this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El médico de familia debe ser diferente", + "Por favor, seleccione un médico de familia diferente al que tiene actualmente asignado."); + error++; + } + + if (error == 0) { + try { + PatientTO paTO = this.getRemoteManagerProfile().changeFamilyDoctor(this.getId(), this.newFamilyDoctor.getId()); + this.currentFamilyDoctor = paTO.getFamilyDoctor(); + this.newFamilyDoctor = null; + + this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Su médico de familia asignado se ha cambiado correctamente."); + } catch (Exception e) { + this.manageException(e); + } + } + } + + public FamilyDoctorTO getCurrentFamilyDoctor() { + return currentFamilyDoctor; + } + + public void setCurrentFamilyDoctor(FamilyDoctorTO familyDoctor) { + this.currentFamilyDoctor = familyDoctor; + } + + public FamilyDoctorTO getNewFamilyDoctor() { + return newFamilyDoctor; + } + + public void setNewFamilyDoctor(FamilyDoctorTO familyDoctor) { + this.newFamilyDoctor = familyDoctor; } } diff --git a/1.sources/MyHealth/src/managedbean/profile/ChangePrimaryHealthCareCenterMBean.java b/1.sources/MyHealth/src/managedbean/profile/ChangePrimaryHealthCareCenterMBean.java index d45b95a..7d894a0 100644 --- a/1.sources/MyHealth/src/managedbean/profile/ChangePrimaryHealthCareCenterMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/ChangePrimaryHealthCareCenterMBean.java @@ -48,9 +48,9 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen this.id = Integer.valueOf(usr.getId()); if (usr.getUserType() == UserType.FAMILY_DOCTOR) { - this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs(); + this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs(); - FamilyDoctorTO fd = this.getRemoteManagerProfile().retrieveFamilyDoctor(this.id); + FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id); this.setCurrentCenter(fd.getPrimaryHealthCareCenter()); } } diff --git a/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java b/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java index 844a4ed..331f6eb 100644 --- a/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/RegisterUserMBean.java @@ -67,8 +67,8 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable { this.userType = UserType.PATIENT.name(); - this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities(); - this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs(); + this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities(); + this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs(); } public List getUserTypes() { diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java index 08daeb5..6bd252f 100644 --- a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java @@ -87,7 +87,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable switch (usr.getUserType()) { case PATIENT: - PatientTO pat = this.getRemoteManagerProfile().retrievePatient(this.id); + PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id); this.name = pat.getName(); this.surname = pat.getName(); @@ -96,8 +96,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable this.currentPassword = pat.getPassword(); break; case SPECIALIST_DOCTOR: - this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities(); - SpecialistDoctorTO sd = this.getRemoteManagerProfile().retrieveSpecialistDoctor(this.id); + this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities(); + SpecialistDoctorTO sd = this.getRemoteManagerCommon().retrieveSpecialistDoctor(this.id); this.name = sd.getName(); this.surname = sd.getName(); @@ -107,8 +107,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable this.medicalSpecialty = sd.getMedicalSpecialty(); break; case FAMILY_DOCTOR: - this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs(); - FamilyDoctorTO fd = this.getRemoteManagerProfile().retrieveFamilyDoctor(this.id); + this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs(); + FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id); this.name = fd.getName(); this.surname = fd.getName();