Mejora en visualización de especialistas por especialidad (Vista
páginada de datos).
This commit is contained in:
@@ -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,18 +52,17 @@ 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);
|
||||
qjpa.setTitle(title);
|
||||
qjpa.setMessage(message);
|
||||
qjpa.setStatus(QuestionStatus.PENDING);
|
||||
|
||||
|
||||
PatientJPA pat = entman.find(PatientJPA.class, userId);
|
||||
qjpa.setPatient(pat);
|
||||
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
||||
|
||||
|
||||
entman.persist(qjpa);
|
||||
}
|
||||
|
||||
@@ -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,24 +184,33 @@ 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();
|
||||
|
||||
for (SpecialistDoctorJPA item : allJPA) {
|
||||
|
||||
@@ -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
|
||||
*
|
||||
@@ -53,7 +51,7 @@ public interface MedicalTestFacadeRemote {
|
||||
* Recuperar las preguntas hechas por un paciente
|
||||
*/
|
||||
public List<QuestionTO> listAllMyQuestions(int userId);
|
||||
|
||||
|
||||
/**
|
||||
* Recuperar una pregunta por su String
|
||||
*
|
||||
@@ -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