Esqueleto de nueva vista para visualizar las visitas programadas de un
paciente.
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package managedbean.visit;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.model.LazyDataModel;
|
||||
import org.primefaces.model.SortOrder;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.PatientTO;
|
||||
import TO.VisitTO;
|
||||
import common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@Named("PatientVisitList")
|
||||
@ViewScoped
|
||||
public class PatientVisitListMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private PatientTO patient;
|
||||
|
||||
private Integer patientId;
|
||||
private LazyDataModel<VisitTO> lazyDataModelVisitList;
|
||||
private Date selectedDate;
|
||||
|
||||
public PatientVisitListMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Si el usuario es un paciente listamos las visitas de ese paciente, si es admnistrador listamos todas.
|
||||
switch (SessionUtils.getUserType())
|
||||
{
|
||||
case ADMINISTRATOR:
|
||||
this.patientId = null;
|
||||
this.setPatient(null);
|
||||
this.selectedDate = new Date();
|
||||
break;
|
||||
case PATIENT:
|
||||
this.patientId = Integer.valueOf(SessionUtils.getUserId());
|
||||
this.setPatient(this.getRemoteManagerCommon().findPatientById(patientId));
|
||||
this.selectedDate = null;
|
||||
break;
|
||||
case FAMILY_DOCTOR:
|
||||
case SPECIALIST_DOCTOR:
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Acesso denegado", "Su perfil de usuario no está autorizado acceder a esta página.");
|
||||
return;
|
||||
}
|
||||
|
||||
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 = getRemoteManagerVisit().getVisitsCount(patientId, selectedDate);
|
||||
this.setRowCount(totalRowCount.intValue());
|
||||
|
||||
return getRemoteManagerVisit().listVisitsPaged(patientId, selectedDate, (first / pageSize), pageSize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void removeVisit(Integer visitId) throws IOException {
|
||||
// TODO: Eliminar visita de la BBDD
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Visita eliminada", String.format("La visita con Id: %d se ha eliminado correctamente", visitId));
|
||||
}
|
||||
|
||||
public void editVisit(Integer visitId) throws IOException {
|
||||
FacesContext.getCurrentInstance().getExternalContext().redirect("VisitView.xhtml?id=" + visitId.toString());
|
||||
}
|
||||
|
||||
public LazyDataModel<VisitTO> getLazyDataModelVisitList() {
|
||||
return lazyDataModelVisitList;
|
||||
}
|
||||
|
||||
public void showData() {
|
||||
}
|
||||
|
||||
public Date getSelectedDate() {
|
||||
return selectedDate;
|
||||
}
|
||||
|
||||
public void setSelectedDate(Date selectedDate) {
|
||||
this.selectedDate = selectedDate;
|
||||
}
|
||||
|
||||
public PatientTO getPatient() {
|
||||
return patient;
|
||||
}
|
||||
|
||||
public void setPatient(PatientTO patient) {
|
||||
this.patient = patient;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user