diff --git a/1.sources/MyHealth/build.xml b/1.sources/MyHealth/build.xml index 2210832..5cf2dcd 100644 --- a/1.sources/MyHealth/build.xml +++ b/1.sources/MyHealth/build.xml @@ -4,7 +4,7 @@ - + diff --git a/1.sources/MyHealth/docroot/medicaltest/PendingQuestions.xhtml b/1.sources/MyHealth/docroot/medicaltest/PendingQuestions.xhtml deleted file mode 100644 index 625f747..0000000 --- a/1.sources/MyHealth/docroot/medicaltest/PendingQuestions.xhtml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- -
- -
-
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- -
-
- -
-
-
-
- - - - - diff --git a/1.sources/MyHealth/docroot/medicaltest/Questions.xhtml b/1.sources/MyHealth/docroot/medicaltest/Questions.xhtml new file mode 100644 index 0000000..b6774f2 --- /dev/null +++ b/1.sources/MyHealth/docroot/medicaltest/Questions.xhtml @@ -0,0 +1,80 @@ + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+
+
+ + #{Questions.selected.title} + + + + +

Respuesta:

+ + +
+
+ +
+ + +
+
+
+
+
+
+ diff --git a/1.sources/MyHealth/docroot/resources/css/estilos.css b/1.sources/MyHealth/docroot/resources/css/estilos.css index 2c95b88..f60ebb1 100644 --- a/1.sources/MyHealth/docroot/resources/css/estilos.css +++ b/1.sources/MyHealth/docroot/resources/css/estilos.css @@ -1,4 +1,4 @@ -BODY { +body { font-family: Verdana, Arial, Helvetica, sans-serif; } @@ -36,4 +36,9 @@ ul.ui-menu-list { .red-button.ui-button.ui-state-default:enabled:hover, .red-button.ui-button.ui-state-default:focus { background-color: #d43f3a; border-color: #d9534f; +} + +.ui-orderlist .ui-orderlist-list { + height: 70vh !important; + width: 25vw !important; } \ No newline at end of file diff --git a/1.sources/MyHealth/docroot/resources/images/ANSWERED.png b/1.sources/MyHealth/docroot/resources/images/ANSWERED.png new file mode 100644 index 0000000..5427f7d Binary files /dev/null and b/1.sources/MyHealth/docroot/resources/images/ANSWERED.png differ diff --git a/1.sources/MyHealth/docroot/resources/images/ANSWERED.svg b/1.sources/MyHealth/docroot/resources/images/ANSWERED.svg new file mode 100644 index 0000000..16dd26b --- /dev/null +++ b/1.sources/MyHealth/docroot/resources/images/ANSWERED.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/1.sources/MyHealth/docroot/resources/images/PENDING.png b/1.sources/MyHealth/docroot/resources/images/PENDING.png new file mode 100644 index 0000000..d2a21bc Binary files /dev/null and b/1.sources/MyHealth/docroot/resources/images/PENDING.png differ diff --git a/1.sources/MyHealth/docroot/resources/images/PENDING.svg b/1.sources/MyHealth/docroot/resources/images/PENDING.svg new file mode 100644 index 0000000..32a7f04 --- /dev/null +++ b/1.sources/MyHealth/docroot/resources/images/PENDING.svg @@ -0,0 +1,248 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/1.sources/MyHealth/docroot/resources/images/clock.png b/1.sources/MyHealth/docroot/resources/images/clock.png new file mode 100644 index 0000000..ed0f093 Binary files /dev/null and b/1.sources/MyHealth/docroot/resources/images/clock.png differ diff --git a/1.sources/MyHealth/docroot/resources/images/clock.svg b/1.sources/MyHealth/docroot/resources/images/clock.svg new file mode 100644 index 0000000..d2b759c --- /dev/null +++ b/1.sources/MyHealth/docroot/resources/images/clock.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/1.sources/MyHealth/docroot/resources/images/quote.png b/1.sources/MyHealth/docroot/resources/images/quote.png new file mode 100644 index 0000000..2aab88a Binary files /dev/null and b/1.sources/MyHealth/docroot/resources/images/quote.png differ diff --git a/1.sources/MyHealth/docroot/resources/images/quote.svg b/1.sources/MyHealth/docroot/resources/images/quote.svg new file mode 100644 index 0000000..45d5294 --- /dev/null +++ b/1.sources/MyHealth/docroot/resources/images/quote.svg @@ -0,0 +1,11 @@ + + + + + + + diff --git a/1.sources/MyHealth/ecosystem.json b/1.sources/MyHealth/ecosystem.json new file mode 100644 index 0000000..e590ff6 --- /dev/null +++ b/1.sources/MyHealth/ecosystem.json @@ -0,0 +1,9 @@ +{ + "apps" : [{ + "name": "ANT", + "script": "start.sh", + "cwd": "./", + "ignore_watch": ["*.ear", "*.jar", "*.war", "./build/*", "./dist/*"], + "watch": true + }] +} diff --git a/1.sources/MyHealth/src/TO/QuestionTO.java b/1.sources/MyHealth/src/TO/QuestionTO.java index 7c5cc17..99096be 100644 --- a/1.sources/MyHealth/src/TO/QuestionTO.java +++ b/1.sources/MyHealth/src/TO/QuestionTO.java @@ -27,6 +27,8 @@ public class QuestionTO implements Serializable { public QuestionTO() { super(); + this.patient = new PatientTO(); + this.fdoctor = new FamilyDoctorTO(); } public QuestionTO(int id, String title, String message, QuestionStatus status, PatientTO patient, @@ -96,5 +98,21 @@ public class QuestionTO implements Serializable { public void setResponse(String response) { this.response = response; } + + public String toString() { + return "{" + + "ObjectID" + super.toString() + + ",id" + this.getId() + + ",title" + this.getTitle() + + ",message" + this.getMessage() + + ",response" + this.getResponse() + + ",status" + this.getStatus() + + ",patient-id" + this.getPatient().getId() + + ",patient-name-surname" + this.getPatient().getName() + " " + this.getPatient().getSurname() + + ",fdoctor-id" + this.getDoctor().getId() + + ",fdoctor-name-surname" + this.getDoctor().getName() + " " + this.getDoctor().getSurname() + + "}"; + + } } diff --git a/1.sources/MyHealth/src/common/QuestionStatus.java b/1.sources/MyHealth/src/common/QuestionStatus.java index b32bbf6..ac3ba66 100644 --- a/1.sources/MyHealth/src/common/QuestionStatus.java +++ b/1.sources/MyHealth/src/common/QuestionStatus.java @@ -6,7 +6,7 @@ package common; * */ public enum QuestionStatus { - ANSWERED("Respondida"), PENDING("Pendiente"); + ANSWERED("Respondida"), PENDING("Pendiente"), NEW("New"); private String questionStatusName; diff --git a/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeBean.java b/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeBean.java index 8dd4956..c796b9d 100644 --- a/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeBean.java +++ b/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeBean.java @@ -74,11 +74,35 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote { * @param response */ @Override - public void answerQuestion(String question, String response) { + public void answerQuestion(QuestionTO q) { + QuestionJPA qjpa = entman.find(QuestionJPA.class, q.getId()); + qjpa.setResponse(q.getResponse()); + qjpa.setStatus(QuestionStatus.ANSWERED); + + PatientJPA patient = entman.find(PatientJPA.class, q.getPatient().getId()); + // 1. Buscar el médico de familia con ese professionalNumber + FamilyDoctorJPA fdoctor = entman.find(FamilyDoctorJPA.class, q.getDoctor().getId()); + + qjpa.setPatient(patient); + qjpa.setFamilyDoctor(fdoctor); + + entman.persist(qjpa); } public List listAllPendingQuestions(int familyDoctorId) { - return null; + // TypedQuery query = entman.createQuery("SELECT q from QuestionJPA q where q.status=:status and q.familyDoctor.id=:docId order by q.title", QuestionJPA.class); + TypedQuery query = entman.createQuery("SELECT q from QuestionJPA q where q.familyDoctor.id=:docId order by q.status desc, q.title asc", QuestionJPA.class); + // query.setParameter("status", QuestionStatus.PENDING); + query.setParameter("docId", familyDoctorId); + + List allJPA = query.getResultList(); + List pendingQuestions = new ArrayList(); + + for (QuestionJPA item : allJPA) { + pendingQuestions.add(commonServices.getPOJOforQuestionJPA(item, 1)); + } + + return pendingQuestions; } public Long getPendingQuestionsCount(int familyDoctorId) { diff --git a/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeRemote.java b/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeRemote.java index 73fcc00..8382cc2 100644 --- a/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeRemote.java +++ b/1.sources/MyHealth/src/ejb/medicalTest/MedicalTestFacadeRemote.java @@ -37,7 +37,7 @@ public interface MedicalTestFacadeRemote { * @param question * @param response */ - public void answerQuestion(String question, String response); + public void answerQuestion(QuestionTO question); /** * Recuperar las preguntas sin respuesta para un médico diff --git a/1.sources/MyHealth/src/jpa/QuestionJPA.java b/1.sources/MyHealth/src/jpa/QuestionJPA.java index 3b5f826..40132a0 100644 --- a/1.sources/MyHealth/src/jpa/QuestionJPA.java +++ b/1.sources/MyHealth/src/jpa/QuestionJPA.java @@ -12,6 +12,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; +import TO.QuestionTO; import common.QuestionStatus; /** diff --git a/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java b/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java index 946fff9..1142b0f 100644 --- a/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java +++ b/1.sources/MyHealth/src/managedbean/common/AuthorizationFilter.java @@ -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; diff --git a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java index 7342482..d17400f 100644 --- a/1.sources/MyHealth/src/managedbean/common/MenuMBean.java +++ b/1.sources/MyHealth/src/managedbean/common/MenuMBean.java @@ -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)); } } diff --git a/1.sources/MyHealth/src/managedbean/medicalTest/PendingQuestionsMBean.java b/1.sources/MyHealth/src/managedbean/medicalTest/PendingQuestionsMBean.java deleted file mode 100644 index f179753..0000000 --- a/1.sources/MyHealth/src/managedbean/medicalTest/PendingQuestionsMBean.java +++ /dev/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 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() { - private static final long serialVersionUID = 1L; - - @Override - public List load(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) { - Long totalRowCount = getRemoteManagerMedicalTest().getPendingQuestionsCount(familyDoctorId); - this.setRowCount(totalRowCount.intValue()); - - return getRemoteManagerMedicalTest().listPendingQuestionsPaged(familyDoctorId, (first / pageSize), pageSize); - } - }; - } - - public LazyDataModel getLazyDataModelQuestionList() { - return lazyDataModelQuestionList; - } - - public void saveData() { - - } -} diff --git a/1.sources/MyHealth/src/managedbean/medicalTest/QuestionsMBean.java b/1.sources/MyHealth/src/managedbean/medicalTest/QuestionsMBean.java new file mode 100644 index 0000000..d335145 --- /dev/null +++ b/1.sources/MyHealth/src/managedbean/medicalTest/QuestionsMBean.java @@ -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 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 getPendingQuestions() { + return pendingQuestions; + } + + public void setPendingQuestions(List 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() { + // + } + +} diff --git a/1.sources/MyHealth/start.sh b/1.sources/MyHealth/start.sh new file mode 100755 index 0000000..a9db8b4 --- /dev/null +++ b/1.sources/MyHealth/start.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +ant + +read -p "Di hola pringao!" asd