Avances en la pantalla de registro de usuarios nuevos (pacientes).
* Actualización de script para crear tablas (Todo a minusculas, no case sensitive) * Script de datos de pruebas de especialides médicas. * Nuevo bean para registro de usuarios (Quidato de filtro de seguridad de login, acceso sin login). * Actualización de entidades JPA con campos Identity. * Enumerado para gestionar tipos de usuarios (Paciente, Medico Familia, Especialista y Administrador) * Clase común para realizar validaciones (función para validar nif).
This commit is contained in:
@@ -7,6 +7,10 @@
|
|||||||
<from-outcome>home</from-outcome>
|
<from-outcome>home</from-outcome>
|
||||||
<to-view-id>/home.xhtml</to-view-id>
|
<to-view-id>/home.xhtml</to-view-id>
|
||||||
</navigation-case>
|
</navigation-case>
|
||||||
|
<navigation-case>
|
||||||
|
<from-outcome>RegisterUser</from-outcome>
|
||||||
|
<to-view-id>/profile/RegisterUser.xhtml</to-view-id>
|
||||||
|
</navigation-case>
|
||||||
<navigation-case>
|
<navigation-case>
|
||||||
<from-outcome>AddPatient</from-outcome>
|
<from-outcome>AddPatient</from-outcome>
|
||||||
<to-view-id>/profile/AddPatient.xhtml</to-view-id>
|
<to-view-id>/profile/AddPatient.xhtml</to-view-id>
|
||||||
|
|||||||
@@ -68,11 +68,12 @@
|
|||||||
<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 type="button" value="Logout" icon="pi pi-user" action="#{loginView.logout}" />
|
<p:commandButton value="Logout" update="messages" icon="pi pi-user" 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 type="button" value="login" icon="pi pi-user" onclick="PF('dlgLogin').show();" title="login" />
|
<p:commandButton value="login" icon="pi pi-user" onclick="PF('dlgLogin').show();" title="login" />
|
||||||
|
<p:button value="Registrarse" icon="pi pi-user" outcome="RegisterUser" />
|
||||||
|
|
||||||
<p:dialog header="Acceder al sistema" widgetVar="dlgLogin" resizable="false">
|
<p:dialog header="Acceder al sistema" widgetVar="dlgLogin" resizable="false">
|
||||||
<h:panelGrid columns="2" cellpadding="5">
|
<h:panelGrid columns="2" cellpadding="5">
|
||||||
@@ -83,7 +84,7 @@
|
|||||||
<p:password id="password" value="#{loginView.password}" required="true" label="password" />
|
<p:password id="password" value="#{loginView.password}" required="true" label="password" />
|
||||||
|
|
||||||
<f:facet name="footer">
|
<f:facet name="footer">
|
||||||
<p:commandButton value="Login" update="messages" action="#{loginView.login}" oncomplete="handleLoginRequest(xhr, status, args)" />
|
<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>
|
<i class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
|
||||||
</f:facet>
|
</f:facet>
|
||||||
</h:panelGrid>
|
</h:panelGrid>
|
||||||
|
|||||||
@@ -1,23 +1,60 @@
|
|||||||
<?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">
|
||||||
|
|
||||||
|
<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 id="testForm">
|
<h:form>
|
||||||
<div align="center">
|
<p:messages id="mesgs" showDetail="true" closable="true">
|
||||||
<h1>AddPaciente Page</h1>
|
<p:autoUpdate />
|
||||||
<hr/>
|
</p:messages>
|
||||||
<div>AddPaciente:</div>
|
|
||||||
<div>
|
<p:panel id="AltaPaciente" header="Registrarse en el sistema como paciente">
|
||||||
AddPaciente content
|
<h:panelGrid columns="3">
|
||||||
</div>
|
<p:outputLabel value="NIF:" for="nif" />
|
||||||
</div>
|
<p:inputText id="nif" required="true" requiredMessage="Por favor, indque su NIF" />
|
||||||
<p align="center">
|
<p:message for="nif" />
|
||||||
<h:button value="Volver al inicio" outcome="home" />
|
|
||||||
</p>
|
<p:outputLabel value="Nombre:" for="name" />
|
||||||
|
<p:inputText id="name" required="true" requiredMessage="Por favor, indique su nombre" />
|
||||||
|
<p:message for="name" />
|
||||||
|
|
||||||
|
<p:outputLabel value="Apellidos:" for="surname" />
|
||||||
|
<p:inputText id="surname" required="true" requiredMessage="Por favor, indique sus apellidos" />
|
||||||
|
<p:message for="surname" />
|
||||||
|
|
||||||
|
<p:outputLabel value="Correo electrónico:" for="email"/>
|
||||||
|
<p:inputText id="email" required="true" requiredMessage="Por favor, especifique su correo electrónico" />
|
||||||
|
<p:message for="email" />
|
||||||
|
|
||||||
|
<p:outputLabel value="Contraseña" for="password" />
|
||||||
|
<p:inputMask id="password" mask="*" required="true" requiredMessage="Por faovr, especifique una contraseña" maxlength="50" />
|
||||||
|
<p:message for="password" />
|
||||||
|
|
||||||
|
<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>
|
||||||
</h:form>
|
</h:form>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
|
|||||||
89
1.sources/MyHealth/docroot/profile/RegisterUser.xhtml
Normal file
89
1.sources/MyHealth/docroot/profile/RegisterUser.xhtml
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?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">
|
||||||
|
<h:outputScript>
|
||||||
|
function handleRequest(xhr, status, args) {
|
||||||
|
if(args.specs) {
|
||||||
|
PF('caps').hide();
|
||||||
|
$('#caps').fadeOut();
|
||||||
|
PF('especialidades').show()
|
||||||
|
$('#especialidades').fadeIn();
|
||||||
|
}
|
||||||
|
else if (args.caps) {
|
||||||
|
PF('especialidades').hide();
|
||||||
|
$('#especialidades').fadeOut();
|
||||||
|
PF('caps').show()
|
||||||
|
$('#caps').fadeIn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</h:outputScript>
|
||||||
|
<ui:define name="content">
|
||||||
|
<h:form>
|
||||||
|
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
|
|
||||||
|
<p:panel id="tipoUsuario" header="Especifique el tipo de usuario que desea registrarse">
|
||||||
|
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
|
||||||
|
<p:selectOneRadio id="usertype" value="#{registerUser.userType}" unselectable="true" required="true" requiredMessage="Debe especificar un tipo de usuario">
|
||||||
|
<p:ajax listener="#{registerUser.onUserTypeChange}" update="medicalSpecialty" oncomplete="handleRequest(xhr, status, args)" />
|
||||||
|
<f:selectItems value="#{registerUser.userTypes}" />
|
||||||
|
</p:selectOneRadio>
|
||||||
|
</h:panelGrid>
|
||||||
|
</p:panel>
|
||||||
|
<p:panel id="RegisterUser" header="Registrarse en el sistema como paciente">
|
||||||
|
<h:panelGrid columns="3">
|
||||||
|
<p:outputLabel value="NIF:" for="nif" />
|
||||||
|
<p:inputText id="nif" value="#{registerUser.nif}" required="true" requiredMessage="Por favor, indque su NIF" />
|
||||||
|
<p:message for="nif" display="text" />
|
||||||
|
|
||||||
|
<p:outputLabel value="Especialidad médica:" for="medicalSpecialty" />
|
||||||
|
<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" itemDescription="#{c.description}" itemValue="#{c.id}" />
|
||||||
|
</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 una centro..." itemValue="" noSelectionOption="true" />
|
||||||
|
<f:selectItems value="#{registerUser.medicalSpecialties}" var="c" itemDescription="#{c.description}" itemValue="#{c.id}" />
|
||||||
|
</p:selectOneMenu>
|
||||||
|
<p:message for="primaryHealthCareCenter" />
|
||||||
|
|
||||||
|
|
||||||
|
<p:outputLabel value="Nombre:" for="name" />
|
||||||
|
<p:inputText id="name" value="#{registerUser.name}" required="true" requiredMessage="Por favor, indique su nombre" />
|
||||||
|
<p:message for="name" />
|
||||||
|
|
||||||
|
<p:outputLabel value="Apellidos:" for="surname" />
|
||||||
|
<p:inputText id="surname" value="#{registerUser.surname}" required="true" requiredMessage="Por favor, indique sus apellidos" />
|
||||||
|
<p:message for="surname" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
<p:message for="email" />
|
||||||
|
|
||||||
|
<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"
|
||||||
|
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" />
|
||||||
|
<p:message for="password" />
|
||||||
|
|
||||||
|
<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" />
|
||||||
|
<p:message for="passwordRepeat" />
|
||||||
|
</h:panelGrid>
|
||||||
|
<h:panelGroup>
|
||||||
|
<h:panelGrid columns="3">
|
||||||
|
<p:commandButton validateClient="true" value="Registrarse" update="mesgs" action="#{registerUser.addNewUser}" icon="pi pi-check" />
|
||||||
|
<p:commandButton value="Volver" outcome="home" />
|
||||||
|
</h:panelGrid>
|
||||||
|
</h:panelGroup>
|
||||||
|
</p:panel>
|
||||||
|
</h:form>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
|
||||||
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
|
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
|
||||||
version="1.0">
|
|
||||||
<persistence-unit name="MyHealth">
|
<persistence-unit name="MyHealth">
|
||||||
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
<provider>org.hibernate.ejb.HibernatePersistence</provider>
|
||||||
<jta-data-source>java:jboss/postgresDS</jta-data-source>
|
<jta-data-source>java:jboss/postgresDS</jta-data-source>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="hibernate.dialect"
|
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL94Dialect" />
|
||||||
value="org.hibernate.dialect.PostgreSQL94Dialect" />
|
<!-- <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" /> -->
|
||||||
|
<!-- <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.EJB3NamingStrategy" /> -->
|
||||||
|
<property name="hibernate.show_sql" value="true"></property>
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
||||||
@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
public class FamilyDoctorTO implements Serializable {
|
public class FamilyDoctorTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String id;
|
private Integer id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -24,7 +24,7 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorTO(String id, String nif, String name, String surname, String password, String email) {
|
public FamilyDoctorTO(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.setId(id);
|
this.setId(id);
|
||||||
this.setNif(nif);
|
this.setNif(nif);
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
@@ -73,11 +73,11 @@ public class FamilyDoctorTO implements Serializable {
|
|||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import jpa.FamilyDoctorJPA;
|
|||||||
public class PatientTO implements Serializable {
|
public class PatientTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String id;
|
private Integer id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -30,7 +30,7 @@ public class PatientTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO(String id, String nif, String name, String surname, String password, String email) {
|
public PatientTO(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.setId(id);
|
this.setId(id);
|
||||||
this.setNif(nif);
|
this.setNif(nif);
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
@@ -79,11 +79,11 @@ public class PatientTO implements Serializable {
|
|||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,33 @@ public class PrimaryHealthCareCenterTO implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
public PrimaryHealthCareCenterTO() {
|
public PrimaryHealthCareCenterTO() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PrimaryHealthCareCenterTO(String name, String description) {
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
public class SpecialistDoctorTO implements Serializable {
|
public class SpecialistDoctorTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private String id;
|
private Integer id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -24,7 +24,7 @@ public class SpecialistDoctorTO implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorTO(String id, String nif, String name, String surname, String password, String email) {
|
public SpecialistDoctorTO(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.setId(id);
|
this.setId(id);
|
||||||
this.setNif(nif);
|
this.setNif(nif);
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
@@ -73,11 +73,11 @@ public class SpecialistDoctorTO implements Serializable {
|
|||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
@PersistenceContext(unitName = "MyHealth")
|
@PersistenceContext(unitName = "MyHealth")
|
||||||
private EntityManager entman;
|
private EntityManager entman;
|
||||||
|
|
||||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId) {
|
public PatientTO changeFamilyDoctor(Integer id, Integer ProfessionalNumberId) {
|
||||||
PatientTO paTO = null;
|
PatientTO paTO = null;
|
||||||
|
|
||||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, ProfessionalNumberId);
|
||||||
@@ -42,7 +42,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return paTO;
|
return paTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO registerPacient(String 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;
|
||||||
|
|
||||||
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
|
PatientJPA ms = new PatientJPA(id, nif, name, surname, password, email);
|
||||||
@@ -52,7 +52,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return paTO;
|
return paTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorTO registerSpecialistDoctor(String id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
public SpecialistDoctorTO registerSpecialistDoctor(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
||||||
SpecialistDoctorTO sdTO = null;
|
SpecialistDoctorTO sdTO = null;
|
||||||
|
|
||||||
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
|
MedicalSpecialtyJPA ms = entman.find(MedicalSpecialtyJPA.class, specialty.getName());
|
||||||
@@ -67,7 +67,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return sdTO;
|
return sdTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorTO registerFamilyDoctor1(String 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, String cap) {
|
||||||
FamilyDoctorTO fdTO = null;
|
FamilyDoctorTO fdTO = null;
|
||||||
|
|
||||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, cap);
|
||||||
@@ -86,7 +86,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientTO updatePacientData(String 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) {
|
||||||
PatientJPA fd = entman.find(PatientJPA.class, id);
|
PatientJPA fd = entman.find(PatientJPA.class, id);
|
||||||
PatientTO ptTO = null;
|
PatientTO ptTO = null;
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return ptTO;
|
return ptTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorTO updateSpecialistDoctorData(String id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
public SpecialistDoctorTO updateSpecialistDoctorData(Integer id, String nif, String name, String surname, String password, String email, MedicalSpecialtyTO specialty) {
|
||||||
SpecialistDoctorTO sdTO = null;
|
SpecialistDoctorTO sdTO = null;
|
||||||
|
|
||||||
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, id);
|
SpecialistDoctorJPA sd = entman.find(SpecialistDoctorJPA.class, id);
|
||||||
@@ -129,7 +129,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return sdTO;
|
return sdTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorTO updateFamilyDoctorData(String 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) {
|
||||||
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, id);
|
FamilyDoctorJPA fd = entman.find(FamilyDoctorJPA.class, id);
|
||||||
FamilyDoctorTO fdTO = null;
|
FamilyDoctorTO fdTO = null;
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ public class ProfileFacadeBean implements ProfileFacadeRemote {
|
|||||||
return fdTO;
|
return fdTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorTO changePrimaryHealthCareCenter(String FamilyDoctorId, PrimaryHealthCareCenterTO newCenter) {
|
public FamilyDoctorTO changePrimaryHealthCareCenter(Integer FamilyDoctorId, PrimaryHealthCareCenterTO newCenter) {
|
||||||
FamilyDoctorTO fdTO = null;
|
FamilyDoctorTO fdTO = null;
|
||||||
|
|
||||||
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter);
|
PrimaryHealthCareCenterJPA phcC = entman.find(PrimaryHealthCareCenterJPA.class, newCenter);
|
||||||
|
|||||||
@@ -16,21 +16,21 @@ import TO.SpecialistDoctorTO;
|
|||||||
@Remote
|
@Remote
|
||||||
public interface ProfileFacadeRemote {
|
public interface ProfileFacadeRemote {
|
||||||
|
|
||||||
public PatientTO changeFamilyDoctor(String id, String ProfessionalNumberId);
|
public PatientTO changeFamilyDoctor(Integer id, Integer ProfessionalNumberId);
|
||||||
|
|
||||||
public PatientTO registerPacient(String 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(String 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(String 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, String cap);
|
||||||
|
|
||||||
public PatientTO updatePacientData(String 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(String 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(String 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);
|
||||||
|
|
||||||
public FamilyDoctorTO changePrimaryHealthCareCenter(String id, PrimaryHealthCareCenterTO newCenter);
|
public FamilyDoctorTO changePrimaryHealthCareCenter(Integer id, PrimaryHealthCareCenterTO newCenter);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,15 @@
|
|||||||
package ejb.systemAdmin;
|
package ejb.systemAdmin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.ejb.Stateless;
|
import javax.ejb.Stateless;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import javax.persistence.Query;
|
||||||
|
|
||||||
|
import TO.MedicalSpecialtyTO;
|
||||||
|
import jpa.MedicalSpecialtyJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||||
@@ -20,9 +26,37 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
@PersistenceContext(unitName = "MyHealth")
|
@PersistenceContext(unitName = "MyHealth")
|
||||||
private EntityManager entman;
|
private EntityManager entman;
|
||||||
|
|
||||||
public void ejbMethod(String parameter)
|
/**
|
||||||
{
|
* Metodo que devuelve todas las especialidades medicas
|
||||||
|
*/
|
||||||
|
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities() {
|
||||||
|
return this.listPagedMedicalSpecialities(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Metodo que devuelve las especialidades médicas de forma paginada
|
||||||
|
*
|
||||||
|
* Acepta como parametro la página (comenzando en 0) y el número de elementos de
|
||||||
|
* cada página
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public Collection<MedicalSpecialtyTO> listPagedMedicalSpecialities(int pageNumber, int pageSize) {
|
||||||
|
Query query = entman.createQuery("from MedicalSpecialtyJPA order by name");
|
||||||
|
|
||||||
|
if (pageSize > 0) {
|
||||||
|
query.setFirstResult(pageNumber * pageSize);
|
||||||
|
query.setMaxResults(pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Collection<MedicalSpecialtyJPA> allJPA = query.getResultList();
|
||||||
|
Collection<MedicalSpecialtyTO> allSpecialities = new ArrayList<MedicalSpecialtyTO>();
|
||||||
|
|
||||||
|
for (MedicalSpecialtyJPA ms : allJPA) {
|
||||||
|
allSpecialities.add(new MedicalSpecialtyTO(ms.getName(), ms.getDescription()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return allSpecialities;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package ejb.systemAdmin;
|
package ejb.systemAdmin;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.ejb.Remote;
|
import javax.ejb.Remote;
|
||||||
|
|
||||||
|
import TO.MedicalSpecialtyTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||||
* los clientes del EJB
|
* los clientes del EJB
|
||||||
@@ -14,5 +18,5 @@ public interface SystemAdminFacadeRemote {
|
|||||||
/**
|
/**
|
||||||
* Definimos la interfaz remota
|
* Definimos la interfaz remota
|
||||||
*/
|
*/
|
||||||
public void ejbMethod(String parameter);
|
public Collection<MedicalSpecialtyTO> listAllMedicalSpecialities();
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ import java.util.Collection;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
@@ -24,7 +26,7 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private Integer id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -40,7 +42,7 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorJPA(String id, String nif, String name, String surname, String password, String email) {
|
public FamilyDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -50,11 +52,12 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
public String getId() {
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String value) {
|
public void setId(Integer value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package jpa;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
@@ -20,12 +22,15 @@ public class PatientJPA implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
private Integer 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 email;
|
private String email;
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn (name="FamilyDoctorId")
|
||||||
private FamilyDoctorJPA familyDoctor;
|
private FamilyDoctorJPA familyDoctor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +40,7 @@ public class PatientJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatientJPA(String id, String nif, String name, String surname, String password, String email) {
|
public PatientJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -44,12 +49,11 @@ public class PatientJPA implements Serializable {
|
|||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
public Integer getId() {
|
||||||
public String getId() {
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String value) {
|
public void setId(Integer value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,8 +100,6 @@ public class PatientJPA implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Methods get/set persistent relationships
|
* Methods get/set persistent relationships
|
||||||
*/
|
*/
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn (name="FamilyDoctorId")
|
|
||||||
public FamilyDoctorJPA getFamilyDoctor() {
|
public FamilyDoctorJPA getFamilyDoctor() {
|
||||||
return familyDoctor;
|
return familyDoctor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ public class PrimaryHealthCareCenterJPA implements Serializable {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package jpa;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
@@ -20,7 +22,7 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private String id;
|
private Integer id;
|
||||||
private String nif;
|
private String nif;
|
||||||
private String name;
|
private String name;
|
||||||
private String surname;
|
private String surname;
|
||||||
@@ -35,7 +37,7 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpecialistDoctorJPA(String id, String nif, String name, String surname, String password, String email) {
|
public SpecialistDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.nif = nif;
|
this.nif = nif;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -45,11 +47,12 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
public String getId() {
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String value) {
|
public void setId(Integer value) {
|
||||||
this.id = value;
|
this.id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class AuthorizationFilter implements Filter {
|
|||||||
HttpSession ses = reqt.getSession(false);
|
HttpSession ses = reqt.getSession(false);
|
||||||
|
|
||||||
String reqURI = reqt.getRequestURI();
|
String reqURI = reqt.getRequestURI();
|
||||||
if (reqURI.indexOf("/login.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|
if (reqURI.indexOf("/login.xhtml") >= 0 || reqURI.indexOf("/RegisterUser.xhtml") >= 0 || (ses != null && ses.getAttribute("username") != null)
|
||||||
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource"))
|
|| reqURI.indexOf("/public/") >= 0 || reqURI.indexOf("/home.xhtml") >= 0 || reqURI.contains("javax.faces.resource"))
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
else
|
else
|
||||||
|
|||||||
18
1.sources/MyHealth/src/managedbean/common/UserType.java
Normal file
18
1.sources/MyHealth/src/managedbean/common/UserType.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package managedbean.common;
|
||||||
|
|
||||||
|
public enum UserType {
|
||||||
|
PATIENT("Paciente"),
|
||||||
|
FAMILY_DOCTOR("Médico de familia"),
|
||||||
|
SPECIALIST_DOCTOR("Médico especialista"),
|
||||||
|
ADMINISTRADOR("Administrador");
|
||||||
|
|
||||||
|
private String userTypename;
|
||||||
|
|
||||||
|
private UserType (String userTypename){
|
||||||
|
this.userTypename = userTypename;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserTypename() {
|
||||||
|
return userTypename;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package managedbean.common;
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ValidationUtils {
|
||||||
|
static final String NIF_LETTERS = "TRWAGMYFPDXBNJZSQVHLCKE";
|
||||||
|
static final String NIE_LETTERS = "XYZ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param nif NIF a validar
|
||||||
|
* @return true si es válido, false en otro caso
|
||||||
|
*/
|
||||||
|
public static boolean isValid(String nif) {
|
||||||
|
if (nif == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
nif = nif.toUpperCase().replace("-", "").replace(".", "");
|
||||||
|
|
||||||
|
if (nif.length() < 2 || nif.length() > 9)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (nif.startsWith("X")) {
|
||||||
|
nif = nif.replace('X', '0');
|
||||||
|
} else if (nif.startsWith("Y")) {
|
||||||
|
nif = nif.replace('Y', '1');
|
||||||
|
} else if (nif.startsWith("Z")) {
|
||||||
|
nif = nif.replace('Z', '2');
|
||||||
|
}
|
||||||
|
|
||||||
|
char letra = nif.charAt(nif.length() - 1);
|
||||||
|
if (NIF_LETTERS.indexOf(letra) < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
String numbers = nif.substring(0, nif.length() - 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (NIF_LETTERS.charAt(Integer.parseInt(numbers) % 23) == letra)
|
||||||
|
return true;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
package managedbean.profile;
|
package managedbean.profile;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.InitialContext;
|
|
||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||||
@@ -17,31 +14,98 @@ import ejb.profile.ProfileFacadeRemote;
|
|||||||
* @author mark
|
* @author mark
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Named( "AddPatientMBean")
|
@Named("addPatientMBean")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
public class AddPatientMBean extends ProfileMBeanBase implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String nif;
|
||||||
|
private String name;
|
||||||
|
private String surname;
|
||||||
|
private String password;
|
||||||
|
private String passwordRepeat;
|
||||||
|
private String email;
|
||||||
|
private String primaryHealthCareCenter;
|
||||||
|
private String medicalSpecialty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public AddPatientMBean() throws Exception {
|
public AddPatientMBean() throws Exception {
|
||||||
initializeAdminFacadeRemote();
|
super.initializeProfileFacadeRemote();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getEmail() {
|
||||||
* Inicializa la conexión con el EJB Remoto
|
return email;
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
private void initializeAdminFacadeRemote() throws Exception {
|
|
||||||
Properties props = System.getProperties();
|
|
||||||
Context ctx = new InitialContext(props);
|
|
||||||
remoteManager = (ProfileFacadeRemote) ctx
|
|
||||||
.lookup("java:app/myHealth.jar/ProfileFacadeBean!ejb.component.ProfileFacadeRemote");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSurname() {
|
||||||
|
return surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurname(String surname) {
|
||||||
|
this.surname = surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNif() {
|
||||||
|
return nif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNif(String nif) {
|
||||||
|
this.nif = nif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
FacesMessage msg;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Alta realizada", "El usuario " + name + " " + surname + " se ha registrado correctamente.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Se ha producido un error inesperado: " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPasswordRepeat() {
|
||||||
|
return passwordRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPasswordRepeat(String passwordRepeat) {
|
||||||
|
this.passwordRepeat = passwordRepeat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,21 @@ import javax.naming.InitialContext;
|
|||||||
|
|
||||||
import ejb.profile.ProfileFacadeRemote;
|
import ejb.profile.ProfileFacadeRemote;
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Named("profileMBean")
|
@Named("profileMBean")
|
||||||
public class ProfileMBeanBase {
|
public class ProfileMBeanBase {
|
||||||
@EJB
|
@EJB
|
||||||
protected ProfileFacadeRemote remoteManager;
|
protected ProfileFacadeRemote remoteManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inicializa la conexión con el EJB Remoto
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
protected void initializeProfileFacadeRemote() throws Exception {
|
protected void initializeProfileFacadeRemote() throws Exception {
|
||||||
Properties props = System.getProperties();
|
Properties props = System.getProperties();
|
||||||
Context ctx = new InitialContext(props);
|
Context ctx = new InitialContext(props);
|
||||||
|
|||||||
@@ -0,0 +1,228 @@
|
|||||||
|
package managedbean.profile;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
|
import javax.faces.context.FacesContext;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.naming.Context;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.resource.NotSupportedException;
|
||||||
|
|
||||||
|
import org.primefaces.PrimeFaces;
|
||||||
|
|
||||||
|
import TO.FamilyDoctorTO;
|
||||||
|
import TO.MedicalSpecialtyTO;
|
||||||
|
import TO.PatientTO;
|
||||||
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
|
import TO.SpecialistDoctorTO;
|
||||||
|
import ejb.systemAdmin.SystemAdminFacadeRemote;
|
||||||
|
import managedbean.common.UserType;
|
||||||
|
import managedbean.common.ValidationUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ManagedBEan que gestiona la edición y actualización de una especialidad
|
||||||
|
* médica.
|
||||||
|
*
|
||||||
|
* @author mark
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Named("registerUser")
|
||||||
|
@RequestScoped
|
||||||
|
public class RegisterUserMBean extends ProfileMBeanBase implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
private String nif;
|
||||||
|
private String name;
|
||||||
|
private String surname;
|
||||||
|
private String password;
|
||||||
|
private String passwordRepeat;
|
||||||
|
private String email;
|
||||||
|
private HashMap<String, String> userTypes;
|
||||||
|
private String userType;
|
||||||
|
private String primaryHealthCareCenter;
|
||||||
|
private String medicalSpecialty;
|
||||||
|
private Collection<MedicalSpecialtyTO> medicalSpecialities;
|
||||||
|
private Collection<PrimaryHealthCareCenterTO> healthcareCenters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public RegisterUserMBean() throws Exception {
|
||||||
|
super.initializeProfileFacadeRemote();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
this.userTypes = new HashMap<String, String>();
|
||||||
|
this.userTypes.put(UserType.PATIENT.getUserTypename(), UserType.PATIENT.name());
|
||||||
|
this.userTypes.put(UserType.FAMILY_DOCTOR.getUserTypename(), UserType.FAMILY_DOCTOR.name());
|
||||||
|
this.userTypes.put(UserType.SPECIALIST_DOCTOR.getUserTypename(), UserType.SPECIALIST_DOCTOR.name());
|
||||||
|
this.userType = "patient";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, String> getUserTypes() {
|
||||||
|
return userTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUserTypeChange() {
|
||||||
|
switch (UserType.valueOf(this.userType)) {
|
||||||
|
case SPECIALIST_DOCTOR:
|
||||||
|
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);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.manageException(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case FAMILY_DOCTOR:
|
||||||
|
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);
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.manageException(e);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ADMINISTRADOR:
|
||||||
|
case PATIENT:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<MedicalSpecialtyTO> getMedicalSpecialties() {
|
||||||
|
return medicalSpecialities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSurname() {
|
||||||
|
return surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSurname(String surname) {
|
||||||
|
this.surname = surname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNif() {
|
||||||
|
return nif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNif(String nif) {
|
||||||
|
this.nif = nif;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNewUser() {
|
||||||
|
if (ValidationUtils.isValid(nif) == false) {
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "El NIF indicado no es válido", "Por favor, especifique un NIF válido.");
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
switch (UserType.valueOf(this.userType)) {
|
||||||
|
case PATIENT:
|
||||||
|
PatientTO pat = this.remoteManager.registerPatient(id, nif, name, surname, password, email);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case FAMILY_DOCTOR:
|
||||||
|
FamilyDoctorTO fd = this.remoteManager.registerFamilyDoctor1(id, nif, name, surname, password, email, null);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SPECIALIST_DOCTOR:
|
||||||
|
SpecialistDoctorTO sd = this.remoteManager.registerSpecialistDoctor(id, nif, name, surname, password, email, null);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ADMINISTRADOR:
|
||||||
|
throw new NotSupportedException("No se soporta el registro directo de administradores.");
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
this.manageException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addFacesMessage(FacesMessage.Severity severity, String summary, String detail) {
|
||||||
|
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(severity, summary, detail));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void manageException(Exception ex) {
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Se ha producido un error inesperado", "Descripción del error: " + ex.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPasswordRepeat() {
|
||||||
|
return passwordRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPasswordRepeat(String passwordRepeat) {
|
||||||
|
this.passwordRepeat = passwordRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserType() {
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserType(String userType) {
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getmedicalSpecialty() {
|
||||||
|
return medicalSpecialty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setmedicalSpecialty(String medicalSpecialty) {
|
||||||
|
this.medicalSpecialty = medicalSpecialty;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package managedbean.systemAdmin;
|
|||||||
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.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
|||||||
@@ -1,207 +1,223 @@
|
|||||||
-- Table: "MyHealth"."Administrator"
|
/*
|
||||||
|
DROP TABLE myhealth.Administrator;
|
||||||
|
DROP TABLE myhealth.FamilyDoctor;
|
||||||
|
DROP TABLE myhealth.MedicalSpecialty;
|
||||||
|
DROP TABLE myhealth.MedicalTest;
|
||||||
|
DROP TABLE myhealth.Patient;
|
||||||
|
DROP TABLE myhealth.PrimaryHealthCareCenter;
|
||||||
|
DROP TABLE myhealth.Question;
|
||||||
|
DROP TABLE myhealth.Response;
|
||||||
|
DROP TABLE myhealth.SpecialistDoctor;
|
||||||
|
DROP TABLE myhealth.Visit;
|
||||||
|
*/
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."Administrator";
|
-- Table: MyHealth.Administrator
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."Administrator"
|
-- DROP TABLE MyHealth.Administrator;
|
||||||
|
|
||||||
|
CREATE TABLE MyHealth.Administrator
|
||||||
(
|
(
|
||||||
email character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
email character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
password character varying(100) COLLATE pg_catalog."default",
|
password character varying(100) COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "Administrator_pkey" PRIMARY KEY (email)
|
CONSTRAINT Administrator_pkey PRIMARY KEY (email)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
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 character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
nif character(50) COLLATE pg_catalog."default",
|
password character(50) COLLATE pg_catalog.default,
|
||||||
surname character varying(100) COLLATE pg_catalog."default",
|
nif character(50) COLLATE pg_catalog.default,
|
||||||
email character varying(120) COLLATE pg_catalog."default",
|
surname character varying(100) COLLATE pg_catalog.default,
|
||||||
name character varying(100) COLLATE pg_catalog."default",
|
email character varying(120) COLLATE pg_catalog.default,
|
||||||
"PrimaryHealthCareCenterId" character varying(50) COLLATE pg_catalog."default",
|
name character varying(100) COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "FamilyDoctor_pkey" PRIMARY KEY (id)
|
PrimaryHealthCareCenterId character varying(50) COLLATE pg_catalog.default,
|
||||||
|
CONSTRAINT FamilyDoctor_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."FamilyDoctor"
|
ALTER TABLE MyHealth.FamilyDoctor
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."MedicalSpeciality"
|
-- Table: MyHealth.MedicalSpecialty
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."MedicalSpeciality";
|
-- DROP TABLE MyHealth.MedicalSpecialty;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."MedicalSpeciality"
|
CREATE TABLE MyHealth.MedicalSpecialty
|
||||||
(
|
(
|
||||||
name text COLLATE pg_catalog."default" NOT NULL,
|
name text COLLATE pg_catalog.default NOT NULL,
|
||||||
description text COLLATE pg_catalog."default",
|
description text COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "MedicalSpeciality_pkey" PRIMARY KEY (name)
|
CONSTRAINT MedicalSpecialty_pkey PRIMARY KEY (name)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."MedicalSpeciality"
|
ALTER TABLE MyHealth.MedicalSpecialty
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."MedicalTest"
|
-- Table: MyHealth.MedicalTest
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."MedicalTest";
|
-- DROP TABLE MyHealth.MedicalTest;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."MedicalTest"
|
CREATE TABLE MyHealth.MedicalTest
|
||||||
(
|
(
|
||||||
id integer NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
date date,
|
date date,
|
||||||
"time" abstime,
|
time abstime,
|
||||||
result text COLLATE pg_catalog."default",
|
result text COLLATE pg_catalog.default,
|
||||||
"highResImage" bytea,
|
highResImage bytea,
|
||||||
type integer,
|
type integer,
|
||||||
"PatientId" character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
PatientId character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
"SpecialistDoctorId" character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
SpecialistDoctorId character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
CONSTRAINT "MedicalTest_pkey" PRIMARY KEY (id)
|
CONSTRAINT MedicalTest_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
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 character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
nif character(50) COLLATE pg_catalog."default",
|
password character(50) COLLATE pg_catalog.default,
|
||||||
surname character varying(100) COLLATE pg_catalog."default",
|
nif character(50) COLLATE pg_catalog.default,
|
||||||
email character varying(120) COLLATE pg_catalog."default",
|
surname character varying(100) COLLATE pg_catalog.default,
|
||||||
name character varying(100) COLLATE pg_catalog."default",
|
email character varying(120) COLLATE pg_catalog.default,
|
||||||
"FamilyDoctorId" character varying(50) COLLATE pg_catalog."default",
|
name character varying(100) COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "Patient_pkey" PRIMARY KEY (id)
|
FamilyDoctorId character varying(50) COLLATE pg_catalog.default,
|
||||||
|
CONSTRAINT Patient_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
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"
|
-- Table: MyHealth.PrimaryHealthCareCenter
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."PrimaryHealthCareCenter";
|
-- DROP TABLE MyHealth.PrimaryHealthCareCenter;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."PrimaryHealthCareCenter"
|
CREATE TABLE MyHealth.PrimaryHealthCareCenter
|
||||||
(
|
(
|
||||||
name character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
name character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
location character varying(256) COLLATE pg_catalog."default",
|
location character varying(256) COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "PrimaryHealthCareCenter_pkey" PRIMARY KEY (name)
|
CONSTRAINT PrimaryHealthCareCenter_pkey PRIMARY KEY (name)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."PrimaryHealthCareCenter"
|
ALTER TABLE MyHealth.PrimaryHealthCareCenter
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."Question"
|
-- Table: MyHealth.Question
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."Question";
|
-- DROP TABLE MyHealth.Question;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."Question"
|
CREATE TABLE MyHealth.Question
|
||||||
(
|
(
|
||||||
id integer NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
title character varying(512) COLLATE pg_catalog."default" NOT NULL,
|
title character varying(512) COLLATE pg_catalog.default NOT NULL,
|
||||||
message character varying(8000) COLLATE pg_catalog."default" NOT NULL,
|
message character varying(8000) COLLATE pg_catalog.default NOT NULL,
|
||||||
status integer,
|
status integer,
|
||||||
"PatientId" character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
PatientId character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
CONSTRAINT "Question_pkey" PRIMARY KEY (id)
|
CONSTRAINT Question_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."Question"
|
ALTER TABLE MyHealth.Question
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."Response"
|
-- Table: MyHealth.Response
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."Response";
|
-- DROP TABLE MyHealth.Response;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."Response"
|
CREATE TABLE MyHealth.Response
|
||||||
(
|
(
|
||||||
id integer NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
response character varying(8000) COLLATE pg_catalog."default",
|
response character varying(8000) COLLATE pg_catalog.default,
|
||||||
"QuestionId" integer NOT NULL,
|
QuestionId integer NOT NULL,
|
||||||
CONSTRAINT "Response_pkey" PRIMARY KEY (id)
|
CONSTRAINT Response_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."Response"
|
ALTER TABLE MyHealth.Response
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."SpecialistDoctor"
|
-- Table: MyHealth.SpecialistDoctor
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."SpecialistDoctor";
|
-- DROP TABLE MyHealth.SpecialistDoctor;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."SpecialistDoctor"
|
CREATE TABLE MyHealth.SpecialistDoctor
|
||||||
(
|
(
|
||||||
id character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
nif character(50) COLLATE pg_catalog."default",
|
password character(50) COLLATE pg_catalog.default,
|
||||||
surname character varying(100) COLLATE pg_catalog."default",
|
nif character(50) COLLATE pg_catalog.default,
|
||||||
email character varying(120) COLLATE pg_catalog."default",
|
surname character varying(100) COLLATE pg_catalog.default,
|
||||||
name character varying(100) COLLATE pg_catalog."default",
|
email character varying(120) COLLATE pg_catalog.default,
|
||||||
"MedicalSpecialtyId" character varying(50) COLLATE pg_catalog."default",
|
name character varying(100) COLLATE pg_catalog.default,
|
||||||
CONSTRAINT "SpecialistDoctor_pkey" PRIMARY KEY (id)
|
MedicalSpecialtyId character varying(50) COLLATE pg_catalog.default,
|
||||||
|
CONSTRAINT SpecialistDoctor_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."SpecialistDoctor"
|
ALTER TABLE MyHealth.SpecialistDoctor
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
-- Table: "MyHealth"."Visit"
|
-- Table: MyHealth.Visit
|
||||||
|
|
||||||
-- DROP TABLE "MyHealth"."Visit";
|
-- DROP TABLE MyHealth.Visit;
|
||||||
|
|
||||||
CREATE TABLE "MyHealth"."Visit"
|
CREATE TABLE MyHealth.Visit
|
||||||
(
|
(
|
||||||
id integer NOT NULL,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||||
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 character varying(4000) 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 character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
"FamilyDoctorId" character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
FamilyDoctorId character varying(50) COLLATE pg_catalog.default NOT NULL,
|
||||||
CONSTRAINT "Visit_pkey" PRIMARY KEY (id)
|
CONSTRAINT Visit_pkey PRIMARY KEY (id)
|
||||||
)
|
)
|
||||||
WITH (
|
WITH (
|
||||||
OIDS = FALSE
|
OIDS = FALSE
|
||||||
)
|
)
|
||||||
TABLESPACE pg_default;
|
TABLESPACE pg_default;
|
||||||
|
|
||||||
ALTER TABLE "MyHealth"."Visit"
|
ALTER TABLE MyHealth.Visit
|
||||||
OWNER to "USER";
|
OWNER to "USER";
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
-- Inserta Especialidades médicas
|
-- Inserta Especialidades médicas
|
||||||
|
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Alergologia','Especialidad médica de Alergologia');
|
values ('Alergologia','Especialidad médica de Alergologia');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía cardiaca','Especialidad médica de Cirugía cardiaca');
|
values ('Cirugía cardiaca','Especialidad médica de Cirugía cardiaca');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía general','Especialidad médica de Cirugía general');
|
values ('Cirugía general','Especialidad médica de Cirugía general');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía plastica','Especialidad médica de Cirugía plastica');
|
values ('Cirugía plastica','Especialidad médica de Cirugía plastica');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía de mama','Especialidad médica de Cirugía de mama');
|
values ('Cirugía de mama','Especialidad médica de Cirugía de mama');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía maxilofacial','Especialidad médica de Cirugía maxilofacial');
|
values ('Cirugía maxilofacial','Especialidad médica de Cirugía maxilofacial');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Cirugía vascular','Especialidad médica de Cirugía vascular');
|
values ('Cirugía vascular','Especialidad médica de Cirugía vascular');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Dermatología','Especialidad médica de Dermatología');
|
values ('Dermatología','Especialidad médica de Dermatología');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Endocrinología y nutrición','Especialidad médica de Endocrinología y nutrición');
|
values ('Endocrinología y nutrición','Especialidad médica de Endocrinología y nutrición');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Gastroenterología- digestivo','Especialidad médica de Gastroenterología- digestivo');
|
values ('Gastroenterología- digestivo','Especialidad médica de Gastroenterología- digestivo');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Neurocirugía','Especialidad médica de Neurocirugía');
|
values ('Neurocirugía','Especialidad médica de Neurocirugía');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Oftalmología','Especialidad médica de Oftalmología');
|
values ('Oftalmología','Especialidad médica de Oftalmología');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
insert into MyHealth.MedicalSpecialty(name, description)
|
||||||
values ('Otorrinolaringologia','Especialidad médica de Otorrinolaringologia');
|
values ('Otorrinolaringologia','Especialidad médica de Otorrinolaringologia');
|
||||||
insert into "MyHealth"."MedicalSpeciality"(name, description)
|
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"."MedicalSpeciality"(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');
|
||||||
|
|||||||
Reference in New Issue
Block a user