Usando las firmas del MagicDraw
This commit is contained in:
@@ -49,7 +49,8 @@
|
|||||||
<h:outputText rendered="#{Questions.selected.status == 'ANSWERED'}" value="#{Questions.selected.response}" escape="false"></h:outputText>
|
<h:outputText rendered="#{Questions.selected.status == 'ANSWERED'}" value="#{Questions.selected.response}" escape="false"></h:outputText>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
<br/>
|
<br/>
|
||||||
<p:commandButton rendered="#{Questions.selected.status != 'ANSWERED'}" value="#{Questions.selected.status == 'NEW' ? 'Preguntar' : 'Responder'}" action="#{Questions.save}" update="frmQuestions" icon="pi pi-save" ></p:commandButton>
|
<p:commandButton rendered="#{Questions.askButton}" value="Preguntar" action="#{Questions.askQuestion}" update="frmQuestions" icon="pi pi-save" ></p:commandButton>
|
||||||
|
<p:commandButton rendered="#{Questions.answerButton}" value="Responder" action="#{Questions.answerQuestion}" update="frmQuestions" icon="pi pi-save" ></p:commandButton>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -53,16 +53,18 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void askQuestion(int professionalNumber, String title, String message) {
|
public void askQuestion(int userId, String title, String message) {
|
||||||
LoggedUserTO user = SessionUtils.getloggedOnUser();
|
QuestionJPA qjpa = new QuestionJPA();
|
||||||
// 0. Conseguir el paciente en sesión
|
qjpa.setId(0);
|
||||||
PatientJPA patient = entman.find(PatientJPA.class, user.getId());
|
qjpa.setTitle(title);
|
||||||
// 1. Buscar el médico de familia con ese professionalNumber
|
qjpa.setMessage(message);
|
||||||
FamilyDoctorJPA fdoctor = entman.find(FamilyDoctorJPA.class, professionalNumber);
|
qjpa.setStatus(QuestionStatus.PENDING);
|
||||||
// 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);
|
PatientJPA pat = entman.find(PatientJPA.class, userId);
|
||||||
// 3. Guardar
|
qjpa.setPatient(pat);
|
||||||
entman.persist(question);
|
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
|
||||||
|
|
||||||
|
entman.persist(qjpa);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,23 +74,11 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void answerQuestion(QuestionTO q) {
|
public void answerQuestion(int questionId, String response) {
|
||||||
QuestionJPA qjpa;
|
QuestionJPA qjpa;
|
||||||
if(q.getId() >= 0) {
|
qjpa = entman.find(QuestionJPA.class, questionId);
|
||||||
qjpa = entman.find(QuestionJPA.class, q.getId());
|
qjpa.setResponse(response);
|
||||||
qjpa.setResponse(q.getResponse());
|
|
||||||
qjpa.setStatus(QuestionStatus.ANSWERED);
|
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());
|
|
||||||
|
|
||||||
entman.persist(qjpa);
|
entman.persist(qjpa);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public interface MedicalTestFacadeRemote {
|
|||||||
* @param title
|
* @param title
|
||||||
* @param message
|
* @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
|
* El médico responde a una pregunta
|
||||||
@@ -37,7 +37,7 @@ public interface MedicalTestFacadeRemote {
|
|||||||
* @param question
|
* @param question
|
||||||
* @param response
|
* @param response
|
||||||
*/
|
*/
|
||||||
public void answerQuestion(QuestionTO question);
|
public void answerQuestion(int questionId, String response);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recuperar las preguntas sin respuesta para un médico
|
* Recuperar las preguntas sin respuesta para un médico
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
|
|
||||||
private int userID;
|
private int userID;
|
||||||
private UserType userType;
|
private UserType userType;
|
||||||
private List<QuestionTO> pendingQuestions;
|
private List<QuestionTO> allQuestions;
|
||||||
protected String title;
|
|
||||||
protected String message;
|
|
||||||
protected String response;
|
|
||||||
protected QuestionTO selected;
|
protected QuestionTO selected;
|
||||||
|
|
||||||
public QuestionsMBean() {
|
public QuestionsMBean() {
|
||||||
@@ -40,36 +37,41 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
this.selected = null;
|
this.selected = null;
|
||||||
|
|
||||||
this.loadQuestions();
|
this.loadQuestions();
|
||||||
this.printSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printSelected() {
|
private void printSelected(String asd) {
|
||||||
System.out.println("Selected: ");
|
if(asd!=null) {
|
||||||
|
asd = "'" + asd + "'";
|
||||||
|
}else {
|
||||||
|
asd = "";
|
||||||
|
}
|
||||||
|
System.out.println("Selected " + asd + ": ");
|
||||||
System.out.println(this.selected);
|
System.out.println(this.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QuestionTO> getPendingQuestions() {
|
public List<QuestionTO> getPendingQuestions() {
|
||||||
return pendingQuestions;
|
return allQuestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPendingQuestions(List<QuestionTO> value) {
|
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á
|
* Cargará las preguntas enviadas al médico o escritas por el paciente, esto irá
|
||||||
* en función del tipo de usuario en sesión
|
* en función del tipo de usuario en sesión
|
||||||
*/
|
*/
|
||||||
private void loadQuestions() {
|
private void loadQuestions() {
|
||||||
this.printSelected();
|
this.printSelected("");
|
||||||
if (userType == UserType.FAMILY_DOCTOR) {
|
if (userType == UserType.FAMILY_DOCTOR) {
|
||||||
// Listar las preguntas destinadas a él
|
// Listar las preguntas destinadas a él
|
||||||
// El método disponible del API básico es referente al doctor
|
// 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) {
|
} else if (userType == UserType.PATIENT) {
|
||||||
// Listar las preguntas realiadas por él
|
// Listar las preguntas realiadas por él
|
||||||
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
// Para reutilizar la misma view, necesitaremos nuevos métodos para el API de
|
||||||
// cara a recoger sus preguntas realizadas.
|
// cara a recoger sus preguntas realizadas.
|
||||||
this.pendingQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
this.allQuestions = getRemoteManagerMedicalTest().listAllMyQuestions(userID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,9 +103,9 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
this.printSelected();
|
this.printSelected("onSelect antes");
|
||||||
this.selected = (QuestionTO) event.getObject();
|
this.selected = (QuestionTO) event.getObject();
|
||||||
this.printSelected();
|
this.printSelected("onSelect despues");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUnSelect(SelectEvent event) {
|
public void onUnSelect(SelectEvent event) {
|
||||||
@@ -111,34 +113,30 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(QuestionTO selected) {
|
public void setSelected(QuestionTO selected) {
|
||||||
this.printSelected();
|
this.printSelected("setSelected antes");
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
|
this.printSelected("setSelected despues");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestionTO getSelected() {
|
public QuestionTO getSelected() {
|
||||||
return this.selected;
|
return this.selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTitle(String title) {
|
public void answerQuestion() {
|
||||||
this.title = title;
|
// Es un selected recuperado de la lista
|
||||||
|
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
||||||
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessage(String message) {
|
public void askQuestion() {
|
||||||
this.message = message;
|
// Es un question nuevo
|
||||||
}
|
QuestionTO q = this.selected;
|
||||||
|
getRemoteManagerMedicalTest().askQuestion(q.getPatient().getId(), q.getTitle(), q.getMessage());
|
||||||
public void setResponse(String response) {
|
|
||||||
this.response = response;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save() {
|
|
||||||
this.printSelected();
|
|
||||||
getRemoteManagerMedicalTest().answerQuestion(this.selected);
|
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create() {
|
public void create() {
|
||||||
this.printSelected();
|
this.printSelected("create start");
|
||||||
String template = "";
|
String template = "";
|
||||||
this.selected = new QuestionTO();
|
this.selected = new QuestionTO();
|
||||||
this.selected.setId(-1);
|
this.selected.setId(-1);
|
||||||
@@ -148,7 +146,7 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
this.selected.setStatus(QuestionStatus.NEW);
|
this.selected.setStatus(QuestionStatus.NEW);
|
||||||
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
||||||
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
||||||
this.printSelected();
|
this.printSelected("create end");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPanelDetail() {
|
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