QuestionTO y QuestionJPA updated
This commit is contained in:
@@ -7,9 +7,19 @@ import javax.ejb.Stateless;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.MedicalTestTO.MedicalTestType;
|
||||
import TO.PatientTO;
|
||||
import common.QuestionStatus;
|
||||
import common.UserType;
|
||||
import TO.QuestionTO;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.QuestionJPA;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
/**
|
||||
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||
@@ -32,7 +42,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
@EJB
|
||||
CommonFacadeLocal commonServices;
|
||||
|
||||
// ********************************************************************* QUESTION_RESPONSE
|
||||
// *********************************************************************
|
||||
// QUESTION_RESPONSE
|
||||
|
||||
/**
|
||||
* Realizar una pregunta al médico por un paciente
|
||||
@@ -43,6 +54,17 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
*/
|
||||
@Override
|
||||
public void askQuestion(int professionalNumber, String title, String message) {
|
||||
if (SessionUtils.getUserType() == UserType.PATIENT) {
|
||||
LoggedUserTO user = SessionUtils.getloggedOnUser();
|
||||
// 0. Conseguir el paciente en sesión
|
||||
PatientTO patient = this.commonServices.findPatientById(Integer.parseInt(user.getId()));
|
||||
// 1. Buscar el médico de familia con ese professionalNumber
|
||||
FamilyDoctorTO fdoctor = this.commonServices.findFamilyDoctorById(professionalNumber);
|
||||
// 2. Crear un objeto de Question para ese médico desde el paciente en sesión
|
||||
QuestionJPA question = new QuestionJPA(0, title, message, QuestionStatus.PENDING, patient, fdoctor, null);
|
||||
// 3. Guardar
|
||||
entman.persist(question);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +95,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
public void getQuestion(String question) {
|
||||
}
|
||||
|
||||
// ********************************************************************* MEDICAL_TEST
|
||||
// *********************************************************************
|
||||
// MEDICAL_TEST
|
||||
|
||||
/**
|
||||
* Añadir pruebas médicas a una cita
|
||||
|
||||
Reference in New Issue
Block a user