Preguntas y respuestas funcionando para médicos
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
package managedbean.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.event.SelectEvent;
|
||||
|
||||
import TO.PatientTO;
|
||||
import TO.QuestionTO;
|
||||
import common.QuestionStatus;
|
||||
import common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@Named("Questions")
|
||||
@ViewScoped
|
||||
public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int userID;
|
||||
private UserType userType;
|
||||
private List<QuestionTO> pendingQuestions;
|
||||
protected String title;
|
||||
protected String message;
|
||||
protected String response;
|
||||
protected QuestionTO selected;
|
||||
|
||||
public QuestionsMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Inicialización de variables y propiedades van aquí.
|
||||
this.userType = SessionUtils.getUserType();
|
||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||
|
||||
this.loadQuestions();
|
||||
this.printSelected();
|
||||
}
|
||||
|
||||
private void printSelected() {
|
||||
System.out.println("Selected: ");
|
||||
System.out.println(this.selected);
|
||||
}
|
||||
|
||||
public List<QuestionTO> getPendingQuestions() {
|
||||
return pendingQuestions;
|
||||
}
|
||||
|
||||
public void setPendingQuestions(List<QuestionTO> value) {
|
||||
this.pendingQuestions = 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();
|
||||
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);
|
||||
} 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.
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowCreate() {
|
||||
return userType == UserType.PATIENT;
|
||||
}
|
||||
|
||||
public boolean isShowCreate() {
|
||||
return this.getShowCreate();
|
||||
}
|
||||
|
||||
public void setShowCreate() {
|
||||
//
|
||||
}
|
||||
|
||||
public boolean getDisabledMessage() {
|
||||
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 boolean getEnableResponseEditor() {
|
||||
if(this.selected != null) {
|
||||
return this.selected.getStatus() == QuestionStatus.PENDING;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEnableResponseEditor() {
|
||||
return this.getEnableResponseEditor();
|
||||
}
|
||||
|
||||
public void setEnableResponseEditor(boolean bval) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public boolean getEnableResponseOutput() {
|
||||
if(this.selected != null) {
|
||||
return this.selected.getStatus() == QuestionStatus.ANSWERED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isEnableResponseOutput() {
|
||||
return this.getEnableResponseEditor();
|
||||
}
|
||||
|
||||
public void setEnableResponseOutput(boolean bval) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
this.printSelected();
|
||||
this.selected = (QuestionTO) event.getObject();
|
||||
this.printSelected();
|
||||
}
|
||||
|
||||
public void onUnSelect(SelectEvent event) {
|
||||
this.selected = null;
|
||||
}
|
||||
|
||||
public void setSelected(QuestionTO selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public QuestionTO getSelected() {
|
||||
return this.selected;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public void setResponse(String response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
getRemoteManagerMedicalTest().answerQuestion(this.selected);
|
||||
}
|
||||
|
||||
public void create() {
|
||||
this.printSelected();
|
||||
String template = "-";
|
||||
this.selected = new QuestionTO();
|
||||
this.selected.setTitle(template);
|
||||
this.selected.setMessage(template);
|
||||
this.selected.setResponse(template);
|
||||
this.selected.setStatus(QuestionStatus.NEW);
|
||||
this.selected.getPatient().setName(template);
|
||||
this.selected.getPatient().setSurname(template);
|
||||
this.printSelected();
|
||||
}
|
||||
|
||||
public boolean getShowPanelDetail() {
|
||||
return this.selected != null;
|
||||
}
|
||||
|
||||
public boolean isShowPanelDetail() {
|
||||
return this.getShowPanelDetail();
|
||||
}
|
||||
|
||||
public void setShowPanelDetail() {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user