Nueva funcionalidad (vista, controlador y persistencia) de cambiar
medico de familia asignado. Incluidos cambios para utilizar nuvo EJB Common con interfaz local y remota.
This commit is contained in:
@@ -1,39 +1,75 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
||||||
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
|
||||||
xmlns:p="http://primefaces.org/ui">
|
xmlns:p="http://primefaces.org/ui">
|
||||||
|
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="frmRegisterUser">
|
<h:form id="frmChangeFD">
|
||||||
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
|
<p:panel id="badProfile" rendered="#{not home.patient}">
|
||||||
|
<div class="ui-g-3 ui-md-3" />
|
||||||
|
<div class="ui-g-6 ui-md-6">
|
||||||
|
<p:panel id="badProfileInfo" header="Perfil de usuario incorrecto para realizar acción">
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
<div class="ui-g-12">
|
||||||
|
Su perfil de usuario no permite que pueda cambiar su Médico de Familia asignado.<br /> 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.
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3"></div>
|
||||||
|
<div class="ui-g-6">
|
||||||
|
<p:button value="Ir a la página principal" outcome="/home" icon="pi pi-home" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3"></div>
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3 ui-md-3" />
|
||||||
|
</p:panel>
|
||||||
|
|
||||||
<p:panel id="DatosPersonales" header="Cambiar médico de familia">
|
<p:panel id="PanelPHC" header="Cambiar médico de familia asignado" rendered="#{home.patient}">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-2 ui-md-2">
|
|
||||||
<p:outputLabel value="Campo1:" for="campo1" />
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:outputLabel value="Médico de familia actualmente asignado:" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-4 ui-md-4">
|
||||||
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
|
<p:outputLabel id="lblCurrentCenter" value="#{ChangeFD.currentFamilyDoctor.displayDescription}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-6 ui-md-6">
|
<div class="ui-g-4 ui-md-4" />
|
||||||
<p:message for="campo1" display="text" />
|
|
||||||
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:outputLabel value="Nuevo médico de familia:" for="newFamilyDoc" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:selectOneMenu id="newFamilyDoc" value="#{ChangeFD.newFamilyDoctor}" converter="omnifaces.SelectItemsConverter" required="true"
|
||||||
|
requiredMessage="Por favor, selecciona un nuevo centro de antención primaria">
|
||||||
|
<f:selectItem itemLabel="Seleccione un nuevo centro de antención primario..." itemValue="" noSelectionOption="true" />
|
||||||
|
<f:selectItems value="#{ChangeFD.familyDoctorList}" var="fd" itemLabel="#{fd.displayDescription}" itemValue="#{fd}" />
|
||||||
|
<p:column headerText="Num. Prof."><h:outputText value="#{fd.id}" /></p:column>
|
||||||
|
<p:column headerText="Nombre"><h:outputText value="#{fd.name}" /></p:column>
|
||||||
|
<p:column headerText="Apellido"><h:outputText value="#{fd.surname}" /></p:column>
|
||||||
|
</p:selectOneMenu>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:message for="newFamilyDoc" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="ui-g-12 ui-g-nopad">
|
<div class="ui-g-12 ui-g-nopad">
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4" />
|
||||||
<div class="ui-g-2 ui-md-2 ">
|
<div class="ui-g-2 ui-md-2 ">
|
||||||
<p:commandButton validateClient="true" value="Guardar" update="mesgs" icon="pi pi-check" />
|
<p:commandButton validateClient="true" value="Guardar" update="frmChangeFD" action="#{ChangeFD.saveData}" icon="pi pi-check" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
<p:button value="Volver" outcome="home" icon="pi pi-home"/>
|
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</p:panel>
|
</p:panel>
|
||||||
</h:form>
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -175,7 +175,7 @@
|
|||||||
<div class="ui-g-12 ui-g-nopad">
|
<div class="ui-g-12 ui-g-nopad">
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
<div class="ui-g-2 ui-md-2 ">
|
<div class="ui-g-2 ui-md-2 ">
|
||||||
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" action="#{RegisterUser.addNewUser}" icon="pi pi-check" />
|
<p:commandButton validateClient="true" value="Registrarse" ajax="false" update="frmRegisterUserResult, frmRegisterUser" action="#{RegisterUser.addNewUser}" icon="pi pi-check" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-2 ui-md-2">
|
<div class="ui-g-2 ui-md-2">
|
||||||
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
|
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
public void setId(Integer id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayDescription() {
|
||||||
|
return String.format("[%d] %s %s", this.id, this.name, this.surname);
|
||||||
|
}
|
||||||
|
|
||||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||||
return primaryHealthCareCenter;
|
return primaryHealthCareCenter;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package ejb.profile;
|
package ejb.profile;
|
||||||
|
|
||||||
|
import javax.ejb.EJB;
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
@@ -10,6 +11,9 @@ import TO.PatientTO;
|
|||||||
import TO.PrimaryHealthCareCenterTO;
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
import TO.SpecialistDoctorTO;
|
import TO.SpecialistDoctorTO;
|
||||||
import common.HashUtils;
|
import common.HashUtils;
|
||||||
|
import ejb.common.CommonFacadeBean;
|
||||||
|
import ejb.common.CommonFacadeLocal;
|
||||||
|
import ejb.common.CommonFacadeRemote;
|
||||||
import jpa.FamilyDoctorJPA;
|
import jpa.FamilyDoctorJPA;
|
||||||
import jpa.MedicalSpecialtyJPA;
|
import jpa.MedicalSpecialtyJPA;
|
||||||
import jpa.PatientJPA;
|
import jpa.PatientJPA;
|
||||||
@@ -27,6 +31,9 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
// Persistence Unit Context
|
// Persistence Unit Context
|
||||||
@PersistenceContext(unitName = "MyHealth")
|
@PersistenceContext(unitName = "MyHealth")
|
||||||
private EntityManager entman;
|
private EntityManager entman;
|
||||||
|
|
||||||
|
@EJB
|
||||||
|
CommonFacadeLocal commonServices;
|
||||||
|
|
||||||
public PatientTO changeFamilyDoctor(int patientId, int ProfessionalNumberId) throws Exception {
|
public PatientTO changeFamilyDoctor(int patientId, int ProfessionalNumberId) throws Exception {
|
||||||
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
||||||
@@ -44,7 +51,8 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
pat.setFamilyDoctor(fd);
|
pat.setFamilyDoctor(fd);
|
||||||
entman.persist(pat);
|
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) {
|
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;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 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 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;
|
|
||||||
}
|
}
|
||||||
@@ -32,62 +32,6 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
@PersistenceContext(unitName = "MyHealth")
|
@PersistenceContext(unitName = "MyHealth")
|
||||||
private EntityManager entman;
|
private EntityManager entman;
|
||||||
|
|
||||||
/**
|
|
||||||
* Metodo que devuelve todas las especialidades medicas
|
|
||||||
*/
|
|
||||||
public Collection<MedicalSpecialtyTO> 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<MedicalSpecialtyTO> 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<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
|
||||||
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
|
||||||
|
|
||||||
for (MedicalSpecialtyJPA ms : allJPA) {
|
|
||||||
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return allSpecialities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
|
|
||||||
return this.listPagedAllCAPs(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<PrimaryHealthCareCenterTO> 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<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
|
||||||
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
|
|
||||||
|
|
||||||
for (PrimaryHealthCareCenterJPA cap : allJPA) {
|
|
||||||
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return allCAPs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoggedUserTO login(String id, String pwd) {
|
public LoggedUserTO login(String id, String pwd) {
|
||||||
LoggedUserTO usr = null;
|
LoggedUserTO usr = null;
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ public interface SystemAdminFacadeRemote {
|
|||||||
/**
|
/**
|
||||||
* Definimos la interfaz remota
|
* Definimos la interfaz remota
|
||||||
*/
|
*/
|
||||||
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
|
||||||
|
|
||||||
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
|
||||||
|
|
||||||
public LoggedUserTO login(String id, String pwd);
|
public LoggedUserTO login(String id, String pwd);
|
||||||
}
|
}
|
||||||
@@ -1,50 +1,114 @@
|
|||||||
package managedbean.profile;
|
package managedbean.profile;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Properties;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.ejb.EJB;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Named;
|
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.ManagedBeanBase;
|
||||||
|
import managedbean.common.SessionUtils;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*
|
*
|
||||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Named( "ChangeFamilyDoctorMBean")
|
@Named("ChangeFD")
|
||||||
@RequestScoped
|
@ViewScoped
|
||||||
public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@EJB
|
private int id;
|
||||||
private ProfileFacadeRemote remoteManager;
|
private FamilyDoctorTO currentFamilyDoctor;
|
||||||
|
private FamilyDoctorTO newFamilyDoctor;
|
||||||
|
private Collection<FamilyDoctorTO> familyDoctorList;
|
||||||
|
|
||||||
|
public ChangeFamilyDoctorMBean() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
public ChangeFamilyDoctorMBean() throws Exception {
|
|
||||||
initializeAdminFacadeRemote();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@PostConstruct
|
||||||
* Inicializa la conexión con el EJB Remoto
|
public void init() {
|
||||||
*
|
// Recuperamos el usuario logeado actual
|
||||||
* @throws Exception
|
LoggedUserTO usr = null;
|
||||||
*/
|
try {
|
||||||
private void initializeAdminFacadeRemote() throws Exception {
|
usr = SessionUtils.getloggedOnUser();
|
||||||
Properties props = System.getProperties();
|
|
||||||
Context ctx = new InitialContext(props);
|
if (usr == null)
|
||||||
remoteManager = (ProfileFacadeRemote) ctx
|
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida",
|
||||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
"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<FamilyDoctorTO> 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
|||||||
this.id = Integer.valueOf(usr.getId());
|
this.id = Integer.valueOf(usr.getId());
|
||||||
|
|
||||||
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
|
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());
|
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
|||||||
|
|
||||||
this.userType = UserType.PATIENT.name();
|
this.userType = UserType.PATIENT.name();
|
||||||
|
|
||||||
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
|
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
|
||||||
this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs();
|
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserType> getUserTypes() {
|
public List<UserType> getUserTypes() {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
|
|
||||||
switch (usr.getUserType()) {
|
switch (usr.getUserType()) {
|
||||||
case PATIENT:
|
case PATIENT:
|
||||||
PatientTO pat = this.getRemoteManagerProfile().retrievePatient(this.id);
|
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
|
||||||
|
|
||||||
this.name = pat.getName();
|
this.name = pat.getName();
|
||||||
this.surname = pat.getName();
|
this.surname = pat.getName();
|
||||||
@@ -96,8 +96,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
this.currentPassword = pat.getPassword();
|
this.currentPassword = pat.getPassword();
|
||||||
break;
|
break;
|
||||||
case SPECIALIST_DOCTOR:
|
case SPECIALIST_DOCTOR:
|
||||||
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
|
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
|
||||||
SpecialistDoctorTO sd = this.getRemoteManagerProfile().retrieveSpecialistDoctor(this.id);
|
SpecialistDoctorTO sd = this.getRemoteManagerCommon().retrieveSpecialistDoctor(this.id);
|
||||||
|
|
||||||
this.name = sd.getName();
|
this.name = sd.getName();
|
||||||
this.surname = sd.getName();
|
this.surname = sd.getName();
|
||||||
@@ -107,8 +107,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
|||||||
this.medicalSpecialty = sd.getMedicalSpecialty();
|
this.medicalSpecialty = sd.getMedicalSpecialty();
|
||||||
break;
|
break;
|
||||||
case FAMILY_DOCTOR:
|
case 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.name = fd.getName();
|
this.name = fd.getName();
|
||||||
this.surname = fd.getName();
|
this.surname = fd.getName();
|
||||||
|
|||||||
Reference in New Issue
Block a user