QuestionTO y QuestionJPA updated

This commit is contained in:
Roberto Orden Erena
2019-12-15 19:24:41 +01:00
parent e5900a8d0f
commit 6eb1bda423
4 changed files with 65 additions and 23 deletions

View File

@@ -4,6 +4,8 @@ import java.io.Serializable;
import javax.xml.bind.annotation.XmlRootElement;
import common.QuestionStatus;
/**
*
* @author Roberto Orden Erena <rorden@uoc.edu>
@@ -12,10 +14,6 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "Question")
public class QuestionTO implements Serializable {
public static enum QuestionStatus {
ANSWERED, PENDING
}
private static final long serialVersionUID = 1L;
private int id;

View File

@@ -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

View File

@@ -1,7 +1,6 @@
package jpa;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -11,8 +10,9 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import TO.FamilyDoctorTO;
import TO.PatientTO;
import TO.SpecialistDoctorTO;
import common.QuestionStatus;
/**
*
@@ -26,25 +26,32 @@ public class QuestionJPA implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String title;
private String message;
private int status;
private QuestionStatus status;
private String response;
@ManyToOne
@JoinColumn (name="PatientId")
@JoinColumn(name = "PatientId")
private PatientTO patient;
@ManyToOne
@JoinColumn(name = "FamilyDoctorId")
private FamilyDoctorTO doctor;
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.title = title;
this.message = message;
this.status = status;
this.patient = patient;
this.doctor = doctor;
this.response = response;
}
public int getId() {
@@ -71,14 +78,6 @@ public class QuestionJPA implements Serializable {
this.message = message;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public PatientTO getPatient() {
return patient;
}
@@ -87,6 +86,28 @@ public class QuestionJPA implements Serializable {
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.