Merge branch 'master' into rorden

# Conflicts:
#	2.database/02.Datos_prueba.sql
This commit is contained in:
Roberto Orden Erena
2019-12-23 12:34:11 +01:00
16 changed files with 397 additions and 83 deletions

View File

@@ -183,7 +183,7 @@
<div class="ui-g-12 ui-g-nopad"> <div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4"></div> <div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-2 ui-md-2 "> <div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Guardar" update="frmUpdateProfile" action="#{UpdateProfile.saveData}" icon="pi pi-check" /> <p:commandButton validateClient="true" value="Guardar" update="frmUpdateProfile,frmMenu" action="#{UpdateProfile.saveData}" icon="pi pi-check" />
</div> </div>
<div class="ui-g-2 ui-md-2"> <div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" /> <p:button value="Volver" outcome="/home" icon="pi pi-home" />

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="../header.xhtml">
<ui:define name="content">
<h:form id="frmVisitList">
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel id="PanelUnderConstruction" header="Pagina en construcción de Visitas">
<div class="ui-g ui-fluid">
<div class="ui-g-3">
<p:outputLabel for="fecha" value="Ver agenda del día:" />
</div>
<div class="ui-g-3">
<div class="ui-inputgroup">
<p:calendar id="fecha" value="#{VisitList.selectedDate}" pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
<p:commandButton value="Consultar" onclick="dtVisitList.getPaginator().setPage(0);"/>
</div>
</div>
<div class="ui-g-7">
<p:message for="fecha" display="text" />
</div>
<p:dataTable widgetVar="dtVisitList" var="v" value="#{VisitList.lazyDataModelVisitList}" lazy="true" paginator="true" rows="10" paginatorPosition="bottom"
paginatorAlwaysVisible="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30,40">
<p:column headerText="Id" width="60px;">
<h:outputText value="#{v.id}" />
</p:column>
<p:column headerText="Fecha" width="auto">
<h:outputText value="#{v.date}" />
</p:column>
<p:column headerText="Hora" width="auto">
<h:outputText value="#{v.time}" />
</p:column>
<p:column headerText="Paciente" width="auto">
<h:outputText value="#{v.patient.displayName}" />
</p:column>
<p:column headerText="Observaciones" width="auto">
<h:outputText value="#{v.observations}" />
</p:column>
<p:column headerText="Resultado" width="auto">
<h:outputText value="#{v.result}" />
</p:column>
<p:column headerText="Acción" width="80px;">
<p:commandButton value="Ver" action="showVisit" icon="pi pi-check" />
</p:column>
<f:facet name="paginatorBottomLeft">
<p:commandButton type="button" action="#{VisitList.showData}" icon="pi pi-refresh" onclick="PF('dtVisitList').getPaginator().setPage(0);" />
</f:facet>
</p:dataTable>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4" />
<div class="ui-g-2 ui-md-2 ">
<p:commandButton validateClient="true" value="Consultar" update="frmVisitList" action="#{VisitList.consultar}" icon="pi pi-check" />
</div>
<div class="ui-g-2 ui-md-2">
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
</div>
<div class="ui-g-4 ui-md-4" />
</div>
</div>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</html>

View File

@@ -11,35 +11,44 @@
<p:panel id="PanelUnderConstruction" header="Pagina en construcción de Visitas"> <p:panel id="PanelUnderConstruction" header="Pagina en construcción de Visitas">
<div class="ui-g ui-fluid"> <div class="ui-g ui-fluid">
<div class="ui-g-4 ui-md-4"> <div class="ui-g-3">
<p:outputLabel for="campo" value="Etiqueta para campo de formulario:" /> <p:outputLabel for="campo" value="Ver agenda del día:" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-3">
<p:inputText id="campo" value="Valor del campo del formulario" required="true" requiredMessage="Por favor, especifique un valor" /> <div class="ui-inputgroup">
<p:calendar id="campo" value="" pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
<p:commandButton value="Fecha" />
</div>
</div> </div>
<div class="ui-g-4 ui-md-4"> <div class="ui-g-7">
<p:message for="campo" display="text" /> <p:message for="campo" display="text" />
</div> </div>
<div class="ui-g-4 ui-md-4"> <p:dataTable widgetVar="dtPendingQuestions" var="qs" value="#{PendingQuestions.lazyDataModelQuestionList}" lazy="true" paginator="true" rows="10" paginatorPosition="bottom" paginatorAlwaysVisible="true"
<p:outputLabel for="campo2" value="Etiqueta para campo 2 de formulario:" /> paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,30,40">
</div> <p:column headerText="Id" width="60px;">
<div class="ui-g-4 ui-md-4"> <h:outputText value="#{qs.id}" />
<p:inputText id="campo2" value="Valor del campo 2 del formulario" required="true" requiredMessage="Por favor, especifique un valor" /> </p:column>
</div>
<div class="ui-g-4 ui-md-4">
<p:message for="campo" display="text" />
</div>
<div class="ui-g-4 ui-md-4"> <p:column headerText="Title" width="auto">
<p:outputLabel for="campo3" value="Etiqueta para campo 3 de formulario:" /> <h:outputText value="#{qs.title}"/>
</div> </p:column>
<div class="ui-g-4 ui-md-4">
<p:inputText id="campo3" value="Valor del campo 3 del formulario" required="true" requiredMessage="Por favor, especifique un valor" /> <p:column headerText="Patient" width="auto">
</div> <h:outputText value="#{qs.patient.displayName}" />
<div class="ui-g-4 ui-md-4"> </p:column>
<p:message for="campo" display="text" />
</div> <p:column headerText="Status" width="90px;">
<h:outputText value="#{qs.status}" />
</p:column>
<p:column headerText="Acción" width="80px;">
<h:outputText value="Responder" />
</p:column>
<f:facet name="paginatorBottomLeft">
<p:commandButton type="button" icon="pi pi-refresh" onclick="PF('dtPendingQuestions').getPaginator().setPage(0);" />
</f:facet>
</p:dataTable>
<div class="ui-g-12 ui-g-nopad"> <div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4" /> <div class="ui-g-4 ui-md-4" />

View File

@@ -7,20 +7,15 @@ import java.util.Date;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
/** /**
* Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la * Transfer object (TO) MedicalSpecialtyTO Para el intercambio de datos entre la capa de interfaz y la capa de negocio
* capa de interfaz y la capa de negocio
* *
* Además esta clase facilita la implementación futura de una Capa SOA (Se * Además esta clase facilita la implementación futura de una Capa SOA (Se define la anotación para la serialización de esta clase: @XmlRootElement(name = "medicalspeciality")
* define la anotación para la serialización de esta clase: @XmlRootElement(name
* = "medicalspeciality")
* *
* @author mark * @author mark
* *
*/ */
@XmlRootElement(name = "Visit") @XmlRootElement(name = "Visit")
public class VisitTO implements Serializable { public class VisitTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Integer id; private Integer id;
@@ -34,42 +29,71 @@ public class VisitTO implements Serializable {
public VisitTO() { public VisitTO() {
super(); super();
} }
public VisitTO(Integer id, Date date, Time time, String observation, String result) {
this.setId(id); public VisitTO(Integer Id, Date date, Time time, String observations, String result, FamilyDoctorTO fd, PatientTO pat) {
this.date=date; this.id = Id;
//this.time this.date = date;
this.time = time;
this.observations = observations;
this.result = result;
this.familyDoctor = fd;
this.patient = pat;
} }
public Integer getId() { public Integer getId() {
return this.id; return this.id;
} }
public void setId(Integer id) { public void setId(Integer id) {
this.id=id; this.id = id;
} }
public Date getDate() { public Date getDate() {
return this.date; return this.date;
} }
public void setDate(Date date) { public void setDate(Date date) {
this.date=date; this.date = date;
} }
public Time getTime() { public Time getTime() {
return this.time; return this.time;
} }
public void setTime(Time time) { public void setTime(Time time) {
this.time=time; this.time = time;
} }
public String getObservations() { public String getObservations() {
return this.observations; return this.observations;
} }
public void setObservations(String observations) { public void setObservations(String observations) {
this.observations=observations; this.observations = observations;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public FamilyDoctorTO getFamilyDoctor() {
return familyDoctor;
}
public void setFamilyDoctor(FamilyDoctorTO familyDoctor) {
this.familyDoctor = familyDoctor;
}
public PatientTO getPatient() {
return patient;
}
public void setPatient(PatientTO patient) {
this.patient = patient;
} }
} }

View File

@@ -14,6 +14,7 @@ import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.QuestionTO; import TO.QuestionTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import TO.VisitTO;
import common.Utils; import common.Utils;
import jpa.FamilyDoctorJPA; import jpa.FamilyDoctorJPA;
import jpa.MedicalSpecialtyJPA; import jpa.MedicalSpecialtyJPA;
@@ -21,6 +22,7 @@ import jpa.PatientJPA;
import jpa.PrimaryHealthCareCenterJPA; import jpa.PrimaryHealthCareCenterJPA;
import jpa.QuestionJPA; import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA; import jpa.SpecialistDoctorJPA;
import jpa.VisitJPA;
/*** /***
* *
@@ -479,4 +481,22 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
return qsTO; return qsTO;
} }
public VisitTO getPOJOforVisitJPA(VisitJPA qs, int nestedProps) {
VisitTO qsTO = null;
if (qs != null) {
FamilyDoctorJPA fd = null;
PatientJPA pat = null;
if (nestedProps > 0) {
fd = qs.getFamilyDoctor();
pat = qs.getPatient();
}
nestedProps--;
qsTO = new VisitTO(qs.getId(), qs.getDate(), qs.getTime(), qs.getObservations(), qs.getResult(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps),
this.getPOJOforPatientJPA(pat, nestedProps));
}
return qsTO;
}
} }

View File

@@ -10,12 +10,14 @@ import TO.PatientTO;
import TO.PrimaryHealthCareCenterTO; import TO.PrimaryHealthCareCenterTO;
import TO.QuestionTO; import TO.QuestionTO;
import TO.SpecialistDoctorTO; import TO.SpecialistDoctorTO;
import TO.VisitTO;
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.QuestionJPA; import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA; import jpa.SpecialistDoctorJPA;
import jpa.VisitJPA;
/** /**
* *
@@ -52,13 +54,13 @@ public interface CommonFacadeLocal {
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId); public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
public FamilyDoctorTO findFamilyDoctorByCode(String code); public FamilyDoctorTO findFamilyDoctorByCode(String code);
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue); public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId); public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
public SpecialistDoctorTO findSpecialistDoctorByCode(String code); public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue); public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms); public MedicalSpecialtyTO getPOJOforMedicalSpecialtyJPA(MedicalSpecialtyJPA ms);
@@ -72,4 +74,6 @@ public interface CommonFacadeLocal {
public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps); public PatientTO getPOJOforPatientJPA(PatientJPA pat, int nestedProps);
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps); public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps);
public VisitTO getPOJOforVisitJPA(VisitJPA qs, int nestedProps);
} }

View File

@@ -1,28 +1,63 @@
package ejb.visit; package ejb.visit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import TO.VisitTO;
import common.QuestionStatus;
import ejb.common.CommonFacadeLocal;
import jpa.QuestionJPA;
import jpa.VisitJPA;
/** /**
* 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 métodos de la capa de negocio que implementan la logica de negocio y la interacción con la capa de
* métodos de la capa de negocio que implementan la logica de negocio y la * persistencia.
* interacción con la capa de persistencia.
* *
* @author mark * @author mark
* *
*/ */
@Stateless @Stateless
public class VisitFacadeBean implements VisitFacadeRemote { public class VisitFacadeBean implements VisitFacadeRemote {
// Persistence Unit Context // Persistence Unit Context
@PersistenceContext(unitName = "MyHealth") @PersistenceContext(unitName = "MyHealth")
private EntityManager entman; EntityManager entman;
public void ejbMethod(String parameter) @EJB
{ CommonFacadeLocal commonServices;
public Long getScheduledVisitsCount(int familyDoctorId, Date date) {
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId", Long.class);
query.setParameter("date", date);
query.setParameter("docId", familyDoctorId);
return query.getSingleResult();
}
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize) {
TypedQuery<VisitJPA> query = entman.createQuery("SELECT v from VisitJPA v where v.date=:date and v.familyDoctor.id=:docId order by v.date, v.time", VisitJPA.class);
query.setParameter("date", date);
query.setParameter("docId", familyDoctorId);
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
List<VisitJPA> allJPA = query.getResultList();
List<VisitTO> listTO = new ArrayList<VisitTO>();
for (VisitJPA item : allJPA) {
listTO.add(commonServices.getPOJOforVisitJPA(item, 1));
}
return listTO;
} }
} }

View File

@@ -1,10 +1,14 @@
package ejb.visit; package ejb.visit;
import java.util.Date;
import java.util.List;
import javax.ejb.Remote; import javax.ejb.Remote;
import TO.VisitTO;
/** /**
* 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
* *
* @author mark * @author mark
* *
@@ -14,5 +18,8 @@ public interface VisitFacadeRemote {
/** /**
* Definimos la interfaz remota * Definimos la interfaz remota
*/ */
public void ejbMethod(String parameter);
public Long getScheduledVisitsCount(int familyDoctorId, Date date);
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize);
} }

View File

@@ -32,9 +32,11 @@ public class VisitJPA implements Serializable {
private Time time; private Time time;
private String observations; private String observations;
private String result; private String result;
@ManyToOne @ManyToOne
@JoinColumn(name = "FamilyDoctorId") @JoinColumn(name = "FamilyDoctorId")
private FamilyDoctorJPA familyDoctor; private FamilyDoctorJPA familyDoctor;
@ManyToOne @ManyToOne
@JoinColumn(name = "PatientId") @JoinColumn(name = "PatientId")
private PatientJPA patient; private PatientJPA patient;
@@ -46,16 +48,16 @@ public class VisitJPA implements Serializable {
super(); super();
} }
public VisitJPA(Integer id, Date date, Time time, String observations, String result) { public VisitJPA(Integer id, Date date, Time time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
this.id = id; this.id = id;
this.date = date; this.date = date;
this.time = time; this.time = time;
this.observations = observations; this.observations = observations;
this.result = result; this.result = result;
this.patient = patient;
this.familyDoctor = familydoctor;
} }
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Integer getId() { public Integer getId() {
return id; return id;
} }
@@ -84,8 +86,8 @@ public class VisitJPA implements Serializable {
return observations; return observations;
} }
public void setObservations(String observation) { public void setObservations(String value) {
this.observations = observations; this.observations = value;
} }
/** /**
@@ -106,4 +108,12 @@ public class VisitJPA implements Serializable {
public void setPatient(PatientJPA pat) { public void setPatient(PatientJPA pat) {
this.patient = pat; this.patient = pat;
} }
public String getResult() {
return result;
}
public void setResult(String value) {
this.result = value;
}
} }

View File

@@ -117,7 +117,7 @@ public class AuthorizationFilter implements Filter {
authorized = true; authorized = true;
if (reqURI.indexOf("/visit/VisitAddResult") > 0) if (reqURI.indexOf("/visit/VisitAddResult") > 0)
authorized = true; authorized = true;
if (reqURI.indexOf("/visit/VisitViewSchedules") > 0) if (reqURI.indexOf("/visit/VisitList") > 0)
authorized = true; authorized = true;
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0) if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
authorized = true; authorized = true;

View File

@@ -64,7 +64,7 @@ public class MenuMBean implements Serializable {
if (tipoUsuario == UserType.FAMILY_DOCTOR) if (tipoUsuario == UserType.FAMILY_DOCTOR)
subMenu.addElement(createMenuItem("Añadir resultado", "fa fa-align-left", "/visit/VisitView", null)); subMenu.addElement(createMenuItem("Añadir resultado", "fa fa-align-left", "/visit/VisitView", null));
if (tipoUsuario == UserType.FAMILY_DOCTOR) if (tipoUsuario == UserType.FAMILY_DOCTOR)
subMenu.addElement(createMenuItem("Ver agenda del día", "fa fa-repeat", "/visit/VisitView", null)); subMenu.addElement(createMenuItem("Ver agenda del día", "fa fa-repeat", "/visit/VisitList", null));
model.addElement(subMenu); model.addElement(subMenu);
} }

View File

@@ -17,13 +17,17 @@ public class SessionUtils {
public static final String SESSION_VAR_USER = "loggedOnUser"; public static final String SESSION_VAR_USER = "loggedOnUser";
public static final String SESSION_VAR_MESSAGE = "facesMessage"; public static final String SESSION_VAR_MESSAGE = "facesMessage";
public static HttpSession getSession() { public static HttpSession getSession(boolean create) {
FacesContext ctx = FacesContext.getCurrentInstance(); FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx != null) if (ctx != null)
return (HttpSession) ctx.getExternalContext().getSession(false); return (HttpSession) ctx.getExternalContext().getSession(create);
else else
return null; return null;
} }
public static HttpSession getSession() {
return getSession(false);
}
public static HttpServletRequest getRequest() { public static HttpServletRequest getRequest() {
return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); return (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
@@ -33,8 +37,8 @@ public class SessionUtils {
return ((HttpServletRequest) request).getSession(false); return ((HttpServletRequest) request).getSession(false);
} }
public static void CreateSession(LoggedUserTO usr) { public static void createOrUpdateSession(LoggedUserTO usr) {
HttpSession ses = getSession(); HttpSession ses = getSession(true);
ses.setAttribute(SessionUtils.SESSION_VAR_USERNAME, usr.getName()); ses.setAttribute(SessionUtils.SESSION_VAR_USERNAME, usr.getName());
ses.setAttribute(SessionUtils.SESSION_VAR_USERID, usr.getId()); ses.setAttribute(SessionUtils.SESSION_VAR_USERID, usr.getId());
ses.setAttribute(SessionUtils.SESSION_VAR_USERTYPE, usr.getUserType()); ses.setAttribute(SessionUtils.SESSION_VAR_USERTYPE, usr.getUserType());

View File

@@ -26,8 +26,7 @@ import managedbean.common.SessionUtils;
import managedbean.common.ValidationUtils; import managedbean.common.ValidationUtils;
/** /**
* ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente" * ManagedBEan que gestiona el registro de usuarios: Usuarios de tipo "Paciente" Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
* Usuarios de tipo "Médico de Familia" usuarios de tipo "Médico especialista"
* *
* @author Marcos García Núñez (mgarcianun@uoc.edu) * @author Marcos García Núñez (mgarcianun@uoc.edu)
* *
@@ -175,13 +174,13 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
public void hadleNIFValueChange() { public void hadleNIFValueChange() {
boolean isDupe = false; boolean isDupe = false;
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) { if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) {
isDupe = true; isDupe = true;
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
} }
PrimeFaces.current().ajax().addCallbackParam("NIFisDupe", isDupe); PrimeFaces.current().ajax().addCallbackParam("NIFisDupe", isDupe);
} }
public List<FamilyDoctorTO> getFamilyDoctorList() { public List<FamilyDoctorTO> getFamilyDoctorList() {
return familyDoctorList; return familyDoctorList;
} }
@@ -257,11 +256,11 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
public void saveData() { public void saveData() {
int error = 0; int error = 0;
// Si no hay tipo de usuario, es que algo raro ha pasado (sesión caducada?). salimos. // Si no hay tipo de usuario, es que algo raro ha pasado (sesión caducada?). salimos.
if (this.userType == null) if (this.userType == null)
return; return;
boolean changePassword = (this.oldPassword != null && this.oldPassword.equals("") == false) || (this.password != null && this.password.equals("") == false); boolean changePassword = (this.oldPassword != null && this.oldPassword.equals("") == false) || (this.password != null && this.password.equals("") == false);
if (this.isUserTypeFamilyDoctor() && this.primaryHealthCareCenter == null) { if (this.isUserTypeFamilyDoctor() && this.primaryHealthCareCenter == null) {
@@ -279,7 +278,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) { if (ValidationUtils.checkIfNifAlreadyRegistered(this.getRemoteManagerCommon(), this.userType, this.nif, this.id) == true) {
this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado"); this.addFacesMessage("frmUpdateProfile:nif", FacesMessage.SEVERITY_WARN, "NIF duplicado", "El nif indicado pertenece a otro usuario previamente registrado");
error++; error++;
} }
if (changePassword == true) { if (changePassword == true) {
// el usuario queire cambiar el password Comprobamos que el password // el usuario queire cambiar el password Comprobamos que el password
// especificado coincide con el guardado // especificado coincide con el guardado
@@ -295,20 +294,25 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
if (error == 0) { if (error == 0) {
try { try {
LoggedUserTO usr = null;
switch (this.userType) { switch (this.userType) {
case PATIENT: case PATIENT:
PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email); PatientTO pat = this.getRemoteManagerProfile().updatePatientData(id, nif, name, surname, password, email);
this.setPatientData(pat); this.setPatientData(pat);
usr = new LoggedUserTO(pat.getId().toString(), pat.getName(), pat.getPassword(), this.userType);
break; break;
case FAMILY_DOCTOR: case FAMILY_DOCTOR:
FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter); FamilyDoctorTO fd = this.getRemoteManagerProfile().updateFamilyDoctorData(id, nif, name, surname, password, email, this.primaryHealthCareCenter);
this.setFamilyDoctorData(fd); this.setFamilyDoctorData(fd);
usr = new LoggedUserTO(fd.getId().toString(), fd.getName(), fd.getPassword(), this.userType);
break; break;
case SPECIALIST_DOCTOR: case SPECIALIST_DOCTOR:
SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty); SpecialistDoctorTO sd = this.getRemoteManagerProfile().updateSpecialistDoctorData(id, nif, name, surname, password, email, this.medicalSpecialty);
this.setSpecialistDoctorData(sd); this.setSpecialistDoctorData(sd);
usr = new LoggedUserTO(sd.getId().toString(), sd.getName(), sd.getPassword(), this.userType);
break; break;
case ADMINISTRATOR: case ADMINISTRATOR:
@@ -321,6 +325,9 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
this.oldPassword = ""; this.oldPassword = "";
} }
// Actualizamos la sessión del usuario actual por si ha cambiado el nombre de usuario.
SessionUtils.createOrUpdateSession(usr);
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos de su perfil se han guardado correctamente."); this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos de su perfil se han guardado correctamente.");
} catch (Exception e) { } catch (Exception e) {
this.manageException(e); this.manageException(e);

View File

@@ -45,7 +45,7 @@ public class LoginMBean extends ManagedBeanBase {
if (usr != null) { if (usr != null) {
loggedIn = true; loggedIn = true;
SessionUtils.CreateSession(usr); SessionUtils.createOrUpdateSession(usr);
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Login correcto", "Bienvenido " + usr.getName()); this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Login correcto", "Bienvenido " + usr.getName());
viewRedirect = "/home?faces-redirect=true"; viewRedirect = "/home?faces-redirect=true";

View File

@@ -0,0 +1,70 @@
package managedbean.visit;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;
import TO.VisitTO;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@Named("VisitList")
@RequestScoped
public class VisitListMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
private int familyDoctorId;
private LazyDataModel<VisitTO> lazyDataModelVisitList;
private Date selectedDate;
public VisitListMBean() {
}
@PostConstruct
public void init() {
// El usuario actual es un medico de familia, recuperamos su Id de la sessión actual
this.familyDoctorId = Integer.valueOf(SessionUtils.getUserId());
this.selectedDate = new Date();
this.lazyDataModelVisitList = new LazyDataModel<VisitTO>() {
private static final long serialVersionUID = 1L;
@Override
public List<VisitTO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
Long totalRowCount = getRemoteManagerMedicalTest().getPendingQuestionsCount(familyDoctorId);
this.setRowCount(totalRowCount.intValue());
return getRemoteManagerVisit().listAllScheduledVisitsPaged(familyDoctorId, selectedDate, (first / pageSize), pageSize);
}
};
}
public LazyDataModel<VisitTO> getLazyDataModelVisitList() {
return lazyDataModelVisitList;
}
public void saveData() {
}
public void showData() {
}
public Date getSelectedDate() {
return selectedDate;
}
public void setSelectedDate(Date selectedDate) {
this.selectedDate = selectedDate;
}
}

View File

@@ -1,4 +1,4 @@
--Inserta usuarios administradores (contraseña Hash MD5 'admin' para todos) -- Inserta usuarios administradores (contraseña Hash MD5 'admin' para todos)
insert into myhealth.administrator (email, password) values insert into myhealth.administrator (email, password) values
('admin@example.com', '21232F297A57A5A743894A0E4A801FC3') ('admin@example.com', '21232F297A57A5A743894A0E4A801FC3')
,('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3'); ,('marcos@example.com', '21232F297A57A5A743894A0E4A801FC3');
@@ -67,7 +67,7 @@ INSERT INTO myhealth.specialistdoctor(professionalnumber, password, nif, surname
,('PRO#119','912EC803B2CE49E4A541068D495AB570','04431824T','Requena Calderon', 'Ferran@example.ecom','Ferran', 10) ,('PRO#119','912EC803B2CE49E4A541068D495AB570','04431824T','Requena Calderon', 'Ferran@example.ecom','Ferran', 10)
,('PRO#120','912EC803B2CE49E4A541068D495AB570','27476123R','Angulo Zamora', 'Ana@example.ecom','Ana', 11); ,('PRO#120','912EC803B2CE49E4A541068D495AB570','27476123R','Angulo Zamora', 'Ana@example.ecom','Ana', 11);
--Insertar Pacientes -- Insertar Pacientes
INSERT INTO myhealth.patient(personalidentificationcode, password, nif, surname, email, name, familydoctorid) VALUES INSERT INTO myhealth.patient(personalidentificationcode, password, nif, surname, email, name, familydoctorid) VALUES
('PAT#100','912EC803B2CE49E4A541068D495AB570','97758900E','Singh Vila', 'Soledad@example.ecom','Soledad', 1) ('PAT#100','912EC803B2CE49E4A541068D495AB570','97758900E','Singh Vila', 'Soledad@example.ecom','Soledad', 1)
,('PAT#101','912EC803B2CE49E4A541068D495AB570','Z9518183Y','Jimenez Merino', 'Ainhoa@example.ecom','Ainhoa', 2) ,('PAT#101','912EC803B2CE49E4A541068D495AB570','Z9518183Y','Jimenez Merino', 'Ainhoa@example.ecom','Ainhoa', 2)
@@ -80,6 +80,7 @@ INSERT INTO myhealth.patient(personalidentificationcode, password, nif, surname,
,('PAT#108','912EC803B2CE49E4A541068D495AB570','73569670F','Bosch Zapata', 'Esperanza@example.ecom','Esperanza', 9) ,('PAT#108','912EC803B2CE49E4A541068D495AB570','73569670F','Bosch Zapata', 'Esperanza@example.ecom','Esperanza', 9)
,('PAT#109','912EC803B2CE49E4A541068D495AB570','53986482P','Carretero Ayala', 'Eduardo@example.ecom','Eduardo', 10); ,('PAT#109','912EC803B2CE49E4A541068D495AB570','53986482P','Carretero Ayala', 'Eduardo@example.ecom','Eduardo', 10);
-- Insertar datos de prueba para preguntas
INSERT INTO myhealth.question(title, message, status, response, patientid, familydoctorid) VALUES INSERT INTO myhealth.question(title, message, status, response, patientid, familydoctorid) VALUES
('titulo de la pregunta número 1', 'Doctor, tengo dolor en la articulación numero 1', 'PENDING', null, 1, 1) ('titulo de la pregunta número 1', 'Doctor, tengo dolor en la articulación numero 1', 'PENDING', null, 1, 1)
,('titulo de la pregunta número 2', 'Doctor, tengo dolor en la articulación numero 2', 'PENDING', null, 2, 1) ,('titulo de la pregunta número 2', 'Doctor, tengo dolor en la articulación numero 2', 'PENDING', null, 2, 1)
@@ -105,7 +106,52 @@ INSERT INTO myhealth.question(title, message, status, response, patientid, famil
,('titulo de la pregunta número 22', 'Doctor, tengo dolor en la articulación numero 22', 'PENDING', null, 9, 1) ,('titulo de la pregunta número 22', 'Doctor, tengo dolor en la articulación numero 22', 'PENDING', null, 9, 1)
,('titulo de la pregunta número 23', 'Doctor, tengo dolor en la articulación numero 23', 'PENDING', null, 10, 1); ,('titulo de la pregunta número 23', 'Doctor, tengo dolor en la articulación numero 23', 'PENDING', null, 10, 1);
INSERT INTO myhealth.medicaltest(date, "time", observations, highresimage,"type",patientid, specialistdoctorid) VALUES INSERT INTO myhealth.medicaltest(date, "time", observations, highresimage,"type",patientid, specialistdoctorid) VALUES
('2019/12/15',now(),'',null,0,1,1), ('2019/12/15',now(),'',null,0,1,1),
('2019/12/15',now(),'',null,0,1,2), ('2019/12/15',now(),'',null,0,1,2),
('2019/12/15',now(),'',null,0,2,1); ('2019/12/15',now(),'',null,0,2,1);
-- Insertar datos de prueba para visitas
INSERT INTO myhealth.visit(date, "time", observations, result, patientid, familydoctorid) VALUES
('23/12/2019','09:00','Observaciones de la visita 43822','',1,1),
('23/12/2019','10:00','Observaciones de la visita 43822','',2,1),
('23/12/2019','11:00','Observaciones de la visita 43822','',3,1),
('23/12/2019','12:00','Observaciones de la visita 43822','',4,1),
('23/12/2019','13:00','Observaciones de la visita 43822','',5,1),
('23/12/2019','14:00','Observaciones de la visita 43822','',6,1),
('23/12/2019','15:00','Observaciones de la visita 43822','',7,1),
('23/12/2019','16:00','Observaciones de la visita 43822','',8,1),
('23/12/2019','17:00','Observaciones de la visita 43822','',9,1),
('23/12/2019','18:00','Observaciones de la visita 43822','',10,1),
('24/12/2019','09:00','Observaciones de la visita 43823','',1,1),
('25/12/2019','10:00','Observaciones de la visita 43824','',2,1),
('26/12/2019','11:00','Observaciones de la visita 43825','',3,1),
('27/12/2019','12:00','Observaciones de la visita 43826','',4,1),
('28/12/2019','13:00','Observaciones de la visita 43827','',5,1),
('29/12/2019','14:00','Observaciones de la visita 43828','',6,1),
('30/12/2019','15:00','Observaciones de la visita 43829','',7,1),
('31/12/2019','16:00','Observaciones de la visita 43830','',8,1),
('01/01/2020','17:00','Observaciones de la visita 43831','',9,1),
('02/01/2020','18:00','Observaciones de la visita 43832','',10,1),
('23/12/2019','09:00','Observaciones de la visita 43822','',1,2),
('23/12/2019','10:00','Observaciones de la visita 43822','',2,2),
('23/12/2019','11:00','Observaciones de la visita 43822','',3,2),
('23/12/2019','12:00','Observaciones de la visita 43822','',4,2),
('23/12/2019','13:00','Observaciones de la visita 43822','',5,2),
('23/12/2019','14:00','Observaciones de la visita 43822','',6,2),
('23/12/2019','15:00','Observaciones de la visita 43822','',7,2),
('23/12/2019','16:00','Observaciones de la visita 43822','',8,2),
('23/12/2019','17:00','Observaciones de la visita 43822','',9,2),
('23/12/2019','18:00','Observaciones de la visita 43822','',10,2),
('24/12/2019','09:00','Observaciones de la visita 43823','',1,2),
('25/12/2019','10:00','Observaciones de la visita 43824','',2,2),
('26/12/2019','11:00','Observaciones de la visita 43825','',3,2),
('27/12/2019','12:00','Observaciones de la visita 43826','',4,2),
('28/12/2019','13:00','Observaciones de la visita 43827','',5,2),
('29/12/2019','14:00','Observaciones de la visita 43828','',6,2),
('30/12/2019','15:00','Observaciones de la visita 43829','',7,2),
('31/12/2019','16:00','Observaciones de la visita 43830','',8,2),
('01/01/2020','17:00','Observaciones de la visita 43831','',9,2),
('02/01/2020','18:00','Observaciones de la visita 43832','',10,2);