Issue #40 corregida.
This commit is contained in:
@@ -20,10 +20,12 @@ import jpa.QuestionJPA;
|
|||||||
import jpa.SpecialistDoctorJPA;
|
import jpa.SpecialistDoctorJPA;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||||
* persistencia.
|
* 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
|
* @author rorden
|
||||||
*
|
*
|
||||||
@@ -47,18 +49,28 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
* @param title
|
* @param title
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public void askQuestion(int userId, String title, String message) {
|
public String 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);
|
PatientJPA pat = entman.find(PatientJPA.class, userId);
|
||||||
qjpa.setPatient(pat);
|
|
||||||
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
|
||||||
|
|
||||||
entman.persist(qjpa);
|
if (pat.getFamilyDoctor() != null) {
|
||||||
|
|
||||||
|
QuestionJPA qjpa = new QuestionJPA();
|
||||||
|
qjpa.setId(0);
|
||||||
|
qjpa.setTitle(title);
|
||||||
|
qjpa.setMessage(message);
|
||||||
|
qjpa.setStatus(QuestionStatus.PENDING);
|
||||||
|
|
||||||
|
qjpa.setPatient(pat);
|
||||||
|
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
||||||
|
|
||||||
|
entman.persist(qjpa);
|
||||||
|
|
||||||
|
return "ok";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return "No tienes médico de familia elegido, por favor acude a la sección 'Gestionar Perfil' -> 'Cambiar médico de familia'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +92,9 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
||||||
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
||||||
// QuestionJPA.class);
|
// 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("status", QuestionStatus.PENDING);
|
||||||
query.setParameter("docId", familyDoctorId);
|
query.setParameter("docId", familyDoctorId);
|
||||||
|
|
||||||
@@ -99,7 +113,9 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
// TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA
|
||||||
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
// q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
||||||
// QuestionJPA.class);
|
// 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("status", QuestionStatus.PENDING);
|
||||||
query.setParameter("patientId", userId);
|
query.setParameter("patientId", userId);
|
||||||
|
|
||||||
@@ -120,7 +136,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
public QuestionTO getQuestion(int idQuestion) {
|
public QuestionTO getQuestion(int idQuestion) {
|
||||||
QuestionTO resp = new QuestionTO();
|
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);
|
query.setParameter("idquestion", idQuestion);
|
||||||
|
|
||||||
@@ -140,7 +157,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
* @param idMedicalTest
|
* @param idMedicalTest
|
||||||
* @param date
|
* @param date
|
||||||
* @param time
|
* @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
|
* @param observations
|
||||||
*/
|
*/
|
||||||
public void addMedicalTest(int idMedicalTest, Date date, long time, MedicalTestType testType, String observations) {
|
public void addMedicalTest(int idMedicalTest, Date date, long time, MedicalTestType testType, String observations) {
|
||||||
@@ -183,29 +201,32 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId) {
|
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId) {
|
||||||
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId", Long.class);
|
TypedQuery<Long> query = entman.createQuery(
|
||||||
|
"SELECT count(1) from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId", Long.class);
|
||||||
query.setParameter("specId", specialityId);
|
query.setParameter("specId", specialityId);
|
||||||
|
|
||||||
return query.getSingleResult();
|
return query.getSingleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listar médicos con una especialidad concreta
|
* Listar médicos con una especialidad concreta
|
||||||
*
|
*
|
||||||
* @param speciality
|
* @param speciality
|
||||||
*/
|
*/
|
||||||
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber, int pageSize) {
|
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber,
|
||||||
|
int pageSize) {
|
||||||
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
|
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
|
||||||
|
|
||||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
|
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
|
||||||
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId order by q.medicalSpecialty.name asc, q.surname asc", SpecialistDoctorJPA.class);
|
"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);
|
query.setParameter("specId", specialityId);
|
||||||
|
|
||||||
if (pageSize > 0) {
|
if (pageSize > 0) {
|
||||||
query.setFirstResult(pageNumber * pageSize);
|
query.setFirstResult(pageNumber * pageSize);
|
||||||
query.setMaxResults(pageSize);
|
query.setMaxResults(pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<SpecialistDoctorJPA> allJPA = query.getResultList();
|
List<SpecialistDoctorJPA> allJPA = query.getResultList();
|
||||||
|
|
||||||
for (SpecialistDoctorJPA item : allJPA) {
|
for (SpecialistDoctorJPA item : allJPA) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public interface MedicalTestFacadeRemote {
|
|||||||
* @param title
|
* @param title
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
public void askQuestion(int userID, String title, String message);
|
public String askQuestion(int userID, String title, String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* El médico responde a una pregunta
|
* El médico responde a una pregunta
|
||||||
|
|||||||
@@ -100,10 +100,15 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addNewQuestion() {
|
public void addNewQuestion() {
|
||||||
getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
String result = getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
||||||
this.create();
|
if(result == "ok") {
|
||||||
this.loadQuestions();
|
this.create();
|
||||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
this.loadQuestions();
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
||||||
|
} else {
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error", result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowPanelDetail() {
|
public boolean isShowPanelDetail() {
|
||||||
|
|||||||
Reference in New Issue
Block a user