Merge branch 'master' into rorden

This commit is contained in:
Roberto Orden Erena
2019-12-14 11:23:42 +01:00
39 changed files with 1348 additions and 644 deletions

View File

@@ -48,7 +48,7 @@
<target name="compileEjb" depends="init"> <target name="compileEjb" depends="init">
<copy file="${sourcesrc}/META-INF/persistence.xml" todir="${buildjar}/META-INF" /> <copy file="${sourcesrc}/META-INF/persistence.xml" todir="${buildjar}/META-INF" />
<copy file="${sourcesrc}/log4j.properties" todir="${buildjar}" /> <copy file="${sourcesrc}/log4j.properties" todir="${buildjar}" />
<javac srcdir="${sourcesrc}" destdir="${buildjar}" includes="ejb/**/*.java, jpa/**/*.java, TO/**/*.java" classpathref="jboss.classpath" includeantruntime="true" /> <javac srcdir="${sourcesrc}" destdir="${buildjar}" includes="ejb/**/*.java, jpa/**/*.java, TO/**/*.java, common/**/*.java" classpathref="jboss.classpath" includeantruntime="true" />
</target> </target>
<!-- Update the EJB jar file and create if not exist --> <!-- Update the EJB jar file and create if not exist -->
@@ -70,7 +70,8 @@
<delete verbose="true" dir="${buildwar}/WEB-INF/classes/ejb" /> <delete verbose="true" dir="${buildwar}/WEB-INF/classes/ejb" />
<delete verbose="true" dir="${buildwar}/WEB-INF/classes/jpa" /> <delete verbose="true" dir="${buildwar}/WEB-INF/classes/jpa" />
<delete verbose="true" dir="${buildwar}/WEB-INF/classes/TO" /> <delete verbose="true" dir="${buildwar}/WEB-INF/classes/TO" />
</target> <delete verbose="true" dir="${buildwar}/WEB-INF/classes/common" />
</target>
<!-- <war destfile="${build.dir}/CrunchifyRESTJerseyExample.war" webxml="WebContent/WEB-INF/web.xml"> --> <!-- <war destfile="${build.dir}/CrunchifyRESTJerseyExample.war" webxml="WebContent/WEB-INF/web.xml"> -->
<!-- <classes dir="${build.dir}" /> --> <!-- <classes dir="${build.dir}" /> -->
<!-- <lib dir="${lib.dir}"> --> <!-- <lib dir="${lib.dir}"> -->
@@ -79,7 +80,7 @@
<!-- Update the WAR file and create if not exist --> <!-- Update the WAR file and create if not exist -->
<target name="deployWar" depends="compileWar"> <target name="deployWar" depends="compileWar">
<jar jarfile="${dist}/MyHealth.war" basedir="${buildwar}" excludes="/WEB-INF/classes/ejb/*.*, /WEB-INF/classes/jpa/*.*, /WEB-INF/classes/TO/*.*" update="yes" /> <jar jarfile="${dist}/MyHealth.war" basedir="${buildwar}" excludes="/WEB-INF/classes/ejb/*.*, /WEB-INF/classes/jpa/*.*, /WEB-INF/classes/TO/*.*, /WEB-INF/classes/common/*.*" update="yes" />
</target> </target>
<!-- Update the application ear file and created if not exist --> <!-- Update the application ear file and created if not exist -->

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

@@ -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">
@@ -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,190 +2,205 @@
<!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-12">
Enhorabuena
<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}" />
<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.
</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.cipCode}" />
</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) {
/*
if(args.specs) {
$('#panCentros').slideUp();
$('#panEspecialidades').slideDown();
}
else if (args.caps) {
$('#panEspecialidades').slideUp();
$('#panCentros').slideDown();
} else if (args.pats) {
$('#panCentros').slideUp();
$('#panEspecialidades').slideUp();
}
*/
}
</h:outputScript>
<p:messages id="mesgs" 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 ui-fluid">
<div class="ui-g-2 ui-md-2">
<div class="ui-g-12"> <p:outputLabel value="Tipo de usuario:" for="selUsertype" />
Enhorabuena
<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}" />
<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.
</div> </div>
<div class="ui-g-6 ui-md-6">
<div class="ui-g-12"> <p:selectOneButton id="selUsertype" value="#{RegisterUser.userType}" required="true" unselectable="false" requiredMessage="Debe especificar un tipo de usuario">
<p:outputLabel value="Su Código de Identificación Personal (CIP) es el siguiente:" rendered="#{RegisterUser.patient}" /> <f:selectItems value="#{RegisterUser.availableUserTypes}" var="item" itemLabel="#{item.userTypename}" />
<p:outputLabel value="Número de Profesional es el siguiente:" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" /> <p:ajax listener="#{RegisterUser.onUserTypeChange}" update="panCombos" oncomplete="handleRequest(xhr, status, args)" />
</p:selectOneButton>
</div> </div>
<div class="ui-g-4 ui-md-4" />
<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>
</p:panel> </p:panel>
</div> <br />
<div class="ui-g-3 ui-md-3" /> <p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
</h:form> <div class="ui-g ui-fluid">
<h:form id="frmRegisterUser" rendered="#{not RegisterUser.registered}">
<h:outputScript>
function handleRequest(xhr, status, args) {
if(args.specs) {
$('#panCentros').slideUp();
$('#panEspecialidades').slideDown();
}
else if (args.caps) {
$('#panEspecialidades').slideUp();
$('#panCentros').slideDown();
} else {
$('#panCentros').slideUp();
$('#panEspecialidades').slideUp();
}
}
</h:outputScript>
<p:messages id="mesgs" 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">
<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="NIF:" for="nif" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{RegisterUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.familyDoctor}" <p:inputText id="nif" value="#{RegisterUser.nif}" validator="nifValidator" maxlength="20" required="true" requiredMessage="Por favor, indque su NIF" />
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:message for="nif" display="text" showDetail="true" showSummary="true" />
</div> </div>
</div>
<div id="panEspecialidades" 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="Especialidad médica:" for="selMS" /> <p:outputLabel value="Nombre:" for="name" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{RegisterUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.specialistDoctor}" <p:inputText id="name" value="#{RegisterUser.name}" required="true" maxlength="100" requiredMessage="Por favor, indique su nombre" />
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>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="selMS" /> <p:message for="name" />
</div> </div>
</div>
<div class="ui-g-12 ui-g-nopad"> <div class="ui-g-2 ui-md-2">
<div class="ui-g-4 ui-md-4"></div> <p:outputLabel value="Apellidos:" for="surname" />
<div class="ui-g-2 ui-md-2 "> </div>
<p:commandButton validateClient="true" value="Registrarse" ajax="false" update="frmRegisterUserResult, frmRegisterUser" action="#{RegisterUser.addNewUser}" icon="pi pi-check" /> <div class="ui-g-4 ui-md-4">
<p:inputText id="surname" value="#{RegisterUser.surname}" required="true" maxlength="100" 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" 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>
<div class="ui-g-6 ui-md-6">
<p:message for="email" display="text" showDetail="true" showSummary="true" />
</div> </div>
<div class="ui-g-2 ui-md-2"> <div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" /> <p: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" 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>
<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" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
</div>
<div class="ui-g-6">
<p:message for="passwordRepeat" />
</div> </div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</div>
</p:panel> <h:panelGroup id="panCombos" class="ui-g-12 nopadding" layout="block">
</h:form> <h:panelGroup class="ui-g-12 nopadding" layout="block" 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 layout="block" class="ui-g-12 nopadding" 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>
</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,21 +27,21 @@
<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="cipCode" />
<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="cipCode" />
</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="cipCode" value="#{UpdateProfile.cipCode}" disabled="true" required="true" requiredMessage="Es necesario un código de identificación" />
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="id" display="text" /> <p:message for="cipCode" display="text" />
</div> </div>
<div class="ui-g-2 ui-md-2"> <div class="ui-g-2 ui-md-2">
<p:outputLabel value="NIF:" for="nif" /> <p:outputLabel value="NIF:" for="nif" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:inputText id="nif" value="#{UpdateProfile.nif}" required="true" 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" />
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="nif" display="text" /> <p:message for="nif" display="text" />
@@ -51,7 +51,7 @@
<p:outputLabel value="Nombre:" for="name" /> <p:outputLabel value="Nombre:" for="name" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:inputText id="name" value="#{UpdateProfile.name}" required="true" requiredMessage="Por favor, indique su nombre" /> <p:inputText id="name" value="#{UpdateProfile.name}" required="true" maxlength="100" requiredMessage="Por favor, indique su nombre" />
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="name" /> <p:message for="name" />
@@ -61,7 +61,7 @@
<p:outputLabel value="Apellidos:" for="surname" /> <p:outputLabel value="Apellidos:" for="surname" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:inputText id="surname" value="#{UpdateProfile.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" /> <p:inputText id="surname" value="#{UpdateProfile.surname}" required="true" maxlength="100" requiredMessage="Por favor, indique sus apellidos" />
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="surname" /> <p:message for="surname" />
@@ -71,16 +71,19 @@
<p:outputLabel value="Correo electrónico:" for="email" /> <p:outputLabel value="Correo electrónico:" for="email" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:inputText id="email" value="#{UpdateProfile.email}" required="true" 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> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="email" /> <p:message for="email" display="text" showDetail="true" showSummary="true" />
</div> </div>
<div class="ui-g-2 ui-md-2"> <div class="ui-g-2 ui-md-2">
<p:outputLabel value="Contraseña anterior" for="oldpassword" /> <p:outputLabel value="Contraseña anterior" for="oldpassword" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:password id="oldpassword" value="#{UpdateProfile.oldPassword}" required="false" requiredMessage="Por favor, especifique su contraseña actual" maxlength="50" /> <p:password id="oldpassword" value="#{UpdateProfile.oldPassword}" required="false" maxlength="100" requiredMessage="Por favor, especifique su contraseña actual" />
</div> </div>
<div class="ui-g-6 ui-md-6"> <div class="ui-g-6 ui-md-6">
<p:message for="oldpassword" /> <p:message for="oldpassword" />
@@ -89,7 +92,7 @@
<p:outputLabel value="Nueva contraseña" for="password" /> <p:outputLabel value="Nueva contraseña" for="password" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-4 ui-md-4">
<p:password id="password" value="#{UpdateProfile.password}" match="passwordRepeat" required="false" requiredMessage="Por favor, especifique una contraseña" maxlength="50" <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" 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" /> validatorMessage="La contraseña y su verificación deben ser iguales" />
</div> </div>
@@ -100,48 +103,78 @@
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" /> <p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
</div> </div>
<div class="ui-g-4"> <div class="ui-g-4">
<p:password id="passwordRepeat" value="#{UpdateProfile.password}" required="false" requiredMessage="Por favor, escriba la verificación de su contraseña" maxlength="50" /> <p:password id="passwordRepeat" value="#{UpdateProfile.password}" required="false" maxlength="100" requiredMessage="Por favor, escriba la verificación de su contraseña" />
</div> </div>
<div class="ui-g-6"> <div class="ui-g-6">
<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 nopadding" 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 nopadding" 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 nopadding" 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

@@ -1,7 +1,12 @@
BODY{ BODY {
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
} }
.hide { .hide {
display: none; display: none;
}
.nopadding {
padding: 0 !important;
margin: 0 !important;
} }

View File

@@ -14,6 +14,7 @@ public class FamilyDoctorTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id; private Integer id;
private String professionalNumber;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -25,14 +26,15 @@ public class FamilyDoctorTO implements Serializable {
super(); super();
} }
public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) { public FamilyDoctorTO(Integer id, String pic, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phc) {
this.setId(id); this.id = id;
this.setNif(nif); this.professionalNumber = pic;
this.setName(name); this.nif = nif;
this.setSurname(surname); this.name = name;
this.setPassword(password); this.surname = surname;
this.setEmail(email); this.password = password;
this.setPrimaryHealthCareCenter(phc); this.email =email;
this.primaryHealthCareCenter = phc;
} }
public String getEmail() { public String getEmail() {
@@ -83,7 +85,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);
} }
@@ -95,4 +97,11 @@ public class FamilyDoctorTO implements Serializable {
this.primaryHealthCareCenter = primaryHealthCareCenter; this.primaryHealthCareCenter = primaryHealthCareCenter;
} }
public String getProfessionalNumber() {
return professionalNumber;
}
public void setProfessionalNumber(String professionalNumber) {
this.professionalNumber = professionalNumber;
}
} }

View File

@@ -60,8 +60,8 @@ public class LoggedUserTO implements Serializable {
return userType; return userType;
} }
public void setUserType(UserType userType) { public void setUserType(UserType value) {
this.userType = userType; this.userType = value;
} }
} }

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

@@ -16,6 +16,7 @@ public class PatientTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id; private Integer id;
private String personalIdentificationCode;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -30,14 +31,15 @@ public class PatientTO implements Serializable {
super(); super();
} }
public PatientTO(Integer id, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) { public PatientTO(Integer id, String pic, String nif, String name, String surname, String password, String email, FamilyDoctorTO familyDoc) {
this.setId(id); this.id = id;
this.setNif(nif); this.personalIdentificationCode = pic;
this.setName(name); this.nif = nif;
this.setSurname(surname); this.name = name;
this.setPassword(password); this.surname = surname;
this.setEmail(email); this.password = password;
this.setFamilyDoctor(familyDoc); this.email =email;
this.familyDoctor = familyDoc;
} }
public String getEmail() { public String getEmail() {
@@ -96,5 +98,11 @@ public class PatientTO implements Serializable {
this.familyDoctor = familyDoctor; this.familyDoctor = familyDoctor;
} }
public String getPersonalIdentificationCode() {
return personalIdentificationCode;
}
public void setPersonalIdentificationCode(String personalIdentificationCode) {
this.personalIdentificationCode = personalIdentificationCode;
}
} }

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

@@ -14,6 +14,7 @@ public class SpecialistDoctorTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id; private Integer id;
private String professionalNumber;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -25,14 +26,15 @@ public class SpecialistDoctorTO implements Serializable {
super(); super();
} }
public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) { public SpecialistDoctorTO(Integer id, String pic, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO medicalSpec) {
this.setId(id); this.id = id;
this.setNif(nif); this.professionalNumber = pic;
this.setName(name); this.nif = nif;
this.setSurname(surname); this.name = name;
this.setPassword(password); this.surname = surname;
this.setEmail(email); this.password = password;
this.setMedicalSpecialty(medicalSpec); this.email =email;
this.medicalSpecialty = medicalSpec;
} }
public String getEmail() { public String getEmail() {
@@ -91,4 +93,11 @@ public class SpecialistDoctorTO implements Serializable {
this.medicalSpecialty = medicalSpecialty; this.medicalSpecialty = medicalSpecialty;
} }
public String getProfessionalNumber() {
return professionalNumber;
}
public void setProfessionalNumber(String professionalNumber) {
this.professionalNumber = professionalNumber;
}
} }

View File

@@ -0,0 +1,12 @@
package common;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public class Constants {
public static final int MAX_ITEMS_AUTOCOMPLETE_SEARCH = 200;
public static final String PROFESSIONAL_NUMBER_PREFIX = "PRO#";
public static final String PERSONAL_IDENTIFICATION_CODE_PREFIX = "PAT#";
}

View File

@@ -1,10 +1,14 @@
package common; package common;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.xml.bind.DatatypeConverter; import javax.xml.bind.DatatypeConverter;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public class HashUtils { public class HashUtils {
public static String hashMD5(String stringValue) { public static String hashMD5(String stringValue) {

View File

@@ -0,0 +1,24 @@
package common;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public enum QuestionStatus {
ANSWERED("Respondida"), PENDING("Pendiente");
private String questionStatusName;
private QuestionStatus(String typeName) {
this.questionStatusName = typeName;
}
public String getQuestionStatusName() {
return questionStatusName;
}
public String getName() {
return this.name();
}
}

View File

@@ -0,0 +1,24 @@
package common;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public enum TestType {
MAGNETIC_RESONANCE_IMAGING("Imagen por Resonancia Magnética"), CT_SCAN("Tomografía Áxial Computerizada"), BLOOD_TEST("Análisis de sangre");
private String testTypeName;
private TestType(String typeName) {
this.testTypeName = typeName;
}
public String getTestTypeName() {
return testTypeName;
}
public String getName() {
return this.name();
}
}

View File

@@ -1,22 +1,24 @@
package common; package common;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public enum UserType { public enum UserType {
PATIENT("Paciente"), PATIENT("Paciente"), FAMILY_DOCTOR("Médico de familia"), SPECIALIST_DOCTOR("Médico especialista"), ADMINISTRATOR("Administrador");
FAMILY_DOCTOR("Médico de familia"),
SPECIALIST_DOCTOR("Médico especialista"),
ADMINISTRATOR("Administrador");
private String userTypename; private String userTypename;
private UserType (String userTypename){ private UserType(String userTypename) {
this.userTypename = userTypename; this.userTypename = userTypename;
}
public String getUserTypename() {
return userTypename;
}
public String getName() {
return this.name();
}
} }
public String getUserTypename() {
return userTypename;
}
public String getName() {
return this.name();
}
}

View File

@@ -0,0 +1,19 @@
package common;
import java.text.Normalizer;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public class Utils {
public static String stripAccents(String input) {
return input == null ? null : Normalizer.normalize(input, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
}
public static String normalizeTerm(String input) {
//return stripAccents(input).toLowerCase();
return input.toLowerCase();
}
}

View File

@@ -1,18 +1,22 @@
package ejb.common; package ejb.common;
import java.util.ArrayList; import java.util.ArrayList;
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 org.jboss.security.auth.spi.Users.User;
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 +32,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,114 +43,233 @@ 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.normalizeTerm(searchTerm);
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 item : allJPA) {
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription())); allSpecialities.add(this.getPOJOforMedicalSpecialtyJPA(item));
} }
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.normalizeTerm(searchTerm);
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 item : allJPA) {
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation())); allCAPs.add(this.getPOJOforPrimaryHealthCareCenterJPA(item));
} }
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.normalizeTerm(searchTerm);
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);
query.setMaxResults(pageSize); query.setMaxResults(pageSize);
} }
@SuppressWarnings("unchecked") List<FamilyDoctorJPA> allFDsJPA = query.getResultList();
Collection<FamilyDoctorJPA> allFDsJPA = query.getResultList(); List<FamilyDoctorTO> allFDTOs = new ArrayList<FamilyDoctorTO>();
Collection<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(this.getPOJOforFamilyDoctorJPA(item, 0));
} }
return allFDTOs; return allFDTOs;
} }
public PatientTO retrievePatient(int patientId) throws Exception { public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms) {
PatientJPA pat = entman.find(PatientJPA.class, patientId); MedicalSpecialtyTO msTO = null;
if (pat == null) { if (ms != null) {
throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId)); msTO = new MedicalSpecialtyTO(ms.getId(), ms.getName(), ms.getDescription());
} }
FamilyDoctorTO fdTO = null; return msTO;
if (pat.getFamilyDoctor() != null) {
FamilyDoctorJPA fd = pat.getFamilyDoctor();
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), null);
}
PatientTO paTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), fdTO);
return paTO;
} }
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception { public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc) {
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId); PrimaryHealthCareCenterTO phcTO = null;
if (fd == null) {
throw new Exception("No se encuentra en la base de datos ningún médico de familia con id: " + String.valueOf(ProfessionalNumberId)); if (phc != null) {
phcTO = new PrimaryHealthCareCenterTO(phc.getId(), phc.getName(), phc.getLocation());
} }
PrimaryHealthCareCenterTO phc = null; return phcTO;
if (fd.getPrimaryHealthCareCenter() != null) }
phc = new PrimaryHealthCareCenterTO(fd.getPrimaryHealthCareCenter().getName(), fd.getPrimaryHealthCareCenter().getLocation());
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));
}
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));
}
FamilyDoctorTO fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phc);
return fdTO; return fdTO;
} }
public SpecialistDoctorTO retrieveSpecialistDoctor(int professionalId) throws Exception { public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps) {
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, professionalId); PatientTO paTO = null;
if (sd == null) {
throw new Exception( if (pat != null) {
"No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(professionalId)); 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));
} }
MedicalSpecialtyTO ms = null; return paTO;
if (sd.getMedicalSpecialty() != null) }
ms = new MedicalSpecialtyTO(sd.getMedicalSpecialty().getName(), sd.getMedicalSpecialty().getDescription());
SpecialistDoctorTO sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), ms); public PatientTO findPatientById(int patientId) {
return sdTO; // Recuperamos propiedades anidadas 1 nivel!
return this.getPOJOforPatientJPA(entman.find(PatientJPA.class, patientId), 1);
}
public PatientJPA findPatientByCode(String code) {
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
query.setParameter("code", code);
List<PatientJPA> results = query.getResultList();
if (results.size() > 0)
return results.get(0);
else
return null; }
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
}
public FamilyDoctorJPA 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);
else
return null;
}
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
}
public SpecialistDoctorJPA 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);
else
return null;
} }
} }

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;
@@ -9,6 +10,11 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA;
import jpa.SpecialistDoctorJPA;
/** /**
* *
@@ -18,21 +24,44 @@ 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 PatientTO retrievePatient(int patientId) throws Exception; public List<FamilyDoctorTO> listAllFamilyDoctors();
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception; public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public PatientTO findPatientById(int patientId);
public PatientJPA findPatientByCode(String code);
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);
public SpecialistDoctorTO getPOJOforSpecialistDoctorJPA(SpecialistDoctorJPA sd, int nestedProps);
public PrimaryHealthCareCenterTO getPOJOforPrimaryHealthCareCenterJPA(PrimaryHealthCareCenterJPA phc);
public FamilyDoctorTO getPOJOforFamilyDoctorJPA(FamilyDoctorJPA fd, int nestedProps);
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps);
public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) 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;
@@ -9,6 +10,9 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import jpa.FamilyDoctorJPA;
import jpa.PatientJPA;
import jpa.SpecialistDoctorJPA;
/** /**
* *
@@ -18,21 +22,34 @@ 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 PatientTO retrievePatient(int patientId) throws Exception; public List<FamilyDoctorTO> listAllFamilyDoctors();
public FamilyDoctorTO retrieveFamilyDoctor(int ProfessionalNumberId) throws Exception; public List<FamilyDoctorTO> listFamilyDoctorsPaged(int pageNumber, int pageSize);
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
public PatientTO findPatientById(int patientId);
public PatientJPA findPatientByCode(String code);
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
public FamilyDoctorJPA findFamilyDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorJPA findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO retrieveSpecialistDoctor(int ProfessionalNumberId) throws Exception;
} }

View File

@@ -4,16 +4,16 @@ import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query;
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.Constants;
import common.HashUtils; import common.HashUtils;
import ejb.common.CommonFacadeBean;
import ejb.common.CommonFacadeLocal; import ejb.common.CommonFacadeLocal;
import ejb.common.CommonFacadeRemote;
import jpa.FamilyDoctorJPA; import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA; import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA; import jpa.PatientJPA;
@@ -32,69 +32,71 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
@PersistenceContext(unitName = "MyHealth") @PersistenceContext(unitName = "MyHealth")
private EntityManager entman; private EntityManager entman;
@EJB @EJB
CommonFacadeLocal commonServices; CommonFacadeLocal commonServices;
public PatientTO changeFamilyDoctor(int patientId, int ProfessionalNumberId) throws Exception { private String getNextProfessionalNumber() {
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
return Constants.PROFESSIONAL_NUMBER_PREFIX.concat(String.valueOf(q.getSingleResult()));
}
private String getNextPersonalIdentificationCode() {
Query q = entman.createNativeQuery("select nextval('myhealth.profesionalnumber')");
return Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX.concat(String.valueOf(q.getSingleResult()));
}
public PatientTO changeFamilyDoctor(int patientId, int newDoctor) throws Exception {
PatientJPA pat = entman.find(PatientJPA.class, patientId); PatientJPA pat = entman.find(PatientJPA.class, patientId);
if (pat == null) { if (pat == null) {
throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId)); throw new Exception("No se pueden actualizar los datos del paciente porque no se encuentra en la base de datos ningún registro con id: " + String.valueOf(patientId));
} }
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId); FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, newDoctor);
if (fd == null) { if (fd == null) {
throw new Exception("No se pueden actualizar los datos del médico de familia porque no se encuentra en la base de datos ningún registro con id: " throw new Exception(
+ String.valueOf(ProfessionalNumberId)); "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(newDoctor));
} }
PatientTO paTO = null;
pat.setFamilyDoctor(fd); pat.setFamilyDoctor(fd);
entman.persist(pat); entman.persist(pat);
//CommonFacadeRemote common = new CommonFacadeBean(); return this.commonServices.getPOJOforPatientJPA(pat, 1);
return commonServices.retrievePatient(pat.getId());
} }
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email) { public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email) {
PatientTO paTO = null; PatientTO paTO = null;
PatientJPA pat = new PatientJPA(nif, name, surname, HashUtils.hashMD5(password), email, null); PatientJPA pat = new PatientJPA(this.getNextPersonalIdentificationCode(), nif, name, surname, HashUtils.hashMD5(password), email, null);
entman.persist(pat); entman.persist(pat);
paTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
return paTO; return this.commonServices.getPOJOforPatientJPA(pat, 1);
} }
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());
} }
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, ms); SpecialistDoctorJPA sd = new SpecialistDoctorJPA(this.getNextProfessionalNumber(), nif, name, surname, HashUtils.hashMD5(password), email, ms);
entman.persist(sd); entman.persist(sd);
SpecialistDoctorTO sdTO = null; return this.commonServices.getPOJOforSpecialistDoctorJPA(sd, 1);
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
return sdTO;
} }
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());
} }
FamilyDoctorJPA fd = new FamilyDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, phcC); FamilyDoctorJPA fd = new FamilyDoctorJPA(this.getNextProfessionalNumber(), nif, name, surname, HashUtils.hashMD5(password), email, phcC);
entman.persist(fd); entman.persist(fd);
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), cap); return commonServices.getPOJOforFamilyDoctorJPA(fd, 1);
return fdTO;
} }
public PatientTO updatePatientData(int id, String nif, String name, String surname, String password, String email) throws Exception { public PatientTO updatePatientData(int id, String nif, String name, String surname, String password, String email) throws Exception {
@@ -114,10 +116,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
entman.persist(pat); entman.persist(pat);
PatientTO patTO = null; return this.commonServices.getPOJOforPatientJPA(pat, 1);
patTO = new PatientTO(pat.getId(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(), null);
return patTO;
} }
public SpecialistDoctorTO updateSpecialistDoctorData(int id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) public SpecialistDoctorTO updateSpecialistDoctorData(int id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty)
@@ -127,7 +126,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());
} }
@@ -143,10 +142,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
entman.persist(sd); entman.persist(sd);
SpecialistDoctorTO sdTO = null; return this.commonServices.getPOJOforSpecialistDoctorJPA(sd, 1);
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(), specialty);
return sdTO;
} }
public FamilyDoctorTO updateFamilyDoctorData(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phcTO) throws Exception { public FamilyDoctorTO updateFamilyDoctorData(int id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO phcTO) throws Exception {
@@ -155,7 +151,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());
} }
@@ -171,10 +167,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
entman.persist(fd); entman.persist(fd);
FamilyDoctorTO fdTO = null; return this.commonServices.getPOJOforFamilyDoctorJPA(fd, 1);
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), phcTO);
return fdTO;
} }
public FamilyDoctorTO changePrimaryHealthCareCenter(int professionalId, PrimaryHealthCareCenterTO newCenter) throws Exception { public FamilyDoctorTO changePrimaryHealthCareCenter(int professionalId, PrimaryHealthCareCenterTO newCenter) throws Exception {
@@ -185,15 +178,14 @@ 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());
} }
fd.setPrimaryHealthCareCenter(phcC); fd.setPrimaryHealthCareCenter(phcC);
entman.persist(fd); entman.persist(fd);
fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(), newCenter);
return fdTO; return this.commonServices.getPOJOforFamilyDoctorJPA(fd, 1);
} }
} }

View File

@@ -16,7 +16,7 @@ import TO.SpecialistDoctorTO;
@Remote @Remote
public interface ProfileFacadeRemote { public interface ProfileFacadeRemote {
public PatientTO changeFamilyDoctor(int id, int ProfessionalNumberId) throws Exception; public PatientTO changeFamilyDoctor(int id, int newDoctor) throws Exception;
public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email); public PatientTO registerPatient(int id, String nif, String name, String surname, String password, String email);

View File

@@ -1,23 +1,18 @@
package ejb.systemAdmin; package ejb.systemAdmin;
import java.util.ArrayList; import javax.ejb.EJB;
import java.util.Collection;
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 TO.LoggedUserTO; import TO.LoggedUserTO;
import TO.MedicalSpecialtyTO; import common.Constants;
import TO.PrimaryHealthCareCenterTO;
import common.HashUtils; import common.HashUtils;
import common.UserType; import common.UserType;
import ejb.common.CommonFacadeLocal;
import jpa.AdministratorJPA; import jpa.AdministratorJPA;
import jpa.FamilyDoctorJPA; import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA; import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA;
import jpa.SpecialistDoctorJPA; import jpa.SpecialistDoctorJPA;
/** /**
@@ -32,49 +27,80 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
@PersistenceContext(unitName = "MyHealth") @PersistenceContext(unitName = "MyHealth")
private EntityManager entman; private EntityManager entman;
public LoggedUserTO login(String id, String pwd) { @EJB
CommonFacadeLocal commonServices;
/**
* Si la autenticación no es correcgta devuelve null, sino devuelve un POJO con
* datos del usuario logeado.
*
* La autenticación se realiza en 2 pasos:
*
* Paso 1. Se intenta localizar un registro de usuario, por orden:
*
* a. Primero Paciente, si el identificador comienza por los caracteres
* correctos.
*
* b.Después médico de familia, si el identificador es de profesional
*
* c. Si no lo localizamos buscamos el identificador en la tabla de médicos
* especialistas (el identificador es de profesional)
*
* d. Si no hemos localizado aún al usuario, lo buscamos en la tabla de
* administradores, aún cuando el identificador comience por cualquier carácter
* (podría ser una dirección de email que comienza por caracteres del
* identificaodr de paciente o profesional)
*
* Paso 2. Si hemos localizado un registro de usuario, verificamos si el
* password recibido coincide con el de la base de datos, en tal caso la
* autenticación se compelta y es correcta.
*/
public LoggedUserTO login(String userCode, String pwd) {
LoggedUserTO usr = null; LoggedUserTO usr = null;
// First try to login as Admin if (userCode.startsWith(Constants.PERSONAL_IDENTIFICATION_CODE_PREFIX)) {
AdministratorJPA adm = entman.find(AdministratorJPA.class, id); // Si el identificador de usuario es de tipo paciente, intentamos realizar el
if (adm != null) { // login.
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR); PatientJPA pat = this.commonServices.findPatientByCode(userCode);
} else { if (pat != null) {
try { usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
int iId = Integer.parseInt(id);
// Try to login Patient, FamilyDoctor or SpecialistDoctor
// TODO: Si Patient, FamilyDoctor o Specialist Doctor tienen el mismo id, solo
// el paciente se puede logear. ¿Deberíamos cambiar esto permitiendo seleccionar
// el perfil a logearse?
PatientJPA pat = entman.find(PatientJPA.class, iId);
if (pat != null) {
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
} else {
FamilyDoctorJPA fdoc = entman.find(FamilyDoctorJPA.class, iId);
if (fdoc != null) {
usr = new LoggedUserTO(String.valueOf(fdoc.getId()), fdoc.getName(), fdoc.getPassword(), UserType.FAMILY_DOCTOR);
} else {
SpecialistDoctorJPA sdoc = entman.find(SpecialistDoctorJPA.class, iId);
if (sdoc != null) {
usr = new LoggedUserTO(String.valueOf(sdoc.getId()), sdoc.getName(), sdoc.getPassword(), UserType.SPECIALIST_DOCTOR);
}
}
}
} catch (NumberFormatException nf) {
// id is not an intenger, so, login fails
usr = null;
} }
} 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);
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);
if (sd != null) {
usr = new LoggedUserTO(String.valueOf(sd.getId()), sd.getName(), sd.getPassword(), UserType.SPECIALIST_DOCTOR);
}
}
} }
// Si todavía no hemos conseguido autenticar al usuario, podría tratarse de una
// dirección de email de un administrador que empiece por
// PERSONAL_IDENTIFICATION_CODE_PREFIX o por PROFESSIONAL_NUMBER_PREFIX, por lo
// cual intentamos login contra la tabla de administradores
if (usr == null) {
// Intentamos recuperar un registro de administrador
AdministratorJPA adm = entman.find(AdministratorJPA.class, userCode);
if (adm != null) {
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRATOR);
}
}
// Si el objeto usr, es que hemos localizado un registro de usuario, verificamos
// la contraseña.
if (usr != null) { if (usr != null) {
// Comprobamos el password // Comprobamos el password
if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) { if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) {
// Bad Password, devolvemos null! // Bad Password, devolvemos null! La autenticación falla.
usr = null; usr = null;
} }
} }

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,8 +27,11 @@ 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;
@Column(nullable = false, unique = true)
private String professionalNumber;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -47,7 +51,8 @@ public class FamilyDoctorJPA implements Serializable {
super(); super();
} }
public FamilyDoctorJPA(String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) { public FamilyDoctorJPA(String pin, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
this.setProfessionalNumber(pin);
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
@@ -122,4 +127,12 @@ public class FamilyDoctorJPA implements Serializable {
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) { public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
this.primaryHealthCareCenter = center; this.primaryHealthCareCenter = center;
} }
public String getProfessionalNumber() {
return professionalNumber;
}
public void setProfessionalNumber(String professionalNumber) {
this.professionalNumber = professionalNumber;
}
} }

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,15 +23,18 @@ 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;
@Column(nullable = false, unique = true)
private String personalIdentificationCode;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
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;
/** /**
@@ -40,7 +44,8 @@ public class PatientJPA implements Serializable {
super(); super();
} }
public PatientJPA(String nif, String name, String surname, String password, String email, FamilyDoctorJPA familyDoc) { public PatientJPA(String pic, String nif, String name, String surname, String password, String email, FamilyDoctorJPA familyDoc) {
this.personalIdentificationCode = pic;
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
@@ -100,7 +105,16 @@ 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;
} }
public String getPersonalIdentificationCode() {
return personalIdentificationCode;
}
public void setPersonalIdentificationCode(String personalIdentificationCode) {
this.personalIdentificationCode = personalIdentificationCode;
}
} }

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,8 +23,11 @@ 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;
@Column(nullable = false, unique = true)
private String professionalNumber;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -40,7 +44,8 @@ public class SpecialistDoctorJPA implements Serializable {
super(); super();
} }
public SpecialistDoctorJPA(String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) { public SpecialistDoctorJPA(String pic, String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
this.setProfessionalNumber(pic);
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
@@ -104,4 +109,12 @@ public class SpecialistDoctorJPA implements Serializable {
public void setMedicalSpecialty(MedicalSpecialtyJPA specialty) { public void setMedicalSpecialty(MedicalSpecialtyJPA specialty) {
this.medicalSpecialty = specialty; this.medicalSpecialty = specialty;
} }
public String getProfessionalNumber() {
return professionalNumber;
}
public void setProfessionalNumber(String professionalNumber) {
this.professionalNumber = professionalNumber;
}
} }

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,9 +51,9 @@ 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().findPatientById(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,9 +53,9 @@ public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implemen
this.id = Integer.valueOf(usr.getId()); this.id = Integer.valueOf(usr.getId());
if (usr.getUserType() == UserType.FAMILY_DOCTOR) { if (usr.getUserType() == UserType.FAMILY_DOCTOR) {
this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listAllCAPs(); this.primaryHealthCareCentersList = this.getRemoteManagerCommon().listCAPsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
FamilyDoctorTO fd = this.getRemoteManagerCommon().retrieveFamilyDoctor(this.id); FamilyDoctorTO fd = this.getRemoteManagerCommon().findFamilyDoctorById(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

@@ -2,7 +2,6 @@ package managedbean.profile;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@@ -19,6 +18,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;
@@ -35,8 +35,8 @@ import managedbean.common.ValidationUtils;
public class RegisterUserMBean extends ManagedBeanBase implements Serializable { public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int id; private int id;
private String cipCode;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -44,14 +44,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> availableUserTypes;
private String userType; private UserType 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() {
@@ -59,24 +61,26 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
@PostConstruct @PostConstruct
public void init() { public void init() {
this.userTypes = new ArrayList<UserType>(); this.availableUserTypes = new ArrayList<UserType>();
this.userTypes.add(UserType.PATIENT); this.availableUserTypes.add(UserType.PATIENT);
this.userTypes.add(UserType.FAMILY_DOCTOR); this.availableUserTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.add(UserType.SPECIALIST_DOCTOR); this.availableUserTypes.add(UserType.SPECIALIST_DOCTOR);
this.registered = false; this.registered = false;
this.lastUIQueryPH = "";
this.lastUIQueryMS = "";
this.userType = UserType.PATIENT.name(); this.userType = UserType.PATIENT;
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> getAvailableUserTypes() {
return userTypes; return availableUserTypes;
} }
public void onUserTypeChange() { public void onUserTypeChange() {
switch (UserType.valueOf(this.userType)) { switch (this.userType) {
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
try { try {
PrimeFaces.current().ajax().addCallbackParam("specs", true); PrimeFaces.current().ajax().addCallbackParam("specs", true);
@@ -98,24 +102,42 @@ 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 (this.userType == UserType.PATIENT);
} }
public boolean isFamilyDoctor() { public boolean isFamilyDoctor() {
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR); return (this.userType == UserType.FAMILY_DOCTOR);
} }
public boolean isSpecialistDoctor() { public boolean isSpecialistDoctor() {
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR); return (this.userType == UserType.SPECIALIST_DOCTOR);
} }
public boolean isDoctor() { public boolean isDoctor() {
@@ -162,14 +184,6 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
this.nif = nif; this.nif = nif;
} }
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public void addNewUser() { public void addNewUser() {
int error = 0; int error = 0;
@@ -188,20 +202,20 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
if (error == 0) { if (error == 0) {
try { try {
switch (UserType.valueOf(this.userType)) { switch (this.userType) {
case PATIENT: case PATIENT:
PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email); PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
this.id = pat.getId(); this.cipCode = pat.getPersonalIdentificationCode();
break; break;
case FAMILY_DOCTOR: case FAMILY_DOCTOR:
FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor(id, nif, name, surname, password, email, this.primaryHealthCareCenter); FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
this.id = fd.getId(); this.cipCode = fd.getProfessionalNumber();
break; break;
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty); SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
this.id = sd.getId(); this.cipCode = sd.getProfessionalNumber();
break; break;
case ADMINISTRATOR: case ADMINISTRATOR:
@@ -217,32 +231,40 @@ public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
} }
} }
public String getUserType() { public UserType getUserType() {
return userType; return userType;
} }
public void setUserType(String userType) { public void setUserType(UserType value) {
this.userType = userType; this.userType = value;
} }
public MedicalSpecialtyTO getMedicalSpecialty() { public MedicalSpecialtyTO getMedicalSpecialty() {
return medicalSpecialty; return medicalSpecialty;
} }
public void setMedicalSpecialty(MedicalSpecialtyTO medicalSpecialty) { public void setMedicalSpecialty(MedicalSpecialtyTO value) {
this.medicalSpecialty = medicalSpecialty; this.medicalSpecialty = value;
} }
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() { public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
return primaryHealthCareCenter; return primaryHealthCareCenter;
} }
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO primaryHealthCareCenter) { public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO value) {
this.primaryHealthCareCenter = primaryHealthCareCenter; this.primaryHealthCareCenter = value;
} }
public boolean isRegistered() { public boolean isRegistered() {
return registered; return registered;
} }
public String getCipCode() {
return cipCode;
}
public void setCipCode(String cipCode) {
this.cipCode = cipCode;
}
} }

View File

@@ -2,20 +2,12 @@ package managedbean.profile;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
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 +18,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;
@@ -47,6 +39,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private int id; private int id;
private String cipCode;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -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 UserType 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;
@@ -82,40 +82,21 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida", this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida",
"Su sesión actual no es válida, por favor cierre su sesión y vuelva a logearse en el sistema."); "Su sesión actual no es válida, por favor cierre su sesión y vuelva a logearse en el sistema.");
else { else {
this.userType = usr.getUserType().getName(); this.userType = usr.getUserType();
this.id = Integer.valueOf(usr.getId()); this.id = Integer.valueOf(usr.getId());
switch (usr.getUserType()) { switch (usr.getUserType()) {
case PATIENT: case PATIENT:
PatientTO pat = this.getRemoteManagerCommon().retrievePatient(this.id); this.familyDoctorList = this.getRemoteManagerCommon().listFamilyDoctorsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.setPatientData(this.getRemoteManagerCommon().findPatientById(this.id));
this.name = pat.getName();
this.surname = pat.getName();
this.nif = pat.getNif();
this.email = pat.getEmail();
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); this.setSpecialistDoctorData(this.getRemoteManagerCommon().findSpecialistDoctorById(this.id));
this.name = sd.getName();
this.surname = sd.getName();
this.nif = sd.getNif();
this.email = sd.getEmail();
this.currentPassword = sd.getPassword();
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); this.setFamilyDoctorData(this.getRemoteManagerCommon().findFamilyDoctorById(this.id));
this.name = fd.getName();
this.surname = fd.getName();
this.nif = fd.getNif();
this.email = fd.getEmail();
this.currentPassword = fd.getPassword();
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
break; break;
case ADMINISTRATOR: case ADMINISTRATOR:
// TODO: Recuperar usuario administrador para editar su perfil ¿? // TODO: Recuperar usuario administrador para editar su perfil ¿?
@@ -126,58 +107,98 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
} catch (Exception e) { } catch (Exception e) {
this.manageException(e); this.manageException(e);
} }
}
private void setPatientData(PatientTO pat) {
this.id = pat.getId();
this.cipCode = pat.getPersonalIdentificationCode();
this.name = pat.getName();
this.surname = pat.getName();
this.nif = pat.getNif();
this.email = pat.getEmail();
this.currentPassword = pat.getPassword();
this.familyDoctor = pat.getFamilyDoctor();
}
private void setFamilyDoctorData(FamilyDoctorTO fd) {
this.id = fd.getId();
this.cipCode = fd.getProfessionalNumber();
this.name = fd.getName();
this.surname = fd.getName();
this.nif = fd.getNif();
this.email = fd.getEmail();
this.currentPassword = fd.getPassword();
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
}
private void setSpecialistDoctorData(SpecialistDoctorTO sd) {
this.id = sd.getId();
this.cipCode = sd.getProfessionalNumber();
this.name = sd.getName();
this.surname = sd.getName();
this.nif = sd.getNif();
this.email = sd.getEmail();
this.currentPassword = sd.getPassword();
this.medicalSpecialty = sd.getMedicalSpecialty();
} }
public List<UserType> getUserTypes() { public List<UserType> getUserTypes() {
return userTypes; return userTypes;
} }
public void onUserTypeChange() { public List<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
switch (UserType.valueOf(this.userType)) {
case SPECIALIST_DOCTOR:
try {
PrimeFaces.current().ajax().addCallbackParam("specs", true);
} catch (Exception e) {
this.manageException(e);
}
break;
case FAMILY_DOCTOR:
try {
PrimeFaces.current().ajax().addCallbackParam("caps", true);
} catch (Exception e) {
this.manageException(e);
}
break;
case ADMINISTRATOR:
case PATIENT:
PrimeFaces.current().ajax().addCallbackParam("pats", true);
break;
}
}
public Collection<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) {
return (UserType.valueOf(this.userType) == UserType.PATIENT); 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 boolean isFamilyDoctor() { public List<MedicalSpecialtyTO> completeMedicalSpecialty(String query) {
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR); 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 isSpecialistDoctor() { public List<FamilyDoctorTO> getFamilyDoctorList() {
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR); return familyDoctorList;
} }
public boolean isDoctor() { public List<FamilyDoctorTO> completeFamilyDoctor(String query) {
return (isFamilyDoctor() || isSpecialistDoctor()); 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 (this.userType == UserType.PATIENT);
}
public boolean isUserTypeFamilyDoctor() {
return (this.userType == UserType.FAMILY_DOCTOR);
}
public boolean isUserTypeSpecialistDoctor() {
return (this.userType == UserType.SPECIALIST_DOCTOR);
}
public boolean isUserTypeDoctor() {
return (isUserTypeFamilyDoctor() || isUserTypeSpecialistDoctor());
} }
public String getEmail() { public String getEmail() {
@@ -228,11 +249,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++;
} }
@@ -255,20 +276,20 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
if (error == 0) { if (error == 0) {
try { try {
switch (UserType.valueOf(this.userType)) { switch (this.userType) {
case PATIENT: case PATIENT:
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email); PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
this.id = pat.getId(); this.setPatientData(pat);
break; break;
case FAMILY_DOCTOR: case FAMILY_DOCTOR:
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter); FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
this.id = fd.getId(); this.setFamilyDoctorData(fd);
break; break;
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty); SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
this.id = sd.getId(); this.setSpecialistDoctorData(sd);
break; break;
case ADMINISTRATOR: case ADMINISTRATOR:
@@ -288,12 +309,12 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
} }
} }
public String getUserType() { public UserType getUserType() {
return userType; return userType;
} }
public void setUserType(String userType) { public void setUserType(UserType value) {
this.userType = userType; this.userType = value;
} }
public MedicalSpecialtyTO getMedicalSpecialty() { public MedicalSpecialtyTO getMedicalSpecialty() {
@@ -320,4 +341,16 @@ 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;
}
public String getCipCode() {
return cipCode;
}
} }

View File

@@ -0,0 +1,43 @@
package managedbean.validators;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.primefaces.validate.ClientValidator;
@FacesValidator("emailValidator")
public class EmailValidator implements Validator, ClientValidator {
private final static String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
private final static Pattern EMAIL_COMPILED_PATTERN = Pattern.compile(EMAIL_PATTERN);
public void validate(FacesContext context, UIComponent comp, Object value) throws ValidatorException {
String strValue = "";
if (value != null)
strValue = String.valueOf(value);
if (strValue.equals(""))
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Correo electrónico no válido", "La dirección " + value + " no es una dirección válida"));
Matcher matcher = EMAIL_COMPILED_PATTERN.matcher((String) value);
if (!matcher.matches())
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Correo electrónico no válido", "La dirección " + value + " no es una dirección válida"));
}
public Map<String, Object> getMetadata() {
return null;
}
public String getValidatorId() {
return "emailValidator";
}
}

View File

@@ -0,0 +1,39 @@
package managedbean.validators;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.primefaces.validate.ClientValidator;
import managedbean.common.ValidationUtils;
@FacesValidator("nifValidator")
public class NifValidator implements Validator, ClientValidator {
public void validate(FacesContext context, UIComponent comp, Object value) throws ValidatorException {
String strValue = "";
if (value != null)
strValue = String.valueOf(value);
if (strValue.equals(""))
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "El NIF no es válido", "El NIF " + value + " no es válido"));
if (ValidationUtils.isValid(strValue) == false)
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "El NIF no es válido", "El NIF " + value + " no es válido"));
}
public Map<String, Object> getMetadata() {
return null;
}
public String getValidatorId() {
return "nifValidator";
}
}

View File

@@ -1,20 +1,88 @@
DO
$$
begin
IF NOT EXISTS(SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'myhealth') THEN
CREATE SCHEMA myhealth;
END IF;
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname='usrmyhealth') THEN
create user usrmyhealth with encrypted password 'myhealth.123';
END IF;
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname='USER') THEN
create user "USER" with encrypted password 'PASSWORD';
END IF;
GRANT ALL ON SCHEMA myhealth TO "USER";
GRANT ALL ON SCHEMA myhealth TO usrmyhealth;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='administrator') THEN
drop table myhealth.administrator;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='familydoctor') THEN
drop table myhealth.familydoctor;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='medicalspecialty') THEN
drop table myhealth.medicalspecialty;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='medicaltest') THEN
drop table myhealth.medicaltest;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='patient') THEN
drop table myhealth.patient;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='primaryhealthcarecenter') THEN
drop table myhealth.primaryhealthcarecenter;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='question') THEN
drop table myhealth.question;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='response') THEN
drop table myhealth.response;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='specialistdoctor') THEN
drop table myhealth.specialistdoctor;
end if;
if exists (SELECT 1 FROM pg_tables WHERE schemaname='myhealth' and tablename='visit') THEN
drop table myhealth.visit;
end if;
/* /*
DROP TABLE myhealth.Administrator; drop table myhealth.administrator;
DROP TABLE myhealth.FamilyDoctor; drop table myhealth.familydoctor;
DROP TABLE myhealth.MedicalSpecialty; drop table myhealth.medicalspecialty;
DROP TABLE myhealth.MedicalTest; drop table myhealth.medicaltest;
DROP TABLE myhealth.Patient; drop table myhealth.patient;
DROP TABLE myhealth.PrimaryHealthCareCenter; drop table myhealth.primaryhealthcarecenter;
DROP TABLE myhealth.Question; drop table myhealth.question;
DROP TABLE myhealth.Response; drop table myhealth.response;
DROP TABLE myhealth.SpecialistDoctor; drop table myhealth.specialistdoctor;
DROP TABLE myhealth.Visit; drop table myhealth.visit;
*/ */
if exists (SELECT 1 FROM pg_sequences WHERE schemaname='myhealth' and sequencename='profesionalnumber') THEN
drop sequence myhealth.profesionalnumber;
end if;
if exists (SELECT 1 FROM pg_sequences WHERE schemaname='myhealth' and sequencename='codigoidentificacionpaciente') THEN
drop sequence myhealth.codigoidentificacionpaciente;
end if;
CREATE SEQUENCE myhealth.ProfesionalNumber
INCREMENT 1
START 1000
MINVALUE 1000
CACHE 1;
CREATE SEQUENCE myhealth.CodigoIdentificacionPaciente
INCREMENT 1
START 1000
MINVALUE 1000
CACHE 1;
-- Table: myhealth.administrator -- Table: myhealth.administrator
-- DROP TABLE myhealth.administrator; -- DROP TABLE myhealth.administrator;
CREATE TABLE myhealth.administrator CREATE TABLE myhealth.administrator
( (
email VARCHAR(120) COLLATE pg_catalog."default" NOT NULL, email VARCHAR(120) COLLATE pg_catalog."default" NOT NULL,
@@ -32,17 +100,21 @@ ALTER TABLE myhealth.administrator
CREATE TABLE myhealth.familydoctor CREATE TABLE myhealth.familydoctor
( (
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password VARCHAR(100) COLLATE pg_catalog."default" NOT NULL, professionalnumber VARCHAR(15) NOT NULL COLLATE pg_catalog."default",
nif VARCHAR(50) COLLATE pg_catalog."default", password VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) COLLATE pg_catalog."default", nif VARCHAR(50) NOT NULL COLLATE pg_catalog."default",
name VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
email VARCHAR(120) COLLATE pg_catalog."default", email VARCHAR(120) COLLATE pg_catalog."default",
name VARCHAR(100) COLLATE pg_catalog."default", primaryhealthcarecenterid integer,
primaryhealthcarecenterid VARCHAR(50) COLLATE pg_catalog."default",
CONSTRAINT familydoctor_pkey PRIMARY KEY (id) CONSTRAINT familydoctor_pkey PRIMARY KEY (id)
) )
TABLESPACE pg_default; TABLESPACE pg_default;
CREATE UNIQUE INDEX family_doctor_professionaln_index
ON myhealth.familydoctor (professionalnumber);
ALTER TABLE myhealth.familydoctor ALTER TABLE myhealth.familydoctor
OWNER to "USER"; OWNER to "USER";
@@ -90,43 +162,33 @@ ALTER TABLE myhealth.medicaltest
CREATE TABLE myhealth.patient CREATE TABLE myhealth.patient
( (
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password VARCHAR(100) COLLATE pg_catalog."default", personalIdentificationCode VARCHAR(15) NOT NULL COLLATE pg_catalog."default",
nif VARCHAR(50) COLLATE pg_catalog."default", password VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) COLLATE pg_catalog."default", nif VARCHAR(50) NOT NULL COLLATE pg_catalog."default",
name VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
email VARCHAR(120) COLLATE pg_catalog."default", email VARCHAR(120) COLLATE pg_catalog."default",
name VARCHAR(100) COLLATE pg_catalog."default",
familydoctorid INTEGER, familydoctorid INTEGER,
CONSTRAINT patient_pkey PRIMARY KEY (id) CONSTRAINT patient_pkey PRIMARY KEY (id)
) )
TABLESPACE pg_default; TABLESPACE pg_default;
CREATE UNIQUE INDEX patient_pic_index
ON myhealth.patient (personalIdentificationCode);
ALTER TABLE myhealth.patient ALTER TABLE myhealth.patient
OWNER to "USER"; OWNER to "USER";
-- Table: myhealth.location
-- DROP TABLE myhealth.location;
CREATE TABLE myhealth.location
(
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
name VARCHAR(100) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT primarylocation_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE myhealth.location
OWNER to "USER";
-- Table: myhealth.primaryhealthcarecenter -- Table: myhealth.primaryhealthcarecenter
-- DROP TABLE myhealth.primaryhealthcarecenter; -- DROP TABLE myhealth.primaryhealthcarecenter;
CREATE TABLE myhealth.primaryhealthcarecenter CREATE TABLE myhealth.primaryhealthcarecenter
( (
name VARCHAR(50) COLLATE pg_catalog."default" NOT NULL, id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
location INTEGER, name VARCHAR(150) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT primaryhealthcarecenter_pkey PRIMARY KEY (name) location VARCHAR(512) COLLATE pg_catalog."default",
CONSTRAINT primaryhealthcarecenter_pkey PRIMARY KEY (id)
) )
TABLESPACE pg_default; TABLESPACE pg_default;
@@ -174,16 +236,20 @@ ALTER TABLE myhealth.response
CREATE TABLE myhealth.specialistdoctor CREATE TABLE myhealth.specialistdoctor
( (
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ), id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password VARCHAR(100) COLLATE pg_catalog."default", professionalnumber VARCHAR(15) NOT NULL COLLATE pg_catalog."default",
nif VARCHAR(50) COLLATE pg_catalog."default", password VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) COLLATE pg_catalog."default", nif VARCHAR(50) NOT NULL COLLATE pg_catalog."default",
name VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
surname VARCHAR(100) NOT NULL COLLATE pg_catalog."default",
email VARCHAR(120) COLLATE pg_catalog."default", email VARCHAR(120) COLLATE pg_catalog."default",
name VARCHAR(100) COLLATE pg_catalog."default",
medicalspecialtyid INTEGER, medicalspecialtyid INTEGER,
CONSTRAINT specialistdoctor_pkey PRIMARY KEY (id) CONSTRAINT specialistdoctor_pkey PRIMARY KEY (id)
) )
TABLESPACE pg_default; TABLESPACE pg_default;
CREATE UNIQUE INDEX specialistdoctor_professionaln_index
ON myhealth.specialistdoctor (professionalnumber);
ALTER TABLE myhealth.specialistdoctor ALTER TABLE myhealth.specialistdoctor
OWNER to "USER"; OWNER to "USER";
@@ -207,3 +273,5 @@ TABLESPACE pg_default;
ALTER TABLE myhealth.visit ALTER TABLE myhealth.visit
OWNER to "USER"; OWNER to "USER";
END;
$$

View File

@@ -2,8 +2,26 @@
insert into myhealth.administrator (email, password) values ('admin@example.com', '21232F297A57A5A743894A0E4A801FC3'); insert into myhealth.administrator (email, password) values ('admin@example.com', '21232F297A57A5A743894A0E4A801FC3');
insert into myhealth.administrator (email, password) values ('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3'); insert into myhealth.administrator (email, password) values ('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3');
-- Inserta Especialidades médicas -- Insertar Algunos centros médicos
INSERT INTO myhealth.primaryhealthcarecenter(name, location) VALUES
('CENTRO SAUDE A DOBLADA',' CALLE RUA FAISAN S/N '),
('CENTRO SAUDE BEMBRIVE',' CARRETERA BEMBRIVE 259 '),
('CENTRO SAUDE BOLIVIA',' CALLE PIZARRO 22 '),
('CENTRO SAUDE CASCO VELLO',' PLAZA CONSTITUCION 7 '),
('CENTRO SAUDE COIA',' CALLE PONTEAREAS S/N '),
('CENTRO SAUDE COLMEIRO',' CALLE PINTOR COLMEIRO 11 '),
('CENTRO SAUDE CORUXO',' CALLE RUA JOSE RIVAS CARRASQUEIRA S/N '),
('CENTRO SAUDE LAVADORES',' TRAVESIA BARREIRO 1 36 '),
('CENTRO SAUDE LOPEZ MORA',' CALLE LOPEZ MORA 54 '),
('CENTRO SAUDE MATAMA',' CAMINO CAMIÑO BABIO-AS CARNEIRAS S/N '),
('CENTRO SAUDE NICOLAS PEÑA',' CAMINO CAMIÑO REGUEIRO S/N '),
('CENTRO SAUDE ROSALIA DE CASTRO-BEIRAMAR',' CALLE ROSALIA DE CASTRO 21 '),
('CENTRO SAUDE RUA CUBA',' CALLE CUBA 10 '),
('CENTRO SAUDE SAN PAIO DE NAVIA',' CALLE POZA CABALO S/N '),
('CENTRO SAUDE SARDOMA',' CALLE RUA CANTEIRA DE BALIN 76 '),
('CENTRO SAUDE TEIS',' CALLE ANGELA IGLESIAS REBOLLAR S/N ');
-- Inserta Especialidades médicas
insert into MyHealth.MedicalSpecialty(name, description) insert into MyHealth.MedicalSpecialty(name, description)
values ('Alergologia','Especialidad médica de Alergologia'); values ('Alergologia','Especialidad médica de Alergologia');
insert into MyHealth.MedicalSpecialty(name, description) insert into MyHealth.MedicalSpecialty(name, description)

11
CHANGELOG Normal file
View File

@@ -0,0 +1,11 @@
Hoy he subido multiples cambios para que las entidades de Paciente, Medico de Familia y Medico Especialista tengan un código, diferente del identificador de base de datos que se pueda utlizar para realizar el login correctamente.
Ahora mismo, con la última version:
* Hay 2 secuencias en base de datos (las he añadido al script de base de datos) que generan identificadores númericos únicos.
* Una secuencia genera los identificadores para Pacientes, y otra secuencia para profesionales (tal como requieren los requisitos).
* Los medicos de familia y los medicos especialistas comparten el identificador único (secuencia) y por lo tanto sus identificadores no se solapan.
* Los identificadores númericos se completan con 4 caracteres que se contatenas al inicio, y que hacen único al identificador (PAT#XXXX para Pacientes y PRO#0000 para profesionales)
* El login tiene en cuenta estos nuevos códigos, y por lo tanto el login se puede realizar correctametne.
* También he añadido varios métodos al EJB común para recuperar entidades, tanto por Id como por codigo.
* También he añadido junciones para convertir entidades JPA e entidades POJO de forma más o menos automática, y con minimo soporte para mapeo de propiedades de objetos relacionados.