Cambiado tipo de datos Date a LocalDate para componente visit.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<!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">
|
||||
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||
|
||||
<ui:composition template="../header.xhtml">
|
||||
<ui:define name="content">
|
||||
@@ -36,8 +36,10 @@
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<div class="ui-inputgroup">
|
||||
<p:datePicker id="fecha" value="#{AddVisit.date}" pattern="dd/MM/yyyy" showIcon="true" showOn="none" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la fecha de la visita." />
|
||||
<p:datePicker id="fecha" widgetVar="fecha" value="#{AddVisit.date}" pattern="dd/MM/yyyy" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la fecha de la visita.">
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
</p:datePicker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui-g-8">
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<div class="ui-g-3">
|
||||
<div class="ui-inputgroup">
|
||||
<p:datePicker id="fecha" value="#{PatientVisitList.selectedDate}" pattern="dd/MM/yyyy" showIcon="true" showButtonBar="true" autocomplete="true">
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
<p:ajax event="dateSelect" listener="#{PatientVisitList.showData}" update="frmPatientVisitList" />
|
||||
</p:datePicker>
|
||||
<p:commandButton value="Mostrar" update="frmPatientVisitList" action="#{PatientVisitList.showData}" icon="fa calendar-alt" />
|
||||
@@ -50,7 +51,7 @@
|
||||
|
||||
<p:column headerText="Fecha" width="90">
|
||||
<h:outputText value="#{v.date}">
|
||||
<f:convertDateTime type="date" pattern="dd/MM/yyyy" timeStyle="short" />
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
</h:outputText>
|
||||
</p:column>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!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">
|
||||
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||
|
||||
<f:viewParam name="id" value="#{UpdateVisit.id}" required="true" />
|
||||
<ui:composition template="../header.xhtml">
|
||||
@@ -37,8 +37,10 @@
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<div class="ui-inputgroup">
|
||||
<p:datePicker id="fecha" value="#{UpdateVisit.date}" pattern="dd/MM/yyyy" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la fecha de la visita." readonly="#{UpdateVisit.onlyResult}" />
|
||||
<p:datePicker id="fecha" value="#{UpdateVisit.date}" pattern="dd/MM/yyyy" disabled="#{UpdateVisit.onlyResult}" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la fecha de la visita." readonly="#{UpdateVisit.onlyResult}">
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" timeStyle="short" />
|
||||
</p:datePicker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui-g-8">
|
||||
@@ -49,9 +51,9 @@
|
||||
<p:outputLabel for="hora" value="Hora:" />
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<p:datePicker id="hora" value="#{UpdateVisit.time}" timeOnly="true" pattern="HH:mm" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
<p:datePicker id="hora" value="#{UpdateVisit.time}" timeOnly="true" pattern="HH:mm" disabled="#{UpdateVisit.onlyResult}" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la hora de la visita." readonly="#{UpdateVisit.onlyResult}">
|
||||
<f:convertDateTime type="localTime" pattern="HH:mm" />
|
||||
<f:convertDateTime type="localTime" pattern="HH:mm" timeStyle="Short" />
|
||||
</p:datePicker>
|
||||
</div>
|
||||
<div class="ui-g-8">
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<div class="ui-inputgroup">
|
||||
<p:datePicker id="fecha" value="#{VisitList.selectedDate}" pattern="dd/MM/yyyy" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique una fecha para realizar la consulta.">
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
<p:ajax event="dateSelect" listener="#{VisitList.showData}" update="frmVisitList" />
|
||||
</p:datePicker>
|
||||
<p:commandButton value="Mostrar" update="frmVisitList" action="#{VisitList.showData}" icon="fa calendar-alt" />
|
||||
@@ -35,7 +36,7 @@
|
||||
|
||||
<p:column headerText="Fecha" width="90">
|
||||
<h:outputText value="#{v.date}">
|
||||
<f:convertDateTime type="date" pattern="dd/MM/yyyy" timeStyle="short" />
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
</h:outputText>
|
||||
</p:column>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!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">
|
||||
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||
|
||||
<f:viewParam name="id" value="#{VisitView.id}" required="true" />
|
||||
<ui:composition template="../header.xhtml">
|
||||
@@ -37,8 +37,10 @@
|
||||
</div>
|
||||
<div class="ui-g-2">
|
||||
<div class="ui-inputgroup">
|
||||
<p:datePicker id="fecha" value="#{VisitView.date}" pattern="dd/MM/yyyy" showIcon="true" disabled="true" showButtonBar="true"
|
||||
autocomplete="true" required="true" requiredMessage="Especifique la fecha de la visita." />
|
||||
<p:datePicker id="fecha" value="#{VisitView.date}" pattern="dd/MM/yyyy" showIcon="true" disabled="true" showButtonBar="true" autocomplete="true" required="true"
|
||||
requiredMessage="Especifique la fecha de la visita.">
|
||||
<f:convertDateTime type="localDate" pattern="dd/MM/yyyy" />
|
||||
</p:datePicker>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui-g-8">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package TO;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -19,7 +20,7 @@ public class VisitTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String result;
|
||||
@@ -30,7 +31,7 @@ public class VisitTO implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public VisitTO(Integer Id, Date date, LocalTime time, String observations, String result, FamilyDoctorTO fd, PatientTO pat) {
|
||||
public VisitTO(Integer Id, LocalDate date, LocalTime time, String observations, String result, FamilyDoctorTO fd, PatientTO pat) {
|
||||
this.id = Id;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
@@ -48,11 +49,11 @@ public class VisitTO implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
public LocalDate getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package ejb.visit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.EJB;
|
||||
@@ -17,9 +17,8 @@ import jpa.PatientJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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
|
||||
*
|
||||
@@ -33,19 +32,16 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
@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);
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, LocalDate 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);
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, LocalDate 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);
|
||||
|
||||
@@ -64,7 +60,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
return listTO;
|
||||
}
|
||||
|
||||
public Long getVisitsCount(Integer patientId, Date date) {
|
||||
public Long getVisitsCount(Integer patientId, LocalDate date) {
|
||||
String strQuery = "SELECT count(1) from VisitJPA v %s";
|
||||
String strFilter = "";
|
||||
if (patientId != null)
|
||||
@@ -87,7 +83,7 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize) {
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, LocalDate date, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT v from VisitJPA v %s order by v.patient, v.date";
|
||||
String strFilter = "";
|
||||
if (patientId != null)
|
||||
@@ -143,14 +139,14 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
entman.remove(vi);
|
||||
}
|
||||
|
||||
public void updateVisit(int id, Date date, LocalTime time) {
|
||||
public void updateVisit(int id, LocalDate date, LocalTime time) {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
vi.setDate(date);
|
||||
vi.setTime(time);
|
||||
entman.persist(vi);
|
||||
}
|
||||
|
||||
public VisitTO addVisit(int patientId, Date date, LocalTime time, String observations) {
|
||||
public VisitTO addVisit(int patientId, LocalDate date, LocalTime time, String observations) {
|
||||
|
||||
PatientJPA pat = entman.find(PatientJPA.class, patientId);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ejb.visit;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
@@ -9,8 +9,7 @@ import javax.ejb.Remote;
|
||||
import TO.VisitTO;
|
||||
|
||||
/**
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para
|
||||
* los clientes del EJB
|
||||
* Interfaz remota del EJB Definimos los métodos que estarán disponibles para los clientes del EJB
|
||||
*
|
||||
* @author alina
|
||||
*
|
||||
@@ -21,13 +20,13 @@ public interface VisitFacadeRemote {
|
||||
* Definimos la interfaz remota
|
||||
*/
|
||||
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, Date date);
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, LocalDate date);
|
||||
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize);
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, LocalDate date, int pageNumber, int pageSize);
|
||||
|
||||
public Long getVisitsCount(Integer patientId, Date date);
|
||||
public Long getVisitsCount(Integer patientId, LocalDate date);
|
||||
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize);
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, LocalDate date, int pageNumber, int pageSize);
|
||||
|
||||
public VisitTO getVisit(int id) throws Exception;
|
||||
|
||||
@@ -35,8 +34,8 @@ public interface VisitFacadeRemote {
|
||||
|
||||
public void removeVisit(int id);
|
||||
|
||||
public void updateVisit(int id, Date date, LocalTime time);
|
||||
public void updateVisit(int id, LocalDate date, LocalTime time);
|
||||
|
||||
public VisitTO addVisit(int patientId, Date date, LocalTime time, String observations);
|
||||
public VisitTO addVisit(int patientId, LocalDate date, LocalTime time, String observations);
|
||||
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -29,7 +28,7 @@ public class VisitJPA implements Serializable {
|
||||
@Column(updatable = false)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String result;
|
||||
@@ -49,7 +48,7 @@ public class VisitJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public VisitJPA(Date date, LocalTime time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
|
||||
public VisitJPA(LocalDate date, LocalTime time, String observations, String result, PatientJPA patient, FamilyDoctorJPA familydoctor) {
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
this.observations = observations;
|
||||
@@ -66,11 +65,11 @@ public class VisitJPA implements Serializable {
|
||||
this.id = value;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date value) {
|
||||
public void setDate(LocalDate value) {
|
||||
this.date = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package managedbean.visit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
@@ -22,7 +23,7 @@ public class AddVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String result;
|
||||
@@ -43,7 +44,7 @@ public class AddVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
this.patient = this.getRemoteManagerCommon().findPatientById(patientId);
|
||||
this.familyDoctor = this.patient.getFamilyDoctor();
|
||||
|
||||
this.date = new Date();
|
||||
this.date = LocalDate.now();
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
@@ -53,14 +54,15 @@ public class AddVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
public void saveData() {
|
||||
// Comprobamos que la fecha fijada para la visita no sea anterior a la actual
|
||||
int error = 0;
|
||||
if (this.date.before( new Date())) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta",
|
||||
"La cita fijada es anterior al momento actual");
|
||||
LocalTime midnight = LocalTime.MIDNIGHT;
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
if (this.date.isBefore(today)) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta", "La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
if (this.date.equals(new Date()) && this.time.isBefore(LocalTime.now())){
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta",
|
||||
"La cita fijada es anterior al momento actual");
|
||||
if (this.date.equals(today) && this.time.isBefore(LocalTime.now())) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta", "La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
if (error == 0) {
|
||||
@@ -72,14 +74,13 @@ public class AddVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package managedbean.visit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,7 +33,7 @@ public class PatientVisitListMBean extends ManagedBeanBase implements Serializab
|
||||
|
||||
private Integer patientId;
|
||||
private LazyDataModel<VisitTO> lazyDataModelVisitList;
|
||||
private Date selectedDate;
|
||||
private LocalDate selectedDate;
|
||||
private String lastUIQuery;
|
||||
private List<PatientTO> patientList;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class PatientVisitListMBean extends ManagedBeanBase implements Serializab
|
||||
case ADMINISTRATOR:
|
||||
this.patientId = null;
|
||||
this.patient = null;
|
||||
this.selectedDate = new Date();
|
||||
this.selectedDate = LocalDate.now();
|
||||
|
||||
this.patientList = this.getRemoteManagerCommon().listPatientsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
break;
|
||||
@@ -111,11 +112,11 @@ public class PatientVisitListMBean extends ManagedBeanBase implements Serializab
|
||||
public void showData() {
|
||||
}
|
||||
|
||||
public Date getSelectedDate() {
|
||||
public LocalDate getSelectedDate() {
|
||||
return selectedDate;
|
||||
}
|
||||
|
||||
public void setSelectedDate(Date selectedDate) {
|
||||
public void setSelectedDate(LocalDate selectedDate) {
|
||||
this.selectedDate = selectedDate;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package managedbean.visit;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -24,7 +25,7 @@ public class UpdateVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String result;
|
||||
@@ -81,66 +82,55 @@ public class UpdateVisitMBean extends ManagedBeanBase implements Serializable {
|
||||
this.onlyResult = true;
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Acesso denegado",
|
||||
"Su perfil de usuario no está autorizado acceder a esta página.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Acesso denegado", "Su perfil de usuario no está autorizado acceder a esta página.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
//Comprobamos que la fecha fijada para la visita no sea anterior a la actual
|
||||
int error = 0;
|
||||
if (this.date.before( new Date())) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta",
|
||||
"La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
if (this.date.equals(new Date()) && this.time.isBefore(LocalTime.now())){
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta",
|
||||
"La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
// Si el usuario es un paciente listamos las visitas de ese paciente, si es
|
||||
// admnistrador listamos todas.
|
||||
if(error==0) {
|
||||
try {
|
||||
switch (SessionUtils.getUserType()) {
|
||||
case ADMINISTRATOR:
|
||||
case PATIENT:
|
||||
// Administrador y paciente pueden actualizar la fecha y hora de la visita
|
||||
// (excepto esl resultado)
|
||||
// TODO: Implementar método en EJB
|
||||
// Administrador y paciente pueden actualizar la fecha y hora de la visita (excepto el resultado)
|
||||
// Comprobamos que la fecha fijada para la visita no sea anterior a la actual
|
||||
int error = 0;
|
||||
LocalTime midnight = LocalTime.MIDNIGHT;
|
||||
LocalDate today = LocalDate.now();
|
||||
|
||||
if (this.date.isBefore(today)) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta", "La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
if (this.date.equals(today) && this.time.isBefore(LocalTime.now())) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Fecha incorrecta", "La cita fijada es anterior al momento actual");
|
||||
error++;
|
||||
}
|
||||
if (error == 0) {
|
||||
this.getRemoteManagerVisit().updateVisit(this.id, this.date, this.time);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Visita actualizada",
|
||||
"La fecha y hora de la visita se ha actualizado correctamente.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Visita actualizada", "La fecha y hora de la visita se ha actualizado correctamente.");
|
||||
}
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
// El médico de familia solo puede actualizar el resultado.
|
||||
// TODO: implementar método EJB para actualizar el resultado.
|
||||
this.getRemoteManagerVisit().addResultToVisit(this.id, this.result);
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Resultado actualizado",
|
||||
"El resultado de la visita se ha actualizado correctamente.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Resultado actualizado", "El resultado de la visita se ha actualizado correctamente.");
|
||||
break;
|
||||
case SPECIALIST_DOCTOR:
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Acesso denegado",
|
||||
"Su perfil de usuario no está autorizado acceder a esta página.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Acesso denegado", "Su perfil de usuario no está autorizado acceder a esta página.");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package managedbean.visit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -27,7 +28,7 @@ public class VisitListMBean extends ManagedBeanBase implements Serializable {
|
||||
private int familyDoctorId;
|
||||
private String familyDoctorDisplayName;
|
||||
private LazyDataModel<VisitTO> lazyDataModelVisitList;
|
||||
private Date selectedDate;
|
||||
private LocalDate selectedDate;
|
||||
|
||||
public VisitListMBean() {
|
||||
}
|
||||
@@ -38,7 +39,7 @@ public class VisitListMBean extends ManagedBeanBase implements Serializable {
|
||||
this.familyDoctorId = Integer.valueOf(SessionUtils.getUserId());
|
||||
this.familyDoctorDisplayName = SessionUtils.getUserDisplayName();
|
||||
|
||||
this.selectedDate = new Date();
|
||||
this.selectedDate = LocalDate.now();
|
||||
|
||||
this.lazyDataModelVisitList = new LazyDataModel<VisitTO>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -70,11 +71,11 @@ public class VisitListMBean extends ManagedBeanBase implements Serializable {
|
||||
ctx.getExternalContext().redirect(String.format("UpdateVisit.xhtml?id=%d&fromPage=%s", visitId, ctx.getViewRoot().getViewId()));
|
||||
}
|
||||
|
||||
public Date getSelectedDate() {
|
||||
public LocalDate getSelectedDate() {
|
||||
return selectedDate;
|
||||
}
|
||||
|
||||
public void setSelectedDate(Date selectedDate) {
|
||||
public void setSelectedDate(LocalDate selectedDate) {
|
||||
this.selectedDate = selectedDate;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package managedbean.visit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
@@ -24,7 +24,7 @@ public class VisitMBean extends ManagedBeanBase implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private Date date;
|
||||
private LocalDate date;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String result;
|
||||
@@ -75,11 +75,11 @@ public class VisitMBean extends ManagedBeanBase implements Serializable {
|
||||
ctx.getExternalContext().redirect(String.format("UpdateVisit.xhtml?id=%d&fromPage=%s", visitId, this.fromPage));
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user