QuestionTO y QuestionJPA updated
This commit is contained in:
@@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import common.QuestionStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Roberto Orden Erena <rorden@uoc.edu>
|
* @author Roberto Orden Erena <rorden@uoc.edu>
|
||||||
@@ -12,10 +14,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlRootElement(name = "Question")
|
@XmlRootElement(name = "Question")
|
||||||
public class QuestionTO implements Serializable {
|
public class QuestionTO implements Serializable {
|
||||||
|
|
||||||
public static enum QuestionStatus {
|
|
||||||
ANSWERED, PENDING
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|||||||
@@ -7,9 +7,19 @@ import javax.ejb.Stateless;
|
|||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
||||||
|
import TO.FamilyDoctorTO;
|
||||||
|
import TO.LoggedUserTO;
|
||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.MedicalTestTO.MedicalTestType;
|
import TO.MedicalTestTO.MedicalTestType;
|
||||||
|
import TO.PatientTO;
|
||||||
|
import common.QuestionStatus;
|
||||||
|
import common.UserType;
|
||||||
|
import TO.QuestionTO;
|
||||||
import ejb.common.CommonFacadeLocal;
|
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
|
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
|
||||||
@@ -32,7 +42,8 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
@EJB
|
@EJB
|
||||||
CommonFacadeLocal commonServices;
|
CommonFacadeLocal commonServices;
|
||||||
|
|
||||||
// ********************************************************************* QUESTION_RESPONSE
|
// *********************************************************************
|
||||||
|
// QUESTION_RESPONSE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Realizar una pregunta al médico por un paciente
|
* Realizar una pregunta al médico por un paciente
|
||||||
@@ -43,6 +54,17 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void askQuestion(int professionalNumber, String title, String message) {
|
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) {
|
public void getQuestion(String question) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ********************************************************************* MEDICAL_TEST
|
// *********************************************************************
|
||||||
|
// MEDICAL_TEST
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Añadir pruebas médicas a una cita
|
* Añadir pruebas médicas a una cita
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package jpa;
|
package jpa;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
@@ -11,8 +10,9 @@ import javax.persistence.JoinColumn;
|
|||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import TO.FamilyDoctorTO;
|
||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
import TO.SpecialistDoctorTO;
|
import common.QuestionStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -30,21 +30,28 @@ public class QuestionJPA implements Serializable {
|
|||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
private String message;
|
private String message;
|
||||||
private int status;
|
private QuestionStatus status;
|
||||||
|
private String response;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "PatientId")
|
@JoinColumn(name = "PatientId")
|
||||||
private PatientTO patient;
|
private PatientTO patient;
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "FamilyDoctorId")
|
||||||
|
private FamilyDoctorTO doctor;
|
||||||
|
|
||||||
public QuestionJPA() {
|
public QuestionJPA() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestionJPA(int id, String title, String message, int status, PatientTO patient) {
|
public QuestionJPA(int id, String title, String message, QuestionStatus status, PatientTO patient,
|
||||||
|
FamilyDoctorTO doctor, String response) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.patient = patient;
|
this.patient = patient;
|
||||||
|
this.doctor = doctor;
|
||||||
|
this.response = response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -71,14 +78,6 @@ public class QuestionJPA implements Serializable {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatus(int status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PatientTO getPatient() {
|
public PatientTO getPatient() {
|
||||||
return patient;
|
return patient;
|
||||||
}
|
}
|
||||||
@@ -87,6 +86,28 @@ public class QuestionJPA implements Serializable {
|
|||||||
this.patient = patient;
|
this.patient = patient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public QuestionStatus getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(QuestionStatus status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FamilyDoctorTO getDoctor() {
|
||||||
|
return doctor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoctor(FamilyDoctorTO doctor) {
|
||||||
|
this.doctor = doctor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResponse() {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResponse(String response) {
|
||||||
|
this.response = response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user