Cambiadas todas las listas deplegables fijas, a listas con búsqueda AJAX

integrada (Estilo typeahead). Permite búsquedas en tiempo real.
* Se muestra información organizada por columnas de datos.
* Identificadores basados en Ids autogenerados.
* Nuevos métodos en EJB común para poder realizar búsquedas de datos con
filtro y paginadas (para los comboBox).
* Varias correcciones de interfaz de usuario.
* Nueva clase de utilidades.
This commit is contained in:
Marcos Garcia Nuñez
2019-12-11 00:37:26 +01:00
parent 1be6cfd72c
commit 3e315f866a
25 changed files with 607 additions and 335 deletions

View File

@@ -2,7 +2,7 @@
<!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:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
@@ -14,8 +14,8 @@
<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.
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">
@@ -35,25 +35,30 @@
<p:outputLabel value="Médico de familia actualmente asignado:" />
</div>
<div class="ui-g-4 ui-md-4">
<p:outputLabel id="lblCurrentCenter" style="font-weight: bold;" value="#{ChangeFD.currentFamilyDoctor.displayDescription}" />
<p:outputLabel id="lblCurrentCenter" style="font-weight: bold;" value="#{ChangeFD.currentFamilyDoctor.displayName}" />
</div>
<div class="ui-g-4 ui-md-4" />
<div class="ui-g-4 ui-md-4">
<p:outputLabel value="Nuevo médico de familia:" for="newFamilyDoc" />
<p:outputLabel value="Nuevo médico de familia:" for="newFamilyDocAC" />
</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>
<p:autoComplete id="newFamilyDocAC" dropdown="true" required="true" value="#{ChangeFD.newFamilyDoctor}" completeMethod="#{ChangeFD.completeFamilyDoctor}" var="fd"
itemLabel="#{fd.displayName}" itemValue="#{fd}" forceSelection="true" requiredMessage="Por favor, selecciona un médico de familia">
<o:converter converterId="omnifaces.ListConverter" list="#{ChangeFD.familyDoctorList}" />
<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="Apellidos">
<h:outputText value="#{fd.surname}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-4 ui-md-4">
<p:message for="newFamilyDoc" />
<p:message for="newFamilyDocAC" />
</div>
<div class="ui-g-12 ui-g-nopad">

View File

@@ -35,7 +35,7 @@
<p:outputLabel value="Centro de antención primaria actualmente asignado:" />
</div>
<div class="ui-g-4 ui-md-4">
<p:outputLabel id="lblCurrentCenter" style="font-weight: bold;" value="#{ChangeCAP.currentCenter.displayDescription}" />
<p:outputLabel id="lblCurrentCenter" style="font-weight: bold;" value="#{ChangeCAP.currentCenter.displayName}" />
</div>
<div class="ui-g-4 ui-md-4" />
@@ -43,13 +43,12 @@
<p:outputLabel value="Nuevo centro de atención primaria:" for="newCenter" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="newCenter" value="#{ChangeCAP.newCenter}" 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="#{ChangeCAP.phcList}" var="phc" itemLabel="#{phc.displayDescription}" itemValue="#{phc}" />
<p:autoComplete id="newCenter" dropdown="true" required="true" value="#{ChangeCAP.newCenter}" completeMethod="#{ChangeCAP.completePrimaryHealCareCenter}" var="phc"
itemLabel="#{phc.displayName}" itemValue="#{phc}" forceSelection="true" requiredMessage="Por favor, selecciona un nuevo centro de antención primaria">
<o:converter converterId="omnifaces.ListConverter" list="#{ChangeCAP.phcList}" />
<p:column headerText="Nombre"><h:outputText value="#{phc.name}" /></p:column>
<p:column headerText="Localización"><h:outputText value="#{phc.location}" /></p:column>
</p:selectOneMenu>
</p:autoComplete>
</div>
<div class="ui-g-4 ui-md-4">
<p:message for="newCenter" />

View File

@@ -2,15 +2,16 @@
<!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:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:panelGroup id="globalPage">
<h:form id="frmRegisterUserResult" rendered="#{RegisterUser.registered}">
<div class="ui-g-3 ui-md-3" />
<div class="ui-g-6 ui-md-6">
<p:panel id="DatosPersonales" header="El registro se ha realizado correctamente">
<p:panel id="ResultadoAccion" header="El registro se ha realizado correctamente">
<div class="ui-g ui-fluid">
<div class="ui-g-12">
@@ -67,7 +68,8 @@
<div class="ui-g-6 ui-md-6">
<p:selectOneButton id="selUsertype" value="#{RegisterUser.userType}" required="true" unselectable="false" requiredMessage="Debe especificar un tipo de usuario">
<f:selectItems value="#{RegisterUser.userTypes}" var="item" itemLabel="#{item.userTypename}" itemValue="#{item.name}" />
<p:ajax listener="#{RegisterUser.onUserTypeChange}" update="selMS,selPHC" oncomplete="handleRequest(xhr, status, args)" />
<p:ajax listener="#{RegisterUser.onUserTypeChange}" update="DatosPersonales" oncomplete="handleRequest(xhr, status, args)" />
<!-- <p:ajax listener="#{RegisterUser.onUserTypeChange}" update="panEspecialidades, panCentros" oncomplete="handleRequest(xhr, status, args)" /> -->
</p:selectOneButton>
</div>
<div class="ui-g-4 ui-md-4"></div>
@@ -136,46 +138,53 @@
<p:message for="passwordRepeat" />
</div>
<div id="panCentros" class="ui-g-12 ui-g-nopad hide">
<h:panelGroup id="panCentros" layout="block" styleClass="ui-g-12" rendered="#{RegisterUser.familyDoctor}">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Centro:" for="selPHC" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{RegisterUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.familyDoctor}"
requiredMessage="Por favor, selecciona un centro de antención primaria">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
<p:column>#{phc.name}</p:column>
<p:column>#{phc.location}</p:column>
</p:selectOneMenu>
<p:autoComplete id="selPHC" dropdown="true" value="#{RegisterUser.primaryHealthCareCenter}" completeMethod="#{RegisterUser.completePrimaryHealCareCenter}" var="phc"
itemLabel="#{phc.displayName}" itemValue="#{phc}" forceSelection="true" requiredMessage="Por favor, selecciona un nuevo centro de antención primaria">
<o:converter converterId="omnifaces.ListConverter" list="#{RegisterUser.phcList}" />
<p:column headerText="Nombre">
<h:outputText value="#{phc.name}" />
</p:column>
<p:column headerText="Localización">
<h:outputText value="#{phc.location}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selPHC" />
</div>
</div>
</h:panelGroup>
<div id="panEspecialidades" class="ui-g-12 ui-g-nopad hide">
<h:panelGroup id="panEspecialidades" layout="block" styleClass="ui-g-12" rendered="#{RegisterUser.specialistDoctor}">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Especialidad médica:" for="selMS" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{RegisterUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.specialistDoctor}"
requiredMessage="Por favor, seleccione una especialidad médica">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
<p:column>#{ms.name}</p:column>
<p:column>#{ms.description}</p:column>
</p:selectOneMenu>
<p:autoComplete id="selMS" dropdown="true" value="#{RegisterUser.medicalSpecialty}" completeMethod="#{RegisterUser.completeMedicalSpecialty}" var="ms"
itemLabel="#{ms.displayName}" itemValue="#{ms}" forceSelection="true" requiredMessage="Por favor, selecciona una especialidad médica">
<o:converter converterId="omnifaces.ListConverter" list="#{RegisterUser.medicalSpecialtiesList}" />
<p:column headerText="Nombre">
<h:outputText value="#{ms.name}" />
</p:column>
<p:column headerText="Localización">
<h:outputText value="#{ms.description}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selMS" />
</div>
</div>
</h:panelGroup>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Registrarse" ajax="false" update="frmRegisterUserResult, frmRegisterUser" action="#{RegisterUser.addNewUser}" icon="pi pi-check" />
<p:commandButton validateClient="true" value="Registrarse" update="globalPage" action="#{RegisterUser.addNewUser}" icon="pi pi-check" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
@@ -183,9 +192,9 @@
<div class="ui-g-4 ui-md-4"></div>
</div>
</div>
</p:panel>
</h:form>
</h:panelGroup>
</ui:define>
</ui:composition>
</html>

View File

@@ -2,7 +2,7 @@
<!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:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
@@ -27,8 +27,8 @@
<p:panel id="DatosPersonales" header="Actualizar datos personales">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Código de Identificación Personal (CIP):" rendered="#{UpdateProfile.patient}" for="id" />
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.familyDoctor or UpdateProfile.specialistDoctor}" for="id" />
<p:outputLabel value="Código de Identificación Personal (CIP):" rendered="#{UpdateProfile.userTypePatient}" for="id" />
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.userTypeDoctor}" for="id" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="id" value="#{UpdateProfile.id}" disabled="true" required="true" requiredMessage="Por favor, indque su identificador" />
@@ -106,42 +106,72 @@
<p:message for="passwordRepeat" />
</div>
<h:panelGroup id="panCentros" layout="block" class="ui-g-12 ui-g-nopad" rendered="#{UpdateProfile.familyDoctor}">
<h:panelGroup id="panCentros" layout="block" styleClass="ui-g-12" rendered="#{UpdateProfile.userTypeFamilyDoctor}">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Centro:" for="selPHC" />
<p:outputLabel value="Centro de atención (CAP):" for="selPHC" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{UpdateProfile.primaryHealthCareCenter.name}" converter="omnifaces.SelectItemsConverter" required="#{UpdateProfile.familyDoctor}"
requiredMessage="Por favor, selecciona un centro de antención primaria">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{UpdateProfile.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc.name}" />
<p:column>#{phc.name}</p:column>
<p:column>#{phc.location}</p:column>
</p:selectOneMenu>
<p:autoComplete id="selPHC" dropdown="true" value="#{UpdateProfile.primaryHealthCareCenter}" completeMethod="#{UpdateProfile.completePrimaryHealCareCenter}" var="phc"
itemLabel="#{phc.displayName}" itemValue="#{phc}" forceSelection="true" requiredMessage="Por favor, selecciona un nuevo centro de antención primaria">
<o:converter converterId="omnifaces.ListConverter" list="#{UpdateProfile.phcList}" />
<p:column headerText="Nombre">
<h:outputText value="#{phc.name}" />
</p:column>
<p:column headerText="Localización">
<h:outputText value="#{phc.location}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selPHC" />
</div>
</h:panelGroup>
<h:panelGroup id="panEspecialidades" layout="block" class="ui-g-12 ui-g-nopad" rendered="#{UpdateProfile.specialistDoctor}">
<h:panelGroup id="panEspecialidades" layout="block" styleClass="ui-g-12" rendered="#{UpdateProfile.userTypeSpecialistDoctor}">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Especialidad médica:" for="selMS" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{UpdateProfile.medicalSpecialty.name}" converter="omnifaces.SelectItemsConverter" required="#{UpdateProfile.specialistDoctor}"
requiredMessage="Por favor, seleccione una especialidad médica">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{UpdateProfile.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms.name}" />
<p:column>#{ms.name}</p:column>
<p:column>#{ms.description}</p:column>
</p:selectOneMenu>
<p:autoComplete id="selMS" dropdown="true" value="#{UpdateProfile.medicalSpecialty}" completeMethod="#{UpdateProfile.completeMedicalSpecialty}" var="ms"
itemLabel="#{ms.displayName}" itemValue="#{ms}" forceSelection="true" requiredMessage="Por favor, selecciona una especialidad médica">
<o:converter converterId="omnifaces.ListConverter" list="#{UpdateProfile.medicalSpecialtiesList}" />
<p:column headerText="Nombre">
<h:outputText value="#{ms.name}" />
</p:column>
<p:column headerText="Localización">
<h:outputText value="#{ms.description}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selMS" />
</div>
</h:panelGroup>
<h:panelGroup id="panMedicosFamilia" layout="block" styleClass="ui-g-12" rendered="#{UpdateProfile.userTypePatient}">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Médico de familia:" for="FamilyDoc" />
</div>
<div class="ui-g-4 ui-md-4">
<p:autoComplete id="FamilyDoc" disabled="true" dropdown="true" required="true" value="#{UpdateProfile.familyDoctor}" completeMethod="#{UpdateProfile.completeFamilyDoctor}" var="fd"
itemLabel="#{fd.displayName}" itemValue="#{fd}" forceSelection="true" requiredMessage="Por favor, selecciona un médico de familia">
<o:converter converterId="omnifaces.ListConverter" list="#{UpdateProfile.familyDoctorList}" />
<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="Apellidos">
<h:outputText value="#{fd.surname}" />
</p:column>
</p:autoComplete>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="FamilyDoc" />
</div>
</h:panelGroup>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">

View File

@@ -26,13 +26,13 @@ public class FamilyDoctorTO implements Serializable {
}
public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setPrimaryHealthCareCenter(phc);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.primaryHealthCareCenter = phc;
}
public String getEmail() {
@@ -83,7 +83,7 @@ public class FamilyDoctorTO implements Serializable {
this.id = id;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%d] %s %s", this.id, this.name, this.surname);
}

View File

@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlRootElement;
public class MedicalSpecialtyTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String description;
@@ -21,11 +21,20 @@ public class MedicalSpecialtyTO implements Serializable {
super();
}
public MedicalSpecialtyTO(String name, String description) {
public MedicalSpecialtyTO(Integer id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
@@ -42,7 +51,7 @@ public class MedicalSpecialtyTO implements Serializable {
this.description = description;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%s] %s", this.name, this.description);
}

View File

@@ -31,13 +31,13 @@ public class PatientTO implements Serializable {
}
public PatientTO(Integer id, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setFamilyDoctor(familyDoc);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.familyDoctor = familyDoc;
}
public String getEmail() {

View File

@@ -13,20 +13,28 @@ import javax.xml.bind.annotation.XmlRootElement;
public class PrimaryHealthCareCenterTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private String name;
private String location;
public PrimaryHealthCareCenterTO() {
super();
}
public PrimaryHealthCareCenterTO(String name, String location) {
public PrimaryHealthCareCenterTO(Integer Id, String name, String location) {
this.id = Id;
this.name = name;
this.location = location;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
@@ -39,11 +47,11 @@ public class PrimaryHealthCareCenterTO implements Serializable {
return location;
}
public void setLocation(String description) {
this.location = description;
public void setLocation(String value) {
this.location = value;
}
public String getDisplayDescription() {
public String getDisplayName() {
return String.format("[%s] %s", this.name, this.location);
}

View File

@@ -26,13 +26,13 @@ public class SpecialistDoctorTO implements Serializable {
}
public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
this.setId(id);
this.setNif(nif);
this.setName(name);
this.setSurname(surname);
this.setPassword(password);
this.setEmail(email);
this.setMedicalSpecialty(medicalSpec);
this.id = id;
this.nif = nif;
this.name = name;
this.surname = surname;
this.password = password;
this.email =email;
this.medicalSpecialty = medicalSpec;
}
public String getEmail() {

View File

@@ -0,0 +1,5 @@
package common;
public class Constants {
public static final int MAX_ITEMS_AUTOCOMPLETE_SEARCH = 200;
}

View File

@@ -0,0 +1,11 @@
package common;
import java.text.Normalizer;
public class Utils {
public static String stripAccents(String input){
return input == null ? null :
Normalizer.normalize(input, Normalizer.Form.NFD)
.replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
}

View File

@@ -2,17 +2,20 @@ package ejb.common;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import TO.FamilyDoctorTO;
import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Utils;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
@@ -28,8 +31,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
/**
* Metodo que devuelve todas las especialidades medicas
*/
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() {
return this.listPagedMedicalSpecialities(0, 0);
public List<MedicalSpecialtyTO> listAllMedicalSpecialities() {
return this.listMedicalSpecialitiesPaged(0, 0);
}
/**
@@ -39,54 +42,106 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
* cada página
*
*/
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) {
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name");
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize) {
return listMedicalSpecialitiesFiltered(null, pageNumber, pageSize);
}
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT ms from MedicalSpecialtyJPA ms %s order by ms.name, ms.description";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(ms.name) LIKE :searchTerm OR lower(ms.description) LIKE :searchTerm";
}
TypedQuery<MedicalSpecialtyJPA> query = entman.createQuery(String.format(strQuery, strFilter), MedicalSpecialtyJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
@SuppressWarnings("unchecked")
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList();
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
List<MedicalSpecialtyJPA> allJPA = query.getResultList();
List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
for (MedicalSpecialtyJPA ms : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
for (MedicalSpecialtyJPA cap : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(cap.getId(), cap.getName(), cap.getDescription()));
}
return allSpecialities;
}
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listPagedAllCAPs(0, 0);
public List<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listCAPsPaged(0, 0);
}
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
return this.listCAPsFiltered(null, pageNumber, pageSize);
}
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT phc from PrimaryHealthCareCenterJPA phc %s order by phc.name, phc.location";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(phc.name) LIKE :searchTerm OR lower(phc.location) LIKE :searchTerm";
}
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery(String.format(strQuery, strFilter), PrimaryHealthCareCenterJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
@SuppressWarnings("unchecked")
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
for (PrimaryHealthCareCenterJPA cap : allJPA) {
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getId(), cap.getName(), cap.getLocation()));
}
return allCAPs;
}
public Collection<FamilyDoctorTO> listAllFamilyDoctors() {
return this.listAllFamilyDoctors(0, 0);
public List<FamilyDoctorTO> listAllFamilyDoctors() {
return this.listFamilyDoctorsPaged(0, 0);
}
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize) {
Query query = entman.createQuery("from FamilyDoctorJPA order by name, surname");
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize) {
return this.listFamilyDoctorsFiltered(null, pageNumber, pageSize);
}
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT fd FROM FamilyDoctorJPA fd %s order by fd.name, fd.surname";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.stripAccents(searchTerm).toLowerCase();
if (searchTerm.length() > 0) {
strFilter = "WHERE lower(fd.name) LIKE :searchTerm OR lower(fd.surname) LIKE :searchTerm";
}
TypedQuery<FamilyDoctorJPA> query = entman.createQuery(String.format(strQuery, strFilter), FamilyDoctorJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
@@ -94,8 +149,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
}
@SuppressWarnings("unchecked")
Collection<FamilyDoctorJPA> allFDsJPA = query.getResultList();
Collection<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
for (FamilyDoctorJPA item : allFDsJPA) {
allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null));
@@ -129,7 +184,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
PrimaryHealthCareCenterTO phc = null;
if (fd.getPrimaryHealthCareCenter() != null)
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getId(), fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
return fdTO;
@@ -144,7 +199,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
MedicalSpecialtyTO ms = null;
if (sd.getMedicalSpecialty() != null)
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getId(), sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms);
return sdTO;

View File

@@ -1,6 +1,7 @@
package ejb.common;
import java.util.Collection;
import java.util.List;
import javax.ejb.Local;
@@ -18,17 +19,23 @@ import TO.SpecialistDoctorTO;
@Local
public interface CommonFacadeLocal {
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listAllCAPs();
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
public List<FamilyDoctorTO> listAllFamilyDoctors();
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public PatientTO retrievePatient(int patientId) throws Exception;

View File

@@ -1,6 +1,7 @@
package ejb.common;
import java.util.Collection;
import java.util.List;
import javax.ejb.Remote;
@@ -18,17 +19,23 @@ import TO.SpecialistDoctorTO;
@Remote
public interface CommonFacadeRemote {
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
public List<MedicalSpecialtyTO> listAllMedicalSpecialities();
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize);
public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
public List<MedicalSpecialtyTO> listMedicalSpecialitiesFiltered(String searchTerm, int pageNumber, int pageSize);
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listAllCAPs();
public Collection<FamilyDoctorTO> listAllFamilyDoctors();
public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize);
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize);
public List<PrimaryHealthCareCenterTO> listCAPsFiltered(String searchTerm, int pageNumber, int pageSize);
public List<FamilyDoctorTO> listAllFamilyDoctors();
public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public PatientTO retrievePatient(int patientId) throws Exception;

View File

@@ -67,7 +67,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public SpecialistDoctorTO registerSpecialistDoctor(int id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty)
throws Exception {
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getId());
if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
}
@@ -84,7 +84,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public FamilyDoctorTO registerFamilyDoctor(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) throws Exception {
FamilyDoctorTO fdTO = null;
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + cap.getName());
}
@@ -127,7 +127,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
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(id));
}
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getId());
if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName());
}
@@ -155,7 +155,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
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(id));
}
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, phcTO.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, phcTO.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + phcTO.getName());
}
@@ -185,7 +185,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
throw new Exception("No se encuentra en la base de datos ningún médico de familia con id: " + String.valueOf(professionalId));
}
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter.getName());
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter.getId());
if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + newCenter.getName());
}

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
@@ -26,6 +27,7 @@ public class FamilyDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id;
private String nif;

View File

@@ -2,7 +2,10 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@@ -18,6 +21,9 @@ public class MedicalSpecialtyJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String description;
@@ -33,7 +39,14 @@ public class MedicalSpecialtyJPA implements Serializable {
this.description = description;
}
@Id
public Integer getId() {
return id;
}
public void setId(Integer value) {
this.id = value;
}
public String getName() {
return name;
}

View File

@@ -2,6 +2,7 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -22,6 +23,7 @@ public class PatientJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nif;
@@ -100,6 +102,7 @@ public class PatientJPA implements Serializable {
public FamilyDoctorJPA getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
this.familyDoctor = familyDoc;
}

View File

@@ -2,7 +2,10 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@@ -18,6 +21,9 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String location;
@@ -33,6 +39,14 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
this.location = location;
}
public Integer getId() {
return id;
}
public void setId(Integer value) {
this.id = value;
}
public String getName() {
return name;
}

View File

@@ -2,6 +2,7 @@ package jpa;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -22,6 +23,7 @@ public class SpecialistDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nif;

View File

@@ -4,6 +4,7 @@ import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
@@ -12,7 +13,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
@@ -25,6 +25,8 @@ public class VisitJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(updatable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Date date;
private Time time;
@@ -85,12 +87,14 @@ public class VisitJPA implements Serializable {
public void setObservations(String observation) {
this.observations = observations;
}
/**
* Methods get/set persistent relationships
*/
public FamilyDoctorJPA getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorJPA familyDoc) {
this.familyDoctor = familyDoc;
}

View File

@@ -1,7 +1,7 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
@@ -11,6 +11,7 @@ import javax.inject.Named;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PatientTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@@ -28,7 +29,8 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
private int id;
private FamilyDoctorTO currentFamilyDoctor;
private FamilyDoctorTO newFamilyDoctor;
private Collection<FamilyDoctorTO> familyDoctorList;
private List<FamilyDoctorTO> familyDoctorList;
private String lastUIQuery;
public ChangeFamilyDoctorMBean() {
@@ -38,6 +40,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
public void init() {
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
this.lastUIQuery = "";
try {
usr = SessionUtils.getloggedOnUser();
@@ -48,7 +51,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.PATIENT) {
this.familyDoctorList = this.getRemoteManagerCommon().listAllFamilyDoctors();
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
this.setCurrentFamilyDoctor(pat.getFamilyDoctor());
@@ -60,10 +63,19 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
}
public Collection<FamilyDoctorTO> getFamilyDoctorList() {
public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList;
}
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
if (query != null && query.equals(this.lastUIQuery) == false) {
this.lastUIQuery = query;
// Recuperamos las 200 primeras coincidencias
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.familyDoctorList;
}
public int getId() {
return id;
}

View File

@@ -2,6 +2,7 @@ package managedbean.profile;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
@@ -11,6 +12,7 @@ import javax.inject.Named;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PrimaryHealthCareCenterTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@@ -28,7 +30,8 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
private int id;
private PrimaryHealthCareCenterTO currentCenter;
private PrimaryHealthCareCenterTO newCenter;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private String lastUIQuery;
public ChangePrimaryHealthCareCenterMBean() {
@@ -38,6 +41,8 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
public void init() {
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
this.lastUIQuery = "";
try {
usr = SessionUtils.getloggedOnUser();
@@ -48,7 +53,7 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
this.setCurrentCenter(fd.getPrimaryHealthCareCenter());
@@ -60,10 +65,19 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQuery) == false) {
this.lastUIQuery = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public int getId() {
return id;
}

View File

@@ -19,6 +19,7 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.ValidationUtils;
@@ -44,14 +45,16 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
private String password;
private String email;
private boolean registered;
private String lastUIQueryPH;
private String lastUIQueryMS;
// private HashMap<String, String> userTypes;
private List<UserType> userTypes;
private String userType;
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
public RegisterUserMBean() {
@@ -64,11 +67,13 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.registered = false;
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
this.userType = UserType.PATIENT.name();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
public List<UserType> getUserTypes() {
@@ -98,14 +103,32 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
}
}
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
public List<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
return medicalSpecialitiesList;
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQueryPH) == false) {
this.lastUIQueryPH = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
if (query != null && query.equals(this.lastUIQueryMS) == false) {
this.lastUIQueryMS = query;
// Recuperamos las 200 primeras coincidencias
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.medicalSpecialitiesList;
}
public boolean isPatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT);
}

View File

@@ -4,18 +4,11 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.print.attribute.standard.Severity;
import javax.resource.NotSupportedException;
import org.primefaces.PrimeFaces;
@@ -26,9 +19,9 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.HashUtils;
import common.UserType;
import ejb.systemAdmin.SystemAdminFacadeRemote;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
import managedbean.common.ValidationUtils;
@@ -54,13 +47,18 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
private String oldPassword;
private String password;
private String email;
private String lastUIQueryPH;
private String lastUIQueryMS;
private String lastUIQueryFD;
private List<UserType> userTypes;
private String userType;
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
private FamilyDoctorTO familyDoctor;
private List<FamilyDoctorTO> familyDoctorList;
public UpdateProfileMBean() {
@@ -72,6 +70,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.userTypes.add(UserType.PATIENT);
this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
// Recuperamos el usuario logeado actual
LoggedUserTO usr = null;
@@ -87,6 +87,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
switch (usr.getUserType()) {
case PATIENT:
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
this.name = pat.getName();
@@ -96,7 +97,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.currentPassword = pat.getPassword();
break;
case SPECIALIST_DOCTOR:
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
SpecialistDoctorTO sd = this.getRemoteManagerCommon().retrieveSpecialistDoctor(this.id);
this.name = sd.getName();
@@ -107,7 +108,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.medicalSpecialty = sd.getMedicalSpecialty();
break;
case FAMILY_DOCTOR:
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs();
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id);
this.name = fd.getName();
@@ -156,28 +157,59 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
}
}
public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
public List<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
return medicalSpecialitiesList;
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public boolean isPatient() {
public List<PrimaryHealthCareCenterTO> completePrimaryHealCareCenter(String query) {
if (query != null && query.equals(this.lastUIQueryPH) == false) {
this.lastUIQueryPH = query;
// Recuperamos las 200 primeras coincidencias
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.primaryHealthCareCentersList;
}
public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
if (query != null && query.equals(this.lastUIQueryMS) == false) {
this.lastUIQueryMS = query;
// Recuperamos las 200 primeras coincidencias
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.medicalSpecialitiesList;
}
public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList;
}
public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
if (query != null && query.equals(this.lastUIQueryFD) == false) {
this.lastUIQueryFD = query;
// Recuperamos las 200 primeras coincidencias
this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.familyDoctorList;
}
public boolean isUserTypePatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT);
}
public boolean isFamilyDoctor() {
public boolean isUserTypeFamilyDoctor() {
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR);
}
public boolean isSpecialistDoctor() {
public boolean isUserTypeSpecialistDoctor() {
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR);
}
public boolean isDoctor() {
return (isFamilyDoctor() || isSpecialistDoctor());
public boolean isUserTypeDoctor() {
return (isUserTypeFamilyDoctor() || isUserTypeSpecialistDoctor());
}
public String getEmail() {
@@ -228,11 +260,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
int error = 0;
boolean changePassword = (this.oldPassword != null && this.oldPassword.equals("") == false) || (this.password != null && this.password.equals("") == false);
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
if (this.isUserTypeFamilyDoctor() && this.primaryHealthCareCenter == null) {
this.addFacesMessage(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) {
if (this.isUserTypeSpecialistDoctor() && this.medicalSpecialty == null) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Especialidad médica no seleccionada", "Por favor, especifique una especialidad médica.");
error++;
}
@@ -320,4 +352,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.oldPassword = oldPassword;
}
public FamilyDoctorTO getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorTO familyDoctor) {
this.familyDoctor = familyDoctor;
}
}