Esqueleto de nueva vista para visualizar las visitas programadas de un
paciente.
This commit is contained in:
86
1.sources/MyHealth/docroot/visit/PatientVisitList.xhtml
Normal file
86
1.sources/MyHealth/docroot/visit/PatientVisitList.xhtml
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
<?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="frmPatientVisitList">
|
||||||
|
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
|
<p:panel id="PanelUnderConstruction" header="Próximas visitas agendadas">
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
|
||||||
|
<div class="ui-g-2">
|
||||||
|
<p:outputLabel for="fecha" value="Ver agenda del día:" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-2">
|
||||||
|
<div class="ui-inputgroup">
|
||||||
|
<p:calendar id="fecha" value="#{PatientVisitList.selectedDate}" pattern="dd/MM/yyyy" showButtonPanel="true" autocomplete="true" />
|
||||||
|
<p:commandButton value="Mostrar" update="frmPatientVisitList" action="#{PatientVisitList.showData}" icon="fa calendar-alt" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-3">
|
||||||
|
<p:message for="fecha" display="text" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-5">
|
||||||
|
Paciente: <h:outputText value="#{PatientVisitList.patient.displayName}" style="font-weight: bold;" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p:dataTable id="dtPatientVisitList" widgetVar="dtPatientVisitList" var="v" value="#{PatientVisitList.lazyDataModelVisitList}" lazy="true" paginator="true" rows="10" paginatorPosition="bottom"
|
||||||
|
paginatorAlwaysVisible="true" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
|
||||||
|
rowsPerPageTemplate="10,20,30,40" emptyMessage="No existen datos para los filtros seleccionados.">
|
||||||
|
|
||||||
|
<p:column headerText="Fecha" width="90">
|
||||||
|
<h:outputText value="#{v.date}">
|
||||||
|
<f:convertDateTime type="date" pattern="dd/MM/yyyy" timeStyle="short" />
|
||||||
|
</h:outputText>
|
||||||
|
</p:column>
|
||||||
|
|
||||||
|
<p:column headerText="Hora" width="60">
|
||||||
|
<h:outputText value="#{v.time}">
|
||||||
|
<f:convertDateTime type="time" pattern="HH:mm" />
|
||||||
|
</h:outputText>
|
||||||
|
</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="Anular" width="90">
|
||||||
|
<p:commandButton value="Anular" action="#{PatientVisitList.removeVisit(v.id)}" update="frmPatientVisitList" icon="pi pi-calendar-times" styleClass="red-button" />
|
||||||
|
</p:column>
|
||||||
|
|
||||||
|
<p:column headerText="Editar" width="90">
|
||||||
|
<p:commandButton value="Editar" action="#{PatientVisitList.editVisit(v.id)}" update="frmPatientVisitList" icon="pi pi-pencil" />
|
||||||
|
</p:column>
|
||||||
|
|
||||||
|
<f:facet name="paginatorBottomLeft">
|
||||||
|
<p:commandButton update="dtPatientVisitList" action="#{PatientVisitList.showData}" icon="pi pi-refresh" />
|
||||||
|
</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="frmPatientVisitList" action="#{PatientVisitList.showData}" 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>
|
||||||
@@ -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