Issue #40 corregida.
This commit is contained in:
@@ -20,10 +20,12 @@ import jpa.QuestionJPA;
|
||||
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
|
||||
* 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
|
||||
*
|
||||
@@ -47,18 +49,28 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param title
|
||||
* @param message
|
||||
*/
|
||||
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);
|
||||
public String askQuestion(int userId, String title, String message) {
|
||||
|
||||
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
|
||||
// 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);
|
||||
|
||||
@@ -99,7 +113,9 @@ 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);
|
||||
|
||||
@@ -120,7 +136,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
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);
|
||||
|
||||
@@ -140,7 +157,8 @@ 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
|
||||
*/
|
||||
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) {
|
||||
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);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listar médicos con una especialidad concreta
|
||||
*
|
||||
* @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>();
|
||||
|
||||
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);
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
|
||||
List<SpecialistDoctorJPA> allJPA = query.getResultList();
|
||||
|
||||
for (SpecialistDoctorJPA item : allJPA) {
|
||||
|
||||
Reference in New Issue
Block a user