Merge branch 'master' into rorden
# Conflicts: # 1.sources/MyHealth/src/ejb/common/CommonFacadeBean.java
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
@@ -60,7 +60,7 @@
|
||||
<p:menubar model="#{menuView.model}">
|
||||
<f:facet name="options">
|
||||
<ui:fragment rendered="#{home.logedIn}">
|
||||
<h:outputText value="logeado como #{home.userName} (#{home.userType}) " />
|
||||
<h:outputText value="Bienvenido, #{home.userDisplayName} (#{home.userType}) " />
|
||||
<p:commandButton value="Logout" icon="pi pi-sign-out" action="#{loginView.logout}" />
|
||||
</ui:fragment>
|
||||
<ui:fragment rendered="#{not home.logedIn}">
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
<h:form>
|
||||
<p:panel header="Pagina principal">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-12 ui-md-12">
|
||||
Logeado como: <h:outputLabel value="#{home.userDisplayName}" style="font-weight: bold;" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel for="selectorTema" value="Cambio de tema" />
|
||||
</div>
|
||||
@@ -22,32 +25,6 @@
|
||||
<p:commandButton value="Usar tema" update="messages" action="#{sessionPreferences.updateCurrentTheme}" icon="pi pi-save" />
|
||||
</div>
|
||||
<div class="ui-g-5 ui-md-5" />
|
||||
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<div class="ui-inputgroup">
|
||||
<p:calendar pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
|
||||
<p:commandButton value="Fecha" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui-g-10 ui-md-10" />
|
||||
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<h:outputLabel value="Fecha" />
|
||||
<p:calendar pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
|
||||
</div>
|
||||
<div class="ui-g-10 ui-md-10" />
|
||||
|
||||
<div class="ui-g-12">
|
||||
<h:outputLabel value="Rich Text Editor" />
|
||||
</div>
|
||||
<div class="ui-g-12 ui-md-12">
|
||||
<p:editor />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-12 ui-md-12">
|
||||
<h:outputLabel value="Logeado como:" />
|
||||
<p:inputText readonly="true" value="#{home.userName}" />
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<div class="ui-inputgroup">
|
||||
<p:inputText id="nif" value="#{RegisterUser.nif}" validator="nifValidator" maxlength="20" required="true" requiredMessage="Por favor, indque su NIF">
|
||||
<p:ajax event="blur" update="nifmsg" listener="#{RegisterUser.hadleNIFValueChange}" oncomplete="handleNIFResponse(xhr, status, args)" />
|
||||
<p:ajax event="blur" update="nifmsg" listener="#{RegisterUser.handleNIFValueChange}" oncomplete="handleNIFResponse(xhr, status, args)" />
|
||||
</p:inputText>
|
||||
<p:commandButton widgetVar="nifButton" icon="pi pi-times" styleClass="red-button" />
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<div class="ui-inputgroup">
|
||||
<p:inputText id="nif" value="#{UpdateProfile.nif}" validator="nifValidator" maxlength="20" required="true" requiredMessage="Por favor, indque su NIF">
|
||||
<p:ajax event="blur" update="nifmsg" listener="#{UpdateProfile.hadleNIFValueChange}" oncomplete="handleNIFResponse(xhr, status, args)" />
|
||||
<p:ajax event="blur" update="nifmsg" listener="#{UpdateProfile.handleNIFValueChange}" oncomplete="handleNIFResponse(xhr, status, args)" />
|
||||
</p:inputText>
|
||||
<p:commandButton widgetVar="nifButton" icon="pi pi-check" styleClass="green-button" />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?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">
|
||||
|
||||
<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:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||
|
||||
<ui:composition template="../header.xhtml">
|
||||
<ui:define name="content">
|
||||
<h:form id="frmListCAPs">
|
||||
<p:growl id="mesgsList" showDetail="true" closable="true" autoupdate="true" />
|
||||
<p:panel id="PanelCAPList" style="margin-bottom: 10px;" header="Gestión de Centros de Atención Primaria">
|
||||
<div class="ui-g ui-fluid">
|
||||
<p:dataTable widgetVar="dtCAP" var="cap" value="#{ManageHealthCareCenters.lazyDataModelCAPsList}" editable="true" lazy="true" paginator="true" rows="10" paginatorPosition="bottom" paginatorAlwaysVisible="true"
|
||||
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,30,40">
|
||||
|
||||
<p:ajax event="rowEdit" listener="#{ManageHealthCareCenters.onRowEdit}" update=":frmListCAPs:mesgsList" />
|
||||
<p:ajax event="rowEditCancel" listener="#{ManageHealthCareCenters.onRowCancel}" update=":frmListCAPs:mesgsList" />
|
||||
|
||||
<p:column headerText="Nombre">
|
||||
<p:cellEditor>
|
||||
<f:facet name="output"><h:outputText value="#{cap.name}" /></f:facet>
|
||||
<f:facet name="input"><p:inputText value="#{cap.name}" style="width:100%" label="Nombre"/></f:facet>
|
||||
</p:cellEditor>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Localización">
|
||||
<p:cellEditor>
|
||||
<f:facet name="output"><h:outputText value="#{cap.location}" /></f:facet>
|
||||
<f:facet name="input"><p:inputText value="#{cap.location}" style="width:100%" label="Localización"/></f:facet>
|
||||
</p:cellEditor>
|
||||
</p:column>
|
||||
|
||||
<p:column style="width:80px; text-align: center;" headerText="Editar">
|
||||
<p:rowEditor />
|
||||
</p:column>
|
||||
|
||||
<p:column style="width:80px; text-align: center;" headerText="Eliminar">
|
||||
<p:commandLink onclick="if (! confirm('¿Seguro que quiere borrar el CAP?')) return false" ajax="true" action="#{ManageHealthCareCenters.deleteDataById(cap.id)}" update=":frmListCAPs:mesgsList frmListCAPs" process="frmListCAPs">
|
||||
<span title="Borrar" class="fa fa-remove"/>
|
||||
</p:commandLink>
|
||||
</p:column>
|
||||
|
||||
<f:facet name="paginatorBottomLeft">
|
||||
<p:commandButton type="button" icon="pi pi-refresh" onclick="PF('dtCAP').getPaginator().setPage(0);" />
|
||||
</f:facet>
|
||||
</p:dataTable>
|
||||
</div>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
|
||||
<h:form id="frmAddCAPs">
|
||||
<p:growl id="mesgsAdd" showDetail="true" closable="true" autoupdate="true" />
|
||||
<p:panel id="PanelNewCAP" header="Alta de Centros de Atención Primaria">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-1 ui-md-1">
|
||||
<p:outputLabel value="Nombre: " for="nameNew" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:inputText id="nameNew" value="#{ManageHealthCareCenters.name}" readonly="false" required="ManageHealthCareCenters.medicalSpecialty.name eq null"
|
||||
requiredMessage="Es necesario un nombre" />
|
||||
</div>
|
||||
<div class="ui-g-1 ui-md-1">
|
||||
<p:outputLabel value="Localización: " for="locationNew" />
|
||||
</div>
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:inputText id="locationNew" value="#{ManageHealthCareCenters.location}" readonly="false" required="ManageHealthCareCenters.medicalSpecialty.location eq null"
|
||||
requiredMessage="Es necesaria una localización" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2 ">
|
||||
<p:commandButton validateClient="true" value="Crear" update="mesgsAdd frmListCAPs frmAddCAPs" action="#{ManageHealthCareCenters.insertData}" icon="pi pi-check" />
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
</h:form>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
</html>
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
<div class="ui-g-1 ui-md-1 ">
|
||||
<p:commandButton validateClient="true" value="Borrar" update="frmEditSpecialties" action="#{ManageSpecialities.deleteData}" icon="fa fa-remove">
|
||||
<p:confirm header="Confirme la eliminación" message="¿Esta seguro de que desea eliminar la especialidad?" icon="pi pi-exclamation-triangle" />
|
||||
<p:confirm header="Confirme la eliminación" message="¿Está seguro de que desea eliminar la especialidad?" icon="pi pi-exclamation-triangle" />
|
||||
</p:commandButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<p:outputLabel for="observaciones" value="Observaciones:" />
|
||||
</div>
|
||||
<div class="ui-g-8">
|
||||
<p:inputTextarea id="observaciones" value="#{UpdateVisit.observations}" readonly="true" />
|
||||
<p:inputTextarea id="observaciones" value="#{UpdateVisit.observations}" readonly="#{UpdateVisit.onlyResult}" />
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<p:message for="observaciones" display="text" />
|
||||
|
||||
@@ -244,11 +244,27 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
return allFDTOs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista con todos los pacientes registrados en el sistema de forma paginada.
|
||||
*
|
||||
* Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
*
|
||||
* @return Devuelve una Lista de PatientTO (Transfer Objects).
|
||||
*/
|
||||
public List<PatientTO> listPatientsPaged(int pageNumber, int pageSize) {
|
||||
return this.listPatientsFiltered(null, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista de pacientes que tienen una coincidencia parcial en el nombre o en los apellidos con el termino de búsqueda (searchTerm) especificado.
|
||||
*
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
*
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el parámetro y devuelven todos los registros existentes.
|
||||
*
|
||||
* @return Devuelve una Lista de PatientTO (Transfer Objects).
|
||||
*/
|
||||
public List<PatientTO> listPatientsFiltered(String searchTerm, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT p FROM PatientJPA p %s order by p.name, p.surname";
|
||||
String strFilter = "";
|
||||
@@ -532,8 +548,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Método que recupera un médico especialista a partir de su NIF
|
||||
*
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si
|
||||
* no se encuentra el objeto buscado
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si el objeto JPA es nulo
|
||||
*/
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchedNIF) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif",
|
||||
@@ -552,14 +567,10 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
* Método que convierte un objecto de tipo QuestionJPA (JPA) a su equivalente
|
||||
* QuestionTO (Tranfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de
|
||||
* profundidad se debe navegar a través de las propiedades relacionadas para
|
||||
* convertirlas de JPA a TO. Un valor 0 indica que no se convertirá ninguna
|
||||
* propiedad que tenga un entidad JPA relacionada (tendrá valor null en el
|
||||
* objeto TO).
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
*
|
||||
* @return QuestionTO (Transfer Object del objeto recuperado) o null si no se
|
||||
* encuentra el objeto buscado
|
||||
* @return QuestionTO (Transfer Object del objeto recuperado) o null si el objeto JPA es nulo
|
||||
*/
|
||||
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps) {
|
||||
QuestionTO qsTO = null;
|
||||
@@ -581,6 +592,14 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
return qsTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que converite un objeto de tipo VisitJPA a su equivalente VisitTO (Transfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
*
|
||||
* @return VisitTO (Transfer Object del objeto recuperado) o null si el objeto JPA es nulo
|
||||
*/
|
||||
public VisitTO getPOJOforVisitJPA(VisitJPA vi, int nestedProps) {
|
||||
VisitTO qsTO = null;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
@@ -12,6 +13,7 @@ import TO.FamilyDoctorTO;
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.Constants;
|
||||
import common.HashUtils;
|
||||
@@ -19,6 +21,7 @@ import common.UserType;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.AdministratorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -148,10 +151,81 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
||||
|
||||
@Override
|
||||
public MedicalSpecialtyTO insertSpecialty(String name, String description) throws Exception {
|
||||
|
||||
MedicalSpecialtyJPA ms = new MedicalSpecialtyJPA(name, description);
|
||||
entman.persist(ms);
|
||||
|
||||
return this.commonServices.getPOJOforMedicalSpecialtyJPA(ms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryHealthCareCenterTO updateHealthCareCenter(int id, String name, String location) throws Exception {
|
||||
PrimaryHealthCareCenterJPA ms = entman.find(PrimaryHealthCareCenterJPA.class, id);
|
||||
|
||||
if (ms == null) {
|
||||
throw new Exception("No se pueden actualizar los datos del CAP porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(id));
|
||||
}
|
||||
|
||||
ms.setName(name);
|
||||
ms.setLocation(location);
|
||||
|
||||
entman.persist(ms);
|
||||
|
||||
return this.commonServices.getPOJOforPrimaryHealthCareCenterJPA(ms);
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO findHealthCareCenterByName(String searchedName) {
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery("from PrimaryHealthCareCenterJPA cap where cap.name=:name", PrimaryHealthCareCenterJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("name", searchedName);
|
||||
|
||||
List<PrimaryHealthCareCenterJPA> results = query.getResultList();
|
||||
if (results.size() > 0)
|
||||
return this.commonServices.getPOJOforPrimaryHealthCareCenterJPA(results.get(0));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteHealthCareCenter(int id) throws Exception {
|
||||
PrimaryHealthCareCenterJPA cap = entman.find(PrimaryHealthCareCenterJPA.class, id);
|
||||
|
||||
if (cap == null) {
|
||||
throw new Exception("No se puede borrar el CAP porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(id));
|
||||
}
|
||||
|
||||
entman.remove(cap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrimaryHealthCareCenterTO insertHealthCareCenter(String name, String location) throws Exception {
|
||||
PrimaryHealthCareCenterJPA cap = new PrimaryHealthCareCenterJPA(name, location);
|
||||
entman.persist(cap);
|
||||
|
||||
return this.commonServices.getPOJOforPrimaryHealthCareCenterJPA(cap);
|
||||
}
|
||||
|
||||
public Long getCAPCount() {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from PrimaryHealthCareCenterJPA", Long.class);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery("SELECT c from PrimaryHealthCareCenterJPA c order by c.name", PrimaryHealthCareCenterJPA.class);
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
|
||||
List<PrimaryHealthCareCenterTO> caps = new ArrayList<PrimaryHealthCareCenterTO>();
|
||||
|
||||
for (PrimaryHealthCareCenterJPA item : allJPA) {
|
||||
caps.add(commonServices.getPOJOforPrimaryHealthCareCenterJPA(item));
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package ejb.systemAdmin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -25,4 +28,16 @@ public interface SystemAdminFacadeRemote {
|
||||
public void deleteSpecialty(int id) throws Exception;
|
||||
|
||||
public MedicalSpecialtyTO insertSpecialty(String name, String description) throws Exception;
|
||||
|
||||
public PrimaryHealthCareCenterTO updateHealthCareCenter(int id, String name, String location) throws Exception;
|
||||
|
||||
public PrimaryHealthCareCenterTO findHealthCareCenterByName(String name);
|
||||
|
||||
public void deleteHealthCareCenter(int id) throws Exception;
|
||||
|
||||
public PrimaryHealthCareCenterTO insertHealthCareCenter(String name, String location) throws Exception;
|
||||
|
||||
public Long getCAPCount();
|
||||
|
||||
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package ejb.visit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
@@ -12,11 +13,13 @@ import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.VisitTO;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los métodos de la capa de negocio que implementan la logica de negocio y la interacción con la capa de
|
||||
* persistencia.
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
* métodos de la capa de negocio que implementan la logica de negocio y la
|
||||
* interacción con la capa de persistencia.
|
||||
*
|
||||
* @author mark
|
||||
*
|
||||
@@ -31,7 +34,8 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
CommonFacadeLocal commonServices;
|
||||
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, Date date) {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId", Long.class);
|
||||
TypedQuery<Long> query = entman.createQuery(
|
||||
"SELECT count(1) from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId", Long.class);
|
||||
query.setParameter("date", date);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
@@ -39,7 +43,9 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
}
|
||||
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize) {
|
||||
TypedQuery<VisitJPA> query = entman.createQuery("SELECT v from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId order by v.date, v.time", VisitJPA.class);
|
||||
TypedQuery<VisitJPA> query = entman.createQuery(
|
||||
"SELECT v from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId order by v.date, v.time",
|
||||
VisitJPA.class);
|
||||
query.setParameter("date", date);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
@@ -57,7 +63,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
|
||||
return listTO;
|
||||
}
|
||||
|
||||
|
||||
public Long getVisitsCount(Integer patientId, Date date) {
|
||||
String strQuery = "SELECT count(1) from VisitJPA v %s";
|
||||
String strFilter = "";
|
||||
@@ -80,7 +86,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT v from VisitJPA v %s order by v.patient, v.date";
|
||||
String strFilter = "";
|
||||
@@ -93,7 +99,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
strFilter = "WHERE 1=1 " + strFilter;
|
||||
}
|
||||
strQuery = String.format(strQuery, strFilter);
|
||||
|
||||
|
||||
TypedQuery<VisitJPA> query = entman.createQuery(strQuery, VisitJPA.class);
|
||||
|
||||
if (patientId != null)
|
||||
@@ -105,7 +111,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
|
||||
List<VisitJPA> allJPA = query.getResultList();
|
||||
List<VisitTO> listTO = new ArrayList<VisitTO>();
|
||||
|
||||
@@ -116,7 +122,6 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
return listTO;
|
||||
}
|
||||
|
||||
|
||||
public VisitTO getVisit(int id) throws Exception {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
if (vi == null) {
|
||||
@@ -125,4 +130,33 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
|
||||
return this.commonServices.getPOJOforVisitJPA(vi, 1);
|
||||
}
|
||||
|
||||
public void addResultToVisit(int id, String result) {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
|
||||
vi.setResult(result);
|
||||
entman.persist(vi);
|
||||
}
|
||||
|
||||
public void removeVisit(int id) {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
entman.remove(vi);
|
||||
}
|
||||
|
||||
public void updateVisit(int id, Date date, LocalTime time) {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
vi.setDate(date);
|
||||
vi.setTime(time);
|
||||
entman.persist(vi);
|
||||
}
|
||||
|
||||
public VisitTO addVisit(int patientId, Date date, LocalTime time, String observations) {
|
||||
|
||||
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
||||
|
||||
VisitJPA vi = new VisitJPA(date, time, observations, "", pat, pat.getFamilyDoctor());
|
||||
entman.persist(vi);
|
||||
|
||||
return this.commonServices.getPOJOforVisitJPA(vi, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ejb.visit;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,9 +9,10 @@ import javax.ejb.Remote;
|
||||
import TO.VisitTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para los clientes del EJB
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
*
|
||||
* @author mark
|
||||
* @author alina
|
||||
*
|
||||
*/
|
||||
@Remote
|
||||
@@ -28,4 +30,13 @@ public interface VisitFacadeRemote {
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize);
|
||||
|
||||
public VisitTO getVisit(int id) throws Exception;
|
||||
|
||||
public void addResultToVisit(int id, String result);
|
||||
|
||||
public void removeVisit(int id);
|
||||
|
||||
public void updateVisit(int id, Date date, LocalTime time);
|
||||
|
||||
public VisitTO addVisit(int patientId, Date date, LocalTime time, String observations);
|
||||
|
||||
}
|
||||
@@ -49,8 +49,7 @@ public class VisitJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public VisitJPA(Integer id, Date date, LocalTime time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
|
||||
this.id = id;
|
||||
public VisitJPA(Date date, LocalTime time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
this.observations = observations;
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MenuMBean implements Serializable {
|
||||
subMenu = new DefaultSubMenu("Administración del sistema", "fa fa-wrench");
|
||||
|
||||
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(createMenuItem("Centros At. Primaria", "fa fa-hospital-o", "/systemAdmin/ManageHealthCareCenters", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(createMenuItem("Ver médicos de un CAP", "fa fa-medkit", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import common.UserType;
|
||||
@@ -16,22 +16,23 @@ import common.UserType;
|
||||
*
|
||||
*/
|
||||
@Named("home")
|
||||
@RequestScoped
|
||||
@ViewScoped
|
||||
public class homeMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean isLogedIn;
|
||||
private String userId;
|
||||
private String userName;
|
||||
private String userDisplayName;
|
||||
private UserType userType;
|
||||
private int refresh;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
isLogedIn = SessionUtils.isLogedIn();
|
||||
userName = SessionUtils.getUserName();
|
||||
userId = SessionUtils.getUserId();
|
||||
userType = SessionUtils.getUserType();
|
||||
this.isLogedIn = SessionUtils.isLogedIn();
|
||||
this.userName = SessionUtils.getUserName();
|
||||
this.userDisplayName = SessionUtils.getUserDisplayName();
|
||||
this.userId = SessionUtils.getUserId();
|
||||
this.userType = SessionUtils.getUserType();
|
||||
|
||||
FacesMessage message = SessionUtils.getMessage();
|
||||
|
||||
@@ -54,6 +55,13 @@ public class homeMBean extends ManagedBeanBase implements Serializable {
|
||||
else
|
||||
return this.userName;
|
||||
}
|
||||
|
||||
public String getUserDisplayName() {
|
||||
if (this.isLogedIn == false)
|
||||
return "Invitado";
|
||||
else
|
||||
return this.userDisplayName;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return this.userId;
|
||||
@@ -63,14 +71,6 @@ public class homeMBean extends ManagedBeanBase implements Serializable {
|
||||
return this.userType.getUserTypename();
|
||||
}
|
||||
|
||||
public int getRefresh() {
|
||||
return refresh;
|
||||
}
|
||||
|
||||
public void setRefresh(int refresh) {
|
||||
this.refresh = refresh;
|
||||
}
|
||||
|
||||
public boolean isPatient() {
|
||||
return (this.userType == UserType.PATIENT);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
/***
|
||||
* ManageBean que gestiona la vista para el cambio de médico de familia para un paciente
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
@@ -36,6 +37,14 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa el managed Bean
|
||||
*
|
||||
* Si el usuario logeado es nulo devuelve un error indicando que la sesión actual no es válida.
|
||||
*
|
||||
* Recupera el id del usuario actual desde la sesión. Dado que solo los pacientes pueden seleccionar un médico de familia, si el usuario es de otro tipo se muestra un mensaje
|
||||
* de error.
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Recuperamos el usuario logeado actual
|
||||
@@ -54,8 +63,9 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
|
||||
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
|
||||
PatientTO pat = this.getRemoteManagerCommon().findPatientById(this.id);
|
||||
this.setCurrentFamilyDoctor(pat.getFamilyDoctor());
|
||||
}
|
||||
this.currentFamilyDoctor = pat.getFamilyDoctor();
|
||||
} else
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Perfil no válido", "Su tipo de usuario no permite que pueda tener acceso a esta página.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -63,23 +73,47 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve la lista de médicos de familia para el combo de selección.
|
||||
*
|
||||
* @return Lista de médicos de familia.
|
||||
*/
|
||||
public List<FamilyDoctorTO> getFamilyDoctorList() {
|
||||
return familyDoctorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que permite relizar búsqueda de tipo "typeAhead" en la lista de selección de médico.
|
||||
*
|
||||
* Recibe como parámetro el testo tecleado por el usuario
|
||||
*
|
||||
* @param query Texto tecleado por el usuario
|
||||
* @return Retorna la lista de médicos de familia coincidentes con el termino buscado.
|
||||
*/
|
||||
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
|
||||
if (query != null && query.equals(this.lastUIQuery) == false) {
|
||||
this.lastUIQuery = query;
|
||||
// Recuperamos las 200 primeras coincidencias
|
||||
// Recuperamos las primeras ~30 coincidencias, según constante
|
||||
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
}
|
||||
return this.familyDoctorList;
|
||||
}
|
||||
|
||||
// Id del usuario actual, obtenido de la sessión del usuario logeado.
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que realiza la persistencia del cambio de médico de familia. a través de la invocación al método EJB correspondiente.
|
||||
*
|
||||
* Se realizan 2 comprobaciones adicionales:
|
||||
*
|
||||
* 1. Se ha seleccionado un nuevo médico de familia
|
||||
*
|
||||
* 2. El médico de familia nuevo es diferente al actual
|
||||
*
|
||||
*/
|
||||
public void saveData() {
|
||||
int error = 0;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
/***
|
||||
* ManagedBean que gestiona la vista para el cambio del centro de atención primaria para los médicos de familia
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
@@ -36,12 +37,18 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa el managed Bean.
|
||||
*
|
||||
* Si el usuario atual no se puede recupear de la sesión o si no es un perfil de tipo médicos de familia se muestra un mensaje de error.
|
||||
*
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Recuperamos el usuario logeado actual
|
||||
LoggedUserTO usr = null;
|
||||
this.lastUIQuery = "";
|
||||
|
||||
|
||||
try {
|
||||
usr = SessionUtils.getloggedOnUser();
|
||||
|
||||
@@ -52,11 +59,13 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
||||
this.id = Integer.valueOf(usr.getId());
|
||||
|
||||
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
|
||||
// Recupera la lista de CAPs inicial desde el EJB.
|
||||
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
|
||||
FamilyDoctorTO fd = this.getRemoteManagerCommon().findFamilyDoctorById(this.id);
|
||||
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
|
||||
}
|
||||
} else
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Perfil no válido", "Su tipo de usuario no permite que pueda tener acceso a esta página.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -67,7 +76,13 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
||||
public List<PrimaryHealthCareCenterTO> getPhcList() {
|
||||
return primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de un CAP a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de CAPs que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
|
||||
if (query != null && query.equals(this.lastUIQuery) == false) {
|
||||
this.lastUIQuery = query;
|
||||
@@ -75,22 +90,30 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
|
||||
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
}
|
||||
return this.primaryHealthCareCentersList;
|
||||
}
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que realiza el guardado de los cambios a través de la invocación del método del EJB correspondiente.
|
||||
*
|
||||
* El método realiza dos verificaciones previas: Que se haya seleccionado un CAP y que este sea diferente del asignado actualmente.
|
||||
*
|
||||
*/
|
||||
public void saveData() {
|
||||
int error = 0;
|
||||
|
||||
if (this.getNewCenter() == null) {
|
||||
this.addFacesMessage("frmChangePHCC:newCenter", FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un nuevvo centro de atención primaria.");
|
||||
this.addFacesMessage("frmChangePHCC:newCenter", FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado",
|
||||
"Por favor, especifique un nuevvo centro de atención primaria.");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (this.getNewCenter().getName().equals(this.getCurrentCenter().getName())) {
|
||||
this.addFacesMessage("frmChangePHCC:newCenter", FacesMessage.SEVERITY_WARN, "El centro de atención primeria debe ser diferente", "Por favor, seleccione un centro de atención primaria diferente al cual está actualmente asignado.");
|
||||
this.addFacesMessage("frmChangePHCC:newCenter", FacesMessage.SEVERITY_WARN, "El centro de atención primeria debe ser diferente",
|
||||
"Por favor, seleccione un centro de atención primaria diferente al cual está actualmente asignado.");
|
||||
error++;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.ValidationUtils;
|
||||
|
||||
/**
|
||||
* ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente"
|
||||
* Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
|
||||
* ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente" Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
|
||||
*
|
||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||
*
|
||||
@@ -59,6 +58,11 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa el managedBean actual.
|
||||
*
|
||||
* Carga los tipos de usuario disponibles. Carga la lista de CAPs. Carga la lista de especialidades médicas.
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.availableUserTypes = new ArrayList<UserType>();
|
||||
@@ -79,10 +83,17 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
return availableUserTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gestiona el evento de cambio de tipo de usuario. El usuario que está intentando registrarse en el sistema ha cambiado el tipo de perfil (usuario) con el cual desea
|
||||
* registrarse.
|
||||
*
|
||||
*/
|
||||
public void onUserTypeChange() {
|
||||
switch (this.userType) {
|
||||
case SPECIALIST_DOCTOR:
|
||||
try {
|
||||
// El usuario queire registrarse como médico especialista, lanzamos un evento AJAX de cliente para que la interfaz refleje el cambio en el tipo de usuario
|
||||
// seleccionado: Se muestra la lista de especialidades médicas para obligar a seleccionar una.
|
||||
PrimeFaces.current().ajax().addCallbackParam("specs", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -90,6 +101,8 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
try {
|
||||
// El usuario queire registrarse como médico especialista, lanzamos un evento AJAX de cliente para que la interfaz refleje el cambio en el tipo de usuario
|
||||
// seleccionado: Se muestra la lista de CAPs para obligar a seleccionar uno.
|
||||
PrimeFaces.current().ajax().addCallbackParam("caps", true);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
@@ -97,6 +110,8 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
break;
|
||||
case ADMINISTRATOR:
|
||||
case PATIENT:
|
||||
// El usuario queire registrarse como médico especialista, lanzamos un evento AJAX de cliente para que la interfaz refleje el cambio en el tipo de usuario
|
||||
// seleccionado: Se ocultará la lista de selección de CAP o Especialidad médica
|
||||
PrimeFaces.current().ajax().addCallbackParam("pats", true);
|
||||
break;
|
||||
}
|
||||
@@ -110,6 +125,12 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
return primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de un CAP a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de CAPs que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryPH) == false) {
|
||||
this.lastUIQueryPH = query;
|
||||
@@ -119,6 +140,12 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
return this.primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de una especialidad a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de especialidades que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryMS) == false) {
|
||||
this.lastUIQueryMS = query;
|
||||
@@ -127,14 +154,20 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
return this.medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
public void hadleNIFValueChange() {
|
||||
|
||||
/**
|
||||
* Gestióna el evento de modficación del NIF del usuario actual. Búsca si el NIF ya está en uso para otro usuario. Solo se permite que el mismo NIF se refistro como paciente y
|
||||
* como médico (especialista o de familia, pero no como ambos).
|
||||
*
|
||||
* Un Médico puede estar registrado como paciente con el mismo NIF, pero como médico de familia y especialista al mismo tiempo.
|
||||
*/
|
||||
public void handleNIFValueChange() {
|
||||
boolean isDupe = false;
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true) {
|
||||
isDupe = true;
|
||||
isDupe = true;
|
||||
this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
|
||||
}
|
||||
|
||||
|
||||
PrimeFaces.current().ajax().addCallbackParam("NIFisDupe", isDupe);
|
||||
}
|
||||
|
||||
@@ -194,11 +227,27 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
|
||||
this.nif = nif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que realiza la persistencia de los datos en la base de datos a través de la invocación de los métodos del EJB correspondiente.
|
||||
*
|
||||
* Se realizan comprobaciones adicionales para asegurar que:
|
||||
*
|
||||
* Si el tipo de usuario que se está registrando es un méidco de familia, obliga a seleccionar un CAP para el usuario.
|
||||
*
|
||||
* Si el tipo de usuario que está registrando es un médico especialista, obliga a seleccionar una especialidad médica al usuario.
|
||||
*
|
||||
* Si el tipo de usuario que está registrando es un paciente, no obliga a seleccionar un médicos de familia (puede ser nulo) será necesario que el usuario lo seleccione a
|
||||
* posteriori, una vez logeado en el sistema, a través de la opción de menú correspondiente.
|
||||
*
|
||||
* No se permite el registro de administradores a través de la página de registro pública.
|
||||
*
|
||||
*/
|
||||
public void addNewUser() {
|
||||
int error = 0;
|
||||
|
||||
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
|
||||
this.addFacesMessage("frmRegisterUser:selPHC", FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un centro de atención primaria.");
|
||||
this.addFacesMessage("frmRegisterUser:selPHC", FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado",
|
||||
"Por favor, especifique un centro de atención primaria.");
|
||||
error++;
|
||||
}
|
||||
if (this.isSpecialistDoctor() && this.medicalSpecialty == null) {
|
||||
|
||||
@@ -63,6 +63,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializa el Bean:
|
||||
*
|
||||
* Carga la lsita de tipos de usuario (perfiles) Recupera los datos del usuario logeado actualmente, y los asigna a las propiedades del managedBean.
|
||||
*
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.userTypes = new ArrayList<UserType>();
|
||||
@@ -109,6 +115,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Establece los valores de las propiedades del managedBean a partir de los datos de un Transfer Object de un paciente
|
||||
*
|
||||
* @param pat Paciente que está editando su perfil, y cuyos datos deben mostrarse en la vista.
|
||||
*/
|
||||
private void setPatientData(PatientTO pat) {
|
||||
this.id = pat.getId();
|
||||
this.cipCode = pat.getPersonalIdentificationCode();
|
||||
@@ -120,6 +131,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.familyDoctor = pat.getFamilyDoctor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establece los valores de las propiedades del managedBean a partir de los datos de un Transfer Object de un médico de familia
|
||||
*
|
||||
* @param fd FamilyDoctor que está editando su perfil, y cuyos datos deben mostrarse en la vista.
|
||||
*/
|
||||
private void setFamilyDoctorData(FamilyDoctorTO fd) {
|
||||
this.id = fd.getId();
|
||||
this.cipCode = fd.getProfessionalNumber();
|
||||
@@ -131,6 +147,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Establece los valores de las propiedades del managedBean a partir de los datos de un Transfer Object de un médico especialista
|
||||
*
|
||||
* @param sd SpecialistDoctor que está editando su perfil, y cuyos datos deben mostrarse en la vista.
|
||||
*/
|
||||
private void setSpecialistDoctorData(SpecialistDoctorTO sd) {
|
||||
this.id = sd.getId();
|
||||
this.cipCode = sd.getProfessionalNumber();
|
||||
@@ -154,25 +175,43 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
return primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de un CAP a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de CAPs que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryPH) == false) {
|
||||
this.lastUIQueryPH = query;
|
||||
// Recuperamos las 200 primeras coincidencias
|
||||
// Recuperamos las XXX primeras coincidencias
|
||||
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
}
|
||||
return this.primaryHealthCareCentersList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de una especialidad a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de especialidades que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryMS) == false) {
|
||||
this.lastUIQueryMS = query;
|
||||
// Recuperamos las 200 primeras coincidencias
|
||||
// Recuperamos las XXX primeras coincidencias
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
}
|
||||
return this.medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
public void hadleNIFValueChange() {
|
||||
/**
|
||||
* Gestióna el evento de modficación del NIF del usuario actual. Búsca si el NIF ya está en uso para otro usuario. Solo se permite que el mismo NIF se refistro como paciente y
|
||||
* como médico (especialista o de familia, pero no como ambos).
|
||||
*
|
||||
* Un Médico puede estar registrado como paciente con el mismo NIF, pero como médico de familia y especialista al mismo tiempo.
|
||||
*/
|
||||
public void handleNIFValueChange() {
|
||||
boolean isDupe = false;
|
||||
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) {
|
||||
isDupe = true;
|
||||
@@ -186,6 +225,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
return familyDoctorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que implementa la búsqueda de un médico de familia a través del termino tecleado por el usuario en la lista de selección
|
||||
*
|
||||
* @param query Termino tecleado por el usuario
|
||||
* @return Lista de médicos de familia que coinciden con el termino búscado por el usuario.
|
||||
*/
|
||||
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryFD) == false) {
|
||||
this.lastUIQueryFD = query;
|
||||
@@ -255,6 +300,18 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que guarda los datos realizados en la modificación del perfil.
|
||||
* Tiene en cuenta el tipo de usuario que está editando su perfil.
|
||||
*
|
||||
* Si el usuario es un médico de familia requiere que se seleccione un CAP para el usuario.
|
||||
* Si el usuario es un médico especialista requiere que se seleccione una especialidad médica para el usuario.
|
||||
* Se comprueba que el NIF especificado sea válido y no pertenezca a otro usuario registrado (ver relgas de NIF permitidos para usuarios en el método handleNIFValueChange)
|
||||
*
|
||||
* Si se especifica una nueva contraseña, entonces se realiz un cambio de contraseña, y se requiere además: Que la nueva contraseña sea diferente a la anterior.
|
||||
*
|
||||
* Después de guardar los datos, se actualizan los datos guardados en la sesión actual para reflejar un posible cambio de nombre y/o apellidos.
|
||||
*/
|
||||
public void saveData() {
|
||||
int error = 0;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LoginMBean extends ManagedBeanBase {
|
||||
|
||||
// logout event, invalidate session
|
||||
public String logout() {
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su sesión. Hasta la vista");
|
||||
|
||||
SessionUtils.DestroySession();
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.event.RowEditEvent;
|
||||
import org.primefaces.model.LazyDataModel;
|
||||
import org.primefaces.model.SortOrder;
|
||||
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
@Named("ManageHealthCareCenters")
|
||||
@ViewScoped
|
||||
public class ManageHealthCareCentersMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String location;
|
||||
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
|
||||
private LazyDataModel<PrimaryHealthCareCenterTO> lazyDataModelCAPsList;
|
||||
|
||||
public ManageHealthCareCentersMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.lazyDataModelCAPsList = new LazyDataModel<PrimaryHealthCareCenterTO>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public List<PrimaryHealthCareCenterTO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
|
||||
Long totalRowCount = getRemoteManagerSystemAdmin().getCAPCount();
|
||||
this.setRowCount(totalRowCount.intValue());
|
||||
|
||||
return getRemoteManagerSystemAdmin().listCAPsPaged((first / pageSize), pageSize);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public LazyDataModel<PrimaryHealthCareCenterTO> getlazyDataModelCAPsList() {
|
||||
return lazyDataModelCAPsList;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
private void showPrimaryHealthCareCenterData(PrimaryHealthCareCenterTO cap) {
|
||||
this.primaryHealthCareCenter = cap;
|
||||
|
||||
if (cap == null) {
|
||||
this.id = null;
|
||||
this.name = "";
|
||||
this.location = "";
|
||||
} else {
|
||||
this.id = cap.getId();
|
||||
this.name = cap.getName();
|
||||
this.location = cap.getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||
return primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO value) {
|
||||
this.primaryHealthCareCenter = value;
|
||||
}
|
||||
|
||||
public void onRowEdit(RowEditEvent event) {
|
||||
int error = 0;
|
||||
|
||||
if (((PrimaryHealthCareCenterTO) event.getObject()).getName() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getName().trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Nombre no relleno", "Por favor, escriba un nombre para el centro.");
|
||||
error++;
|
||||
}
|
||||
if (((PrimaryHealthCareCenterTO) event.getObject()).getLocation() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getLocation().trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Localización no rellena", "Por favor, escriba una localización.");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().updateHealthCareCenter(((PrimaryHealthCareCenterTO) event.getObject()).getId(), ((PrimaryHealthCareCenterTO) event.getObject()).getName(),
|
||||
((PrimaryHealthCareCenterTO) event.getObject()).getLocation());
|
||||
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
FacesMessage msg = new FacesMessage("CAP editado", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onRowCancel(RowEditEvent event) {
|
||||
FacesMessage msg = new FacesMessage("Edición cancelada", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
}
|
||||
|
||||
public void deleteDataById(Integer id) throws IOException {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "El CAP se ha borrado", "Los datos del Centro de Atención Primaria se han borrado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertData() {
|
||||
int error = 0;
|
||||
|
||||
if (name == null || name.trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Nombre no relleno", "Por favor, escriba un nombre para el centro.");
|
||||
error++;
|
||||
}
|
||||
if (location == null || location.trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Localización no rellena", "Por favor, escriba una localización.");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (this.getRemoteManagerSystemAdmin().findHealthCareCenterByName(name) != null) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "CAP ya existente", "El CAP ya se encuentra en la base de datos");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().insertHealthCareCenter(name, location);
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos del Centro de Atención Primaria se han guardado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import javax.inject.Named;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import common.Constants;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
}
|
||||
|
||||
private void refreshFormData() {
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
@@ -118,9 +117,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
MedicalSpecialtyTO ms = this.getRemoteManagerSystemAdmin().updateSpecialty(this.medicalSpecialty.getId(), this.medicalSpecialty.getName(),
|
||||
this.medicalSpecialty.getDescription());
|
||||
|
||||
this.getRemoteManagerSystemAdmin().updateSpecialty(this.medicalSpecialty.getId(), this.medicalSpecialty.getName(),this.medicalSpecialty.getDescription());
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
@@ -149,7 +146,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los especialidad se ha borrado", "Los datos de la especialidad se han borrado correctamente.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "La especialidad se ha borrado", "Los datos de la especialidad se han borrado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
@@ -175,8 +172,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
MedicalSpecialtyTO ms = this.getRemoteManagerSystemAdmin().insertSpecialty(name, description);
|
||||
|
||||
this.getRemoteManagerSystemAdmin().insertSpecialty(name, description);
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AddVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
// TODO: Añadir la nueva visita a la BBDD
|
||||
this.getRemoteManagerVisit().addVisit(this.patient.getId(), this.date, this.time, this.observations);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Visita creada", "La nueva visita se ha registrado correctamente en el sistema.");
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PatientVisitListMBean extends ManagedBeanBase implements Serializab
|
||||
}
|
||||
|
||||
public void removeVisit(Integer visitId) throws IOException {
|
||||
// TODO: Eliminar visita de la BBDD
|
||||
this.getRemoteManagerVisit().removeVisit(visitId);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Visita eliminada", String.format("La visita con Id: %d se ha eliminado correctamente", visitId));
|
||||
}
|
||||
|
||||
|
||||
@@ -91,13 +91,13 @@ public class UpdateVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
case PATIENT:
|
||||
// Administrador y paciente pueden actualizar la fecha y hora de la visita (excepto esl resultado)
|
||||
// TODO: Implementar método en EJB
|
||||
// this.getRemoteManagerVisit().updateVisit(this.id, this.date, this.time);
|
||||
this.getRemoteManagerVisit().updateVisit(this.id, this.date, this.time);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Visita actualizada", "La fecha y hora de la visita se ha actualizado correctamente.");
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
// El médico de familia solo puede actualizar el resultado.
|
||||
// TODO: implementar método EJB para actualizar el resultado.
|
||||
// this.getRemoteManagerVisit().addResultToVisit(this.id, this.result);
|
||||
this.getRemoteManagerVisit().addResultToVisit(this.id, this.result);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Resultado actualizado", "El resultado de la visita se ha actualizado correctamente.");
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
|
||||
Reference in New Issue
Block a user