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"> <!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" <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:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
@@ -14,8 +14,8 @@
<p:panel id="badProfileInfo" header="Perfil de usuario incorrecto para realizar acción"> <p:panel id="badProfileInfo" header="Perfil de usuario incorrecto para realizar acción">
<div class="ui-g ui-fluid"> <div class="ui-g ui-fluid">
<div class="ui-g-12"> <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 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
error, por favor, contacte con el soporte de la aplicación para obtener asistencia tecnica. favor, contacte con el soporte de la aplicación para obtener asistencia tecnica.
</div> </div>
<div class="ui-g-3"></div> <div class="ui-g-3"></div>
<div class="ui-g-6"> <div class="ui-g-6">
@@ -35,25 +35,30 @@
<p:outputLabel value="Médico de familia actualmente asignado:" /> <p:outputLabel value="Médico de familia actualmente asignado:" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p: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>
<div class="ui-g-4 ui-md-4" /> <div class="ui-g-4 ui-md-4" />
<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>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="newFamilyDoc" value="#{ChangeFD.newFamilyDoctor}" converter="omnifaces.SelectItemsConverter" required="true" <p:autoComplete id="newFamilyDocAC" dropdown="true" required="true" value="#{ChangeFD.newFamilyDoctor}" completeMethod="#{ChangeFD.completeFamilyDoctor}" var="fd"
requiredMessage="Por favor, selecciona un nuevo centro de antención primaria"> itemLabel="#{fd.displayName}" itemValue="#{fd}" forceSelection="true" requiredMessage="Por favor, selecciona un médico de familia">
<f:selectItem itemLabel="Seleccione un nuevo centro de antención primario..." itemValue="" noSelectionOption="true" /> <o:converter converterId="omnifaces.ListConverter" list="#{ChangeFD.familyDoctorList}" />
<f:selectItems value="#{ChangeFD.familyDoctorList}" var="fd" itemLabel="#{fd.displayDescription}" itemValue="#{fd}" /> <p:column headerText="Num. Prof.">
<p:column headerText="Num. Prof."><h:outputText value="#{fd.id}" /></p:column> <h:outputText value="#{fd.id}" />
<p:column headerText="Nombre"><h:outputText value="#{fd.name}" /></p:column> </p:column>
<p:column headerText="Apellido"><h:outputText value="#{fd.surname}" /></p:column> <p:column headerText="Nombre">
</p:selectOneMenu> <h:outputText value="#{fd.name}" />
</p:column>
<p:column headerText="Apellidos">
<h:outputText value="#{fd.surname}" />
</p:column>
</p:autoComplete>
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:message for="newFamilyDoc" /> <p:message for="newFamilyDocAC" />
</div> </div>
<div class="ui-g-12 ui-g-nopad"> <div class="ui-g-12 ui-g-nopad">

View File

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

View File

@@ -2,48 +2,49 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" <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:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form id="frmRegisterUserResult" rendered="#{RegisterUser.registered}"> <h:panelGroup id="globalPage">
<div class="ui-g-3 ui-md-3" /> <h:form id="frmRegisterUserResult" rendered="#{RegisterUser.registered}">
<div class="ui-g-6 ui-md-6"> <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 ui-fluid">
<div class="ui-g-12"> <div class="ui-g-12">
Enhorabuena Enhorabuena
<p:outputLabel value="#{RegisterUser.name}" /> <p:outputLabel value="#{RegisterUser.name}" />
, se ha registrado correctamente, el sistema le ha asignado un <b> <p:outputLabel value="Código de Identificación Personal (CIP)" rendered="#{RegisterUser.patient}" /> , se ha registrado correctamente, el sistema le ha asignado un <b> <p:outputLabel value="Código de Identificación Personal (CIP)" rendered="#{RegisterUser.patient}" />
<p:outputLabel value="Número de Profesional" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" /> <p:outputLabel value="Número de Profesional" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" />
</b> , por favor recuerdelo ya que deberá utilizarlo para logearse en el sistema. </b> , por favor recuerdelo ya que deberá utilizarlo para logearse en el sistema.
</div>
<div class="ui-g-12">
<p:outputLabel value="Su Código de Identificación Personal (CIP) es el siguiente:" rendered="#{RegisterUser.patient}" />
<p:outputLabel value="Número de Profesional es el siguiente:" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" />
</div>
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;">
<p:outputLabel value="#{RegisterUser.id}" />
</div>
<div class="ui-g-3"></div>
<div class="ui-g-6">
<p:button value="Ir a la página principal" outcome="/home" icon="pi pi-home" />
</div>
<div class="ui-g-3"></div>
</div> </div>
<div class="ui-g-12"> </p:panel>
<p:outputLabel value="Su Código de Identificación Personal (CIP) es el siguiente:" rendered="#{RegisterUser.patient}" /> </div>
<p:outputLabel value="Número de Profesional es el siguiente:" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" /> <div class="ui-g-3 ui-md-3" />
</div> </h:form>
<div class="ui-g-12" style="font-size: larger; font-weight: bold; text-align: center;"> <h:form id="frmRegisterUser" rendered="#{not RegisterUser.registered}">
<p:outputLabel value="#{RegisterUser.id}" /> <h:outputScript>
</div>
<div class="ui-g-3"></div>
<div class="ui-g-6">
<p:button value="Ir a la página principal" outcome="/home" icon="pi pi-home" />
</div>
<div class="ui-g-3"></div>
</div>
</p:panel>
</div>
<div class="ui-g-3 ui-md-3" />
</h:form>
<h:form id="frmRegisterUser" rendered="#{not RegisterUser.registered}">
<h:outputScript>
function handleRequest(xhr, status, args) { function handleRequest(xhr, status, args) {
if(args.specs) { if(args.specs) {
$('#panCentros').slideUp(); $('#panCentros').slideUp();
@@ -58,134 +59,142 @@
} }
} }
</h:outputScript> </h:outputScript>
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" /> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse"> <p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
<div class="ui-g ui-fluid"> <div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Tipo de usuario:" for="selUsertype" />
</div>
<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:selectOneButton>
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</p:panel>
<br />
<p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="NIF:" for="nif" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="nif" value="#{RegisterUser.nif}" required="true" requiredMessage="Por favor, indque su NIF" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="nif" display="text" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Nombre:" for="name" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="name" value="#{RegisterUser.name}" required="true" requiredMessage="Por favor, indique su nombre" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="name" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Apellidos:" for="surname" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="surname" value="#{RegisterUser.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="surname" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Correo electrónico:" for="email" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="email" value="#{RegisterUser.email}" required="true" requiredMessage="Por favor, especifique su correo electrónico" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="email" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Contraseña" for="password" />
</div>
<div class="ui-g-4 ui-md-4">
<p:password id="password" value="#{RegisterUser.password}" match="passwordRepeat" required="true" requiredMessage="Por favor, especifique una contraseña" maxlength="50"
feedback="true" promptLabel="Especifique una contraseña segura" weakLabel="La contraseña es débil" goodLabel="La contraseña es buena" strongLabel="La contraseña es segura"
validatorMessage="La contraseña y su verificación deben ser iguales" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="password" />
</div>
<div class="ui-g-2">
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
</div>
<div class="ui-g-4">
<p:password id="passwordRepeat" value="#{RegisterUser.password}" required="true" requiredMessage="Por favor, escriba la verificación de su contraseña" maxlength="50" />
</div>
<div class="ui-g-6">
<p:message for="passwordRepeat" />
</div>
<div id="panCentros" class="ui-g-12 ui-g-nopad hide">
<div class="ui-g-2 ui-md-2"> <div class="ui-g-2 ui-md-2">
<p:outputLabel value="Centro:" for="selPHC" /> <p:outputLabel value="Tipo de usuario:" for="selUsertype" />
</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>
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="selPHC" /> <p:selectOneButton id="selUsertype" value="#{RegisterUser.userType}" required="true" unselectable="false" requiredMessage="Debe especificar un tipo de usuario">
</div> <f:selectItems value="#{RegisterUser.userTypes}" var="item" itemLabel="#{item.userTypename}" itemValue="#{item.name}" />
</div> <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)" /> -->
<div id="panEspecialidades" class="ui-g-12 ui-g-nopad hide"> </p:selectOneButton>
<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>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selMS" />
</div>
</div>
<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" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
</div> </div>
<div class="ui-g-4 ui-md-4"></div> <div class="ui-g-4 ui-md-4"></div>
</div> </div>
</div> </p:panel>
<br />
<p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="NIF:" for="nif" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="nif" value="#{RegisterUser.nif}" required="true" requiredMessage="Por favor, indque su NIF" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="nif" display="text" />
</div>
</p:panel> <div class="ui-g-2 ui-md-2">
</h:form> <p:outputLabel value="Nombre:" for="name" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="name" value="#{RegisterUser.name}" required="true" requiredMessage="Por favor, indique su nombre" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="name" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Apellidos:" for="surname" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="surname" value="#{RegisterUser.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="surname" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Correo electrónico:" for="email" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="email" value="#{RegisterUser.email}" required="true" requiredMessage="Por favor, especifique su correo electrónico" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="email" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Contraseña" for="password" />
</div>
<div class="ui-g-4 ui-md-4">
<p:password id="password" value="#{RegisterUser.password}" match="passwordRepeat" required="true" requiredMessage="Por favor, especifique una contraseña" maxlength="50"
feedback="true" promptLabel="Especifique una contraseña segura" weakLabel="La contraseña es débil" goodLabel="La contraseña es buena" strongLabel="La contraseña es segura"
validatorMessage="La contraseña y su verificación deben ser iguales" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="password" />
</div>
<div class="ui-g-2">
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
</div>
<div class="ui-g-4">
<p:password id="passwordRepeat" value="#{RegisterUser.password}" required="true" requiredMessage="Por favor, escriba la verificación de su contraseña" maxlength="50" />
</div>
<div class="ui-g-6">
<p:message for="passwordRepeat" />
</div>
<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: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>
</h:panelGroup>
<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: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>
</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" 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" />
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</div>
</p:panel>
</h:form>
</h:panelGroup>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</html> </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"> <!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" <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:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
@@ -27,8 +27,8 @@
<p:panel id="DatosPersonales" header="Actualizar datos personales"> <p:panel id="DatosPersonales" header="Actualizar datos personales">
<div class="ui-g ui-fluid"> <div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2"> <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="Código de Identificación Personal (CIP):" rendered="#{UpdateProfile.userTypePatient}" for="id" />
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.familyDoctor or UpdateProfile.specialistDoctor}" for="id" /> <p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.userTypeDoctor}" for="id" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <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" /> <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" /> <p:message for="passwordRepeat" />
</div> </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"> <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>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{UpdateProfile.primaryHealthCareCenter.name}" converter="omnifaces.SelectItemsConverter" required="#{UpdateProfile.familyDoctor}" <p:autoComplete id="selPHC" dropdown="true" value="#{UpdateProfile.primaryHealthCareCenter}" completeMethod="#{UpdateProfile.completePrimaryHealCareCenter}" var="phc"
requiredMessage="Por favor, selecciona un centro de antención primaria"> itemLabel="#{phc.displayName}" itemValue="#{phc}" forceSelection="true" requiredMessage="Por favor, selecciona un nuevo centro de antención primaria">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" /> <o:converter converterId="omnifaces.ListConverter" list="#{UpdateProfile.phcList}" />
<f:selectItems value="#{UpdateProfile.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc.name}" /> <p:column headerText="Nombre">
<p:column>#{phc.name}</p:column> <h:outputText value="#{phc.name}" />
<p:column>#{phc.location}</p:column> </p:column>
</p:selectOneMenu> <p:column headerText="Localización">
<h:outputText value="#{phc.location}" />
</p:column>
</p:autoComplete>
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="selPHC" /> <p:message for="selPHC" />
</div> </div>
</h:panelGroup> </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"> <div class="ui-g-2 ui-md-2">
<p:outputLabel value="Especialidad médica:" for="selMS" /> <p:outputLabel value="Especialidad médica:" for="selMS" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{UpdateProfile.medicalSpecialty.name}" converter="omnifaces.SelectItemsConverter" required="#{UpdateProfile.specialistDoctor}" <p:autoComplete id="selMS" dropdown="true" value="#{UpdateProfile.medicalSpecialty}" completeMethod="#{UpdateProfile.completeMedicalSpecialty}" var="ms"
requiredMessage="Por favor, seleccione una especialidad médica"> itemLabel="#{ms.displayName}" itemValue="#{ms}" forceSelection="true" requiredMessage="Por favor, selecciona una especialidad médica">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" /> <o:converter converterId="omnifaces.ListConverter" list="#{UpdateProfile.medicalSpecialtiesList}" />
<f:selectItems value="#{UpdateProfile.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms.name}" /> <p:column headerText="Nombre">
<p:column>#{ms.name}</p:column> <h:outputText value="#{ms.name}" />
<p:column>#{ms.description}</p:column> </p:column>
</p:selectOneMenu> <p:column headerText="Localización">
<h:outputText value="#{ms.description}" />
</p:column>
</p:autoComplete>
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="selMS" /> <p:message for="selMS" />
</div> </div>
</h:panelGroup> </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-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div> <div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 "> <div class="ui-g-2 ui-md-2 ">

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) { public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
this.setId(id); this.id = id;
this.setNif(nif); this.nif = nif;
this.setName(name); this.name = name;
this.setSurname(surname); this.surname = surname;
this.setPassword(password); this.password = password;
this.setEmail(email); this.email =email;
this.setPrimaryHealthCareCenter(phc); this.primaryHealthCareCenter = phc;
} }
public String getEmail() { public String getEmail() {
@@ -83,7 +83,7 @@ public class FamilyDoctorTO implements Serializable {
this.id = id; this.id = id;
} }
public String getDisplayDescription() { public String getDisplayName() {
return String.format("[%d] %s %s", this.id, this.name, this.surname); 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 { public class MedicalSpecialtyTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id;
private String name; private String name;
private String description; private String description;
@@ -21,11 +21,20 @@ public class MedicalSpecialtyTO implements Serializable {
super(); super();
} }
public MedicalSpecialtyTO(String name, String description) { public MedicalSpecialtyTO(Integer id, String name, String description) {
this.id = id;
this.name = name; this.name = name;
this.description = description; this.description = description;
} }
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() { public String getName() {
return name; return name;
} }
@@ -42,7 +51,7 @@ public class MedicalSpecialtyTO implements Serializable {
this.description = description; this.description = description;
} }
public String getDisplayDescription() { public String getDisplayName() {
return String.format("[%s] %s", this.name, this.description); 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) { public PatientTO(Integer id, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
this.setId(id); this.id = id;
this.setNif(nif); this.nif = nif;
this.setName(name); this.name = name;
this.setSurname(surname); this.surname = surname;
this.setPassword(password); this.password = password;
this.setEmail(email); this.email =email;
this.setFamilyDoctor(familyDoc); this.familyDoctor = familyDoc;
} }
public String getEmail() { public String getEmail() {

View File

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

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) { public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
this.setId(id); this.id = id;
this.setNif(nif); this.nif = nif;
this.setName(name); this.name = name;
this.setSurname(surname); this.surname = surname;
this.setPassword(password); this.password = password;
this.setEmail(email); this.email =email;
this.setMedicalSpecialty(medicalSpec); this.medicalSpecialty = medicalSpec;
} }
public String getEmail() { 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.TypedQuery;
import TO.FamilyDoctorTO; import TO.FamilyDoctorTO;
import TO.MedicalSpecialtyTO; import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import common.Utils;
import jpa.FamilyDoctorJPA; import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA; import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA; import jpa.PatientJPA;
@@ -28,8 +31,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
/** /**
* Metodo que devuelve todas las especialidades medicas * Metodo que devuelve todas las especialidades medicas
*/ */
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() { public List<MedicalSpecialtyTO> listAllMedicalSpecialities() {
return this.listPagedMedicalSpecialities(0, 0); return this.listMedicalSpecialitiesPaged(0, 0);
} }
/** /**
@@ -39,54 +42,106 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
* cada página * cada página
* *
*/ */
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) { public List<MedicalSpecialtyTO> listMedicalSpecialitiesPaged(int pageNumber, int pageSize) {
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name"); 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) { if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize); query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize); query.setMaxResults(pageSize);
} }
@SuppressWarnings("unchecked") List<MedicalSpecialtyJPA> allJPA = query.getResultList();
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList(); List<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
for (MedicalSpecialtyJPA ms : allJPA) { for (MedicalSpecialtyJPA cap : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription())); allSpecialities.add(new MedicalSpecialtyTO(cap.getId(), cap.getName(), cap.getDescription()));
} }
return allSpecialities; return allSpecialities;
} }
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() { public List<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listPagedAllCAPs(0, 0); return this.listCAPsPaged(0, 0);
} }
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) { public List<PrimaryHealthCareCenterTO> listCAPsPaged(int pageNumber, int pageSize) {
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name"); 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) { if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize); query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize); query.setMaxResults(pageSize);
} }
@SuppressWarnings("unchecked") List<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList(); List<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
for (PrimaryHealthCareCenterJPA cap : allJPA) { for (PrimaryHealthCareCenterJPA cap : allJPA) {
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation())); allCAPs.add(new PrimaryHealthCareCenterTO(cap.getId(), cap.getName(), cap.getLocation()));
} }
return allCAPs; return allCAPs;
} }
public Collection<FamilyDoctorTO> listAllFamilyDoctors() { public List<FamilyDoctorTO> listAllFamilyDoctors() {
return this.listAllFamilyDoctors(0, 0); return this.listFamilyDoctorsPaged(0, 0);
} }
public Collection<FamilyDoctorTO> listAllFamilyDoctors(int pageNumber, int pageSize) { public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize) {
Query query = entman.createQuery("from FamilyDoctorJPA order by name, surname"); 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) { if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize); query.setFirstResult(pageNumber * pageSize);
@@ -94,8 +149,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<FamilyDoctorJPA> allFDsJPA = query.getResultList(); List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
Collection<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>(); List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
for (FamilyDoctorJPA item : allFDsJPA) { for (FamilyDoctorJPA item : allFDsJPA) {
allFDTOs.add(new FamilyDoctorTO(item.getId(), item.getNif(), item.getName(), item.getSurname(), item.getPassword(), item.getEmail(), null)); 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; PrimaryHealthCareCenterTO phc = null;
if (fd.getPrimaryHealthCareCenter() != 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); FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
return fdTO; return fdTO;
@@ -144,7 +199,7 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
MedicalSpecialtyTO ms = null; MedicalSpecialtyTO ms = null;
if (sd.getMedicalSpecialty() != 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); SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms);
return sdTO; return sdTO;

View File

@@ -1,6 +1,7 @@
package ejb.common; package ejb.common;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
@@ -18,17 +19,23 @@ import TO.SpecialistDoctorTO;
@Local @Local
public interface CommonFacadeLocal { 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; public PatientTO retrievePatient(int patientId) throws Exception;

View File

@@ -1,6 +1,7 @@
package ejb.common; package ejb.common;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import javax.ejb.Remote; import javax.ejb.Remote;
@@ -18,17 +19,23 @@ import TO.SpecialistDoctorTO;
@Remote @Remote
public interface CommonFacadeRemote { 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; 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) public SpecialistDoctorTO registerSpecialistDoctor(int id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty)
throws Exception { throws Exception {
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName()); MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getId());
if (ms == null) { if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName()); 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 { public FamilyDoctorTO registerFamilyDoctor(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) throws Exception {
FamilyDoctorTO fdTO = null; FamilyDoctorTO fdTO = null;
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName()); PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getId());
if (phcC == null) { if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + cap.getName()); 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)); 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) { if (ms == null) {
throw new Exception("No se encuentra la especialidad médica con identificador: " + specialty.getName()); 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)); 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) { if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + phcTO.getName()); 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)); 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) { if (phcC == null) {
throw new Exception("No se encuentra el centro de atención primaria con identificador: " + newCenter.getName()); 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 java.util.Collection;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
@@ -26,6 +27,7 @@ public class FamilyDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
@Column(updatable = false)
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id; private Integer id;
private String nif; private String nif;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
package managedbean.profile; package managedbean.profile;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
@@ -11,6 +11,7 @@ import javax.inject.Named;
import TO.FamilyDoctorTO; import TO.FamilyDoctorTO;
import TO.LoggedUserTO; import TO.LoggedUserTO;
import TO.PatientTO; import TO.PatientTO;
import common.Constants;
import common.UserType; import common.UserType;
import managedbean.common.ManagedBeanBase; import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils; import managedbean.common.SessionUtils;
@@ -28,7 +29,8 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
private int id; private int id;
private FamilyDoctorTO currentFamilyDoctor; private FamilyDoctorTO currentFamilyDoctor;
private FamilyDoctorTO newFamilyDoctor; private FamilyDoctorTO newFamilyDoctor;
private Collection<FamilyDoctorTO> familyDoctorList; private List<FamilyDoctorTO> familyDoctorList;
private String lastUIQuery;
public ChangeFamilyDoctorMBean() { public ChangeFamilyDoctorMBean() {
@@ -38,6 +40,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
public void init() { public void init() {
// Recuperamos el usuario logeado actual // Recuperamos el usuario logeado actual
LoggedUserTO usr = null; LoggedUserTO usr = null;
this.lastUIQuery = "";
try { try {
usr = SessionUtils.getloggedOnUser(); usr = SessionUtils.getloggedOnUser();
@@ -48,7 +51,7 @@ public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializ
this.id = Integer.valueOf(usr.getId()); this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.PATIENT) { 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); PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id);
this.setCurrentFamilyDoctor(pat.getFamilyDoctor()); 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; 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() { public int getId() {
return id; return id;
} }

View File

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

View File

@@ -19,6 +19,7 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import common.Constants;
import common.UserType; import common.UserType;
import managedbean.common.ManagedBeanBase; import managedbean.common.ManagedBeanBase;
import managedbean.common.ValidationUtils; import managedbean.common.ValidationUtils;
@@ -44,14 +45,16 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
private String password; private String password;
private String email; private String email;
private boolean registered; private boolean registered;
private String lastUIQueryPH;
private String lastUIQueryMS;
// private HashMap<String, String> userTypes; // private HashMap<String, String> userTypes;
private List<UserType> userTypes; private List<UserType> userTypes;
private String userType; private String userType;
private PrimaryHealthCareCenterTO primaryHealthCareCenter; private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private MedicalSpecialtyTO medicalSpecialty; private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList; private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList; private List<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
public RegisterUserMBean() { public RegisterUserMBean() {
@@ -64,11 +67,13 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
this.userTypes.add(UserType.FAMILY_DOCTOR); this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR); this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.registered = false; this.registered = false;
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
this.userType = UserType.PATIENT.name(); this.userType = UserType.PATIENT.name();
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities(); this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs(); this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
} }
public List<UserType> getUserTypes() { 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; return medicalSpecialitiesList;
} }
public Collection<PrimaryHealthCareCenterTO> getPhcList() { public List<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList; 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() { public boolean isPatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT); return (UserType.valueOf(this.userType) == UserType.PATIENT);
} }

View File

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