Merge branch 'rorden' into 'master'
Merge request desde Rorden a master See merge request pds19-grupo2/myhealth!3
This commit is contained in:
@@ -1,56 +1,85 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
|
||||||
xmlns:ui="http://java.sun.com/jsf/facelets"
|
|
||||||
xmlns:f="http://java.sun.com/jsf/core"
|
|
||||||
xmlns:h="http://java.sun.com/jsf/html"
|
|
||||||
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||||
|
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="frmQuestions">
|
<h:form id="frmQuestions">
|
||||||
<p:growl id="msgs" showDetail="true" closable="true"
|
<p:growl id="mesgs" showDetail="true" closable="true" autoupdate="true" />
|
||||||
autoupdate="true" />
|
|
||||||
<p:panel id="panelQuestions" header="Preguntas">
|
<p:panel id="panelQuestions" header="Preguntas">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-3 ui-md-3">
|
<div class="ui-g-4">
|
||||||
<p:commandButton rendered="#{Questions.showCreate}" action="#{Questions.create}" value="Nuevo" update="panelDetail"></p:commandButton>
|
<p:panel id="panelQuestionList" header="Lista de preguntas">
|
||||||
<p:orderList value="#{Questions.pendingQuestions}" var="pq"
|
<f:facet name="actions">
|
||||||
controlsLocation="none" itemValue="#{pq}">
|
<h:commandLink action="#{Questions.init}" update="frmQuestions" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default"><h:outputText styleClass="ui-icon pi pi-refresh" /></h:commandLink>
|
||||||
<o:converter converterId="omnifaces.ListConverter"
|
<h:commandLink rendered="#{Questions.patient}" action="#{Questions.create}" update="frmQuestions" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default"><h:outputText styleClass="ui-icon pi pi-plus" /></h:commandLink>
|
||||||
list="#{Questions.pendingQuestions}" />
|
</f:facet>
|
||||||
<p:ajax event="select" listener="#{Questions.onSelect}"
|
<p:orderList value="#{Questions.pendingQuestions}" var="pq" controlsLocation="none" itemValue="#{pq}" responsive="true">
|
||||||
update="panelDetail"></p:ajax >
|
<o:converter converterId="omnifaces.ListConverter" list="#{Questions.pendingQuestions}" />
|
||||||
<p:ajax event="unselect" listener="#{Questions.onUnSelect}"
|
<p:ajax event="select" listener="#{Questions.onSelect}" update="frmQuestions"></p:ajax>
|
||||||
update="panelDetail"></p:ajax>
|
<p:ajax event="unselect" listener="#{Questions.onUnSelect}" update="frmQuestions"></p:ajax>
|
||||||
<p:column>
|
<p:column>
|
||||||
<h:graphicImage name="images/#{pq.status}.png"
|
<h:graphicImage name="images/#{pq.status}.png" alt="#{pq.status}" styleClass="ui-theme" />
|
||||||
alt="#{pq.status}" styleClass="ui-theme" />
|
</p:column>
|
||||||
</p:column>
|
<p:column headerText="Título">
|
||||||
<p:column>
|
<h:outputText value="#{pq.title}" />
|
||||||
<h:outputText value="#{pq.title}" />
|
</p:column>
|
||||||
</p:column>
|
</p:orderList>
|
||||||
</p:orderList>
|
</p:panel>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-1 ui-md-1"></div>
|
<div class="ui-g-8">
|
||||||
<div class="ui-g-8 ui-md-8">
|
<p:panel id="panelAddQuestion" rendered="#{Questions.addNewMode}" header="Añadir nueva pregunta">
|
||||||
<p:panel id="panelDetail" visible="#{Questions.showPanelDetail}" header="Pregunta de #{Questions.selected.patient.name} #{Questions.selected.patient.surname} ">
|
<div class="ui-g ui-fluid">
|
||||||
<!-- Creación de pregunta -->
|
<div class="ui-g-12">
|
||||||
<p:inputText rendered="#{Questions.selected.status == 'NEW'}" value="#{Questions.selected.title}"></p:inputText>
|
<h3>Título:</h3>
|
||||||
<p:textEditor rendered="#{Questions.selected.status == 'NEW'}" value="#{Questions.selected.message}" ></p:textEditor>
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
<!-- Respuesta a una pregunta -->
|
<p:inputText value="#{Questions.selected.title}" required="true" requiredMessage="Es necesario especificar el título de la pregunta" />
|
||||||
<h:outputText rendered="#{Questions.selected.status != 'NEW'}">#{Questions.selected.title}</h:outputText>
|
</div>
|
||||||
<h:outputText rendered="#{Questions.selected.status != 'NEW'}" value="#{Questions.selected.message}" escape="false"></h:outputText>
|
<div class="ui-g-12">
|
||||||
<p:panel rendered="#{Questions.selected.status != 'NEW'}" style="border: 0px !important;">
|
<h3>Pregunta:</h3>
|
||||||
<h3>Respuesta:</h3>
|
</div>
|
||||||
<p:textEditor rendered="#{Questions.selected.status == 'PENDING'}" value="#{Questions.selected.response}"></p:textEditor>
|
<div class="ui-g-12">
|
||||||
<h:outputText rendered="#{Questions.selected.status == 'ANSWERED'}" value="#{Questions.selected.response}" escape="false"></h:outputText>
|
<p:textEditor value="#{Questions.selected.message}" required="true" requiredMessage="Es necesario especificar el texto de la pregunta" />
|
||||||
</p:panel>
|
</div>
|
||||||
<br/>
|
<div class="ui-g-4" />
|
||||||
<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>
|
<div class="ui-g-4">
|
||||||
</p:panel>
|
<p:commandButton value="Preguntar" action="#{Questions.addNewQuestion}" update="frmQuestions" icon="pi pi-save" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
<p:panel id="panelDetail" rendered="#{Questions.showPanelDetail}" header="Pregunta de #{Questions.selected.patient.displayName}">
|
||||||
|
<!-- Responder pregunta -->
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Título:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:inputText value="#{Questions.selected.title}" readonly="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Pregunta:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:textEditor value="#{Questions.selected.message}" toolbarVisible="false" readonly="true" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<h3>Respuesta:</h3>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12">
|
||||||
|
<p:textEditor value="#{Questions.selected.response}" toolbarVisible="#{Questions.respuestaEditable}" readonly="#{not Questions.respuestaEditable}" required="true" requiredMessage="Es necesario especificar una respuesta." />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
<div class="ui-g-4">
|
||||||
|
<p:commandButton value="Responder" rendered="#{Questions.respuestaEditable}" action="#{Questions.save}" update="frmQuestions" icon="pi pi-save" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4" />
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:ui="http://java.sun.com/jsf/facelets"
|
||||||
|
xmlns:f="http://java.sun.com/jsf/core"
|
||||||
|
xmlns:h="http://java.sun.com/jsf/html"
|
||||||
|
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||||
|
|
||||||
|
<ui:composition template="../header.xhtml">
|
||||||
|
<ui:define name="content">
|
||||||
|
<h:form id="TestForm">
|
||||||
|
<p:messages id="mesgs" showDetail="true" closable="true"
|
||||||
|
autoupdate="true" />
|
||||||
|
<p:panel id="frmSSbD"
|
||||||
|
header="Búsqueda de médicos especialista por especialidad">
|
||||||
|
<div class="ui-g ui-fluid">
|
||||||
|
|
||||||
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:outputLabel for="selMS" value="Especialidad:" />
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4 ui-md-4">
|
||||||
|
<p:autoComplete id="selMS" dropdown="true" required="true"
|
||||||
|
value="#{sspec.medicalSpeciality}"
|
||||||
|
completeMethod="#{sspec.completeMedicalSpeciality}" var="ms"
|
||||||
|
itemLabel="#{ms.displayName}" itemValue="#{ms}"
|
||||||
|
forceSelection="true"
|
||||||
|
requiredMessage="Por favor, selecciona una especialidad médica"
|
||||||
|
placeholder="Seleccione una especialidad médica o teclee para buscar...">
|
||||||
|
<o:converter converterId="omnifaces.ListConverter"
|
||||||
|
list="#{RegisterUser.medicalSpecialtiesList}" />
|
||||||
|
<p:ajax event="itemSelect" listener="#{sspec.onSelect}"
|
||||||
|
update="frmSSbD" />
|
||||||
|
<p:column headerText="Nombre">
|
||||||
|
<h:outputText value="#{ms.name}" />
|
||||||
|
</p:column>
|
||||||
|
<p:column headerText="Localización">
|
||||||
|
<h:outputText value="#{ms.description}" />
|
||||||
|
</p:column>
|
||||||
|
</p:autoComplete>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
|
|
||||||
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
|
<div class="ui-g-8 ui-md-8">
|
||||||
|
<p:dataList value="#{sspec.listDoctors}" var="dd" type="ordered" emptyMessage="Ningún especialista para la especialidad seleccionada">
|
||||||
|
#{dd.name} #{dd.surname} <#{dd.email}>
|
||||||
|
</p:dataList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</p:panel>
|
||||||
|
</h:form>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
@@ -3,7 +3,11 @@
|
|||||||
"name": "ANT",
|
"name": "ANT",
|
||||||
"script": "start.sh",
|
"script": "start.sh",
|
||||||
"cwd": "./",
|
"cwd": "./",
|
||||||
"ignore_watch": ["*.ear", "*.jar", "*.war", "./build/*", "./dist/*"],
|
"ignore_watch": ["*.ear", "*.jar", "*.war", "./build/*", "./dist/*", "ecosystem.json"],
|
||||||
"watch": true
|
"watch": true
|
||||||
|
},{
|
||||||
|
"name": "Widlfly",
|
||||||
|
"script": "standalone.sh",
|
||||||
|
"cwd": "/opt/wildfly/bin/"
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import javax.persistence.TypedQuery;
|
|||||||
import TO.LoggedUserTO;
|
import TO.LoggedUserTO;
|
||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.QuestionTO;
|
import TO.QuestionTO;
|
||||||
|
import TO.SpecialistDoctorTO;
|
||||||
import common.MedicalTestType;
|
import common.MedicalTestType;
|
||||||
import common.QuestionStatus;
|
import common.QuestionStatus;
|
||||||
import common.UserType;
|
import common.UserType;
|
||||||
@@ -20,6 +21,7 @@ import ejb.common.CommonFacadeLocal;
|
|||||||
import jpa.FamilyDoctorJPA;
|
import jpa.FamilyDoctorJPA;
|
||||||
import jpa.PatientJPA;
|
import jpa.PatientJPA;
|
||||||
import jpa.QuestionJPA;
|
import jpa.QuestionJPA;
|
||||||
|
import jpa.SpecialistDoctorJPA;
|
||||||
import managedbean.common.SessionUtils;
|
import managedbean.common.SessionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,16 +55,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 +76,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);
|
||||||
}
|
}
|
||||||
@@ -134,44 +126,24 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
return pendingQuestions;
|
return pendingQuestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getPendingQuestionsCount(int familyDoctorId) {
|
|
||||||
TypedQuery<Long> query = entman.createQuery(
|
|
||||||
"SELECT count(1) from QuestionJPA q where q.status=:status and q.familyDoctor.id=:docId", Long.class);
|
|
||||||
query.setParameter("status", QuestionStatus.PENDING);
|
|
||||||
query.setParameter("docId", familyDoctorId);
|
|
||||||
|
|
||||||
return query.getSingleResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<QuestionTO> listPendingQuestionsPaged(int familyDoctorId, int pageNumber, int pageSize) {
|
|
||||||
TypedQuery<QuestionJPA> query = entman.createQuery(
|
|
||||||
"SELECT q from QuestionJPA q where q.status=:status and q.familyDoctor.id=:docId order by q.title",
|
|
||||||
QuestionJPA.class);
|
|
||||||
query.setParameter("status", QuestionStatus.PENDING);
|
|
||||||
query.setParameter("docId", familyDoctorId);
|
|
||||||
|
|
||||||
if (pageSize > 0) {
|
|
||||||
query.setFirstResult(pageNumber * pageSize);
|
|
||||||
query.setMaxResults(pageSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<QuestionJPA> allJPA = query.getResultList();
|
|
||||||
List<QuestionTO> pendingQuestions = new ArrayList<QuestionTO>();
|
|
||||||
|
|
||||||
for (QuestionJPA item : allJPA) {
|
|
||||||
pendingQuestions.add(commonServices.getPOJOforQuestionJPA(item, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
return pendingQuestions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recuperar una pregunta por su String
|
* Recuperar una pregunta por su identificador
|
||||||
*
|
*
|
||||||
* @param question
|
* @param question
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void getQuestion(String question) {
|
public QuestionTO getQuestion(int idQuestion) {
|
||||||
|
QuestionTO resp = new QuestionTO();
|
||||||
|
|
||||||
|
TypedQuery<QuestionJPA> query = entman.createQuery(
|
||||||
|
"SELECT q from QuestionJPA q where q.id=:idquestion",
|
||||||
|
QuestionJPA.class);
|
||||||
|
|
||||||
|
query.setParameter("idquestion", idQuestion);
|
||||||
|
|
||||||
|
resp = commonServices.getPOJOforQuestionJPA(query.getSingleResult(),1);
|
||||||
|
|
||||||
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// *********************************************************************
|
// *********************************************************************
|
||||||
@@ -239,7 +211,21 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
|||||||
* @param speciality
|
* @param speciality
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality) {
|
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality) {
|
||||||
|
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
|
||||||
|
|
||||||
|
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
|
||||||
|
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.name=:spec order by q.medicalSpecialty.name asc, q.surname asc",
|
||||||
|
SpecialistDoctorJPA.class);
|
||||||
|
query.setParameter("spec", speciality.getName());
|
||||||
|
|
||||||
|
List<SpecialistDoctorJPA> allJPA = query.getResultList();
|
||||||
|
|
||||||
|
for (SpecialistDoctorJPA item : allJPA) {
|
||||||
|
pendingQuestions.add(commonServices.getPOJOforSpecialistDoctorJPA(item, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
return pendingQuestions;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import javax.ejb.Remote;
|
|||||||
|
|
||||||
import TO.MedicalSpecialtyTO;
|
import TO.MedicalSpecialtyTO;
|
||||||
import TO.QuestionTO;
|
import TO.QuestionTO;
|
||||||
|
import TO.SpecialistDoctorTO;
|
||||||
import common.MedicalTestType;
|
import common.MedicalTestType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +30,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 +38,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
|
||||||
@@ -52,17 +53,13 @@ public interface MedicalTestFacadeRemote {
|
|||||||
* Recuperar las preguntas hechas por un paciente
|
* Recuperar las preguntas hechas por un paciente
|
||||||
*/
|
*/
|
||||||
public List<QuestionTO> listAllMyQuestions(int userId);
|
public List<QuestionTO> listAllMyQuestions(int userId);
|
||||||
|
|
||||||
public Long getPendingQuestionsCount(int familyDoctorId);
|
|
||||||
|
|
||||||
public List<QuestionTO> listPendingQuestionsPaged(int familyDoctorId, int pageNumber, int pageSize);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recuperar una pregunta por su String
|
* Recuperar una pregunta por su String
|
||||||
*
|
*
|
||||||
* @param question
|
* @param question
|
||||||
*/
|
*/
|
||||||
public void getQuestion(String question);
|
public QuestionTO getQuestion(int idQuestion);
|
||||||
|
|
||||||
// ********************************************************************* MEDICAL
|
// ********************************************************************* MEDICAL
|
||||||
// TEST
|
// TEST
|
||||||
@@ -114,5 +111,5 @@ public interface MedicalTestFacadeRemote {
|
|||||||
*
|
*
|
||||||
* @param speciality
|
* @param speciality
|
||||||
*/
|
*/
|
||||||
public void findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality);
|
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality);
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ public class AuthorizationFilter implements Filter {
|
|||||||
authorized = true;
|
authorized = true;
|
||||||
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
|
||||||
authorized = true;
|
authorized = true;
|
||||||
if (reqURI.indexOf("/medicaltest/SearchSpecialistBySpecialty") > 0)
|
if (reqURI.indexOf("/medicaltest/SearchSpecialist") > 0)
|
||||||
authorized = true;
|
authorized = true;
|
||||||
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
|
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
|
||||||
authorized = true;
|
authorized = true;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class MenuMBean implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tipoUsuario == UserType.PATIENT)
|
if (tipoUsuario == UserType.PATIENT)
|
||||||
subMenu.addElement(createMenuItem("Buscar especialista...", "fa fa-heartbeat", "/medicaltest/MedicalTests", null));
|
subMenu.addElement(createMenuItem("Buscar especialista...", "fa fa-heartbeat", "/medicaltest/SearchSpecialist", null));
|
||||||
|
|
||||||
model.addElement(subMenu);
|
model.addElement(subMenu);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.view.ViewScoped;
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@@ -24,10 +25,9 @@ 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> pendingQuestions;
|
||||||
protected String title;
|
private Integer id;
|
||||||
protected String message;
|
private QuestionTO selected;
|
||||||
protected String response;
|
private boolean addNewMode;
|
||||||
protected QuestionTO selected;
|
|
||||||
|
|
||||||
public QuestionsMBean() {
|
public QuestionsMBean() {
|
||||||
}
|
}
|
||||||
@@ -37,15 +37,11 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
// Inicialización de variables y propiedades van aquí.
|
// Inicialización de variables y propiedades van aquí.
|
||||||
this.userType = SessionUtils.getUserType();
|
this.userType = SessionUtils.getUserType();
|
||||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||||
|
|
||||||
|
this.addNewMode = false;
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
|
|
||||||
this.loadQuestions();
|
this.loadQuestions();
|
||||||
this.printSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void printSelected() {
|
|
||||||
System.out.println("Selected: ");
|
|
||||||
System.out.println(this.selected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QuestionTO> getPendingQuestions() {
|
public List<QuestionTO> getPendingQuestions() {
|
||||||
@@ -60,12 +56,11 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
* 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();
|
if (this.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.pendingQuestions = getRemoteManagerMedicalTest().listAllPendingQuestions(userID);
|
||||||
} else if (userType == UserType.PATIENT) {
|
} else if (this.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.
|
||||||
@@ -73,37 +68,9 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
this.printSelected();
|
this.addNewMode = false;
|
||||||
this.selected = (QuestionTO) event.getObject();
|
this.selected = (QuestionTO) event.getObject();
|
||||||
this.printSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onUnSelect(SelectEvent event) {
|
public void onUnSelect(SelectEvent event) {
|
||||||
@@ -111,56 +78,55 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected(QuestionTO selected) {
|
public void setSelected(QuestionTO selected) {
|
||||||
this.printSelected();
|
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestionTO getSelected() {
|
public QuestionTO getSelected() {
|
||||||
return this.selected;
|
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() {
|
public void save() {
|
||||||
this.printSelected();
|
getRemoteManagerMedicalTest().answerQuestion(this.selected.getId(), this.selected.getResponse());
|
||||||
getRemoteManagerMedicalTest().answerQuestion(this.selected);
|
this.loadQuestions();
|
||||||
this.init();
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La respuesta se registrado correctamente en el sistema.");
|
||||||
|
this.selected = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create() {
|
public void create() {
|
||||||
this.printSelected();
|
this.addNewMode = true;
|
||||||
String template = "";
|
|
||||||
this.selected = new QuestionTO();
|
this.selected = new QuestionTO();
|
||||||
this.selected.setId(-1);
|
this.selected.setId(-1);
|
||||||
this.selected.setTitle(template);
|
this.selected.setTitle("");
|
||||||
this.selected.setMessage(template);
|
this.selected.setMessage("");
|
||||||
this.selected.setResponse(template);
|
|
||||||
this.selected.setStatus(QuestionStatus.NEW);
|
|
||||||
this.selected.getPatient().setId(Integer.parseInt(SessionUtils.getloggedOnUser().getId()));
|
|
||||||
this.selected.getPatient().setName(SessionUtils.getloggedOnUser().getName());
|
|
||||||
this.printSelected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getShowPanelDetail() {
|
public void addNewQuestion() {
|
||||||
return this.selected != null;
|
getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
||||||
|
this.loadQuestions();
|
||||||
|
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowPanelDetail() {
|
public boolean isShowPanelDetail() {
|
||||||
return this.getShowPanelDetail();
|
return this.selected != null && this.addNewMode == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowPanelDetail() {
|
public boolean isPatient() {
|
||||||
//
|
return (this.userType == UserType.PATIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isFamilyDoctor() {
|
||||||
|
return (this.userType == UserType.FAMILY_DOCTOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAddNewMode() {
|
||||||
|
return addNewMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRespuestaEditable() {
|
||||||
|
return (this.userType == UserType.FAMILY_DOCTOR && this.selected != null && this.selected.getStatus() == QuestionStatus.PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddNewMode(boolean addNewMode) {
|
||||||
|
this.addNewMode = addNewMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,90 @@
|
|||||||
|
package managedbean.medicalTest;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.faces.view.ViewScoped;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.primefaces.event.SelectEvent;
|
||||||
|
|
||||||
|
import TO.MedicalSpecialtyTO;
|
||||||
|
import TO.SpecialistDoctorTO;
|
||||||
|
import common.Constants;
|
||||||
|
import common.UserType;
|
||||||
|
import managedbean.common.ManagedBeanBase;
|
||||||
|
import managedbean.common.SessionUtils;
|
||||||
|
|
||||||
|
@Named("sspec")
|
||||||
|
@ViewScoped
|
||||||
|
public class SearchSpecialistMBean extends ManagedBeanBase implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private int userID;
|
||||||
|
private UserType userType;
|
||||||
|
private List<SpecialistDoctorTO> listDoctors;
|
||||||
|
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
|
||||||
|
private MedicalSpecialtyTO medicalSpeciality;
|
||||||
|
private String lastUIQueryMS;
|
||||||
|
|
||||||
|
public SearchSpecialistMBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
// Inicialización de variables y propiedades van aquí.
|
||||||
|
this.userType = SessionUtils.getUserType();
|
||||||
|
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||||
|
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0,
|
||||||
|
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
|
this.medicalSpeciality = null;
|
||||||
|
this.lastUIQueryMS = "";
|
||||||
|
this.listDoctors = new ArrayList<SpecialistDoctorTO>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
System.out.println("onSelect");
|
||||||
|
this.medicalSpeciality = (MedicalSpecialtyTO) event.getObject();
|
||||||
|
System.out.println(this.medicalSpeciality);
|
||||||
|
this.listDoctors = getRemoteManagerMedicalTest()
|
||||||
|
.findSpecialistDoctorByMedicalSpeciality(this.medicalSpeciality);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MedicalSpecialtyTO> completeMedicalSpeciality(String query) {
|
||||||
|
if (query != null && query.equals(this.lastUIQueryMS) == false) {
|
||||||
|
this.lastUIQueryMS = query;
|
||||||
|
// Recuperamos las 200 primeras coincidencias
|
||||||
|
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0,
|
||||||
|
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||||
|
}
|
||||||
|
return this.medicalSpecialitiesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TO.SpecialistDoctorTO> getListDoctors() {
|
||||||
|
return listDoctors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setListDoctors(List<TO.SpecialistDoctorTO> listDoctors) {
|
||||||
|
this.listDoctors = listDoctors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MedicalSpecialtyTO> getMedicalSpecialitiesList() {
|
||||||
|
return medicalSpecialitiesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMedicalSpecialitiesList(List<MedicalSpecialtyTO> medicalSpecialitiesList) {
|
||||||
|
this.medicalSpecialitiesList = medicalSpecialitiesList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MedicalSpecialtyTO getMedicalSpeciality() {
|
||||||
|
return medicalSpeciality;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMedicalSpeciality(MedicalSpecialtyTO medicalSpecialty) {
|
||||||
|
this.medicalSpeciality = medicalSpecialty;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user