Preguntas y respuestas funcionando para médicos
This commit is contained in:
@@ -99,7 +99,7 @@ public class AuthorizationFilter implements Filter {
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/visit/CancelVisit") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AddQuestion") > 0)
|
||||
if (reqURI.indexOf("/medicaltest/Questions") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
|
||||
authorized = true;
|
||||
@@ -121,9 +121,7 @@ public class AuthorizationFilter implements Filter {
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/AnswerQuestion") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/PendingQuestions") > 0)
|
||||
if (reqURI.indexOf("/medicaltest/Questions") > 0)
|
||||
authorized = true;
|
||||
if (reqURI.indexOf("/medicaltest/ViewMedicalTest") > 0)
|
||||
authorized = true;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MenuMBean implements Serializable {
|
||||
|
||||
// Todos pueden consultar (P S F)
|
||||
subMenu.addElement(createMenuItem("Consultar prueba", "fa fa-search", "/medicaltest/MedicalTests", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
|
||||
if (tipoUsuario == UserType.SPECIALIST_DOCTOR) {
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
@@ -93,18 +93,7 @@ public class MenuMBean implements Serializable {
|
||||
|
||||
// Preguntas médicas
|
||||
if (tipoUsuario == UserType.PATIENT || tipoUsuario == UserType.FAMILY_DOCTOR) {
|
||||
subMenu = new DefaultSubMenu("Preguntas", "fa fa-question-circle");
|
||||
|
||||
if (tipoUsuario == UserType.PATIENT)
|
||||
subMenu.addElement(createMenuItem("Hacer pregunta", "fa fa-comment-o", "/medicaltest/MedicalTests", null));
|
||||
|
||||
if (tipoUsuario == UserType.FAMILY_DOCTOR)
|
||||
subMenu.addElement(createMenuItem("Responder pregunta", "fa fa-comments", "/medicaltest/MedicalTests", null));
|
||||
|
||||
if (tipoUsuario == UserType.FAMILY_DOCTOR)
|
||||
subMenu.addElement(createMenuItem("Ver preguntas pendientes", "fa fa-comments-o", "/medicaltest/PendingQuestions", null));
|
||||
|
||||
model.addElement(subMenu);
|
||||
model.addElement(createMenuItem("Preguntas", "fa fa-comment-o", "/medicaltest/Questions", null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package managedbean.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.model.LazyDataModel;
|
||||
import org.primefaces.model.SortOrder;
|
||||
|
||||
import TO.QuestionTO;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@Named("PendingQuestions")
|
||||
@ViewScoped
|
||||
public class PendingQuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int familyDoctorId;
|
||||
private LazyDataModel<QuestionTO> lazyDataModelQuestionList;
|
||||
|
||||
public PendingQuestionsMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Inicialización de variables y propiedades van aquí.
|
||||
this.familyDoctorId = Integer.valueOf(SessionUtils.getUserId());
|
||||
|
||||
this.lazyDataModelQuestionList = new LazyDataModel<QuestionTO>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public List<QuestionTO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
|
||||
Long totalRowCount = getRemoteManagerMedicalTest().getPendingQuestionsCount(familyDoctorId);
|
||||
this.setRowCount(totalRowCount.intValue());
|
||||
|
||||
return getRemoteManagerMedicalTest().listPendingQuestionsPaged(familyDoctorId, (first / pageSize), pageSize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public LazyDataModel<QuestionTO> getLazyDataModelQuestionList() {
|
||||
return lazyDataModelQuestionList;
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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