Mejora en visualización de especialistas por especialidad (Vista
páginada de datos).
This commit is contained in:
@@ -1,51 +1,62 @@
|
||||
<?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"
|
||||
<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:o="http://omnifaces.org/ui">
|
||||
|
||||
<ui:composition template="../header.xhtml">
|
||||
<ui:define name="content">
|
||||
<h:form id="TestForm">
|
||||
<p:messages id="mesgs" showDetail="true" closable="true"
|
||||
autoupdate="true" />
|
||||
<p:panel id="frmSSbD"
|
||||
header="Búsqueda de médicos especialista por especialidad">
|
||||
<p:messages id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||
<p:panel id="frmSSbD" header="Búsqueda de médicos especialista por especialidad">
|
||||
<div class="ui-g ui-fluid">
|
||||
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:outputLabel for="selMS" value="Especialidad:" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:autoComplete id="selMS" dropdown="true" required="true"
|
||||
value="#{sspec.medicalSpeciality}"
|
||||
completeMethod="#{sspec.completeMedicalSpeciality}" var="ms"
|
||||
itemLabel="#{ms.displayName}" itemValue="#{ms}"
|
||||
forceSelection="true"
|
||||
requiredMessage="Por favor, selecciona una especialidad médica"
|
||||
<div class="ui-g-6 ui-md-6">
|
||||
<p:autoComplete id="selMS" dropdown="true" required="true" value="#{sspec.medicalSpeciality}" completeMethod="#{sspec.completeMedicalSpeciality}" var="ms"
|
||||
itemLabel="#{ms.displayName}" itemValue="#{ms}" forceSelection="true" requiredMessage="Por favor, selecciona una especialidad médica"
|
||||
placeholder="Seleccione una especialidad médica o teclee para buscar...">
|
||||
<o:converter converterId="omnifaces.ListConverter"
|
||||
list="#{RegisterUser.medicalSpecialtiesList}" />
|
||||
<p:ajax event="itemSelect" listener="#{sspec.onSelect}"
|
||||
update="frmSSbD" />
|
||||
<o:converter converterId="omnifaces.ListConverter" list="#{RegisterUser.medicalSpecialtiesList}" />
|
||||
<p:ajax event="itemSelect" listener="#{sspec.onSelect}" update="frmSSbD" />
|
||||
<p:column headerText="Nombre">
|
||||
<h:outputText value="#{ms.name}" />
|
||||
</p:column>
|
||||
<p:column headerText="Localización">
|
||||
<p:column headerText="Descripción">
|
||||
<h:outputText value="#{ms.description}" />
|
||||
</p:column>
|
||||
</p:autoComplete>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
<div class="ui-g-4 ui-md-4"/>
|
||||
|
||||
<div class="ui-g-4 ui-md-4"></div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<p:dataList value="#{sspec.listDoctors}" var="dd" type="ordered" emptyMessage="Ningún especialista para la especialidad seleccionada">
|
||||
#{dd.name} #{dd.surname} <#{dd.email}>
|
||||
</p:dataList>
|
||||
<div class="ui-g-12">
|
||||
<p:dataTable id="dtDoctorList" var="d" value="#{sspec.lazyDataModelDoctorList}" 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 existe ningún especialista para la especialidad seleccionada.">
|
||||
|
||||
<p:column headerText="Núm Profesional" width="90">
|
||||
<h:outputText value="#{d.professionalNumber}" />
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Nombre" width="60">
|
||||
<h:outputText value="#{d.name}">
|
||||
<f:convertDateTime type="time" pattern="HH:mm" />
|
||||
</h:outputText>
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Apellidos" width="auto">
|
||||
<h:outputText value="#{d.surname}" />
|
||||
</p:column>
|
||||
|
||||
<p:column headerText="Correo electrónico" width="auto">
|
||||
<h:outputText value="#{d.email}" />
|
||||
</p:column>
|
||||
|
||||
<f:facet name="paginatorBottomLeft">
|
||||
<p:commandButton update="dtDoctorList" action="#{sspec.showData}" icon="pi pi-refresh" />
|
||||
</f:facet>
|
||||
</p:dataTable>
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
|
||||
@@ -25,12 +25,10 @@ import jpa.SpecialistDoctorJPA;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* Tanto los pacientes como los médicos deben acceder a la vista de pruebas
|
||||
* médicas.
|
||||
* Tanto los pacientes como los médicos deben acceder a la vista de pruebas médicas.
|
||||
*
|
||||
* @author rorden
|
||||
*
|
||||
@@ -54,7 +52,6 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param title
|
||||
* @param message
|
||||
*/
|
||||
@Override
|
||||
public void askQuestion(int userId, String title, String message) {
|
||||
QuestionJPA qjpa = new QuestionJPA();
|
||||
qjpa.setId(0);
|
||||
@@ -75,7 +72,6 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param question
|
||||
* @param response
|
||||
*/
|
||||
@Override
|
||||
public void answerQuestion(int questionId, String response) {
|
||||
QuestionJPA qjpa;
|
||||
qjpa = entman.find(QuestionJPA.class, questionId);
|
||||
@@ -85,14 +81,11 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
entman.persist(qjpa);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuestionTO> listAllPendingQuestions(int familyDoctorId) {
|
||||
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
||||
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
||||
// QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery(
|
||||
"SELECT q from QuestionJPA q where q.familyDoctor.id=:docId order by q.status desc, q.title asc",
|
||||
QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.familyDoctor.id=:docId order by q.status desc, q.title asc", QuestionJPA.class);
|
||||
// query.setParameter("status", QuestionStatus.PENDING);
|
||||
query.setParameter("docId", familyDoctorId);
|
||||
|
||||
@@ -111,9 +104,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
||||
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
||||
// QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery(
|
||||
"SELECT q from QuestionJPA q where q.patient.id=:patientId order by q.status desc, q.title asc",
|
||||
QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.patient.id=:patientId order by q.status desc, q.title asc", QuestionJPA.class);
|
||||
// query.setParameter("status", QuestionStatus.PENDING);
|
||||
query.setParameter("patientId", userId);
|
||||
|
||||
@@ -131,17 +122,14 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
*
|
||||
* @param question
|
||||
*/
|
||||
@Override
|
||||
public QuestionTO getQuestion(int idQuestion) {
|
||||
QuestionTO resp = new QuestionTO();
|
||||
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery(
|
||||
"SELECT q from QuestionJPA q where q.id=:idquestion",
|
||||
QuestionJPA.class);
|
||||
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.id=:idquestion", QuestionJPA.class);
|
||||
|
||||
query.setParameter("idquestion", idQuestion);
|
||||
|
||||
resp = commonServices.getPOJOforQuestionJPA(query.getSingleResult(),1);
|
||||
resp = commonServices.getPOJOforQuestionJPA(query.getSingleResult(), 1);
|
||||
|
||||
return resp;
|
||||
}
|
||||
@@ -157,11 +145,9 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param idMedicalTest
|
||||
* @param date
|
||||
* @param time
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias
|
||||
* magnéticas y TAC
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
|
||||
* @param observations
|
||||
*/
|
||||
@Override
|
||||
public void addMedicalTest(int idMedicalTest, Date date, long time, MedicalTestType testType, String observations) {
|
||||
}
|
||||
|
||||
@@ -172,7 +158,6 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
*
|
||||
* @param idMedicalTest
|
||||
*/
|
||||
@Override
|
||||
public void getMedicalTest(int idMedicalTest) {
|
||||
}
|
||||
|
||||
@@ -182,7 +167,6 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param idMedicalTest
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void addImage(int idMedicalTest, String image) {
|
||||
}
|
||||
|
||||
@@ -192,7 +176,6 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param idMedicalTest
|
||||
* @param image
|
||||
*/
|
||||
@Override
|
||||
public void updateImage(int idMedicalTest, String image) {
|
||||
}
|
||||
|
||||
@@ -201,23 +184,32 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
*
|
||||
* @param idMedicalTest
|
||||
*/
|
||||
@Override
|
||||
public void removeImage(int idMedicalTest) {
|
||||
}
|
||||
|
||||
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId) {
|
||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId", Long.class);
|
||||
query.setParameter("specId", specialityId);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Listar médicos con una especialidad concreta
|
||||
*
|
||||
* @param speciality
|
||||
*/
|
||||
@Override
|
||||
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality) {
|
||||
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber, int pageSize) {
|
||||
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
|
||||
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
|
||||
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.name=:spec order by q.medicalSpecialty.name asc, q.surname asc",
|
||||
SpecialistDoctorJPA.class);
|
||||
query.setParameter("spec", speciality.getName());
|
||||
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId order by q.medicalSpecialty.name asc, q.surname asc", SpecialistDoctorJPA.class);
|
||||
query.setParameter("specId", specialityId);
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
List<SpecialistDoctorJPA> allJPA = query.getResultList();
|
||||
|
||||
|
||||
@@ -5,14 +5,12 @@ import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.QuestionTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.MedicalTestType;
|
||||
|
||||
/**
|
||||
* 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 rorden
|
||||
*
|
||||
@@ -70,8 +68,7 @@ public interface MedicalTestFacadeRemote {
|
||||
* @param idMedicalTest
|
||||
* @param date
|
||||
* @param time
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias
|
||||
* magnéticas y TAC
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
|
||||
* @param observations
|
||||
*/
|
||||
public void addMedicalTest(int id, Date date, long time, MedicalTestType testType, String observations);
|
||||
@@ -106,10 +103,12 @@ public interface MedicalTestFacadeRemote {
|
||||
*/
|
||||
public void removeImage(int idMedicalTest);
|
||||
|
||||
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId);
|
||||
|
||||
/**
|
||||
* Listar médicos con una especialidad concreta
|
||||
*
|
||||
* @param speciality
|
||||
*/
|
||||
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality);
|
||||
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber, int pageSize);
|
||||
}
|
||||
@@ -3,15 +3,19 @@ package managedbean.medicalTest;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.event.SelectEvent;
|
||||
import org.primefaces.model.LazyDataModel;
|
||||
import org.primefaces.model.SortOrder;
|
||||
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import TO.VisitTO;
|
||||
import common.Constants;
|
||||
import common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
@@ -25,10 +29,10 @@ public class SearchSpecialistMBean extends ManagedBeanBase implements Serializab
|
||||
|
||||
private int userID;
|
||||
private UserType userType;
|
||||
private List<SpecialistDoctorTO> listDoctors;
|
||||
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
|
||||
private MedicalSpecialtyTO medicalSpeciality;
|
||||
private String lastUIQueryMS;
|
||||
private LazyDataModel<SpecialistDoctorTO> lazyDataModelDoctorList;
|
||||
|
||||
public SearchSpecialistMBean() {
|
||||
}
|
||||
@@ -38,39 +42,45 @@ public class SearchSpecialistMBean extends ManagedBeanBase implements Serializab
|
||||
// Inicialización de variables y propiedades van aquí.
|
||||
this.userType = SessionUtils.getUserType();
|
||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0,
|
||||
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
this.medicalSpeciality = null;
|
||||
this.lastUIQueryMS = "";
|
||||
this.listDoctors = new ArrayList<SpecialistDoctorTO>();
|
||||
|
||||
this.lazyDataModelDoctorList = new LazyDataModel<SpecialistDoctorTO>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public List<SpecialistDoctorTO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
|
||||
if (medicalSpeciality == null) {
|
||||
this.setRowCount(0);
|
||||
return null;
|
||||
} else {
|
||||
Long totalRowCount = getRemoteManagerMedicalTest().getSpecialistDoctorByMedicalSpecialityCount(medicalSpeciality.getId());
|
||||
this.setRowCount(totalRowCount.intValue());
|
||||
|
||||
return getRemoteManagerMedicalTest().findSpecialistDoctorByMedicalSpeciality(medicalSpeciality.getId(), (first / pageSize), pageSize);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public LazyDataModel<SpecialistDoctorTO> getLazyDataModelDoctorList() {
|
||||
return lazyDataModelDoctorList;
|
||||
}
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
System.out.println("onSelect");
|
||||
this.medicalSpeciality = (MedicalSpecialtyTO) event.getObject();
|
||||
System.out.println(this.medicalSpeciality);
|
||||
this.listDoctors = getRemoteManagerMedicalTest()
|
||||
.findSpecialistDoctorByMedicalSpeciality(this.medicalSpeciality);
|
||||
}
|
||||
|
||||
public List<MedicalSpecialtyTO> completeMedicalSpeciality(String query) {
|
||||
if (query != null && query.equals(this.lastUIQueryMS) == false) {
|
||||
this.lastUIQueryMS = query;
|
||||
// Recuperamos las 200 primeras coincidencias
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0,
|
||||
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
}
|
||||
return this.medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
public List<TO.SpecialistDoctorTO> getListDoctors() {
|
||||
return listDoctors;
|
||||
}
|
||||
|
||||
public void setListDoctors(List<TO.SpecialistDoctorTO> listDoctors) {
|
||||
this.listDoctors = listDoctors;
|
||||
}
|
||||
|
||||
public List<MedicalSpecialtyTO> getMedicalSpecialitiesList() {
|
||||
return medicalSpecialitiesList;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user