Usando las firmas del MagicDraw
This commit is contained in:
@@ -53,16 +53,18 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param message
|
||||
*/
|
||||
@Override
|
||||
public void askQuestion(int professionalNumber, String title, String message) {
|
||||
LoggedUserTO user = SessionUtils.getloggedOnUser();
|
||||
// 0. Conseguir el paciente en sesión
|
||||
PatientJPA patient = entman.find(PatientJPA.class, user.getId());
|
||||
// 1. Buscar el médico de familia con ese professionalNumber
|
||||
FamilyDoctorJPA fdoctor = entman.find(FamilyDoctorJPA.class, 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);
|
||||
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);
|
||||
|
||||
PatientJPA pat = entman.find(PatientJPA.class, userId);
|
||||
qjpa.setPatient(pat);
|
||||
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
||||
|
||||
entman.persist(qjpa);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,23 +74,11 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param response
|
||||
*/
|
||||
@Override
|
||||
public void answerQuestion(QuestionTO q) {
|
||||
public void answerQuestion(int questionId, String response) {
|
||||
QuestionJPA qjpa;
|
||||
if(q.getId() >= 0) {
|
||||
qjpa = entman.find(QuestionJPA.class, q.getId());
|
||||
qjpa.setResponse(q.getResponse());
|
||||
qjpa.setStatus(QuestionStatus.ANSWERED);
|
||||
} else {
|
||||
qjpa = new QuestionJPA();
|
||||
qjpa.setId(0);
|
||||
qjpa.setTitle(q.getTitle());
|
||||
qjpa.setMessage(q.getMessage());
|
||||
qjpa.setStatus(QuestionStatus.PENDING);
|
||||
}
|
||||
|
||||
PatientJPA pat = entman.find(PatientJPA.class, q.getPatient().getId());
|
||||
qjpa.setPatient(pat);
|
||||
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
||||
qjpa = entman.find(QuestionJPA.class, questionId);
|
||||
qjpa.setResponse(response);
|
||||
qjpa.setStatus(QuestionStatus.ANSWERED);
|
||||
|
||||
entman.persist(qjpa);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public interface MedicalTestFacadeRemote {
|
||||
* @param title
|
||||
* @param message
|
||||
*/
|
||||
public void askQuestion(int professionalNumber, String title, String message);
|
||||
public void askQuestion(int userID, String title, String message);
|
||||
|
||||
/**
|
||||
* El médico responde a una pregunta
|
||||
@@ -37,7 +37,7 @@ public interface MedicalTestFacadeRemote {
|
||||
* @param question
|
||||
* @param response
|
||||
*/
|
||||
public void answerQuestion(QuestionTO question);
|
||||
public void answerQuestion(int questionId, String response);
|
||||
|
||||
/**
|
||||
* Recuperar las preguntas sin respuesta para un médico
|
||||
|
||||
@@ -23,10 +23,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private int userID;
|
||||
private UserType userType;
|
||||
private List<QuestionTO> pendingQuestions;
|
||||
protected String title;
|
||||
protected String message;
|
||||
protected String response;
|
||||
private List<QuestionTO> allQuestions;
|
||||
protected QuestionTO selected;
|
||||
|
||||
public QuestionsMBean() {
|
||||
@@ -40,36 +37,41 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
this.selected = null;
|
||||
|
||||
this.loadQuestions();
|
||||
this.printSelected();
|
||||
}
|
||||
|
||||
private void printSelected() {
|
||||
System.out.println("Selected: ");
|
||||
|
||||
private void printSelected(String asd) {
|
||||
if(asd!=null) {
|
||||
asd = "'" + asd + "'";
|
||||
}else {
|
||||
asd = "";
|
||||
}
|
||||
System.out.println("Selected " + asd + ": ");
|
||||
System.out.println(this.selected);
|
||||
}
|
||||
|
||||
public List<QuestionTO> getPendingQuestions() {
|
||||
return pendingQuestions;
|
||||
return allQuestions;
|
||||
}
|
||||
|
||||
public void setPendingQuestions(List<QuestionTO> value) {
|
||||
this.pendingQuestions = value;
|
||||
this.allQuestions = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cargará las preguntas enviadas al médico o escritas por el paciente, esto irá
|
||||
* en función del tipo de usuario en sesión
|
||||
*/
|
||||
private void loadQuestions() {
|
||||
this.printSelected();
|
||||
this.printSelected("");
|
||||
if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Listar las preguntas destinadas a él
|
||||
// El método disponible del API básico es referente al doctor
|
||||
this.pendingQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||
this.allQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||
} else if (userType == UserType.PATIENT) {
|
||||
// Listar las preguntas realiadas por él
|
||||
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
||||
// cara a recoger sus preguntas realizadas.
|
||||
this.pendingQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||
this.allQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,61 +86,57 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
public void setShowCreate() {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public boolean getDisabledMessage() {
|
||||
if(this.selected != null) {
|
||||
if (this.selected != null) {
|
||||
return this.selected.getStatus() != QuestionStatus.NEW;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isDisabledMessage() {
|
||||
return this.getDisabledMessage();
|
||||
}
|
||||
|
||||
|
||||
public void setDisabledMessage(boolean bval) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
this.printSelected();
|
||||
this.printSelected("onSelect antes");
|
||||
this.selected = (QuestionTO) event.getObject();
|
||||
this.printSelected();
|
||||
this.printSelected("onSelect despues");
|
||||
}
|
||||
|
||||
public void onUnSelect(SelectEvent event) {
|
||||
this.selected = null;
|
||||
}
|
||||
|
||||
|
||||
public void setSelected(QuestionTO selected) {
|
||||
this.printSelected();
|
||||
this.printSelected("setSelected antes");
|
||||
this.selected = selected;
|
||||
this.printSelected("setSelected despues");
|
||||
}
|
||||
|
||||
|
||||
public QuestionTO getSelected() {
|
||||
return this.selected;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
public void answerQuestion() {
|
||||
// Es un selected recuperado de la lista
|
||||
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
||||
this.init();
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
this.printSelected();
|
||||
getRemoteManagerMedicalTest().answerQuestion(this.selected);
|
||||
public void askQuestion() {
|
||||
// Es un question nuevo
|
||||
QuestionTO q = this.selected;
|
||||
getRemoteManagerMedicalTest().askQuestion(q.getPatient().getId(), q.getTitle(), q.getMessage());
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
public void create() {
|
||||
this.printSelected();
|
||||
this.printSelected("create start");
|
||||
String template = "";
|
||||
this.selected = new QuestionTO();
|
||||
this.selected.setId(-1);
|
||||
@@ -148,7 +146,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
this.selected.setStatus(QuestionStatus.NEW);
|
||||
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
||||
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
||||
this.printSelected();
|
||||
this.printSelected("create end");
|
||||
}
|
||||
|
||||
public boolean getShowPanelDetail() {
|
||||
@@ -163,4 +161,28 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
//
|
||||
}
|
||||
|
||||
public boolean getAskButton() {
|
||||
return this.selected == null ? (userType == UserType.PATIENT)
|
||||
: (userType == UserType.PATIENT && this.selected.getStatus() == QuestionStatus.NEW);
|
||||
}
|
||||
|
||||
public boolean isAskButton() {
|
||||
return this.getAskButton();
|
||||
}
|
||||
|
||||
public void setAskButton() {
|
||||
}
|
||||
|
||||
public boolean getAnswerButton() {
|
||||
return this.selected == null ? (userType == UserType.FAMILY_DOCTOR)
|
||||
: (userType == UserType.FAMILY_DOCTOR && this.selected.getStatus() == QuestionStatus.PENDING);
|
||||
}
|
||||
|
||||
public boolean isAnswerButton() {
|
||||
return this.getAnswerButton();
|
||||
}
|
||||
|
||||
public void setAnswerButton() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user