Cambios varios para login de usuario
* Login de diferentes usuarios completado. * Cambiado esquema de BBDD, campos texto a character varying. * Cambiada relación entre paciente y medico de cabecera. * Movida clase UserType a paquete common ya que se utiliza en el EJB. * Datos de prueba para realizar logins, el password es admin para todos (hashMD5).
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div id="menuDiv">
|
<div id="menuDiv">
|
||||||
<p:growl id="messages" sticky="false" showDetail="true" life="3000" />
|
<p:growl id="messages" sticky="false" showDetail="true" life="15000" />
|
||||||
<p:ajaxStatus style="width:32px; height:32px; position:fixed; right:32px; bottom:32px">
|
<p:ajaxStatus style="width:32px; height:32px; position:fixed; right:32px; bottom:32px">
|
||||||
<f:facet name="start">
|
<f:facet name="start">
|
||||||
<i id="loginSpin" class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
|
<i id="loginSpin" class="pi pi-spin pi-spinner" style="font-size: 3em"></i>
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
package TO;
|
package TO;
|
||||||
|
|
||||||
import managedbean.common.UserType;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import common.UserType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
* @author Marcos García Núñez (mgarcianun@uoc.edu)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LoggedUserTO {
|
@XmlRootElement(name = "LoggedUser")
|
||||||
|
public class LoggedUserTO implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package managedbean.common;
|
package common;
|
||||||
|
|
||||||
public enum UserType {
|
public enum UserType {
|
||||||
PATIENT("Paciente"),
|
PATIENT("Paciente"),
|
||||||
@@ -12,20 +12,17 @@ import TO.LoggedUserTO;
|
|||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.PrimaryHealthCareCenterTO;
|
import TO.PrimaryHealthCareCenterTO;
|
||||||
import common.HashUtils;
|
import common.HashUtils;
|
||||||
|
import common.UserType;
|
||||||
import jpa.AdministratorJPA;
|
import jpa.AdministratorJPA;
|
||||||
import jpa.FamilyDoctorJPA;
|
import jpa.FamilyDoctorJPA;
|
||||||
import jpa.MedicalSpecialtyJPA;
|
import jpa.MedicalSpecialtyJPA;
|
||||||
import jpa.PatientJPA;
|
import jpa.PatientJPA;
|
||||||
import jpa.PrimaryHealthCareCenterJPA;
|
import jpa.PrimaryHealthCareCenterJPA;
|
||||||
import jpa.SpecialistDoctorJPA;
|
import jpa.SpecialistDoctorJPA;
|
||||||
import managedbean.common.UserType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -97,27 +94,37 @@ public class SystemAdminFacadeBean implements SystemAdminFacadeRemote {
|
|||||||
// First try to login as Admin
|
// First try to login as Admin
|
||||||
AdministratorJPA adm = entman.find(AdministratorJPA.class, id);
|
AdministratorJPA adm = entman.find(AdministratorJPA.class, id);
|
||||||
if (adm != null) {
|
if (adm != null) {
|
||||||
usr = new LoggedUserTO(adm.getEmail(), "", adm.getPassword(), UserType.ADMINISTRADOR);
|
usr = new LoggedUserTO(adm.getEmail(), adm.getEmail(), adm.getPassword(), UserType.ADMINISTRADOR);
|
||||||
} else {
|
} else {
|
||||||
Integer iId = Integer.valueOf(id);
|
try {
|
||||||
// Try to login Patient
|
int iId = Integer.parseInt(id);
|
||||||
PatientJPA pat = entman.find(PatientJPA.class, iId);
|
|
||||||
|
|
||||||
if (pat != null) {
|
// Try to login Patient, FamilyDoctor or SpecialistDoctor
|
||||||
usr = new LoggedUserTO(pat.getId().toString(), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
// TODO: Si Patient, FamilyDoctor o Specialist Doctor tienen el mismo id, solo
|
||||||
} else {
|
// el paciente se puede logear. ¿Deberíamos cambiar esto permitiendo seleccionar
|
||||||
FamilyDoctorJPA fdoc = entman.find(FamilyDoctorJPA.class, iId);
|
// el perfil a logearse?
|
||||||
|
PatientJPA pat = entman.find(PatientJPA.class, iId);
|
||||||
|
|
||||||
if (fdoc != null) {
|
if (pat != null) {
|
||||||
usr = new LoggedUserTO(fdoc.getId().toString(), fdoc.getName(), fdoc.getPassword(), UserType.FAMILY_DOCTOR);
|
usr = new LoggedUserTO(String.valueOf(pat.getId()), pat.getName(), pat.getPassword(), UserType.PATIENT);
|
||||||
} else {
|
} else {
|
||||||
SpecialistDoctorJPA sdoc = entman.find(SpecialistDoctorJPA.class, iId);
|
FamilyDoctorJPA fdoc = entman.find(FamilyDoctorJPA.class, iId);
|
||||||
|
|
||||||
if (sdoc != null) {
|
if (fdoc != null) {
|
||||||
usr = new LoggedUserTO(sdoc.getId().toString(), sdoc.getName(), sdoc.getPassword(), UserType.SPECIALIST_DOCTOR);
|
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) {
|
if (usr != null) {
|
||||||
|
|||||||
@@ -9,10 +9,8 @@ import TO.PrimaryHealthCareCenterTO;
|
|||||||
import TO.LoggedUserTO;
|
import TO.LoggedUserTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -21,6 +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 Collection<PrimaryHealthCareCenterTO> listAllCAPs();
|
||||||
|
|
||||||
public LoggedUserTO login(String id, String pwd);
|
public LoggedUserTO login(String id, String pwd);
|
||||||
}
|
}
|
||||||
@@ -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,7 +42,7 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FamilyDoctorJPA(Integer id, String nif, String name, String surname, String password, String email) {
|
public FamilyDoctorJPA(int 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;
|
||||||
@@ -53,11 +53,11 @@ public class FamilyDoctorJPA implements Serializable {
|
|||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 +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(int 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;
|
||||||
@@ -49,11 +49,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -48,11 +48,11 @@ public class SpecialistDoctorJPA implements Serializable {
|
|||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ 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.ValidationUtils;
|
import managedbean.common.ValidationUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
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.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.SessionUtils;
|
import managedbean.common.SessionUtils;
|
||||||
|
|
||||||
@Named("loginView")
|
@Named("loginView")
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class LoginMBean {
|
public class LoginMBean {
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
private String password;
|
private String password;
|
||||||
@@ -38,25 +43,35 @@ public class LoginMBean {
|
|||||||
FacesMessage message = null;
|
FacesMessage message = null;
|
||||||
boolean loggedIn = false;
|
boolean loggedIn = false;
|
||||||
|
|
||||||
try {
|
LoggedUserTO usr = null;
|
||||||
Thread.sleep(2000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (username != null && username.equals("admin") && password != null && password.equals("admin")) {
|
if (username != null && password != null) {
|
||||||
loggedIn = true;
|
try {
|
||||||
HttpSession session = SessionUtils.getSession();
|
Properties props = System.getProperties();
|
||||||
session.setAttribute("username", username);
|
Context ctx = new InitialContext(props);
|
||||||
session.setAttribute("userid", "1");
|
SystemAdminFacadeRemote remoteManager = (SystemAdminFacadeRemote) ctx.lookup("java:app/MyHealth.jar/SystemAdminFacadeBean!ejb.systemAdmin.SystemAdminFacadeRemote");
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", username);
|
|
||||||
|
|
||||||
return ("home?faces-redirect=true");
|
usr = remoteManager.login(username, password);
|
||||||
} else {
|
|
||||||
loggedIn = false;
|
if (usr != null) {
|
||||||
|
loggedIn = true;
|
||||||
|
HttpSession session = SessionUtils.getSession();
|
||||||
|
session.setAttribute("username", usr.getName());
|
||||||
|
session.setAttribute("userid", "1");
|
||||||
|
session.setAttribute("userid", usr.getUserType());
|
||||||
|
session.setAttribute("loggedInUser", usr);
|
||||||
|
|
||||||
|
message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", usr.getName());
|
||||||
|
|
||||||
|
return ("home?faces-redirect=true");
|
||||||
|
} else
|
||||||
|
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
message = new FacesMessage(FacesMessage.SEVERITY_FATAL, "Error fatal", ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
message = new FacesMessage(FacesMessage.SEVERITY_WARN, "Loggin Error", "El usuario o la contraseña son incorrectos");
|
||||||
}
|
|
||||||
|
|
||||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||||
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
PrimeFaces.current().ajax().addCallbackParam("loggedIn", loggedIn);
|
||||||
@@ -68,9 +83,10 @@ public class LoginMBean {
|
|||||||
public String logout() {
|
public String logout() {
|
||||||
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
||||||
FacesContext.getCurrentInstance().addMessage(null, message);
|
FacesContext.getCurrentInstance().addMessage(null, message);
|
||||||
|
|
||||||
HttpSession session = SessionUtils.getSession();
|
HttpSession session = SessionUtils.getSession();
|
||||||
session.invalidate();
|
session.invalidate();
|
||||||
|
|
||||||
return "home?faces-redirect=true";
|
return "home?faces-redirect=true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,213 +11,213 @@ 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 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 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 character(50) COLLATE pg_catalog."default",
|
||||||
nif character(50) COLLATE pg_catalog.default,
|
nif character(50) COLLATE pg_catalog."default",
|
||||||
surname character varying(100) COLLATE pg_catalog.default,
|
surname character varying(100) COLLATE pg_catalog."default",
|
||||||
email character varying(120) COLLATE pg_catalog.default,
|
email character varying(120) COLLATE pg_catalog."default",
|
||||||
name character varying(100) COLLATE pg_catalog.default,
|
name character varying(100) COLLATE pg_catalog."default",
|
||||||
PrimaryHealthCareCenterId character varying(50) COLLATE pg_catalog.default,
|
primaryhealthcarecenterid character varying(50) COLLATE pg_catalog."default",
|
||||||
CONSTRAINT FamilyDoctor_pkey PRIMARY KEY (id)
|
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.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,
|
name character varying(50) COLLATE pg_catalog."default" NOT NULL,
|
||||||
description text COLLATE pg_catalog.default,
|
description character varying(1000) COLLATE pg_catalog."default",
|
||||||
CONSTRAINT MedicalSpecialty_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.MedicalSpecialty
|
ALTER TABLE myhealth.medicalspecialty
|
||||||
OWNER to "USER";
|
OWNER to postgres;
|
||||||
|
|
||||||
-- 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,
|
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 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 character varying COLLATE pg_catalog."default",
|
||||||
nif character(50) COLLATE pg_catalog.default,
|
nif character varying COLLATE pg_catalog."default",
|
||||||
surname character varying(100) COLLATE pg_catalog.default,
|
surname character varying(100) COLLATE pg_catalog."default",
|
||||||
email character varying(120) COLLATE pg_catalog.default,
|
email character varying(120) COLLATE pg_catalog."default",
|
||||||
name character varying(100) COLLATE pg_catalog.default,
|
name character varying(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 (
|
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
|
|
||||||
|
|
||||||
-- DROP TABLE MyHealth.PrimaryHealthCareCenter;
|
-- Table: myhealth.primaryhealthcarecenter
|
||||||
|
|
||||||
CREATE TABLE MyHealth.PrimaryHealthCareCenter
|
-- DROP 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 GENERATED ALWAYS AS IDENTITY,
|
id integer NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
||||||
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
|
|
||||||
|
|
||||||
-- DROP TABLE MyHealth.Response;
|
-- Table: myhealth.response
|
||||||
|
|
||||||
CREATE TABLE MyHealth.Response
|
-- 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 ),
|
||||||
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
|
|
||||||
|
|
||||||
-- DROP TABLE MyHealth.SpecialistDoctor;
|
-- Table: myhealth.specialistdoctor
|
||||||
|
|
||||||
CREATE TABLE MyHealth.SpecialistDoctor
|
-- 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 character(50) COLLATE pg_catalog.default,
|
password character varying COLLATE pg_catalog."default",
|
||||||
nif character(50) COLLATE pg_catalog.default,
|
nif character varying COLLATE pg_catalog."default",
|
||||||
surname character varying(100) COLLATE pg_catalog.default,
|
surname character varying(100) COLLATE pg_catalog."default",
|
||||||
email character varying(120) COLLATE pg_catalog.default,
|
email character varying(120) COLLATE pg_catalog."default",
|
||||||
name character varying(100) COLLATE pg_catalog.default,
|
name character varying(100) COLLATE pg_catalog."default",
|
||||||
MedicalSpecialtyId character varying(50) COLLATE pg_catalog.default,
|
medicalspecialtyid character varying(50) COLLATE pg_catalog."default",
|
||||||
CONSTRAINT SpecialistDoctor_pkey PRIMARY KEY (id)
|
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
|
|
||||||
|
|
||||||
-- DROP TABLE MyHealth.Visit;
|
-- Table: myhealth.visit
|
||||||
|
|
||||||
CREATE TABLE MyHealth.Visit
|
-- DROP TABLE myhealth.visit;
|
||||||
|
|
||||||
|
CREATE TABLE myhealth.visit
|
||||||
(
|
(
|
||||||
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 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,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');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user