This commit is contained in:
Roberto Orden Erena
2019-12-15 19:45:22 +01:00
40 changed files with 456 additions and 965 deletions

View File

@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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">
<ui:composition template="./header.xhtml">
<ui:define name="content">
@@ -9,24 +10,29 @@
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2" />
<div class="ui-g-8 ui-md-8">
<p:panel id="ErrorPanel" header="Se ha producido un error inesperado">
<p:panel id="ErrorPanel">
<f:facet name="header">
<p:outputLabel value="Se ha producido un error de autorización" rendered="#{param.type == 'auth'}" />
<p:outputLabel value="Se ha producido un error desconocido" rendered="#{param.type == null}" />
</f:facet>
<div class="ui-g ui-fluid">
<div class="ui-g-12">La acción que estaba realizando a causado un error inesperado en el sistema. A continuación podrá ver un descripción detallada del error para que
pueda comunicarlo al equipo de soporte.</div>
<div class="ui-g-12" style="font-weight: bold;">
Descripción del error
</div>
<div class="ui-g-12">
<h:messages fatalClass="ErrorMessage" showDetail="true" showSummary="true" globalOnly="true" />
<!-- <p:outputLabel value="No está autorizado a acceder a la página solicitada. Por favor, utilice el menú principal de la aplicación." rendered="#{param.type == 'auth'}" /> -->
<!-- <p:outputLabel value="Se ha producido un error desconocido. Si vuelve a repetirse, por favor, contacte con el equipo de soporte." rendered="#{param.type == null}" /> -->
</div>
<div class="ui-g-5" />
<div class="ui-g-2">
<div class="ui-g-12">
<p:messages id="errorMessage" showDetail="true" closable="false" autoupdate="true" showSummary="true" showIcon="true" />
</div>
<div class="ui-g-4" />
<div class="ui-g-4">
<p:button value="Ir a la página principal" outcome="home" icon="pi pi-home" />
</div>
<div class="ui-g-5" />
<div class="ui-g-4" />
</div>
</p:panel>
</div>

View File

@@ -33,7 +33,7 @@
</div>
<hr />
<div id="menuDiv">
<p:growl id="messages" sticky="false" showDetail="true" life="15000" />
<p:growl id="messages" globalOnly="true" sticky="false" showDetail="true" life="15000" />
<p:ajaxStatus style="width:32px; height:32px; position:fixed; right:32px; bottom:32px">
<f:facet name="start">
<i id="loginSpin" class="pi pi-spin pi-spinner" style="font-size: 3em"></i>

View File

@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Añadir un nuevo médico de familia">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Añadir un nuevo paciente">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Añadir un nuevo médico especialista">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define> </ui:composition>
</html>

View File

@@ -47,7 +47,7 @@
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}" />
<h:outputText value="#{fd.professionalNumber}" />
</p:column>
<p:column headerText="Nombre">
<h:outputText value="#{fd.name}" />

View File

@@ -61,7 +61,7 @@
*/
}
</h:outputScript>
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:messages id="mesgs" globalOnly="true" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
@@ -83,10 +83,12 @@
<p:outputLabel value="NIF:" for="nif" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="nif" value="#{RegisterUser.nif}" validator="nifValidator" maxlength="20" required="true" requiredMessage="Por favor, indque su NIF" />
<p:inputText id="nif" value="#{RegisterUser.nif}" validator="nifValidator" maxlength="20" required="true" requiredMessage="Por favor, indque su NIF">
<p:ajax event="blur" update="nifmsg" listener="#{RegisterUser.hadleNIFValueChange}" />
</p:inputText>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="nif" display="text" showDetail="true" showSummary="true" />
<p:message id="nifmsg" for="nif" />
</div>
<div class="ui-g-2 ui-md-2">
@@ -114,12 +116,12 @@
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="email" value="#{RegisterUser.email}" required="true" maxlength="120" validator="emailValidator"
validatorMessage="La dirección #{RegisterUser.email} no es válida" requiredMessage="Por favor, especifique su correo electrónico">
validatorMessage="La dirección de correo electrónico #{RegisterUser.email} no es válida" requiredMessage="Por favor, especifique su correo electrónico">
<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
</p:inputText>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="email" display="text" showDetail="true" showSummary="true" />
<p:message for="email" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Contraseña" for="password" />
@@ -148,8 +150,8 @@
<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">
<p:autoComplete id="selPHC" dropdown="true" required="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}" />
@@ -169,7 +171,7 @@
<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"
<p:autoComplete id="selMS" dropdown="true" required="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">

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Consultar datos de médico de familia">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Consultar datos de paciente">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Consultar datos de especialista">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Actualizar médico de familia">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Actualizar paciente">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -31,7 +31,7 @@
<p:outputLabel value="Número de Profesional:" rendered="#{UpdateProfile.userTypeDoctor}" for="cipCode" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="cipCode" value="#{UpdateProfile.cipCode}" disabled="true" required="true" requiredMessage="Es necesario un código de identificación" />
<p:inputText id="cipCode" value="#{UpdateProfile.cipCode}" readonly="true" required="true" requiredMessage="Es necesario un código de identificación" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="cipCode" display="text" />
@@ -41,10 +41,12 @@
<p:outputLabel value="NIF:" for="nif" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="nif" value="#{UpdateProfile.nif}" validator="nifValidator" required="true" maxlength="50" requiredMessage="Por favor, indque su NIF" />
<p:inputText id="nif" value="#{UpdateProfile.nif}" validator="nifValidator" required="true" maxlength="50" requiredMessage="Por favor, indque su NIF">
<p:ajax event="blur" update="nifmsg" listener="#{UpdateProfile.hadleNIFValueChange}" />
</p:inputText>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="nif" display="text" />
<p:message id="nifmsg" for="nif" display="text" />
</div>
<div class="ui-g-2 ui-md-2">
@@ -71,8 +73,8 @@
<p:outputLabel value="Correo electrónico:" for="email" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="email" value="#{UpdateProfile.email}" required="true" maxlength="120" validator="emailValidator" validatorMessage="La dirección #{RegisterUser.email} no es válida"
requiredMessage="Por favor, especifique su correo electrónico">
<p:inputText id="email" value="#{UpdateProfile.email}" required="true" maxlength="120" validator="emailValidator"
validatorMessage="La dirección #{RegisterUser.email} no es válida" requiredMessage="Por favor, especifique su correo electrónico">
<f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
</p:inputText>
</div>
@@ -92,7 +94,7 @@
<p:outputLabel value="Nueva contraseña" for="password" />
</div>
<div class="ui-g-4 ui-md-4">
<p:password id="password" value="#{UpdateProfile.password}" match="passwordRepeat" required="false" maxlength="100" requiredMessage="Por favor, especifique una contraseña"
<p:password id="password" value="#{UpdateProfile.password}" match="passwordRepeat" required="false" maxlength="100" requiredMessage="Por favor, especifique una contraseña"
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>
@@ -103,7 +105,7 @@
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
</div>
<div class="ui-g-4">
<p:password id="passwordRepeat" value="#{UpdateProfile.password}" required="false" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
<p:password id="passwordRepeat" value="#{UpdateProfile.password}" required="false" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
</div>
<div class="ui-g-6">
<p:message for="passwordRepeat" />
@@ -156,11 +158,11 @@
<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}"
<p:autoComplete id="FamilyDoc" readonly="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}" />
<h:outputText value="#{fd.professionalNumber}" />
</p:column>
<p:column headerText="Nombre">
<h:outputText value="#{fd.name}" />

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="DatosPersonales" header="Consultar médico especialista">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</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="Guardar" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

@@ -86,7 +86,7 @@ public class FamilyDoctorTO implements Serializable {
}
public String getDisplayName() {
return String.format("[%d] %s %s", this.id, this.name, this.surname);
return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname);
}
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {

View File

@@ -90,6 +90,10 @@ public class PatientTO implements Serializable {
this.id = id;
}
public String getDisplayName() {
return String.format("[%s] %s %s", this.personalIdentificationCode, this.name, this.surname);
}
public FamilyDoctorTO getFamilyDoctor() {
return familyDoctor;
}

View File

@@ -85,6 +85,10 @@ public class SpecialistDoctorTO implements Serializable {
this.id = id;
}
public String getDisplayName() {
return String.format("[%s] %s %s", this.professionalNumber, this.name, this.surname);
}
public MedicalSpecialtyTO getMedicalSpecialty() {
return medicalSpecialty;
}

View File

@@ -161,114 +161,153 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
MedicalSpecialtyTO msTO = null;
if (ms != null) {
msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
}
return msTO;
}
public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
PrimaryHealthCareCenterTO phcTO = null;
if (phc != null) {
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
}
return phcTO;
}
public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps) {
SpecialistDoctorTO sdTO = null;
if (sd != null) {
MedicalSpecialtyJPA ms = null;
if (nestedProps > 0)
ms = sd.getMedicalSpecialty();
nestedProps--;
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms));
nestedProps--;
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(),
this.getPOJOforMedicalSpecialtyJPA(ms));
}
return sdTO;
}
public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps) {
FamilyDoctorTO fdTO = null;
if (fd != null) {
PrimaryHealthCareCenterJPA phc = null;
if (nestedProps > 0)
phc = fd.getPrimaryHealthCareCenter();
nestedProps--;
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), this.getPOJOforPrimaryHealthCareCenterJPA(phc));
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(),
this.getPOJOforPrimaryHealthCareCenterJPA(phc));
}
return fdTO;
}
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
PatientTO paTO = null;
if (pat != null) {
FamilyDoctorJPA fd = null;
if (nestedProps > 0)
fd = pat.getFamilyDoctor();
nestedProps--;
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(),
this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
}
return paTO;
}
public PatientTO findPatientById(int patientId) {
// Recuperamos propiedades anidadas 1 nivel!
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
}
public PatientJPA findPatientByCode(String code) {
public PatientTO findPatientByCode(String code) {
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
query.setMaxResults(1);
query.setParameter("code", code);
List<PatientJPA> results = query.getResultList();
if (results.size() > 0)
return results.get(0);
return this.getPOJOforPatientJPA(results.get(0), 1);
else
return null; }
return null;
}
public PatientTO findPatientByNif(String searchValue) {
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.nif=:nif", PatientJPA.class);
query.setMaxResults(1);
query.setParameter("nif", searchValue);
List<PatientJPA> results = query.getResultList();
if (results.size() > 0)
return this.getPOJOforPatientJPA(results.get(0), 1);
else
return null;
}
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
}
public FamilyDoctorJPA findFamilyDoctorByCode(String code) {
public FamilyDoctorTO findFamilyDoctorByCode(String code) {
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
query.setParameter("code", code);
List<FamilyDoctorJPA> results = query.getResultList();
if (results.size() > 0)
return results.get(0);
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
else
return null;
}
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue) {
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif", FamilyDoctorJPA.class);
query.setMaxResults(1);
query.setParameter("nif", searchValue);
List<FamilyDoctorJPA> results = query.getResultList();
if (results.size() > 0)
return this.getPOJOforFamilyDoctorJPA(results.get(0), 1);
else
return null;
}
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
}
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code) {
public SpecialistDoctorTO findSpecialistDoctorByCode(String code) {
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
query.setParameter("code", code);
List<SpecialistDoctorJPA> results = query.getResultList();
if (results.size() > 0)
return results.get(0);
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
else
return null;
}
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue) {
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif", SpecialistDoctorJPA.class);
query.setMaxResults(1);
query.setParameter("nif", searchValue);
List<SpecialistDoctorJPA> results = query.getResultList();
if (results.size() > 0)
return this.getPOJOforSpecialistDoctorJPA(results.get(0), 1);
else
return null;
}

View File

@@ -44,15 +44,21 @@ public interface CommonFacadeLocal {
public PatientTO findPatientById(int patientId);
public PatientJPA findPatientByCode(String code);
public PatientTO findPatientByCode(String code);
public PatientTO findPatientByNif(String searchValue);
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
public FamilyDoctorTO findFamilyDoctorByCode(String code);
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);

View File

@@ -42,14 +42,20 @@ public interface CommonFacadeRemote {
public PatientTO findPatientById(int patientId);
public PatientJPA findPatientByCode(String code);
public PatientTO findPatientByCode(String code);
public PatientTO findPatientByNif(String searchValue);
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
public FamilyDoctorTO findFamilyDoctorByCode(String code);
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
}

View File

@@ -41,7 +41,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
}
private String getNextPersonalIdentificationCode() {
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
Query q = entman.createNativeQuery("select nextval('myhealth.codigoidentificacionpaciente')");
return Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX.concat(String.valueOf(q.getSingleResult()));
}

View File

@@ -5,15 +5,15 @@ import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import TO.FamilyDoctorTO;
import TO.LoggedUserTO;
import TO.PatientTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.HashUtils;
import common.UserType;
import ejb.common.CommonFacadeLocal;
import jpa.AdministratorJPA;
import jpa.FamilyDoctorJPA;
import jpa.PatientJPA;
import jpa.SpecialistDoctorJPA;
/**
*
@@ -29,7 +29,7 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
@EJB
CommonFacadeLocal commonServices;
/**
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
* datos del usuario logeado.
@@ -61,20 +61,20 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
if (userCode.startsWith(Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX)) {
// Si el identificador de usuario es de tipo paciente, intentamos realizar el
// login.
PatientJPA pat = this.commonServices.findPatientByCode(userCode);
PatientTO pat = this.commonServices.findPatientByCode(userCode);
if (pat != null) {
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
}
} else if (userCode.startsWith(Constants.PROFESSIONAL_NUMBER_PREFIX)) {
// Si el identificador de usuario es de tipo profesional, intentamos realizar el
// login, primero como médico de familia, después como especialista
FamilyDoctorJPA fd = this.commonServices.findFamilyDoctorByCode(userCode);
FamilyDoctorTO fd = this.commonServices.findFamilyDoctorByCode(userCode);
if (fd != null) {
usr = new LoggedUserTO(String.valueOf(fd.getId()), fd.getName(), fd.getPassword(), UserType.FAMILY_DOCTOR);
} else {
// No era un código de médico de familia, intenamos logearlo como especialista
SpecialistDoctorJPA sd = this.commonServices.findSpecialistDoctorByCode(userCode);
SpecialistDoctorTO sd = this.commonServices.findSpecialistDoctorByCode(userCode);
if (sd != null) {
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);

View File

@@ -2,7 +2,11 @@
package managedbean.common;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -14,6 +18,11 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.primefaces.model.menu.DefaultSeparator;
import org.primefaces.model.menu.DefaultSubMenu;
import common.UserType;
@WebFilter(filterName = "AuthFilter", urlPatterns = { "*.xhtml" })
public class AuthorizationFilter implements Filter {
@@ -34,11 +43,101 @@ public class AuthorizationFilter implements Filter {
HttpSession ses = req.getSession(false);
String reqURI = req.getRequestURI();
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0
|| reqURI.contains("javax.faces.resource") || SessionUtils.isLogedIn(ses) == true)
// Para recursos publicos permitimos el acceso
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/profile/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0
|| reqURI.indexOf("/error.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0 || reqURI.contains("javax.faces.resource")) {
chain.doFilter(request, response);
else
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
return;
}
// Si el usuario está logeado comprobamos si está autorizado a ver la página
// solicitada.
if (SessionUtils.isLogedIn(ses) == true) {
UserType tipoUsuario = SessionUtils.getUserType(ses);
boolean authorized = false;
switch (tipoUsuario) {
case ADMINISTRATOR:
if (reqURI.indexOf("/systemAdmin/ManageSpecialties") > 0)
authorized = true;
if (reqURI.indexOf("/systemAdmin/ManageHealthCareCenters") > 0)
authorized = true;
if (reqURI.indexOf("/systemAdmin/ListDoctorsByCenter") > 0)
authorized = true;
if (reqURI.indexOf("/visit/VisitView") > 0)
authorized = true;
if (reqURI.indexOf("/visit/UpdateVisit") > 0)
authorized = true;
break;
case PATIENT:
if (reqURI.indexOf("/visit/VisitView") > 0)
authorized = true;
if (reqURI.indexOf("/visit/AddVisit") > 0)
authorized = true;
if (reqURI.indexOf("/visit/UpdateVisit") > 0)
authorized = true;
if (reqURI.indexOf("/visit/CancelVisit") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/AddQuestion") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/SearchSpecialistBySpecialty") > 0)
authorized = true;
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
authorized = true;
if (reqURI.indexOf("/profile/ChangeFamilyDoctor") > 0)
authorized = true;
break;
case FAMILY_DOCTOR:
if (reqURI.indexOf("/visit/VisitView") > 0)
authorized = true;
if (reqURI.indexOf("/visit/VisitAddResult") > 0)
authorized = true;
if (reqURI.indexOf("/visit/VisitViewSchedules") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/AnswerQuestion") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/PendingQuestions") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
authorized = true;
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
authorized = true;
if (reqURI.indexOf("/profile/ChangePrimaryHealthCareCenter") > 0)
authorized = true;
break;
case SPECIALIST_DOCTOR:
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/AddMedicalTest") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/AddImageToMedicalTest") > 0)
authorized = true;
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
authorized = true;
break;
}
if (authorized == true) {
chain.doFilter(request, response);
return;
} else {
SessionUtils.addMessage(ses, FacesMessage.SEVERITY_ERROR, "No está autorizado a acceder a la página solicitada. Por favor, utilice el menú principal de la aplicación.", String.format("Se ha producido una expción de autorización, su usuario no está autorizado a acceder a la página: (%s).", reqURI));
resp.sendRedirect(req.getContextPath() + "/error.xhtml?type=auth");
return;
}
}
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
} catch (Exception e) {
System.out.println(e.getMessage());
}

View File

@@ -95,17 +95,29 @@ public class ManagedBeanBase {
protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) {
FacesContext context = FacesContext.getCurrentInstance();
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
this.addFacesMessage(FacesContext.getCurrentInstance(), null, severity, summary, detail);
context.getExternalContext().getFlash().setKeepMessages(true);
}
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
this.addFacesMessage(FacesContext.getCurrentInstance(), null, severity, summary, detail);
}
protected void addFacesMessage(String clientId, FacesMessage.Severity severity, String summary, String detail) {
this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, severity, summary, detail);
}
protected void addFacesMessage(FacesContext context, FacesMessage.Severity severity, String summary, String detail) {
context.addMessage(null, new FacesMessage(severity, summary, detail));
protected void addFacesMessage(FacesContext context, String clientId, FacesMessage.Severity severity, String summary, String detail) {
this.addFacesMessage(context, clientId, new FacesMessage(severity, summary, detail));
}
protected void addFacesMessage(FacesMessage facesMsg, String clientId) {
this.addFacesMessage(FacesContext.getCurrentInstance(), clientId, facesMsg);
}
protected void addFacesMessage(FacesContext context, String clientId, FacesMessage facesMsg) {
context.addMessage(clientId, facesMsg);
}
protected void manageException(Exception ex) {

View File

@@ -114,9 +114,9 @@ public class MenuMBean implements Serializable {
subMenu = new DefaultSubMenu("Gestionar perfil", "fa fa-gears");
if (SessionUtils.isLogedIn() == false) {
subMenu.addElement(createMenuItem("Registro de usuario", "fa fa-user-plus", "/profile/RegisterUser", null));
subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null));
subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null));
subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null));
// subMenu.addElement(createMenuItem("Registro de paciente", "fa fa-user-plus", "/profile/AddPatient", null));
// subMenu.addElement(createMenuItem("Registro de médico", "fa fa-user-md", "/profile/AddFamilyDoctor", null));
// subMenu.addElement(createMenuItem("Registro de especialista", "fa fa-user-md", "/profile/AddSpecialistDoctor", null));
model.addElement(subMenu);
} else {

View File

@@ -1,6 +1,7 @@
package managedbean.common;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
@@ -14,6 +15,7 @@ public class SessionUtils {
public static final String SESSION_VAR_USERID = "userId";
public static final String SESSION_VAR_USERTYPE = "userType";
public static final String SESSION_VAR_USER = "loggedOnUser";
public static final String SESSION_VAR_MESSAGE = "facesMessage";
public static HttpSession getSession() {
FacesContext ctx = FacesContext.getCurrentInstance();
@@ -47,7 +49,7 @@ public class SessionUtils {
public static boolean isLogedIn() {
return isLogedIn(getSession());
}
public static boolean isLogedIn(HttpSession session) {
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
return true;
@@ -70,15 +72,18 @@ public class SessionUtils {
else
return "";
}
public static UserType getUserType() {
HttpSession session = getSession();
return getUserType(getSession());
}
public static UserType getUserType(HttpSession session) {
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE) != null)
return UserType.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_USERTYPE));
else
return null;
}
}
public static LoggedUserTO getloggedOnUser() {
HttpSession session = getSession();
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USER) != null)
@@ -86,4 +91,24 @@ public class SessionUtils {
else
return null;
}
public static FacesMessage getMessage() {
HttpSession session = getSession();
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE) != null) {
FacesMessage msg = FacesMessage.class.cast(session.getAttribute(SessionUtils.SESSION_VAR_MESSAGE));
session.removeAttribute(SessionUtils.SESSION_VAR_MESSAGE);
return msg;
} else
return null;
}
public static void addMessage(FacesMessage.Severity severity, String summary, String detail) {
addMessage(getSession(), severity, summary, detail);
}
public static void addMessage(HttpSession session, FacesMessage.Severity severity, String summary, String detail) {
if (session != null)
session.setAttribute(SessionUtils.SESSION_VAR_MESSAGE, new FacesMessage(severity, summary, detail));
}
}

View File

@@ -1,5 +1,11 @@
package managedbean.common;
import TO.FamilyDoctorTO;
import TO.PatientTO;
import TO.SpecialistDoctorTO;
import common.UserType;
import ejb.common.CommonFacadeRemote;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
@@ -47,4 +53,51 @@ public class ValidationUtils {
return false;
}
/**
* Comprueba si un NIF existe para un tipo de usuario. * No se permite que el
* mismo NIF esté registrado como médico de familia y como especialista. * Se
* permite que el mismo NIF esté registrado como paciente y como médico (de
* familia o especialista)
*
* @param remoteSvc Servicio Remoto para recuperar datos.
* @param userType Tipo de usuario a comprobar
* @param nif NIF a comprobar.
* @param id Parámetro opcional, id del usuario actual (si encuentra el
* mismo nif y el usuario coincide no se devuelve la
* coincidencia)
* @return true si el NIF ya estaba registrado para un usuario diferente.
*/
public static boolean checkIfNifAlreadyRegistered(CommonFacadeRemote remoteSvc, UserType userType, String nif, Integer id) {
boolean nifExists = false;
switch (userType) {
case ADMINISTRATOR:
break;
case FAMILY_DOCTOR:
case SPECIALIST_DOCTOR:
FamilyDoctorTO fd = remoteSvc.findFamilyDoctorByNif(nif);
if (fd == null) {
// Si el nif no está en uso para un médico de familia, reivsamos si está en uso
// para los especialistas
SpecialistDoctorTO sd = remoteSvc.findSpecialistDoctorByNif(nif);
if (sd != null && (id == null || fd.getId() != id))
nifExists = true;
} else if (id == null || fd.getId() != id)
// Si se trata de un usuario diferente, entonces está repetido
nifExists = true;
break;
case PATIENT:
PatientTO pat = remoteSvc.findPatientByNif(nif);
// Si se trata de un usuario diferente, entonces está repetido
if (pat != null && (id == null || pat.getId() != id))
nifExists = true;
break;
}
return nifExists;
}
}

View File

@@ -5,6 +5,7 @@ import java.util.List;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.inject.Named;
import common.UserType;
@@ -16,7 +17,7 @@ import common.UserType;
*/
@Named("home")
@RequestScoped
public class homeMBean implements Serializable {
public class homeMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
private boolean isLogedIn;
@@ -31,6 +32,12 @@ public class homeMBean implements Serializable {
userName = SessionUtils.getUserName();
userId = SessionUtils.getUserId();
userType = SessionUtils.getUserType();
FacesMessage message = SessionUtils.getMessage();
if (message != null) {
this.addFacesMessage(message, null);
}
}
public List<Theme> getThemes() {

View File

@@ -1,29 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("AddFamilyDoctorMBean")
@RequestScoped
public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public AddFamilyDoctorMBean() {
}
}

View File

@@ -1,112 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import managedbean.common.ManagedBeanBase;
/**
* ManagedBEan que gestiona la edición y actualización de una especialidad
* médica.
*
* @author mark
*
*/
@Named("addPatientMBean")
@RequestScoped
public class AddPatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String nif;
private String name;
private String surname;
private String password;
private String passwordRepeat;
private String email;
private String primaryHealthCareCenter;
private String medicalSpecialty;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public AddPatientMBean() {
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNif() {
return nif;
}
public void setNif(String nif) {
this.nif = nif;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public void save() {
FacesMessage msg;
try {
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
} catch (Exception e) {
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Se ha producido un error inesperado: " + e.getLocalizedMessage());
}
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public String getPasswordRepeat() {
return passwordRepeat;
}
public void setPasswordRepeat(String passwordRepeat) {
this.passwordRepeat = passwordRepeat;
}
}

View File

@@ -1,34 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named( "AddSpecialistDoctorMBean")
@RequestScoped
public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public AddSpecialistDoctorMBean() {
}
}

View File

@@ -127,6 +127,11 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
}
return this.medicalSpecialitiesList;
}
public void hadleNIFValueChange() {
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true)
this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
}
public boolean isPatient() {
return (this.userType == UserType.PATIENT);
@@ -199,6 +204,10 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
error++;
}
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, null) == true) {
this.addFacesMessage("frmRegisterUser:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
error++;
}
if (error == 0) {
try {

View File

@@ -1,50 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named( "ShowFamilyDoctorMBean")
@RequestScoped
public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public ShowFamilyDoctorMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}

View File

@@ -1,49 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("ShowPatientMBean")
@RequestScoped
public class ShowPatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public ShowPatientMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}

View File

@@ -1,50 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named( "ShowSpecialistDoctorMBean")
@RequestScoped
public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public ShowSpecialistDoctorMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}

View File

@@ -1,49 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("UpdateFamilyDoctorMBean")
@RequestScoped
public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public UpdateFamilyDoctorMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}

View File

@@ -1,49 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("UpdatePatientMBean")
@RequestScoped
public class UpdatePatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public UpdatePatientMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}

View File

@@ -172,6 +172,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
return this.medicalSpecialitiesList;
}
public void hadleNIFValueChange() {
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true)
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
}
public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList;
}
@@ -261,6 +266,10 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
error++;
}
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) {
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
error++;
}
if (changePassword == true) {
// el usuario queire cambiar el password Comprobamos que el password
// especificado coincide con el guardado

View File

@@ -1,49 +0,0 @@
package managedbean.profile;
import java.io.Serializable;
import java.util.Properties;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("UpdateSpecialistDoctorMBean")
@RequestScoped
public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private ProfileFacadeRemote remoteManager;
/**
* Constructor. Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
public UpdateSpecialistDoctorMBean() throws Exception {
initializeAdminFacadeRemote();
}
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
private void initializeAdminFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
}
}