Merge branch 'master' of

http://pdp-pds.eimt.uoc.edu/pds19-grupo2/myhealth.git

Conflicts:
	1.sources/MyHealth/src/jpa/VisitJPA.java
This commit is contained in:
Alejandro Linares Amado
2019-12-08 19:39:47 +01:00
57 changed files with 1666 additions and 775 deletions

View File

@@ -3,6 +3,7 @@
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 14.0 Runtime"/> <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 14.0 Runtime"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/primefaces-7.0.jar"/> <classpathentry kind="lib" path="docroot/WEB-INF/lib/primefaces-7.0.jar" sourcepath="C:/Users/mark/.m2/repository/org/primefaces/primefaces/7.0/primefaces-7.0-sources.jar"/>
<classpathentry kind="lib" path="docroot/WEB-INF/lib/omnifaces-3.4.1.jar" sourcepath="C:/Users/mark/.m2/repository/org/omnifaces/omnifaces/3.4.1/omnifaces-3.4.1-sources.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@@ -11,8 +11,9 @@
<property name="buildjar" value="${build}/jar" /> <property name="buildjar" value="${build}/jar" />
<property name="buildwar" value="${build}/war" /> <property name="buildwar" value="${build}/war" />
<property name="dist" value="${source}/dist" /> <property name="dist" value="${source}/dist" />
<property name="docroot" value="${source}/docroot" />
<property name="jboss-config" value="default" /> <property name="jboss-config" value="default" />
<property name="deploy" value="${jboss.home}\standalone\deployments" /> <property name="deploy" value="${jboss.home}/standalone/deployments" />
<property name="jboss.module.dir" value="${jboss.home}/modules" /> <property name="jboss.module.dir" value="${jboss.home}/modules" />
<path id="jboss.classpath"> <path id="jboss.classpath">
@@ -20,6 +21,11 @@
<include name="**/*.jar" /> <include name="**/*.jar" />
</fileset> </fileset>
</path> </path>
<path id="lib.dir">
<fileset dir="${docroot}/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
</path>
<target name="all" depends="clean, init, ear" /> <target name="all" depends="clean, init, ear" />
@@ -33,6 +39,7 @@
<mkdir dir="${buildwar}" /> <mkdir dir="${buildwar}" />
<mkdir dir="${buildjar}/META-INF" /> <mkdir dir="${buildjar}/META-INF" />
<mkdir dir="${buildwar}/WEB-INF" /> <mkdir dir="${buildwar}/WEB-INF" />
<mkdir dir="${buildwar}/WEB-INF/lib" />
<mkdir dir="${buildwar}/WEB-INF/classes" /> <mkdir dir="${buildwar}/WEB-INF/classes" />
<mkdir dir="${dist}" /> <mkdir dir="${dist}" />
</target> </target>
@@ -52,13 +59,23 @@
<!-- Compile the client application, creating the structure buildwar --> <!-- Compile the client application, creating the structure buildwar -->
<target name="compileWar" depends="init"> <target name="compileWar" depends="init">
<copy todir="${buildwar}"> <copy todir="${buildwar}">
<fileset dir="${source}/docroot" /> <fileset dir="${docroot}" />
</copy> </copy>
<javac srcdir="${sourcesrc}" destdir="${buildwar}/WEB-INF/classes" includes="managedbean/*.java" classpathref="jboss.classpath" includeantruntime="true" /> <javac srcdir="${sourcesrc}" destdir="${buildwar}/WEB-INF/classes" includes="managedbean/**/*.java" includeantruntime="true">
<classpath>
<path refid="jboss.classpath" />
<path refid="lib.dir" />
</classpath>
</javac>
<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> </target>
<!-- <war destfile="${build.dir}/CrunchifyRESTJerseyExample.war" webxml="WebContent/WEB-INF/web.xml"> -->
<!-- <classes dir="${build.dir}" /> -->
<!-- <lib dir="${lib.dir}"> -->
<!-- </lib> -->
<!-- </war> -->
<!-- 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">
@@ -83,10 +100,11 @@
<fileset dir="${dist}" includes="**/*" /> <fileset dir="${dist}" includes="**/*" />
<fileset dir="${build}" includes="**/*" /> <fileset dir="${build}" includes="**/*" />
<fileset dir="${buildjar}" includes="**/*" /> <fileset dir="${buildjar}" includes="**/*" />
<fileset dir="${buildwar}" includes="**/*" />
<fileset dir="${buildjar}/META-INF" includes="**/*" /> <fileset dir="${buildjar}/META-INF" includes="**/*" />
<fileset dir="${buildwar}/WEB-INF" includes="**/*" /> <fileset dir="${buildwar}/WEB-INF/lib" includes="**/*" />
<fileset dir="${buildwar}/WEB-INF/classes" includes="**/*" /> <fileset dir="${buildwar}/WEB-INF/classes" includes="**/*" />
<fileset dir="${buildwar}/WEB-INF" includes="**/*" />
<fileset dir="${buildwar}" includes="**/*" />
</delete> </delete>
</target> </target>
</project> </project>

View File

@@ -2,70 +2,4 @@
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd" version="2.3"> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd" version="2.3">
<navigation-rule>
<navigation-case>
<from-outcome>home</from-outcome>
<to-view-id>/home.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>RegisterUser</from-outcome>
<to-view-id>/profile/RegisterUser.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>AddPatient</from-outcome>
<to-view-id>/profile/AddPatient.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>AddFamilyDoctor</from-outcome>
<to-view-id>/profile/AddFamilyDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>AddSpecialistDoctor</from-outcome>
<to-view-id>/profile/AddSpecialistDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ChangeFamilyDoctor</from-outcome>
<to-view-id>/profile/ChangeFamilyDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ShowPatient</from-outcome>
<to-view-id>/profile/ShowPatient.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ShowFamilyDoctor</from-outcome>
<to-view-id>/profile/ShowFamilyDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ShowSpecialistDoctor</from-outcome>
<to-view-id>/profile/ShowSpecialistDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>UpdateSpecialistDoctor</from-outcome>
<to-view-id>/profile/UpdateSpecialistDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>UpdateFamilyDoctor</from-outcome>
<to-view-id>/profile/UpdateFamilyDoctor.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>UpdatePatient</from-outcome>
<to-view-id>/profile/UpdatePatient.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>changecap</from-outcome>
<to-view-id>/profile/ChangePrimaryHealthCareCenter.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>MedicalTests</from-outcome>
<to-view-id>/medicaltest/MedicalTests.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>VisitView</from-outcome>
<to-view-id>/visit/VisitView.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>ManageSpecialties</from-outcome>
<to-view-id>/systemAdmin/ManageSpecialties.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config> </faces-config>

View File

@@ -23,6 +23,12 @@
<param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value> <param-value>.xhtml</param-value>
</context-param> </context-param>
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
<context-param> <context-param>
<param-name>primefaces.THEME</param-name> <param-name>primefaces.THEME</param-name>
<param-value>#{sessionPreferences.currentTheme}</param-value> <param-value>#{sessionPreferences.currentTheme}</param-value>
@@ -53,14 +59,10 @@
<url-pattern>*.xhtml</url-pattern> <url-pattern>*.xhtml</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- <error-page> --> <error-page>
<!-- <error-code>404</error-code> --> <error-code>500</error-code>
<!-- <location>/error.xhtml</location> --> <location>/error.xhtml</location>
<!-- </error-page> --> </error-page>
<!-- <error-page> -->
<!-- <error-code>500</error-code> -->
<!-- <location>/error.xhtml</location> -->
<!-- </error-page> -->
<session-config> <session-config>
<session-timeout>30</session-timeout> <session-timeout>30</session-timeout>

View File

@@ -1,25 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!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" <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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="./header.xhtml"> <ui:composition template="./header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form id="errorForm"> <h:form id="errorForm">
<div align="center"> <div class="ui-g ui-fluid">
<h1>Se ha producido un error</h1> <div class="ui-g-2 ui-md-2" />
<hr/> <div class="ui-g-8 ui-md-8">
<div>Descripcion del error:</div> <p:panel id="ErrorPanel" header="Se ha producido un error inesperado">
<div> <div class="ui-g ui-fluid">
<h:messages fatalClass="ErrorMessage" showDetail="true" showSummary="true" globalOnly="true"> <div class="ui-g-12">La acción que estaba realizando a causado un error inesperado en el sistema. A continuación podrá ver un descripción detallada del error para que
</h:messages> pueda comunicarlo al equipo de soporte.</div>
<div class="ui-g-12" style="font-weight: bold;">
Descripción del error
</div>
<div class="ui-g-12">
<h:messages fatalClass="ErrorMessage" showDetail="true" showSummary="true" globalOnly="true" />
</div>
<div class="ui-g-5" />
<div class="ui-g-2">
<p:button value="Ir a la página principal" outcome="home" icon="pi pi-home" />
</div>
<div class="ui-g-5" />
</div>
</p:panel>
</div> </div>
<div class="ui-g-2 ui-md-2" />
</div> </div>
<p align="center"> </h:form>
<h:button value="Volver al inicio" outcome="home?refresh=1" />
</p>
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</html> </html>

View File

@@ -14,12 +14,16 @@
function handleLoginRequest(xhr, status, args) { function handleLoginRequest(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) { if(args.validationFailed || !args.loggedIn) {
PF('dlgLogin').jq.effect("shake", {times:5}, 100); PF('dlgLogin').jq.effect("shake", {times:5}, 100);
//PF('Login').attr("disabled", false);
} }
else { else {
PF('dlgLogin').hide(); PF('dlgLogin').hide();
$('#loginLink').fadeOut();
} }
} }
function startLogin() {
//PF('Login').attr("disabled", true);
}
</h:outputScript> </h:outputScript>
<h:body> <h:body>
<div id="layout"> <div id="layout">
@@ -29,69 +33,51 @@
</div> </div>
<hr /> <hr />
<div id="menuDiv"> <div id="menuDiv">
<h:form> <p:growl id="messages" sticky="false" showDetail="true" life="15000" />
<p:growl id="messages" sticky="true" showDetail="true" life="3000" /> <p:ajaxStatus style="width:32px; height:32px; position:fixed; right:32px; bottom:32px">
<f:facet name="start">
<i id="loginSpin" class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
</f:facet>
<p:menubar> <f:facet name="complete">
<p:menuitem label="Home" icon="pi pi-home" outcome="home" /> <h:outputText value="" />
<p:submenu label="Administración del sistema" icon="pi pi-briefcase"> </f:facet>
<p:menuitem value="Gestionar especialidades" icon="pi pi-briefcase" action="#{menuView.goManageSpecialties}" /> </p:ajaxStatus>
<p:menuitem value="Gestionar CAPs" action="#{menuView.goManageSpecialties}" />
<p:separator />
<p:menuitem value="Consultar medicos de familia por CAP" icon="pi pi-search" action="#{menuView.goManageSpecialties}" />
<p:separator />
<p:menuitem value="Nuevo administrador" icon="pi pi-user" action="#{menuView.goManageSpecialties}" />
</p:submenu>
<p:submenu label="Visitas" icon="pi pi-calendar">
<p:menuitem value="Programar visita" icon="pi pi-briefcase" action="#{menuView.goVisit}" />
<p:menuitem value="Ver visitas programadas" icon="pi pi-briefcase" action="#{menuView.goVisit}" />
</p:submenu>
<p:submenu label="Pruebas médicas" icon="pi pi-clone">
<p:menuitem value="Gestionar pruebas médicas" icon="pi pi-briefcase" action="#{menuView.goMedicalTests}" />
<p:menuitem value="Consultar médicos especialistas por especialidad" action="#{menuView.goMedicalTests}" />
<p:separator />
<p:menuitem value="Listar medicos especialistas por especialidad" icon="pi pi-search" action="#{menuView.goMedicalTests}" />
</p:submenu>
<p:submenu label="Preguntas" icon="pi pi-clone">
<p:menuitem value="Añadir pregunta" action="#{menuView.goMedicalTests}" />
<p:menuitem value="Responder prguntas pendientes" icon="pi pi-search" action="#{menuView.goMedicalTests}" />
</p:submenu>
<p:submenu label="Perfil" icon="pi pi-id-card">
<p:menuitem value="Nuevo paciente" icon="pi pi-briefcase" outcome="AddPatient" />
<p:menuitem value="Nuevo médico de familia" outcome="AddFamilyDoctor" />
<p:menuitem value="Nuevo médico especialista" outcome="AddSpecialistDoctor" />
<p:separator />
<p:menuitem value="Actualizar mi perfil" icon="pi pi-search" action="#{menuView.goUpdateProfile}" />
<p:separator />
<p:menuitem value="Cambiar médico de familia" icon="pi pi-search" outcome="ChangeFamilyDoctor" />
<p:separator />
<p:menuitem value="Cambiar de CAP" icon="pi pi-search" outcome="changecap" />
</p:submenu>
<h:form id="frmLogin">
<p:dialog header="Acceder al sistema" width="350px" widgetVar="dlgLogin" resizable="false" modal="true" closeOnEscape="true">
<div class="ui-g ui-fluid">
<div class="ui-g-12">
<h:outputLabel for="username" value="Usuario:" />
<p:inputText id="username" value="#{loginView.username}" />
</div>
<div class="ui-g-12">
<h:outputLabel for="password" value="Contraseña:" />
<p:password id="password" value="#{loginView.password}" />
</div>
<div class="ui-g-6">
<p:commandButton value="Login" update="frmMenu, messages" icon="pi pi-sign-in" action="#{loginView.login}" onstart="startLogin()"
oncomplete="handleLoginRequest(xhr, status, args)" />
</div>
<div class="ui-g-6">
<p:commandButton value="Cancel" icon="pi pi-ban" onclick="PF('dlgLogin').hide();" />
</div>
</div>
</p:dialog>
</h:form>
<h:form id="frmMenu">
<p:menubar model="#{menuView.model}">
<f:facet name="options"> <f:facet name="options">
<ui:fragment rendered="#{home.logedIn}"> <ui:fragment rendered="#{home.logedIn}">
<h:outputText value="hola, #{home.userName} " /> <h:outputText value="hola, #{home.userName} " />
<p:commandButton value="Logout" update="messages" icon="pi pi-user" action="#{loginView.logout}" /> <p:commandButton value="Logout" icon="pi pi-sign-out" action="#{loginView.logout}" />
</ui:fragment> </ui:fragment>
<ui:fragment rendered="#{not home.logedIn}"> <ui:fragment rendered="#{not home.logedIn}">
<h:outputText value="hola, invitado " /> <h:outputText value="hola, invitado " />
<p:commandButton value="login" icon="pi pi-user" onclick="PF('dlgLogin').show();" title="login" /> <p:commandButton value="login" icon="pi pi-sign-in" onclick="PF('dlgLogin').show();" title="login" />
<p:button value="Registrarse" icon="pi pi-user" outcome="RegisterUser" /> <p:button value="Registrarse" icon="pi pi-user-plus" outcome="/profile/RegisterUser" />
<p:dialog header="Acceder al sistema" widgetVar="dlgLogin" resizable="false">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText id="username" value="#{loginView.username}" required="true" label="username" />
<h:outputLabel for="password" value="Password:" />
<p:password id="password" value="#{loginView.password}" required="true" label="password" />
<f:facet name="footer">
<p:commandButton value="Login" update="messages" icon="pi pi-user" action="#{loginView.login}" oncomplete="handleLoginRequest(xhr, status, args)" />
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
</f:facet>
</h:panelGrid>
</p:dialog>
</ui:fragment> </ui:fragment>
</f:facet> </f:facet>
</p:menubar> </p:menubar>

View File

@@ -23,23 +23,33 @@
<ui:composition template="./header.xhtml"> <ui:composition template="./header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form> <h:form>
<h:outputLink value="javascript:void(0)" onclick="PF('dlg').show();" title="login"> <div class="ui-g ui-fluid">
<h:outputText>Login</h:outputText> <div class="ui-g-4 ui-md-4" />
</h:outputLink> <div class="ui-g-4 ui-md-4">
<p:panel id="LoginPanel" header="Acceder al sistema">
<div class="ui-g ui-fluid">
<div class="ui-g-12">
<h:outputLabel for="username" value="Usuario:" />
<p:inputText id="username" value="#{loginView.username}" />
</div>
<p:growl id="growl" sticky="true" showDetail="true" life="3000" /> <div class="ui-g-12">
<h:outputLabel for="password" value="Contraseña:" />
<p:password id="password" value="#{loginView.password}" />
</div>
<h:panelGrid columns="2" cellpadding="5"> <div class="ui-g-6">
<h:outputLabel for="username" value="Username:" /> <p:commandButton value="Login" update="frmMenu, messages" icon="pi pi-sign-in" action="#{loginView.login}" onstart="startLogin()"
<p:inputText id="username" value="#{loginView.username}" required="true" label="username" /> oncomplete="handleLoginRequest(xhr, status, args)" />
</div>
<h:outputLabel for="password" value="Password:" /> <div class="ui-g-6">
<p:password id="password" value="#{loginView.password}" required="true" label="password" /> <p:button value="Volver" outcome="/home" icon="pi pi-home" />
</div>
<f:facet name="footer"> </div>
<p:commandButton value="Login" update="growl" action="#{loginView.login}" oncomplete="handleLoginRequest(xhr, status, args)" /> </p:panel>
</f:facet> </div>
</h:panelGrid> <div class="ui-g-4 ui-md-4" />
</div>
</h:form> </h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>

View File

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

View File

@@ -4,56 +4,33 @@
<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">
<h:outputScript>
function handleActionMessage(xhr, status, args) {
if(args.validationFailed || !args.loggedIn) {
PF('dlgLogin').jq.effect("shake", {times:5}, 100);
}
else {
PF('dlgLogin').hide();
$('#loginLink').fadeOut();
}
}
</h:outputScript>
<ui:composition template="../header.xhtml"> <ui:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form> <h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true"> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:autoUpdate />
</p:messages>
<p:panel id="AltaPaciente" header="Registrarse en el sistema como paciente"> <p:panel id="DatosPersonales" header="Añadir un nuevo paciente">
<h:panelGrid columns="3"> <div class="ui-g ui-fluid">
<p:outputLabel value="NIF:" for="nif" /> <div class="ui-g-2 ui-md-2">
<p:inputText id="nif" required="true" requiredMessage="Por favor, indque su NIF" /> <p:outputLabel value="Campo1:" for="campo1" />
<p:message for="nif" /> </div>
<div class="ui-g-4 ui-md-4">
<p:outputLabel value="Nombre:" for="name" /> <p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
<p:inputText id="name" required="true" requiredMessage="Por favor, indique su nombre" /> </div>
<p:message for="name" /> <div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
<p:outputLabel value="Apellidos:" for="surname" /> </div>
<p:inputText id="surname" required="true" requiredMessage="Por favor, indique sus apellidos" /> <div class="ui-g-12 ui-g-nopad">
<p:message for="surname" /> <div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:outputLabel value="Correo electrónico:" for="email"/> <p:commandButton validateClient="true" value="Guardar" update="mesgs" icon="pi pi-check" />
<p:inputText id="email" required="true" requiredMessage="Por favor, especifique su correo electrónico" /> </div>
<p:message for="email" /> <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>
<p:inputMask id="password" mask="*" required="true" requiredMessage="Por faovr, especifique una contraseña" maxlength="50" /> <div class="ui-g-4 ui-md-4"></div>
<p:message for="password" /> </div>
</div>
<p:outputLabel value="Repita su contraseña:" for="passwordRepeat" />
<p:inputMask id="passwordRepeat" mask="*" />
<p:message for="passwordRepeat" />
</h:panelGrid>
<h:panelGroup>
<h:panelGrid columns="3" >
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" action="#{addPatientMBean.save}" icon="pi pi-check" />
<p:commandButton value="Volver" outcome="home" />
</h:panelGrid>
</h:panelGroup>
</p:panel> </p:panel>
</h:form> </h:form>
</ui:define> </ui:define>

View File

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

View File

@@ -2,23 +2,38 @@
<!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" <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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml"> <ui:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form id="errorForm"> <h:form id="frmRegisterUser">
<div align="center"> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<h1>ChangeFamilyDoctor Page</h1>
<hr/> <p:panel id="DatosPersonales" header="Cambiar médico de familia">
<div>ChangeFamilyDoctor:</div> <div class="ui-g ui-fluid">
<div> <div class="ui-g-2 ui-md-2">
ChangeFamilyDoctor content <p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</div>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Guardar" update="mesgs" icon="pi pi-check" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="home" icon="pi pi-home"/>
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</div> </div>
</div> </p:panel>
<p align="center"> </h:form>
<h:button value="Volver al inicio" outcome="home" />
</p>
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</html> </html>

View File

@@ -1,24 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!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" <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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml"> <ui:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form id="errorForm"> <h:form id="frmRegisterUser">
<div align="center"> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<h1>ChangePrimaryHealthCareCenter Page</h1>
<hr/> <p:panel id="DatosPersonales" header="Cambiar el Centro de Atención Primaria">
<div>ChangePrimaryHealthCareCenter:</div> <div class="ui-g ui-fluid">
<div> <div class="ui-g-2 ui-md-2">
ChangePrimaryHealthCareCenter content <p:outputLabel value="Campo1:" for="campo1" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</div>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Guardar" update="mesgs" icon="pi pi-check" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</div> </div>
</div> </p:panel>
<p align="center"> </h:form>
<h:button value="Volver al inicio" outcome="home" />
</p>
</h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
</html> </html>

View File

@@ -6,88 +6,184 @@
<ui:composition template="../header.xhtml"> <ui:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:outputScript> <h:form id="frmRegisterUserResult" rendered="#{RegisterUser.registered}">
<div class="ui-g-3 ui-md-3" />
<div class="ui-g-6 ui-md-6">
<p:panel id="DatosPersonales" header="El registro se ha realizado correctamente">
<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.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>
</p:panel>
</div>
<div class="ui-g-3 ui-md-3" />
</h:form>
<h:form id="frmRegisterUser" rendered="#{not RegisterUser.registered}">
<h:outputScript>
function handleRequest(xhr, status, args) { function handleRequest(xhr, status, args) {
if(args.specs) { if(args.specs) {
PF('panCentros').hide(); $('#panCentros').slideUp();
$('#panCentros').fadeOut(); $('#panEspecialidades').slideDown();
PF('panEspecialidad').show()
$('#panEspecialidad').fadeIn();
} }
else if (args.caps) { else if (args.caps) {
PF('panEspecialidad').hide(); $('#panEspecialidades').slideUp();
$('#panEspecialidad').fadeOut(); $('#panCentros').slideDown();
PF('panCentros').show() } else {
$('#panCentros').fadeIn(); $('#panCentros').slideUp();
$('#panEspecialidades').slideUp();
} }
} }
</h:outputScript> </h:outputScript>
<h:form>
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" /> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse"> <p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5"> <div class="ui-g ui-fluid">
<p:selectOneButton id="selUsertype" value="#{registerUser.userType}" required="true" requiredMessage="Debe especificar un tipo de usuario"> <div class="ui-g-2 ui-md-2">
<f:selectItems value="#{registerUser.userTypes}" /> <p:outputLabel value="Tipo de usuario:" for="selUsertype" />
<p:ajax listener="#{registerUser.onUserTypeChange}" update="medicalSpecialty" oncomplete="handleRequest(xhr, status, args)" /> </div>
</p:selectOneButton> <div class="ui-g-6 ui-md-6">
</h:panelGrid> <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> </p:panel>
<p:panel id="RegisterUser" header="Datos personales para el usuario"> <br />
<div class="ui-fluid"> <p:panel id="DatosPersonales" header="Especifique el tipo de usuario que desea registrarse">
<h:panelGrid columns="3" layout="grid" columnClasses="p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4, p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4" <div class="ui-g ui-fluid">
contentStyleClass="ui-fluid"> <div class="ui-g-2 ui-md-2">
<p:outputLabel value="NIF:" for="nif" /> <p:outputLabel value="NIF:" for="nif" />
<p:inputText id="nif" value="#{registerUser.nif}" required="true" requiredMessage="Por favor, indque su 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" /> <p:message for="nif" display="text" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Nombre:" for="name" /> <p:outputLabel value="Nombre:" for="name" />
<p:inputText id="name" value="#{registerUser.name}" required="true" requiredMessage="Por favor, indique su nombre" /> </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" /> <p:message for="name" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Apellidos:" for="surname" /> <p:outputLabel value="Apellidos:" for="surname" />
<p:inputText id="surname" value="#{registerUser.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" /> </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" /> <p:message for="surname" />
</div>
<p:outputLabel value="Especialidad médica:" for="medicalSpecialty" /> <div class="ui-g-2 ui-md-2">
<p:selectOneMenu id="medicalSpecialty" value="#{registerUser.medicalSpecialty}" style="width:350px">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{registerUser.medicalSpecialties}" var="c.TO" itemDescription="#{c.description}" itemValue="#{c.name}" />
</p:selectOneMenu>
<p:message for="medicalSpecialty" />
<p:outputLabel value="Centro:" for="primaryHealthCareCenter" />
<p:selectOneMenu id="primaryHealthCareCenter" value="#{registerUser.medicalSpecialty}" style="width:350px">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{registerUser.medicalSpecialties}" var="c" itemDescription="#{c.description}" itemValue="#{c.name}" />
</p:selectOneMenu>
<p:message for="primaryHealthCareCenter" />
<p:outputLabel value="Correo electrónico:" for="email" /> <p:outputLabel value="Correo electrónico:" for="email" />
<p:inputText id="email" value="#{registerUser.email}" required="true" requiredMessage="Por favor, especifique su correo electrónico" /> </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" /> <p:message for="email" />
</div>
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Contraseña" for="password" /> <p:outputLabel value="Contraseña" for="password" />
<p:password id="password" value="#{registerUser.password}" match="passwordRepeat" required="true" requiredMessage="Por favor, especifique una contraseña" maxlength="50" </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" 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 class="ui-g-6 ui-md-6">
<p:message for="password" /> <p:message for="password" />
</div>
<div class="ui-g-2">
<p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" /> <p:outputLabel value="Verificación de contraseña:" for="passwordRepeat" />
<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-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" /> <p:message for="passwordRepeat" />
</div>
<div id="panCentros" class="ui-g-12 ui-g-nopad hide">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Centro:" for="selPHC" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{RegisterUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.familyDoctor}"
requiredMessage="Por favor, selecciona un centro de antención primaria">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
<p:column>#{phc.name}</p:column>
<p:column>#{phc.location}</p:column>
</p:selectOneMenu>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selPHC" />
</div>
</div>
<div id="panEspecialidades" class="ui-g-12 ui-g-nopad hide">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Especialidad médica:" for="selMS" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{RegisterUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.specialistDoctor}"
requiredMessage="Por favor, seleccione una especialidad médica">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
<p:column>#{ms.name}</p:column>
<p:column>#{ms.description}</p:column>
</p:selectOneMenu>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selMS" />
</div>
</div>
</h:panelGrid> <div class="ui-g-12 ui-g-nopad">
<h:panelGrid columns="3" layout="grid" columnClasses="p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4, p-col-12 p-md-3 p-xl-2, p-col-12 p-md-9 p-xl-4"> <div class="ui-g-4 ui-md-4"></div>
<p:commandButton type="button" validateClient="true" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" /> <div class="ui-g-2 ui-md-2 ">
<p:commandButton type="button" value="Volver" outcome="home" /> <p:commandButton validateClient="true" ajax="false" value="Registrarse" update="mesgs" action="#{RegisterUser.addNewUser}" icon="pi pi-check" />
</div>
</h:panelGrid> <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> </div>
</p:panel> </p:panel>
</h:form> </h:form>
</ui:define> </ui:define>

View File

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

View File

@@ -1,20 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml"> <ui:composition template="../header.xhtml">
<ui:define name="content"> <ui:define name="content">
<h:form id="errorForm"> <h:form id="frmRegisterUser">
<div align="center"> <p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<h1>ShowPaciente Page</h1>
<hr /> <p:panel id="DatosPersonales" header="Consultar datos de paciente">
<div>ShowPaciente:</div> <div class="ui-g ui-fluid">
<div>ShowPaciente content</div> <div class="ui-g-2 ui-md-2">
</div> <p:outputLabel value="Campo1:" for="campo1" />
<p align="center"> </div>
<h:button value="Volver al inicio" outcome="home" /> <div class="ui-g-4 ui-md-4">
</p> <p:inputText id="campo1" value="123 asdf 123" required="true" requiredMessage="Por favor, indque el campo 1" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="campo1" display="text" />
</div>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Guardar" update="mesgs" icon="pi pi-check" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</div>
</p:panel>
</h:form> </h:form>
</ui:define> </ui:define>
</ui:composition> </ui:composition>

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h: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>
<h:form id="frmRegisterUser">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="tipoUsuario" header="Tipo de usuario registrado">
<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}" disabled="true" 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:selectOneButton>
</div>
<div class="ui-g-4 ui-md-4"></div>
</div>
</p:panel>
<br/>
<p:panel id="DatosPersonales" header="Actualizar datos personales">
<div class="ui-g ui-fluid">
<div class="ui-g-2 ui-md-2">
<h:outputLabel value="value = 10" rendered="#{row == 10}" />
<p:outputLabel value="Código de Identificación Personal (CIP):" rendered="#{RegisterUser.patient}" for="id" />
<p:outputLabel value="Número de Profesional:" rendered="#{RegisterUser.familyDoctor or RegisterUser.specialistDoctor}" for="id" />
</div>
<div class="ui-g-4 ui-md-4">
<p:inputText id="id" value="#{RegisterUser.id}" disabled="true" required="true" requiredMessage="Por favor, indque su identificador" />
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="id" display="text" />
</div>
<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">
<p:outputLabel value="Centro:" for="selPHC" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selPHC" value="#{RegisterUser.primaryHealthCareCenter}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.familyDoctor}"
requiredMessage="Por favor, selecciona un centro de antención primaria">
<f:selectItem itemLabel="Seleccione un centro de antención primario..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.phcList}" var="phc" itemLabel="#{phc.location}" itemValue="#{phc}" />
<p:column>#{phc.name}</p:column>
<p:column>#{phc.location}</p:column>
</p:selectOneMenu>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selPHC" />
</div>
</div>
<div id="panEspecialidades" class="ui-g-12 ui-g-nopad hide">
<div class="ui-g-2 ui-md-2">
<p:outputLabel value="Especialidad médica:" for="selMS" />
</div>
<div class="ui-g-4 ui-md-4">
<p:selectOneMenu id="selMS" value="#{RegisterUser.medicalSpecialty}" converter="omnifaces.SelectItemsConverter" required="#{RegisterUser.specialistDoctor}"
requiredMessage="Por favor, seleccione una especialidad médica">
<f:selectItem itemLabel="Seleccione una especialidad médica..." itemValue="" noSelectionOption="true" />
<f:selectItems value="#{RegisterUser.medicalSpecialtiesList}" var="ms" itemLabel="#{ms.description}" itemValue="#{ms}" />
<p:column>#{ms.name}</p:column>
<p:column>#{ms.description}</p:column>
</p:selectOneMenu>
</div>
<div class="ui-g-6 ui-md-6">
<p:message for="selMS" />
</div>
</div>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" 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>
</ui:define>
</ui:composition>
</html>

View File

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

View File

@@ -1,3 +1,7 @@
BODY{ BODY{
font-family: Verdana, Arial, Helvetica, sans-serif; font-family: Verdana, Arial, Helvetica, sans-serif;
}
.hide {
display: none;
} }

View File

@@ -0,0 +1,67 @@
package TO;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import common.UserType;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@XmlRootElement(name = "LoggedUser")
public class LoggedUserTO implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private String password;
private String name;
private UserType userType;
public LoggedUserTO() {
super();
}
public LoggedUserTO(String usrId, String usrName, String usrPwd, UserType usrType) {
id = usrId;
name = usrName;
password = usrPwd;
userType = usrType;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UserType getUserType() {
return userType;
}
public void setUserType(UserType userType) {
this.userType = userType;
}
}

View File

@@ -41,4 +41,10 @@ public class MedicalSpecialtyTO implements Serializable {
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
@Override
public String toString() {
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
}
} }

View File

@@ -15,16 +15,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String name; private String name;
private String description; private String location;
public PrimaryHealthCareCenterTO() { public PrimaryHealthCareCenterTO() {
super(); super();
} }
public PrimaryHealthCareCenterTO(String name, String description) { public PrimaryHealthCareCenterTO(String name, String location) {
this.name = name; this.name = name;
this.description = description; this.location = location;
} }
public String getName() { public String getName() {
@@ -35,12 +35,16 @@ public class PrimaryHealthCareCenterTO implements Serializable {
this.name = name; this.name = name;
} }
public String getDescription() { public String getLocation() {
return description; return location;
} }
public void setDescription(String description) { public void setLocation(String description) {
this.description = description; this.location = description;
}
@Override
public String toString() {
return String.format("%s[name=%s]", getClass().getSimpleName(), getName());
} }
} }

View File

@@ -0,0 +1,24 @@
package common;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.xml.bind.DatatypeConverter;
public class HashUtils {
public static String hashMD5(String stringValue) {
byte[] digest = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(stringValue.getBytes());
digest = md.digest();
} catch (Exception ex) {
// TODO: Register exception to log.
}
return (DatatypeConverter.printHexBinary(digest).toUpperCase());
}
}

View File

@@ -1,4 +1,4 @@
package managedbean.common; package common;
public enum UserType { public enum UserType {
PATIENT("Paciente"), PATIENT("Paciente"),
@@ -15,4 +15,8 @@ public enum UserType {
public String getUserTypename() { public String getUserTypename() {
return userTypename; return userTypename;
} }
public String getName() {
return this.name();
}
} }

View File

@@ -9,6 +9,7 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import common.HashUtils;
import jpa.FamilyDoctorJPA; import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA; import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA; import jpa.PatientJPA;
@@ -44,8 +45,11 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) { public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email) {
PatientTO paTO = null; PatientTO paTO = null;
if (id == null)
id = 1;
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email); PatientJPA ms = new PatientJPA(nif, name, surname, HashUtils.hashMD5(password), email);
entman.persist(ms); entman.persist(ms);
paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail()); paTO = new PatientTO(ms.getId(), ms.getNif(), ms.getName(), ms.getSurname(), ms.getPassword(), ms.getEmail());
@@ -59,25 +63,24 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
// TODO: Lanzar error si no se encuentra la especialidad. // TODO: Lanzar error si no se encuentra la especialidad.
if (ms != null) { if (ms != null) {
SpecialistDoctorJPA sd = new SpecialistDoctorJPA(id, nif, name, surname, password, email); SpecialistDoctorJPA sd = new SpecialistDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, ms);
entman.persist(sd); entman.persist(sd);
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail()); sdTO = new SpecialistDoctorTO(sd.getId(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail());
} }
return sdTO; return sdTO;
} }
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap) { public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap) {
FamilyDoctorTO fdTO = null; FamilyDoctorTO fdTO = null;
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap); PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap.getName());
// TODO: Lanzar error si no encontramos el cap!!!!! // TODO: Lanzar error si no encontramos el cap!!!!!
if (phcC != null) { if (phcC != null) {
FamilyDoctorJPA fd = new FamilyDoctorJPA(id, nif, name, surname, password, email); FamilyDoctorJPA fd = new FamilyDoctorJPA(nif, name, surname, HashUtils.hashMD5(password), email, 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()); fdTO = new FamilyDoctorTO(fd.getId(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail());
@@ -94,7 +97,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
fd.setNif(nif); fd.setNif(nif);
fd.setName(name); fd.setName(name);
fd.setSurname(surname); fd.setSurname(surname);
fd.setPassword(password); fd.setPassword(HashUtils.hashMD5(password));
fd.setEmail(email); fd.setEmail(email);
entman.persist(fd); entman.persist(fd);
@@ -117,7 +120,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
sd.setNif(nif); sd.setNif(nif);
sd.setName(name); sd.setName(name);
sd.setSurname(surname); sd.setSurname(surname);
sd.setPassword(password); sd.setPassword(HashUtils.hashMD5(password));
sd.setEmail(email); sd.setEmail(email);
sd.setMedicalSpecialty(ms); sd.setMedicalSpecialty(ms);
@@ -137,7 +140,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
fd.setNif(nif); fd.setNif(nif);
fd.setName(name); fd.setName(name);
fd.setSurname(surname); fd.setSurname(surname);
fd.setPassword(password); fd.setPassword(HashUtils.hashMD5(password));
fd.setEmail(email); fd.setEmail(email);
// TODO: Es posible actualizar el cap? ¿No debería utilizar el método // TODO: Es posible actualizar el cap? ¿No debería utilizar el método

View File

@@ -20,15 +20,13 @@ public interface ProfileFacadeRemote {
public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email); public PatientTO registerPatient(Integer id, String nif, String name, String surname, String password, String email);
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email, public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
MedicalSpecialtyTO specialty);
public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, String cap); public FamilyDoctorTO registerFamilyDoctor1(Integer id, String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterTO cap);
public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email); public PatientTO updatePacientData(Integer id, String nif, String name, String surname, String password, String email);
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email, public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty);
MedicalSpecialtyTO specialty);
public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap); public FamilyDoctorTO updateFamilyDoctorData(Integer id, String nif, String name, String surname, String password, String email, String cap);

View File

@@ -8,15 +8,21 @@ import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.Query; import javax.persistence.Query;
import TO.LoggedUserTO;
import TO.MedicalSpecialtyTO; import TO.MedicalSpecialtyTO;
import TO.PrimaryHealthCareCenterTO;
import common.HashUtils;
import common.UserType;
import jpa.AdministratorJPA;
import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA; import jpa.MedicalSpecialtyJPA;
import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA;
import jpa.SpecialistDoctorJPA;
/** /**
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
* métodos de la capa de negocio que implementan la logica de negocio y la
* interacción con la capa de persistencia.
* *
* @author mark * @author Marcos García Núñez (mgarcianun@uoc.edu)
* *
*/ */
@Stateless @Stateless
@@ -59,4 +65,76 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
return allSpecialities; return allSpecialities;
} }
public Collection<PrimaryHealthCareCenterTO> listAllCAPs() {
return this.listPagedAllCAPs(0, 0);
}
public Collection<PrimaryHealthCareCenterTO> listPagedAllCAPs(int pageNumber, int pageSize) {
Query query = entman.createQuery("from PrimaryHealthCareCenterJPA order by name");
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
@SuppressWarnings("unchecked")
Collection<PrimaryHealthCareCenterJPA> allJPA = query.getResultList();
Collection<PrimaryHealthCareCenterTO> allCAPs = new ArrayList<PrimaryHealthCareCenterTO>();
for (PrimaryHealthCareCenterJPA cap : allJPA) {
allCAPs.add(new PrimaryHealthCareCenterTO(cap.getName(), cap.getLocation()));
}
return allCAPs;
}
public LoggedUserTO login(String id, String pwd) {
LoggedUserTO usr = null;
// First try to login as Admin
AdministratorJPA adm = entman.find(AdministratorJPA.class, id);
if (adm != null) {
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRADOR);
} else {
try {
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;
}
}
if (usr != null) {
// Comprobamos el password
if (usr.getPassword().equals(HashUtils.hashMD5(pwd)) == false) {
// Bad Password, devolvemos null!
usr = null;
}
}
return usr;
}
} }

View File

@@ -4,13 +4,13 @@ import java.util.Collection;
import javax.ejb.Remote; import javax.ejb.Remote;
import TO.LoggedUserTO;
import TO.MedicalSpecialtyTO; import TO.MedicalSpecialtyTO;
import TO.PrimaryHealthCareCenterTO;
/** /**
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
* los clientes del EJB
* *
* @author mark * @author Marcos García Núñez (mgarcianun@uoc.edu)
* *
*/ */
@Remote @Remote
@@ -19,4 +19,8 @@ public interface SystemAdminFacadeRemote {
* Definimos la interfaz remota * Definimos la interfaz remota
*/ */
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities(); public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
public Collection<PrimaryHealthCareCenterTO> listAllCAPs();
public LoggedUserTO login(String id, String pwd);
} }

View File

@@ -0,0 +1,52 @@
package jpa;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Entity
@Table(name = "MyHealth.Administrator")
public class AdministratorJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String email;
private String password;
/**
* Class constructor methods
*/
public AdministratorJPA() {
super();
}
public AdministratorJPA(String email, String password) {
this.email = email;
this.password = password;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@@ -26,7 +26,7 @@ public class FamilyDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
private Integer id; private int id;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -42,22 +42,22 @@ public class FamilyDoctorJPA implements Serializable {
super(); super();
} }
public FamilyDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) { public FamilyDoctorJPA(String nif, String name, String surname, String password, String email, PrimaryHealthCareCenterJPA phc) {
this.id = id;
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
this.password = password; this.password = password;
this.email = email; this.email = email;
this.primaryHealthCareCenter = phc;
} }
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() { public int getId() {
return id; return id;
} }
public void setId(Integer value) { public void setId(int value) {
this.id = value; this.id = value;
} }
@@ -123,6 +123,4 @@ public class FamilyDoctorJPA implements Serializable {
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) { public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterJPA center) {
this.primaryHealthCareCenter = center; this.primaryHealthCareCenter = center;
} }
} }

View File

@@ -23,7 +23,7 @@ public class PatientJPA implements Serializable {
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
private Integer id; private int id;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -40,8 +40,7 @@ public class PatientJPA implements Serializable {
super(); super();
} }
public PatientJPA(Integer id, String nif, String name, String surname, String password, String email) { public PatientJPA(String nif, String name, String surname, String password, String email) {
this.id = id;
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
@@ -49,11 +48,11 @@ public class PatientJPA implements Serializable {
this.email = email; this.email = email;
} }
public Integer getId() { public int getId() {
return id; return id;
} }
public void setId(Integer value) { public void setId(int value) {
this.id = value; this.id = value;
} }

View File

@@ -19,7 +19,7 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
@Id @Id
private String name; private String name;
private String description; private String location;
/** /**
* Class constructor methods * Class constructor methods
@@ -28,9 +28,9 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
super(); super();
} }
public PrimaryHealthCareCenterJPA(String name, String description) { public PrimaryHealthCareCenterJPA(String name, String location) {
this.name = name; this.name = name;
this.description = description; this.location = location;
} }
public String getName() { public String getName() {
@@ -41,11 +41,11 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
this.name = name; this.name = name;
} }
public String getDescription() { public String getLocation() {
return description; return location;
} }
public void setDescription(String description) { public void setLocation(String description) {
this.description = description; this.location = description;
} }
} }

View File

@@ -22,7 +22,7 @@ public class SpecialistDoctorJPA implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
private Integer id; private int id;
private String nif; private String nif;
private String name; private String name;
private String surname; private String surname;
@@ -37,22 +37,22 @@ public class SpecialistDoctorJPA implements Serializable {
super(); super();
} }
public SpecialistDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) { public SpecialistDoctorJPA(String nif, String name, String surname, String password, String email, MedicalSpecialtyJPA ms) {
this.id = id;
this.nif = nif; this.nif = nif;
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
this.password = password; this.password = password;
this.email = email; this.email = email;
this.medicalSpecialty = ms;
} }
@Id @Id
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() { public int getId() {
return id; return id;
} }
public void setId(Integer value) { public void setId(int value) {
this.id = value; this.id = value;
} }
@@ -97,7 +97,7 @@ public class SpecialistDoctorJPA implements Serializable {
} }
@ManyToOne @ManyToOne
@JoinColumn(name = "MedicalSpecialtyName") @JoinColumn(name = "MedicalSpecialtyId")
public MedicalSpecialtyJPA getMedicalSpecialty() { public MedicalSpecialtyJPA getMedicalSpecialty() {
return medicalSpecialty; return medicalSpecialty;
} }

View File

@@ -1,3 +1,4 @@
<<<<<<< HEAD
package jpa; package jpa;
import java.io.Serializable; import java.io.Serializable;
@@ -103,3 +104,85 @@ public class VisitJPA implements Serializable {
this.patient=pat; this.patient=pat;
} }
} }
=======
package jpa;
import java.io.Serializable;
import java.sql.Time;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Entity
@Table(name = "MyHealth.Visit")
public class VisitJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
private Date date;
private Time time;
private String observations;
private String result;
/**
* Class constructor methods
*/
public VisitJPA() {
super();
}
public VisitJPA(Integer id, Date date, Time time, String observations, String result) {
this.id = id;
this.date=date;
this.time = time;
this.observations = observations;
this.result = result;
}
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getId() {
return id;
}
public void setId(Integer value) {
this.id = value;
}
public Date getDate() {
return date;
}
public void setDate(Date value) {
this.date = value;
}
public Time getTime() {
return time;
}
public void setTime(Time value) {
this.time = value;
}
public String getObservations() {
return observations;
}
public void setObservations(String observation) {
this.observations = observations;
}
}
>>>>>>> branch 'master' of http://pdp-pds.eimt.uoc.edu/pds19-grupo2/myhealth.git

View File

@@ -26,20 +26,19 @@ public class AuthorizationFilter implements Filter {
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
throws IOException, ServletException {
try { try {
HttpServletRequest reqt = (HttpServletRequest) request; HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response; HttpServletResponse resp = (HttpServletResponse) response;
HttpSession ses = reqt.getSession(false); HttpSession ses = req.getSession(false);
String reqURI = reqt.getRequestURI(); String reqURI = req.getRequestURI();
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null) if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.indexOf("/public/") >= 0
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource")) || reqURI.contains("javax.faces.resource") || SessionUtils.isLogedIn(ses) == true)
chain.doFilter(request, response); chain.doFilter(request, response);
else else
resp.sendRedirect(reqt.getContextPath() + "/login.xhtml"); resp.sendRedirect(req.getContextPath() + "/login.xhtml");
} catch (Exception e) { } catch (Exception e) {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }

View File

@@ -0,0 +1,103 @@
package managedbean.common;
import java.util.Properties;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import ejb.medicalTest.MedicalTestFacadeRemote;
import ejb.profile.ProfileFacadeRemote;
import ejb.systemAdmin.SystemAdminFacadeRemote;
import ejb.visit.VisitFacadeRemote;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
public class ManagedBeanBase {
@EJB
protected ProfileFacadeRemote remoteManagerProfile;
@EJB
protected SystemAdminFacadeRemote remoteManagerSystemAdmin;
@EJB
protected VisitFacadeRemote remoteManagerVisit;
@EJB
protected MedicalTestFacadeRemote remoteManagerMedicalTest;
/**
* Inicializa la conexión con el EJB Remoto
*
* @return
*
* @throws Exception
*/
private <T> T getContext(String name, Class<T> type) {
T retObj = null;
try {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
retObj = type.cast(ctx.lookup(name));
} catch (NamingException e) {
this.manageException(e);
}
return retObj;
}
protected ProfileFacadeRemote getRemoteManagerProfile() {
if (remoteManagerProfile == null) {
remoteManagerProfile = this.getContext("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote", ProfileFacadeRemote.class);
}
return remoteManagerProfile;
}
protected SystemAdminFacadeRemote getRemoteManagerSystemAdmin() {
if (remoteManagerSystemAdmin == null) {
remoteManagerSystemAdmin = this.getContext("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote", SystemAdminFacadeRemote.class);
}
return remoteManagerSystemAdmin;
}
protected VisitFacadeRemote getRemoteManagerVisit() {
if (remoteManagerVisit == null) {
remoteManagerVisit = this.getContext("java:app/MyHealth.jar/VisitFacadeBean!ejb.systemAdmin.VisitFacadeRemote", VisitFacadeRemote.class);
}
return remoteManagerVisit;
}
protected MedicalTestFacadeRemote getRemoteManagerMedicalTest() {
if (remoteManagerMedicalTest == null) {
remoteManagerMedicalTest = this.getContext("java:app/MyHealth.jar/MedicalTestFacadeBean!ejb.systemAdmin.MedicalTestFacadeRemote", MedicalTestFacadeRemote.class);
}
return remoteManagerMedicalTest;
}
protected void addFacesMessageKeep(FacesMessage.Severity severity, String summary, String detail) {
FacesContext context = FacesContext.getCurrentInstance();
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
context.getExternalContext().getFlash().setKeepMessages(true);
}
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
this.addFacesMessage(FacesContext.getCurrentInstance(), severity, summary, detail);
}
protected void addFacesMessage(FacesContext context, FacesMessage.Severity severity, String summary, String detail) {
context.addMessage(null, new FacesMessage(severity, summary, detail));
}
protected void manageException(Exception ex) {
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
}
}

View File

@@ -1,5 +1,6 @@
package managedbean.common; package managedbean.common;
import java.awt.MenuItem;
import java.io.Serializable; import java.io.Serializable;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@@ -10,49 +11,115 @@ import javax.inject.Named;
import org.primefaces.model.menu.DefaultMenuItem; import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel; import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.DefaultSeparator;
import org.primefaces.model.menu.DefaultSubMenu; import org.primefaces.model.menu.DefaultSubMenu;
import org.primefaces.model.menu.MenuModel; import org.primefaces.model.menu.MenuModel;
import org.primefaces.model.menu.Submenu;
/**
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("menuView") @Named("menuView")
@RequestScoped @RequestScoped
public class MenuMBean implements Serializable { public class MenuMBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private MenuModel model; private MenuModel model;
@PostConstruct @PostConstruct
public void init() { public void init() {
model = new DefaultMenuModel(); model = new DefaultMenuModel();
DefaultMenuItem item;
DefaultSubMenu subMenu;
// First submenu model.addElement(createMenuItem("Home", "pi pi-home", "/home", null));
DefaultSubMenu firstSubmenu = new DefaultSubMenu("Dynamic submenu");
DefaultMenuItem item = new DefaultMenuItem("External", "", "www.google.com");
// item.setUrl("www.google.com");
firstSubmenu.getElements().add(item);
model.getElements().add(firstSubmenu); if (SessionUtils.isLogedIn() == true) {
// Second submenu // Administracion Sistema
DefaultSubMenu secondSubmenu = new DefaultSubMenu("Dynamic Actions"); // TODO: mostrar este menú solo si el usuario es administrador
if (1 == 1) {
subMenu = new DefaultSubMenu("Administración del sistema", "pi pi-cog");
subMenu.addElement(createMenuItem("Esp. médicas", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null));
subMenu.addElement(createMenuItem("Centros At. Primaria", "pi pi-briefcase", "/systemAdmin/ManageSpecialties", null));
subMenu.addElement(new DefaultSeparator());
subMenu.addElement(createMenuItem("Añadir usuario Admin", "pi pi-calendar", "/systemAdmin/ManageSpecialties", null));
model.addElement(subMenu);
}
item = new DefaultMenuItem("Save", "pi pi-save"); // Visitas
item.setCommand("#{menuView.save}"); // TODO: mostrar este menú solo si el usuario es paciente
item.setUpdate("messages"); if (1 == 1) {
secondSubmenu.getElements().add(item); subMenu = new DefaultSubMenu("Visitas", "pi pi-calendar");
subMenu.addElement(createMenuItem("Agendar", "pi pi-calendar", "/visit/VisitView", null));
subMenu.addElement(createMenuItem("Consultar", "pi pi-briefcase", "/visit/VisitView", null));
model.addElement(subMenu);
}
item = new DefaultMenuItem("Delete", "pi pi-times"); // Pruebas médicas
item.setCommand("#{menuView.delete}"); // TODO: mostrar este menú solo si el usuario es medico // etc...
item.setAjax(false); if (1 == 1) {
secondSubmenu.getElements().add(item);
item = new DefaultMenuItem("Redirect", "pi pi-search"); subMenu = new DefaultSubMenu("Pruebas Medicas", "pi pi-clone");
item.setCommand("#{menuView.redirect}"); subMenu.addElement(createMenuItem("Añadir", "pi pi-clone", "/medicaltest/MedicalTests", null));
secondSubmenu.getElements().add(item); subMenu.addElement(createMenuItem("Gestionar", "pi pi-briefcase", "/medicaltest/MedicalTests", null));
subMenu.addElement(new DefaultSeparator());
subMenu.addElement(createMenuItem("Consultar médicos pro esp.", "pi pi-search", "/medicaltest/MedicalTests", null));
subMenu.addElement(new DefaultSeparator());
subMenu.addElement(createMenuItem("Listar médicos", "pi pi-list", "/medicaltest/MedicalTests", null));
model.addElement(subMenu);
}
model.getElements().add(secondSubmenu); // Preguntas
// TODO: mostrar este menú solo si el usuario es paciente o medico
if (1 == 1) {
subMenu = new DefaultSubMenu("Preguntas", "pi pi-clone");
// TODO: Si es paciente puede preguntar
if (true == true)
subMenu.addElement(createMenuItem("Añadir pregunta", "pi pi-clone", "/medicaltest/MedicalTests", null));
// TODO: Si es medico de familia puede responder
if (true == true)
subMenu.addElement(createMenuItem("Responder pregunta", "pi pi-question", "/medicaltest/MedicalTests", null));
model.addElement(subMenu);
}
}
// Perfil
subMenu = new DefaultSubMenu("Gestionar perfil", "pi pi-id-card");
if (SessionUtils.isLogedIn() == false) {
subMenu.addElement(createMenuItem("Registro de usuario", "pi pi-users", "/profile/RegisterUser", null));
subMenu.addElement(createMenuItem("Registro de paciente", "pi pi-user-plus", "/profile/AddPatient", null));
subMenu.addElement(createMenuItem("Registro de médico", "pi pi-user-plus", "/profile/AddFamilyDoctor", null));
subMenu.addElement(createMenuItem("Registro de especialista", "pi pi-user-plus", "/profile/AddFamilyDoctor", null));
subMenu.addElement(createMenuItem("Registro de médico", "pi pi-user-plus", "/profile/AddSpecialistDoctor", null));
subMenu.addElement(new DefaultSeparator());
} else {
subMenu.addElement(createMenuItem("Actualizar mi perfil", "pi pi-user-edit", "/profile/UpdateProfile", null));
subMenu.addElement(new DefaultSeparator());
// TODO: mostrar este menú solo si el usuario es paciente
if (true == true) {
subMenu.addElement(createMenuItem("Cambiar médico de familia", "pi pi-chevron-circle-right", "/profile/ChangeFamilyDoctor", null));
subMenu.addElement(new DefaultSeparator());
}
// TODO: mostrar este menú solo si el usuario es médico de familia
if (true == true)
subMenu.addElement(createMenuItem("Cambiar CAP", "fa fa-h-square", "/profile/ChangePrimaryHealthCareCenter", null));
}
model.addElement(subMenu);
}
private DefaultMenuItem createMenuItem(String name, String icon, String outcome, String command) {
DefaultMenuItem item = new DefaultMenuItem(name, icon);
if (outcome != null)
item.setOutcome(outcome);
if (command != null)
item.setCommand(command);
return item;
} }
public MenuModel getModel() { public MenuModel getModel() {

View File

@@ -2,39 +2,70 @@
package managedbean.common; package managedbean.common;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import TO.LoggedUserTO;
public class SessionUtils { public class SessionUtils {
public static final String SESSION_VAR_USERNAME = "userName";
public static final String SESSION_VAR_USERID = "userId";
public static final String SESSION_VAR_USERTYPE = "userType";
public static final String SESSION_VAR_USER = "loggedInUser";
public static HttpSession getSession() { public static HttpSession getSession() {
return (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false); FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx != null)
return (HttpSession) ctx.getExternalContext().getSession(false);
else
return null;
} }
public static HttpServletRequest getRequest() { public static HttpServletRequest getRequest() {
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
} }
public static HttpSession getSession(ServletRequest request) {
return ((HttpServletRequest) request).getSession(false);
}
public static void CreateSession(LoggedUserTO usr) {
HttpSession ses = getSession();
ses.setAttribute(SessionUtils.SESSION_VAR_USERNAME, usr.getName());
ses.setAttribute(SessionUtils.SESSION_VAR_USERID, usr.getId());
ses.setAttribute(SessionUtils.SESSION_VAR_USERTYPE, usr.getUserType());
ses.setAttribute(SessionUtils.SESSION_VAR_USER, usr);
}
public static void DestroySession() {
HttpSession ses = getSession();
ses.invalidate();
}
public static boolean isLogedIn() { public static boolean isLogedIn() {
if (getUserId() == "") return isLogedIn(getSession());
return false;
else
return true;
} }
public static boolean isLogedIn(HttpSession session) {
if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
return true;
else
return false;
}
public static String getUserName() { public static String getUserName() {
HttpSession session = getSession(); HttpSession session = getSession();
if (session != null && session.getAttribute("username") != null) if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERNAME) != null)
return session.getAttribute("username").toString(); return session.getAttribute(SessionUtils.SESSION_VAR_USERNAME).toString();
else else
return ""; return "";
} }
public static String getUserId() { public static String getUserId() {
HttpSession session = getSession(); HttpSession session = getSession();
if (session != null && session.getAttribute("userid") != null) if (session != null && session.getAttribute(SessionUtils.SESSION_VAR_USERID) != null)
return session.getAttribute("userid").toString(); return session.getAttribute(SessionUtils.SESSION_VAR_USERID).toString();
else else
return ""; return "";
} }

View File

@@ -5,6 +5,8 @@ import java.io.Serializable;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Named; import javax.inject.Named;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
* @author Marcos García Núñez (mgarcianun@uoc.edu) * @author Marcos García Núñez (mgarcianun@uoc.edu)
@@ -12,7 +14,7 @@ import javax.inject.Named;
*/ */
@Named("AddFamilyDoctorMBean") @Named("AddFamilyDoctorMBean")
@RequestScoped @RequestScoped
public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializable { public class AddFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -21,8 +23,7 @@ public class AddFamilyDoctorMBean extends ProfileMBeanBase implements Serializab
* *
* @throws Exception * @throws Exception
*/ */
public AddFamilyDoctorMBean() throws Exception { public AddFamilyDoctorMBean() {
super.initializeProfileFacadeRemote();
} }
} }

View File

@@ -7,6 +7,8 @@ import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.inject.Named; import javax.inject.Named;
import managedbean.common.ManagedBeanBase;
/** /**
* ManagedBEan que gestiona la edición y actualización de una especialidad * ManagedBEan que gestiona la edición y actualización de una especialidad
* médica. * médica.
@@ -16,7 +18,7 @@ import javax.inject.Named;
*/ */
@Named("addPatientMBean") @Named("addPatientMBean")
@RequestScoped @RequestScoped
public class AddPatientMBean extends ProfileMBeanBase implements Serializable { public class AddPatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -35,8 +37,7 @@ public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
* *
* @throws Exception * @throws Exception
*/ */
public AddPatientMBean() throws Exception { public AddPatientMBean() {
super.initializeProfileFacadeRemote();
} }
public String getEmail() { public String getEmail() {

View File

@@ -7,6 +7,7 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Named; import javax.inject.Named;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -15,7 +16,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named( "AddSpecialistDoctorMBean") @Named( "AddSpecialistDoctorMBean")
@RequestScoped @RequestScoped
public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable { public class AddSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@@ -27,8 +28,7 @@ public class AddSpecialistDoctorMBean extends ProfileMBeanBase implements Serial
* *
* @throws Exception * @throws Exception
*/ */
public AddSpecialistDoctorMBean() throws Exception { public AddSpecialistDoctorMBean() {
super.initializeProfileFacadeRemote();
} }
} }

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named( "ChangeFamilyDoctorMBean") @Named( "ChangeFamilyDoctorMBean")
@RequestScoped @RequestScoped
public class ChangeFamilyDoctorMBean extends ProfileMBeanBase implements Serializable { public class ChangeFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named( "ChangePrimaryHealthCareCenterMBean") @Named( "ChangePrimaryHealthCareCenterMBean")
@RequestScoped @RequestScoped
public class ChangePrimaryHealthCareCenterMBean extends ProfileMBeanBase implements Serializable { public class ChangePrimaryHealthCareCenterMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -1,42 +0,0 @@
package managedbean.profile;
import java.util.Properties;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote;
/***
*
* @author Marcos García Núñez (mgarcianun@uoc.edu)
*
*/
@Named("profileMBean")
public class ProfileMBeanBase {
@EJB
protected ProfileFacadeRemote remoteManager;
/**
* Inicializa la conexión con el EJB Remoto
*
* @throws Exception
*/
protected void initializeProfileFacadeRemote() throws Exception {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
remoteManager = (ProfileFacadeRemote) ctx.lookup("java:app/MyHealth.jar/ProfileFacadeBean!ejb.profile.ProfileFacadeRemote");
}
protected void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
}
protected void manageException(Exception ex) {
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
}
}

View File

@@ -3,15 +3,18 @@ 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.Collection;
import java.util.HashMap; import java.util.List;
import java.util.Properties; import java.util.Properties;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
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.inject.Named; import javax.inject.Named;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.resource.NotSupportedException; import javax.resource.NotSupportedException;
import org.primefaces.PrimeFaces; import org.primefaces.PrimeFaces;
@@ -21,57 +24,65 @@ import TO.MedicalSpecialtyTO;
import TO.PatientTO; import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import common.UserType;
import ejb.systemAdmin.SystemAdminFacadeRemote; import ejb.systemAdmin.SystemAdminFacadeRemote;
import managedbean.common.UserType; import managedbean.common.ManagedBeanBase;
import managedbean.common.ValidationUtils; import managedbean.common.ValidationUtils;
/** /**
* ManagedBEan que gestiona la edición y actualización de una especialidad * ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente"
* médica. * Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
* *
* @author mark * @author Marcos García Núñez (mgarcianun@uoc.edu)
* *
*/ */
@Named("registerUser") @Named("RegisterUser")
@RequestScoped @ViewScoped
public class RegisterUserMBean extends ProfileMBeanBase implements Serializable { public class RegisterUserMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id; private int id;
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 passwordRepeat; private String passwordRepeat;
private String email; private String email;
private HashMap<String, String> userTypes; private boolean registered;
// private HashMap<String, String> userTypes;
private List<UserType> userTypes;
private String userType; private String userType;
private String primaryHealthCareCenter; private PrimaryHealthCareCenterTO primaryHealthCareCenter;
private String medicalSpecialty; private MedicalSpecialtyTO medicalSpecialty;
private Collection<MedicalSpecialtyTO> medicalSpecialities; private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
private Collection<PrimaryHealthCareCenterTO> healthcareCenters; private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
/** /**
* Constructor. Inicializa la conexión con el EJB Remoto * Constructor. Inicializa la conexión con el EJB Remoto
* *
* @throws Exception * @throws Exception
*/ */
public RegisterUserMBean() throws Exception { public RegisterUserMBean() {
super.initializeProfileFacadeRemote();
} }
@PostConstruct @PostConstruct
public void init() { public void init() {
this.userTypes = new HashMap<String, String>(); this.userTypes = new ArrayList<UserType>();
this.userTypes.put(UserType.PATIENT.getUserTypename(), UserType.PATIENT.name()); this.userTypes.add(UserType.PATIENT);
this.userTypes.put(UserType.FAMILY_DOCTOR.getUserTypename(), UserType.FAMILY_DOCTOR.name()); this.userTypes.add(UserType.FAMILY_DOCTOR);
this.userTypes.put(UserType.SPECIALIST_DOCTOR.getUserTypename(), UserType.SPECIALIST_DOCTOR.name()); this.userTypes.add(UserType.SPECIALIST_DOCTOR);
this.userType = UserType.PATIENT.getUserTypename(); this.registered = false;
this.userType = UserType.PATIENT.name();
this.medicalSpecialitiesList = this.getRemoteManagerSystemAdmin().listAllMedicalSpecialities();
this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs();
} }
public HashMap<String, String> getUserTypes() { public List<UserType> getUserTypes() {
return userTypes; return userTypes;
} }
@@ -79,12 +90,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
switch (UserType.valueOf(this.userType)) { switch (UserType.valueOf(this.userType)) {
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
try { try {
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
SystemAdminFacadeRemote rman = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
this.medicalSpecialities = rman.listAllMedicalSpecialities();
PrimeFaces.current().ajax().addCallbackParam("specs", true); PrimeFaces.current().ajax().addCallbackParam("specs", true);
} catch (Exception e) { } catch (Exception e) {
this.manageException(e); this.manageException(e);
@@ -92,11 +97,6 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
break; break;
case FAMILY_DOCTOR: case FAMILY_DOCTOR:
try { try {
// TODO: Load Primary Healthcare Centers from remote EJB
this.healthcareCenters = new ArrayList<PrimaryHealthCareCenterTO>();
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Prueba", "Descripción prueba"));
this.healthcareCenters.add(new PrimaryHealthCareCenterTO("Centro 2", "Centro 2"));
PrimeFaces.current().ajax().addCallbackParam("caps", true); PrimeFaces.current().ajax().addCallbackParam("caps", true);
} catch (Exception e) { } catch (Exception e) {
this.manageException(e); this.manageException(e);
@@ -104,12 +104,32 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
break; break;
case ADMINISTRADOR: case ADMINISTRADOR:
case PATIENT: case PATIENT:
PrimeFaces.current().ajax().addCallbackParam("pats", true);
break; break;
} }
} }
public Collection<MedicalSpecialtyTO> getMedicalSpecialties() { public Collection<MedicalSpecialtyTO> getMedicalSpecialtiesList() {
return medicalSpecialities; return medicalSpecialitiesList;
}
public Collection<PrimaryHealthCareCenterTO> getPhcList() {
return primaryHealthCareCentersList;
}
public boolean isPatient() {
return (UserType.valueOf(this.userType) == UserType.PATIENT);
}
public boolean isFamilyDoctor() {
return (UserType.valueOf(this.userType) == UserType.FAMILY_DOCTOR);
}
public boolean isSpecialistDoctor() {
return (UserType.valueOf(this.userType) == UserType.SPECIALIST_DOCTOR);
}
public boolean isDoctor() {
return (isFamilyDoctor() || isSpecialistDoctor());
} }
public String getEmail() { public String getEmail() {
@@ -152,44 +172,59 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
this.nif = nif; this.nif = nif;
} }
public Integer getId() { public int getId() {
return id; return id;
} }
public void setId(Integer id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public void addNewUser() { public void addNewUser() {
int error = 0;
if (this.isFamilyDoctor() && this.primaryHealthCareCenter == null) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Centro de atención primaria no seleccionado", "Por favor, especifique un centro de atención primaria.");
error++;
}
if (this.isSpecialistDoctor() && this.medicalSpecialty == null) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Especialidad médica no seleccionada", "Por favor, especifique una especialidad médica.");
error++;
}
if (ValidationUtils.isValid(nif) == false) { if (ValidationUtils.isValid(nif) == false) {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido."); this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
} else { error++;
}
if (error == 0) {
try { try {
switch (UserType.valueOf(this.userType)) { switch (UserType.valueOf(this.userType)) {
case PATIENT: case PATIENT:
PatientTO pat = this.remoteManager.registerPatient(id, nif, name, surname, password, email); PatientTO pat = this.getRemoteManagerProfile().registerPatient(id, nif, name, surname, password, email);
this.id = pat.getId();
break; break;
case FAMILY_DOCTOR: case FAMILY_DOCTOR:
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, null); FamilyDoctorTO fd = this.getRemoteManagerProfile().registerFamilyDoctor1(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
this.id = fd.getId();
break; break;
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, null); SpecialistDoctorTO sd = this.getRemoteManagerProfile().registerSpecialistDoctor(id, nif, name, surname, password, email, this.medicalSpecialty);
this.id = sd.getId();
break; break;
case ADMINISTRADOR: case ADMINISTRADOR:
throw new NotSupportedException("No se soporta el registro directo de administradores."); throw new NotSupportedException("No se soporta el registro directo de administradores.");
} }
this.registered = true;
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Registro realizado", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada",
"El usuario " + name + " " + surname + " se ha registrado correctamente. Por favor, comprueba su correo electrónico para verificar su cuenta.");
} catch (Exception e) { } catch (Exception e) {
this.manageException(e); this.manageException(e);
} }
} }
// FacesContext.getCurrentInstance().addMessage(null, msg);
} }
public String getPasswordRepeat() { public String getPasswordRepeat() {
@@ -207,21 +242,25 @@ public class RegisterUserMBean extends ProfileMBeanBase implements Serializable
public void setUserType(String userType) { public void setUserType(String userType) {
this.userType = userType; this.userType = userType;
} }
public String getMedicalSpecialty() { public MedicalSpecialtyTO getMedicalSpecialty() {
return medicalSpecialty; return medicalSpecialty;
} }
public void setMedicalSpecialty(String medicalSpecialty) { public void setMedicalSpecialty(MedicalSpecialtyTO medicalSpecialty) {
this.medicalSpecialty = medicalSpecialty; this.medicalSpecialty = medicalSpecialty;
} }
public String getPrimaryHealthCareCenter() { public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
return primaryHealthCareCenter; return primaryHealthCareCenter;
} }
public void setPrimaryHealthCareCenter(String primaryHealthCareCenter) { public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO primaryHealthCareCenter) {
this.primaryHealthCareCenter = primaryHealthCareCenter; this.primaryHealthCareCenter = primaryHealthCareCenter;
} }
public boolean isRegistered() {
return registered;
}
} }

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named( "ShowFamilyDoctorMBean") @Named( "ShowFamilyDoctorMBean")
@RequestScoped @RequestScoped
public class ShowFamilyDoctorMBean extends ProfileMBeanBase implements Serializable { public class ShowFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named("ShowPatientMBean") @Named("ShowPatientMBean")
@RequestScoped @RequestScoped
public class ShowPatientMBean extends ProfileMBeanBase implements Serializable { public class ShowPatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named( "ShowSpecialistDoctorMBean") @Named( "ShowSpecialistDoctorMBean")
@RequestScoped @RequestScoped
public class ShowSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable { public class ShowSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named("UpdateFamilyDoctorMBean") @Named("UpdateFamilyDoctorMBean")
@RequestScoped @RequestScoped
public class UpdateFamilyDoctorMBean extends ProfileMBeanBase implements Serializable { public class UpdateFamilyDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named("UpdatePatientMBean") @Named("UpdatePatientMBean")
@RequestScoped @RequestScoped
public class UpdatePatientMBean extends ProfileMBeanBase implements Serializable { public class UpdatePatientMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -10,6 +10,7 @@ import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import ejb.profile.ProfileFacadeRemote; import ejb.profile.ProfileFacadeRemote;
import managedbean.common.ManagedBeanBase;
/*** /***
* *
@@ -18,7 +19,7 @@ import ejb.profile.ProfileFacadeRemote;
*/ */
@Named("UpdateSpecialistDoctorMBean") @Named("UpdateSpecialistDoctorMBean")
@RequestScoped @RequestScoped
public class UpdateSpecialistDoctorMBean extends ProfileMBeanBase implements Serializable { public class UpdateSpecialistDoctorMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -1,20 +1,25 @@
package managedbean.systemAdmin; package managedbean.systemAdmin;
import java.util.Properties;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.primefaces.PrimeFaces; import org.primefaces.PrimeFaces;
import TO.LoggedUserTO;
import ejb.systemAdmin.SystemAdminFacadeRemote;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils; import managedbean.common.SessionUtils;
@Named("loginView") @Named("loginView")
@RequestScoped @RequestScoped
public class LoginMBean { public class LoginMBean extends ManagedBeanBase {
private String username; private String username;
private String password; private String password;
@@ -35,29 +40,42 @@ public class LoginMBean {
this.password = password; this.password = password;
} }
public void login() { public String login() {
FacesMessage message = null;
boolean loggedIn = false; boolean loggedIn = false;
if (username != null && username.equals("admin") && password != null && password.equals("admin")) { LoggedUserTO usr = null;
loggedIn = true;
HttpSession session = SessionUtils.getSession(); if (username != null && password != null) {
session.setAttribute("username", username); try {
session.setAttribute("userid", "1"); usr = this.getRemoteManagerSystemAdmin().login(username, password);
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", username);
} else { if (usr != null) {
loggedIn = false; loggedIn = true;
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos"); SessionUtils.CreateSession(usr);
}
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Login correcto", "Bienvenido " + usr.getName());
return ("/home?faces-redirect=true");
} else
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
} catch (Exception ex) {
this.addFacesMessage(FacesMessage.SEVERITY_FATAL, "Error fatal", ex.getMessage());
}
} else
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
FacesContext.getCurrentInstance().addMessage(null, message);
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn); PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
return "";
} }
// logout event, invalidate session // logout event, invalidate session
public String logout() { public String logout() {
HttpSession session = SessionUtils.getSession(); this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
session.invalidate();
return "home?refresh=1&faces-redirect=true"; SessionUtils.DestroySession();
return "/home?faces-redirect=true";
} }
} }

View File

@@ -11,213 +11,199 @@ DROP TABLE myhealth.SpecialistDoctor;
DROP TABLE myhealth.Visit; DROP TABLE myhealth.Visit;
*/ */
-- Table: MyHealth.Administrator -- Table: myhealth.administrator
-- DROP TABLE MyHealth.Administrator; -- DROP TABLE myhealth.administrator;
CREATE TABLE MyHealth.Administrator CREATE TABLE myhealth.administrator
( (
email character varying(50) COLLATE pg_catalog.default NOT NULL, email VARCHAR(120) COLLATE pg_catalog."default" NOT NULL,
password character varying(100) COLLATE pg_catalog.default, password VARCHAR(100) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT Administrator_pkey PRIMARY KEY (email) CONSTRAINT administrator_pkey PRIMARY KEY (email)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.Administrator ALTER TABLE myhealth.administrator
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.FamilyDoctor -- Table: myhealth.familydoctor
-- DROP TABLE MyHealth.FamilyDoctor; -- DROP TABLE myhealth.familydoctor;
CREATE TABLE MyHealth.FamilyDoctor CREATE TABLE myhealth.familydoctor
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password character(50) COLLATE pg_catalog.default, password VARCHAR(100) COLLATE pg_catalog."default" NOT NULL,
nif character(50) COLLATE pg_catalog.default, nif CHAR(50) COLLATE pg_catalog."default",
surname character varying(100) COLLATE pg_catalog.default, surname VARCHAR(100) COLLATE pg_catalog."default",
email character varying(120) COLLATE pg_catalog.default, email VARCHAR(120) COLLATE pg_catalog."default",
name character varying(100) COLLATE pg_catalog.default, name VARCHAR(100) COLLATE pg_catalog."default",
PrimaryHealthCareCenterId character varying(50) COLLATE pg_catalog.default, primaryhealthcarecenterid VARCHAR(50) COLLATE pg_catalog."default",
CONSTRAINT FamilyDoctor_pkey PRIMARY KEY (id) CONSTRAINT familydoctor_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.FamilyDoctor ALTER TABLE myhealth.familydoctor
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.MedicalSpecialty
-- DROP TABLE MyHealth.MedicalSpecialty; -- Table: myhealth.medicalspecialty
CREATE TABLE MyHealth.MedicalSpecialty -- DROP TABLE myhealth.medicalspecialty;
CREATE TABLE myhealth.medicalspecialty
( (
name text COLLATE pg_catalog.default NOT NULL, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
description text COLLATE pg_catalog.default, name VARCHAR(50) COLLATE pg_catalog."default" NOT NULL UNIQUE,
CONSTRAINT MedicalSpecialty_pkey PRIMARY KEY (name) description VARCHAR(1000) COLLATE pg_catalog."default",
) CONSTRAINT medicalspecialty_pkey PRIMARY KEY (id)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.MedicalSpecialty ALTER TABLE myhealth.medicalspecialty
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.MedicalTest
-- DROP TABLE MyHealth.MedicalTest; -- Table: myhealth.medicaltest
CREATE TABLE MyHealth.MedicalTest -- DROP TABLE myhealth.medicaltest;
CREATE TABLE myhealth.medicaltest
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
date date, date date,
time abstime, "time" abstime,
result text COLLATE pg_catalog.default, observations TEXT COLLATE pg_catalog."default",
highResImage bytea, highresimage bytea,
type integer, type INTEGER,
PatientId character varying(50) COLLATE pg_catalog.default NOT NULL, patientid INTEGER NOT NULL,
SpecialistDoctorId character varying(50) COLLATE pg_catalog.default NOT NULL, specialistdoctorid INTEGER NOT NULL,
CONSTRAINT MedicalTest_pkey PRIMARY KEY (id) CONSTRAINT medicaltest_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.MedicalTest ALTER TABLE myhealth.medicaltest
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.Patient -- Table: myhealth.patient
-- DROP TABLE MyHealth.Patient; -- DROP TABLE myhealth.patient;
CREATE TABLE MyHealth.Patient CREATE TABLE myhealth.patient
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password character(50) COLLATE pg_catalog.default, password VARCHAR(100) COLLATE pg_catalog."default",
nif character(50) COLLATE pg_catalog.default, nif VARCHAR(50) COLLATE pg_catalog."default",
surname character varying(100) COLLATE pg_catalog.default, surname VARCHAR(100) COLLATE pg_catalog."default",
email character varying(120) COLLATE pg_catalog.default, email VARCHAR(120) COLLATE pg_catalog."default",
name character varying(100) COLLATE pg_catalog.default, name VARCHAR(100) COLLATE pg_catalog."default",
FamilyDoctorId character varying(50) COLLATE pg_catalog.default, familydoctorid INTEGER,
CONSTRAINT Patient_pkey PRIMARY KEY (id) CONSTRAINT patient_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.Patient ALTER TABLE myhealth.patient
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.PrimaryHealthCareCenter
-- DROP TABLE MyHealth.PrimaryHealthCareCenter; -- Table: myhealth.location
CREATE TABLE MyHealth.PrimaryHealthCareCenter -- DROP TABLE myhealth.location;
CREATE TABLE myhealth.location
( (
name character varying(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 character varying(256) COLLATE pg_catalog.default, name VARCHAR(100) COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT PrimaryHealthCareCenter_pkey PRIMARY KEY (name) CONSTRAINT primarylocation_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.PrimaryHealthCareCenter ALTER TABLE myhealth.location
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.Question
-- DROP TABLE MyHealth.Question; -- Table: myhealth.primaryhealthcarecenter
CREATE TABLE MyHealth.Question -- DROP TABLE myhealth.primaryhealthcarecenter;
CREATE TABLE myhealth.primaryhealthcarecenter
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, name VARCHAR(50) COLLATE pg_catalog."default" NOT NULL,
title character varying(512) COLLATE pg_catalog.default NOT NULL, location INTEGER,
message character varying(8000) COLLATE pg_catalog.default NOT NULL, CONSTRAINT primaryhealthcarecenter_pkey PRIMARY KEY (name)
status integer,
PatientId character varying(50) COLLATE pg_catalog.default NOT NULL,
CONSTRAINT Question_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.Question ALTER TABLE myhealth.primaryhealthcarecenter
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.Response -- Table: myhealth.question
-- DROP TABLE MyHealth.Response; -- DROP TABLE myhealth.question;
CREATE TABLE MyHealth.Response CREATE TABLE myhealth.question
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
response character varying(8000) COLLATE pg_catalog.default, title VARCHAR(512) COLLATE pg_catalog."default" NOT NULL,
QuestionId integer NOT NULL, message TEXT COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT Response_pkey PRIMARY KEY (id) status INTEGER,
) patientid INTEGER NOT NULL,
WITH ( CONSTRAINT question_pkey PRIMARY KEY (id)
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.Response ALTER TABLE myhealth.question
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.SpecialistDoctor
-- DROP TABLE MyHealth.SpecialistDoctor; -- Table: myhealth.response
CREATE TABLE MyHealth.SpecialistDoctor -- DROP TABLE myhealth.response;
CREATE TABLE myhealth.response
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
password character(50) COLLATE pg_catalog.default, response TEXT COLLATE pg_catalog."default",
nif character(50) COLLATE pg_catalog.default, questionid INTEGER NOT NULL,
surname character varying(100) COLLATE pg_catalog.default, CONSTRAINT response_pkey PRIMARY KEY (id)
email character varying(120) COLLATE pg_catalog.default,
name character varying(100) COLLATE pg_catalog.default,
MedicalSpecialtyId character varying(50) COLLATE pg_catalog.default,
CONSTRAINT SpecialistDoctor_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.SpecialistDoctor ALTER TABLE myhealth.response
OWNER to "USER"; OWNER to "USER";
-- Table: MyHealth.Visit
-- DROP TABLE MyHealth.Visit; -- Table: myhealth.specialistdoctor
CREATE TABLE MyHealth.Visit -- DROP TABLE myhealth.specialistdoctor;
CREATE TABLE myhealth.specialistdoctor
( (
id integer NOT NULL GENERATED ALWAYS AS IDENTITY, 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",
nif VARCHAR(50) COLLATE pg_catalog."default",
surname VARCHAR(100) COLLATE pg_catalog."default",
email VARCHAR(120) COLLATE pg_catalog."default",
name VARCHAR(100) COLLATE pg_catalog."default",
medicalspecialtyid INTEGER,
CONSTRAINT specialistdoctor_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE myhealth.specialistdoctor
OWNER to "USER";
-- Table: myhealth.visit
-- DROP TABLE myhealth.visit;
CREATE TABLE myhealth.visit
(
id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
date date NOT NULL, date date NOT NULL,
time abstime NOT NULL, "time" abstime NOT NULL,
observations character varying(4000) COLLATE pg_catalog.default, observations TEXT COLLATE pg_catalog."default",
result text COLLATE pg_catalog.default, result TEXT COLLATE pg_catalog."default",
PatientId character varying(50) COLLATE pg_catalog.default NOT NULL, patientid INTEGER NOT NULL,
FamilyDoctorId character varying(50) COLLATE pg_catalog.default NOT NULL, familydoctorid INTEGER NOT NULL,
CONSTRAINT Visit_pkey PRIMARY KEY (id) CONSTRAINT visit_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
) )
TABLESPACE pg_default; TABLESPACE pg_default;
ALTER TABLE MyHealth.Visit ALTER TABLE myhealth.visit
OWNER to "USER"; OWNER to "USER";

View File

@@ -1,3 +1,7 @@
--Inserta usuarios administradores (contraseña Hash MD5 'admin' para todos)
insert into myhealth.administrator (email, password) values ('admin@example.com', '21232F297A57A5A743894A0E4A801FC3')
insert into myhealth.administrator (email, password) values ('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3')
-- Inserta Especialidades médicas -- Inserta Especialidades médicas
insert into MyHealth.MedicalSpecialty(name, description) insert into MyHealth.MedicalSpecialty(name, description)
@@ -30,3 +34,4 @@ insert into MyHealth.MedicalSpecialty(name, description)
values ('Oncología','Especialidad médica de Oncología'); values ('Oncología','Especialidad médica de Oncología');
insert into MyHealth.MedicalSpecialty(name, description) insert into MyHealth.MedicalSpecialty(name, description)
values ('Pediatría','Especialidad médica de Pediatría'); values ('Pediatría','Especialidad médica de Pediatría');