Ver pruebas médicas casi funcionando al completo: falta cargar imagen real
Crear prueba medica: formulario comenzado.
This commit is contained in:
@@ -1,58 +1,91 @@
|
||||
<?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">
|
||||
<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="PanelUnderConstruction" header="Pagina en construcción de Pruebas médicas">
|
||||
<h:form id="frmMT">
|
||||
<p:messages id="mesgs" showDetail="true" closable="true"
|
||||
autoupdate="true" />
|
||||
<div class="ui-g ui-fluid">
|
||||
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:outputLabel for="campo" value="Etiqueta para campo de formulario:" />
|
||||
<div class="ui-g-5 ui-md-5">
|
||||
<p:panel id="mainPanel" header="Pruebas médicas">
|
||||
<f:facet name="actions">
|
||||
<h:commandLink action="#{mt.addMT}" immediate="true" update="frmMT" rendered="#{mt.patIdSelected != -1}" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
|
||||
<h:outputText styleClass="ui-icon pi pi-plus" />
|
||||
</h:commandLink>
|
||||
</f:facet>
|
||||
<p:selectOneMenu id="lazy" value="#{mt.patIdSelected}" converter="omnifaces.SelectItemsConverter">
|
||||
<p:ajax event="valueChange" listener="#{mt.onSelectPatient}" update="frmMT"/>
|
||||
<f:selectItem itemLabel="Todos" itemValue="-1" />
|
||||
<f:selectItems value="#{mt.patients}" var="el" itemLabel="#{el.name} #{el.surname}" itemValue="#{el.id}" />
|
||||
</p:selectOneMenu>
|
||||
<p:orderList id="medicalTestList" value="#{mt.medicalTests}" var="el" itemValue="#{el}" controlsLocation="none" responsive="true">
|
||||
<p:ajax event="select" listener="#{mt.onSelectMT}" update="frmMT"/>
|
||||
<o:converter converterId="omnifaces.ListConverter" list="#{mt.medicalTests}" />
|
||||
<p:column>
|
||||
<h:outputText value="#{el.onlyDate} - #{el.type.testTypeName}"/>
|
||||
<br/>
|
||||
<h:outputText rendered="#{mt.patIdSelected == -1}" value="#{el.patient.name} #{el.patient.surname}" style="font-size: 0.8em !important; font-style: italic;" />
|
||||
</p:column>
|
||||
</p:orderList>
|
||||
</p:panel>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="campo" value="Valor del campo del formulario" required="true" requiredMessage="Por favor, especifique un valor" />
|
||||
<div class="ui-g-7 ui-md-7">
|
||||
<p:panel rendered="#{mt.viewEdit}" id="detailPanel" header="Detalle de prueba médica">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-4 ui-md-4">Fecha: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<h:outputText value="#{mt.selected.date}"></h:outputText>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:message for="campo" display="text" />
|
||||
<div class="ui-g-4 ui-md-4">Hora: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<h:outputText value="#{mt.selected.time}"></h:outputText>
|
||||
</div>
|
||||
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:outputLabel for="campo2" value="Etiqueta para campo 2 de formulario:" />
|
||||
<div class="ui-g-4 ui-md-4">Observaciones: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<h:outputText value="#{mt.selected.observations}"></h:outputText>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="campo2" value="Valor del campo 2 del formulario" required="true" requiredMessage="Por favor, especifique un valor" />
|
||||
<div class="ui-g-4 ui-md-4">Tipo de prueba: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<h:outputText value="#{mt.selected.type.testTypeName}"></h:outputText>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:message for="campo" display="text" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:outputLabel for="campo3" value="Etiqueta para campo 3 de formulario:" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:inputText id="campo3" value="Valor del campo 3 del formulario" required="true" requiredMessage="Por favor, especifique un valor" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">
|
||||
<p:message for="campo" display="text" />
|
||||
</div>
|
||||
|
||||
<div class="ui-g-12 ui-g-nopad">
|
||||
<div class="ui-g-4 ui-md-4" />
|
||||
<div class="ui-g-2 ui-md-2 ">
|
||||
<p:commandButton validateClient="true" value="Guardar" update="TestForm" action="#{BeanName.actionMethod}" icon="pi pi-check" />
|
||||
</div>
|
||||
<div class="ui-g-2 ui-md-2">
|
||||
<p:button value="Volver" outcome="/home" icon="pi pi-home" />
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4" />
|
||||
<div class="ui-g-4 ui-md-4">Imagen de alta resolución: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<h:outputText rendered="#{mt.selected.highresimage != null}" value="#{mt.selected.highresimage}"></h:outputText>
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
<p:panel rendered="#{mt.viewCreate}" id="createPanel" header="Detalle de prueba médica">
|
||||
<div class="ui-g ui-fluid">
|
||||
<div class="ui-g-4 ui-md-4">Fecha: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<p:inputText value="#{mt.selected.date}"></p:inputText>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">Hora: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<p:inputText value="#{mt.selected.time}"></p:inputText>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">Observaciones: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<p:textEditor value="#{mt.selected.observations}"></p:textEditor>
|
||||
</div>
|
||||
<div class="ui-g-4 ui-md-4">Tipo de prueba: </div>
|
||||
<div class="ui-g-8 ui-md-8">
|
||||
<p:selectOneMenu value="#{mt.selected.type}">
|
||||
<f:selectItems value="#{mt.selected.type}" />
|
||||
</p:selectOneMenu>
|
||||
</div>
|
||||
</div>
|
||||
</p:panel>
|
||||
</div>
|
||||
</div>
|
||||
</h:form>
|
||||
</ui:define>
|
||||
</ui:composition>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package TO;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@@ -19,7 +23,7 @@ public class MedicalTestTO implements Serializable {
|
||||
|
||||
private int id;
|
||||
private Date date;
|
||||
private long time;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String highresimage;
|
||||
private MedicalTestType type;
|
||||
@@ -27,7 +31,15 @@ public class MedicalTestTO implements Serializable {
|
||||
private SpecialistDoctorTO specialistDoctor;
|
||||
|
||||
|
||||
public MedicalTestTO(int id, Date date, int time, String observations, String highresimage, MedicalTestType type,
|
||||
public MedicalTestTO() {
|
||||
super();
|
||||
this.date = new Date();
|
||||
this.time = LocalTime.now();
|
||||
this.patient = new PatientTO();
|
||||
this.specialistDoctor = new SpecialistDoctorTO();
|
||||
}
|
||||
|
||||
public MedicalTestTO(int id, Date date, LocalTime time, String observations, String highresimage, MedicalTestType type,
|
||||
PatientTO patiend, SpecialistDoctorTO specialistDoctor) {
|
||||
this.setId(id);
|
||||
this.setDate(date);
|
||||
@@ -55,11 +67,11 @@ public class MedicalTestTO implements Serializable {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
public LocalTime getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
public void setTime(LocalTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@@ -103,4 +115,15 @@ public class MedicalTestTO implements Serializable {
|
||||
this.specialistDoctor = specialistDoctor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Integer.toString(this.getId());
|
||||
}
|
||||
|
||||
public String getOnlyDate() {
|
||||
DateFormat df = DateFormat.getDateInstance(DateFormat.DATE_FIELD, new Locale("es", "ES"));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
||||
return sdf.format(this.getDate());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.QuestionTO;
|
||||
@@ -18,6 +19,7 @@ import TO.VisitTO;
|
||||
import common.Utils;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.MedicalTestJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
import jpa.QuestionJPA;
|
||||
@@ -36,7 +38,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
private EntityManager entman;
|
||||
|
||||
/**
|
||||
* Metodo que devuelve todas las especialidades medicas registradas en el sistema
|
||||
* Metodo que devuelve todas las especialidades medicas registradas en el
|
||||
* sistema
|
||||
*
|
||||
* @return Devuelve una Lista de MedicalSpecialtyTO (Transfer Objects).
|
||||
*/
|
||||
@@ -47,9 +50,11 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Metodo que devuelve las especialidades médicas de forma paginada
|
||||
*
|
||||
* Acepta como parametro la página (comenzando en 0) y el número de elementos de cada página.
|
||||
* Acepta como parametro la página (comenzando en 0) y el número de elementos de
|
||||
* cada página.
|
||||
*
|
||||
* si pageSize == 0, entonces se devuelven todas las especialidades registradas (Se ignora el parámetro).
|
||||
* si pageSize == 0, entonces se devuelven todas las especialidades registradas
|
||||
* (Se ignora el parámetro).
|
||||
*
|
||||
* @return Devuelve una Lista de MedicalSpecialtyTO (Transfer Objects).
|
||||
*/
|
||||
@@ -58,12 +63,15 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista de espcialidades médicas que tienen una coincidencia parcial en el nombre o en la descripción con el termino de búsqueda (searchTerm)
|
||||
* especificado.
|
||||
* Método que devuelve una lista de espcialidades médicas que tienen una
|
||||
* coincidencia parcial en el nombre o en la descripción con el termino de
|
||||
* búsqueda (searchTerm) especificado.
|
||||
*
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza
|
||||
* paginación y se devuelven todos los resultados.
|
||||
*
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el parámetro y devuelven todas las especialidades existentes.
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el
|
||||
* parámetro y devuelven todas las especialidades existentes.
|
||||
*
|
||||
* @return Devuelve una Lista de MedicalSpecialtyTO (Transfer Objects).
|
||||
*/
|
||||
@@ -79,7 +87,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
strFilter = "WHERE lower(ms.name) LIKE :searchTerm OR lower(ms.description) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<MedicalSpecialtyJPA> query = entman.createQuery(String.format(strQuery, strFilter), MedicalSpecialtyJPA.class);
|
||||
TypedQuery<MedicalSpecialtyJPA> query = entman.createQuery(String.format(strQuery, strFilter),
|
||||
MedicalSpecialtyJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
@@ -109,9 +118,11 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista de CAPs (Centros de Atención Primarios) de forma paginada
|
||||
* Método que devuelve una lista de CAPs (Centros de Atención Primarios) de
|
||||
* forma paginada
|
||||
*
|
||||
* Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
* Si pageSize == 0 no se realiza paginación y se devuelven todos los
|
||||
* resultados.
|
||||
*
|
||||
* @return Devuelve una Lista de MedicalSpecialtyTO (Transfer Objects).
|
||||
*/
|
||||
@@ -120,12 +131,15 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista de CAPs (Centros de Atención Primarios) que tienen una coincidencia parcial en el nombre o en la localización con el termino de búsqueda
|
||||
* (searchTerm) especificado.
|
||||
* Método que devuelve una lista de CAPs (Centros de Atención Primarios) que
|
||||
* tienen una coincidencia parcial en el nombre o en la localización con el
|
||||
* termino de búsqueda (searchTerm) especificado.
|
||||
*
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza
|
||||
* paginación y se devuelven todos los resultados.
|
||||
*
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el parámetro y devuelven todos los CAPs existentes.
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el
|
||||
* parámetro y devuelven todos los CAPs existentes.
|
||||
*
|
||||
* @return Devuelve una Lista de PrimaryHealthCareCenterTO (Transfer Objects).
|
||||
*/
|
||||
@@ -141,7 +155,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
strFilter = "WHERE lower(phc.name) LIKE :searchTerm OR lower(phc.location) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery(String.format(strQuery, strFilter), PrimaryHealthCareCenterJPA.class);
|
||||
TypedQuery<PrimaryHealthCareCenterJPA> query = entman.createQuery(String.format(strQuery, strFilter),
|
||||
PrimaryHealthCareCenterJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
@@ -162,7 +177,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista con todos los médicos de familia registrados en el sistema.
|
||||
* Método que devuelve una lista con todos los médicos de familia registrados en
|
||||
* el sistema.
|
||||
*
|
||||
* @return Devuelve una Lista de FamilyDoctorTO (Transfer Objects).
|
||||
*/
|
||||
@@ -171,9 +187,11 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista con todos los médicos de familia registrados en el sistema de forma paginada.
|
||||
* Método que devuelve una lista con todos los médicos de familia registrados en
|
||||
* el sistema de forma paginada.
|
||||
*
|
||||
* Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
* Si pageSize == 0 no se realiza paginación y se devuelven todos los
|
||||
* resultados.
|
||||
*
|
||||
* @return Devuelve una Lista de FamilyDoctorTO (Transfer Objects).
|
||||
*/
|
||||
@@ -182,11 +200,15 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que devuelve una lista de médicos de familia que tienen una coincidencia parcial en el nombre o en los apellidos con el termino de búsqueda (searchTerm) especificado.
|
||||
* Método que devuelve una lista de médicos de familia que tienen una
|
||||
* coincidencia parcial en el nombre o en los apellidos con el termino de
|
||||
* búsqueda (searchTerm) especificado.
|
||||
*
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza paginación y se devuelven todos los resultados.
|
||||
* Además permite la paginacción de datos. Si pageSize == 0 no se realiza
|
||||
* paginación y se devuelven todos los resultados.
|
||||
*
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el parámetro y devuelven todos los registros existentes.
|
||||
* Si serachTerm es nulo o cadena vacía entonces no se tiene en cuenta el
|
||||
* parámetro y devuelven todos los registros existentes.
|
||||
*
|
||||
* @return Devuelve una Lista de FamilyDoctorTO (Transfer Objects).
|
||||
*/
|
||||
@@ -202,7 +224,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
strFilter = "WHERE lower(fd.name) LIKE :searchTerm OR lower(fd.surname) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery(String.format(strQuery, strFilter), FamilyDoctorJPA.class);
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery(String.format(strQuery, strFilter),
|
||||
FamilyDoctorJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
@@ -259,7 +282,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo MedicalSpecialtyJPA (JPA) a su equivalente MedicalSpecialtyTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo MedicalSpecialtyJPA (JPA) a su
|
||||
* equivalente MedicalSpecialtyTO (Tranfer Object)
|
||||
*
|
||||
* @return MedicalSpecialtyTO (Transfer Object de una especialidad médica)
|
||||
*/
|
||||
@@ -274,7 +298,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo PrimaryHealthCareCenterJPA (JPA) a su equivalente PrimaryHealthCareCenterTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo PrimaryHealthCareCenterJPA (JPA) a su
|
||||
* equivalente PrimaryHealthCareCenterTO (Tranfer Object)
|
||||
*
|
||||
* @return PrimaryHealthCareCenterTO (Transfer Object de un CAP)
|
||||
*/
|
||||
@@ -289,10 +314,14 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo SpecialistDoctorJPA (JPA) a su equivalente SpecialistDoctorTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo SpecialistDoctorJPA (JPA) a su
|
||||
* equivalente SpecialistDoctorTO (Tranfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de
|
||||
* profundidad se debe navegar a través de las propiedades relacionadas para
|
||||
* convertirlas de JPA a TO. Un valor 0 indica que no se convertirá ninguna
|
||||
* propiedad que tenga un entidad JPA relacionada (tendrá valor null en el
|
||||
* objeto TO).
|
||||
*
|
||||
* @return SpecialistDoctorTO (Transfer Object de un médico especialista)
|
||||
*/
|
||||
@@ -305,18 +334,22 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
ms = sd.getMedicalSpecialty();
|
||||
|
||||
nestedProps--;
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(), sd.getSurname(), sd.getPassword(), sd.getEmail(),
|
||||
this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
sdTO = new SpecialistDoctorTO(sd.getId(), sd.getProfessionalNumber(), sd.getNif(), sd.getName(),
|
||||
sd.getSurname(), sd.getPassword(), sd.getEmail(), this.getPOJOforMedicalSpecialtyJPA(ms));
|
||||
}
|
||||
|
||||
return sdTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo FamilyDoctorJPA (JPA) a su equivalente FamilyDoctorTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo FamilyDoctorJPA (JPA) a su
|
||||
* equivalente FamilyDoctorTO (Tranfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de
|
||||
* profundidad se debe navegar a través de las propiedades relacionadas para
|
||||
* convertirlas de JPA a TO. Un valor 0 indica que no se convertirá ninguna
|
||||
* propiedad que tenga un entidad JPA relacionada (tendrá valor null en el
|
||||
* objeto TO).
|
||||
*
|
||||
* @return FamilyDoctorTO (Transfer Object de un médico especialista)
|
||||
*/
|
||||
@@ -329,18 +362,22 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
phc = fd.getPrimaryHealthCareCenter();
|
||||
|
||||
nestedProps--;
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(), fd.getSurname(), fd.getPassword(), fd.getEmail(),
|
||||
this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
fdTO = new FamilyDoctorTO(fd.getId(), fd.getProfessionalNumber(), fd.getNif(), fd.getName(),
|
||||
fd.getSurname(), fd.getPassword(), fd.getEmail(), this.getPOJOforPrimaryHealthCareCenterJPA(phc));
|
||||
}
|
||||
|
||||
return fdTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo PatientJPA (JPA) a su equivalente PatientTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo PatientJPA (JPA) a su equivalente
|
||||
* PatientTO (Tranfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de
|
||||
* profundidad se debe navegar a través de las propiedades relacionadas para
|
||||
* convertirlas de JPA a TO. Un valor 0 indica que no se convertirá ninguna
|
||||
* propiedad que tenga un entidad JPA relacionada (tendrá valor null en el
|
||||
* objeto TO).
|
||||
*
|
||||
* @return PatientTO (Transfer Object de un médico especialista)
|
||||
*/
|
||||
@@ -353,7 +390,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
fd = pat.getFamilyDoctor();
|
||||
|
||||
nestedProps--;
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(), pat.getSurname(), pat.getPassword(), pat.getEmail(),
|
||||
paTO = new PatientTO(pat.getId(), pat.getPersonalIdentificationCode(), pat.getNif(), pat.getName(),
|
||||
pat.getSurname(), pat.getPassword(), pat.getEmail(),
|
||||
this.getPOJOforFamilyDoctorJPA(fd, nestedProps));
|
||||
}
|
||||
|
||||
@@ -361,9 +399,11 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un paciente a partir de su Identificador (Id) de base de datos.
|
||||
* Método que recupera un paciente a partir de su Identificador (Id) de base de
|
||||
* datos.
|
||||
*
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se
|
||||
* encuentra el objeto buscado
|
||||
*/
|
||||
public PatientTO findPatientById(int patientId) {
|
||||
// Recuperamos propiedades anidadas 1 nivel!
|
||||
@@ -371,12 +411,15 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un paciente a partir de su CIP (Código de Identificación de Paciente)
|
||||
* Método que recupera un paciente a partir de su CIP (Código de Identificación
|
||||
* de Paciente)
|
||||
*
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se
|
||||
* encuentra el objeto buscado
|
||||
*/
|
||||
public PatientTO findPatientByCode(String code) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
|
||||
TypedQuery<PatientJPA> query = entman
|
||||
.createQuery("from PatientJPA pat where pat.personalIdentificationCode=:code", PatientJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("code", code);
|
||||
|
||||
@@ -390,7 +433,8 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Método que recupera un paciente a partir de su NIF
|
||||
*
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return PatientTO (Transfer Object del objeto recuperado) o null si no se
|
||||
* encuentra el objeto buscado
|
||||
*/
|
||||
public PatientTO findPatientByNif(String searchedNIF) {
|
||||
TypedQuery<PatientJPA> query = entman.createQuery("from PatientJPA pat where pat.nif=:nif", PatientJPA.class);
|
||||
@@ -405,21 +449,26 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un médico de familia a partir de su Identificador (Id) de base de datos.
|
||||
* Método que recupera un médico de familia a partir de su Identificador (Id) de
|
||||
* base de datos.
|
||||
*
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no
|
||||
* se encuentra el objeto buscado
|
||||
*/
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforFamilyDoctorJPA(entman.find(FamilyDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un médico de familia a partir de su NP (Número de profesional)
|
||||
* Método que recupera un médico de familia a partir de su NP (Número de
|
||||
* profesional)
|
||||
*
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no
|
||||
* se encuentra el objeto buscado
|
||||
*/
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
|
||||
TypedQuery<FamilyDoctorJPA> query = entman
|
||||
.createQuery("from FamilyDoctorJPA d where d.professionalNumber=:code", FamilyDoctorJPA.class);
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
@@ -433,10 +482,12 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Método que recupera un médico de familia a partir de su NIF
|
||||
*
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return FamilyDoctorTO (Transfer Object del objeto recuperado) o null si no
|
||||
* se encuentra el objeto buscado
|
||||
*/
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchedNIF) {
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif", FamilyDoctorJPA.class);
|
||||
TypedQuery<FamilyDoctorJPA> query = entman.createQuery("from FamilyDoctorJPA d where d.nif=:nif",
|
||||
FamilyDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchedNIF);
|
||||
|
||||
@@ -448,21 +499,26 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un médico especialista a partir de su Identificador (Id) de base de datos.
|
||||
* Método que recupera un médico especialista a partir de su Identificador (Id)
|
||||
* de base de datos.
|
||||
*
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si
|
||||
* no se encuentra el objeto buscado
|
||||
*/
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId) {
|
||||
return this.getPOJOforSpecialistDoctorJPA(entman.find(SpecialistDoctorJPA.class, ProfessionalNumberId), 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que recupera un médico especialista a partir de su NP (Número de profesional)
|
||||
* Método que recupera un médico especialista a partir de su NP (Número de
|
||||
* profesional)
|
||||
*
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si
|
||||
* no se encuentra el objeto buscado
|
||||
*/
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman
|
||||
.createQuery("from SpecialistDoctorJPA d where d.professionalNumber=:code", SpecialistDoctorJPA.class);
|
||||
|
||||
query.setParameter("code", code);
|
||||
|
||||
@@ -476,10 +532,12 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
/**
|
||||
* Método que recupera un médico especialista a partir de su NIF
|
||||
*
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return SpecialistDoctorTO (Transfer Object del objeto recuperado) o null si
|
||||
* no se encuentra el objeto buscado
|
||||
*/
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchedNIF) {
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif", SpecialistDoctorJPA.class);
|
||||
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery("from SpecialistDoctorJPA d where d.nif=:nif",
|
||||
SpecialistDoctorJPA.class);
|
||||
query.setMaxResults(1);
|
||||
query.setParameter("nif", searchedNIF);
|
||||
|
||||
@@ -491,12 +549,17 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo QuestionJPA (JPA) a su equivalente QuestionTO (Tranfer Object)
|
||||
* Método que convierte un objecto de tipo QuestionJPA (JPA) a su equivalente
|
||||
* QuestionTO (Tranfer Object)
|
||||
*
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de profundidad se debe navegar a través de las propiedades relacionadas para convertirlas de JPA a TO. Un
|
||||
* valor 0 indica que no se convertirá ninguna propiedad que tenga un entidad JPA relacionada (tendrá valor null en el objeto TO).
|
||||
* El parámetro nestedProps es un valor entero que indica a que nivel de
|
||||
* profundidad se debe navegar a través de las propiedades relacionadas para
|
||||
* convertirlas de JPA a TO. Un valor 0 indica que no se convertirá ninguna
|
||||
* propiedad que tenga un entidad JPA relacionada (tendrá valor null en el
|
||||
* objeto TO).
|
||||
*
|
||||
* @return QuestionTO (Transfer Object del objeto recuperado) o null si no se encuentra el objeto buscado
|
||||
* @return QuestionTO (Transfer Object del objeto recuperado) o null si no se
|
||||
* encuentra el objeto buscado
|
||||
*/
|
||||
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps) {
|
||||
QuestionTO qsTO = null;
|
||||
@@ -510,8 +573,9 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
nestedProps--;
|
||||
qsTO = new QuestionTO(qs.getId(), qs.getTitle(), qs.getMessage(), qs.getStatus(), this.getPOJOforPatientJPA(pat, nestedProps),
|
||||
this.getPOJOforFamilyDoctorJPA(fd, nestedProps), qs.getResponse());
|
||||
qsTO = new QuestionTO(qs.getId(), qs.getTitle(), qs.getMessage(), qs.getStatus(),
|
||||
this.getPOJOforPatientJPA(pat, nestedProps), this.getPOJOforFamilyDoctorJPA(fd, nestedProps),
|
||||
qs.getResponse());
|
||||
}
|
||||
|
||||
return qsTO;
|
||||
@@ -529,8 +593,27 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
}
|
||||
|
||||
nestedProps--;
|
||||
qsTO = new VisitTO(vi.getId(), vi.getDate(), vi.getTime(), vi.getObservations(), vi.getResult(), this.getPOJOforFamilyDoctorJPA(fd, nestedProps),
|
||||
this.getPOJOforPatientJPA(pat, nestedProps));
|
||||
qsTO = new VisitTO(vi.getId(), vi.getDate(), vi.getTime(), vi.getObservations(), vi.getResult(),
|
||||
this.getPOJOforFamilyDoctorJPA(fd, nestedProps), this.getPOJOforPatientJPA(pat, nestedProps));
|
||||
}
|
||||
|
||||
return qsTO;
|
||||
}
|
||||
|
||||
public MedicalTestTO getPOJOforMedicalTestJPA(MedicalTestJPA vi, int nestedProps) {
|
||||
MedicalTestTO qsTO = null;
|
||||
|
||||
if (vi != null) {
|
||||
SpecialistDoctorJPA fd = null;
|
||||
PatientJPA pat = null;
|
||||
if (nestedProps > 0) {
|
||||
fd = vi.getSpecialistDoctor();
|
||||
pat = vi.getPatient();
|
||||
}
|
||||
|
||||
nestedProps--;
|
||||
qsTO = new MedicalTestTO(vi.getId(), vi.getDate(), vi.getTime(), vi.getObservations(), vi.getHighresimage(), vi.getType(),
|
||||
this.getPOJOforPatientJPA(pat, nestedProps), this.getPOJOforSpecialistDoctorJPA(fd, nestedProps));
|
||||
}
|
||||
|
||||
return qsTO;
|
||||
|
||||
@@ -6,6 +6,7 @@ import javax.ejb.Local;
|
||||
|
||||
import TO.FamilyDoctorTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import TO.QuestionTO;
|
||||
@@ -13,6 +14,7 @@ import TO.SpecialistDoctorTO;
|
||||
import TO.VisitTO;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.MedicalTestJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.PrimaryHealthCareCenterJPA;
|
||||
import jpa.QuestionJPA;
|
||||
@@ -79,5 +81,7 @@ public interface CommonFacadeLocal {
|
||||
|
||||
public QuestionTO getPOJOforQuestionJPA(QuestionJPA qs, int nestedProps);
|
||||
|
||||
public MedicalTestTO getPOJOforMedicalTestJPA(MedicalTestJPA mt, int nestedProps);
|
||||
|
||||
public VisitTO getPOJOforVisitJPA(VisitJPA qs, int nestedProps);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ejb.medicalTest;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -10,11 +11,14 @@ import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import TO.QuestionTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.MedicalTestType;
|
||||
import common.QuestionStatus;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.MedicalTestJPA;
|
||||
import jpa.PatientJPA;
|
||||
import jpa.QuestionJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
@@ -152,16 +156,22 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
/**
|
||||
* Añadir pruebas médicas a una cita
|
||||
*
|
||||
* Sólo médicos especialistas pueden gestionar pruebas médicas en el sistema.
|
||||
* Dado que será añadida por el médico especialista en sesión no hace falta más información.
|
||||
*
|
||||
* @param idMedicalTest
|
||||
* @param patientiID
|
||||
* @param date
|
||||
* @param time
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias
|
||||
* magnéticas y TAC
|
||||
* @param observations
|
||||
*/
|
||||
public void addMedicalTest(int idMedicalTest, Date date, long time, MedicalTestType testType, String observations) {
|
||||
public void addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations) {
|
||||
SpecialistDoctorJPA specDoctor = entman.find(SpecialistDoctorJPA.class, doctorSpecialistID);
|
||||
PatientJPA pat = entman.find(PatientJPA.class, patientID);
|
||||
|
||||
MedicalTestJPA mt = new MedicalTestJPA(0, date, time, observations, null, testType, pat, specDoctor);
|
||||
|
||||
entman.persist(mt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +181,19 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
*
|
||||
* @param idMedicalTest
|
||||
*/
|
||||
public void getMedicalTest(int idMedicalTest) {
|
||||
public MedicalTestTO getMedicalTest(int idMedicalTest) {
|
||||
MedicalTestTO resp = new MedicalTestTO();
|
||||
|
||||
resp = commonServices.getPOJOforMedicalTestJPA(this.getMedicalTestJPA(idMedicalTest), 1);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private MedicalTestJPA getMedicalTestJPA(int idMedicalTest) {
|
||||
TypedQuery<MedicalTestJPA> query = entman.createQuery("SELECT q from MedicalTestJPA q where q.id=:idMedicalTest",
|
||||
MedicalTestJPA.class);
|
||||
query.setParameter("idMedicalTest", idMedicalTest);
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +203,10 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param image
|
||||
*/
|
||||
public void addImage(int idMedicalTest, String image) {
|
||||
MedicalTestJPA mt = this.getMedicalTestJPA(idMedicalTest);
|
||||
mt.setHighresimage(image);
|
||||
|
||||
entman.persist(mt);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,6 +216,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param image
|
||||
*/
|
||||
public void updateImage(int idMedicalTest, String image) {
|
||||
this.addImage(idMedicalTest, image);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -198,6 +225,10 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
* @param idMedicalTest
|
||||
*/
|
||||
public void removeImage(int idMedicalTest) {
|
||||
MedicalTestJPA mt = this.getMedicalTestJPA(idMedicalTest);
|
||||
mt.setHighresimage(null);
|
||||
|
||||
entman.persist(mt);
|
||||
}
|
||||
|
||||
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId) {
|
||||
@@ -236,4 +267,124 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
|
||||
return pendingQuestions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MedicalTestTO> loadMedicalTestForPatient(int patientID) {
|
||||
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
|
||||
|
||||
TypedQuery<MedicalTestJPA> query = entman.createQuery(
|
||||
"SELECT q from MedicalTestJPA q where q.patient.id=:patientId order by q.id desc",
|
||||
MedicalTestJPA.class);
|
||||
|
||||
query.setParameter("patientId", patientID);
|
||||
|
||||
List<MedicalTestJPA> allJPA = query.getResultList();
|
||||
|
||||
for (MedicalTestJPA item : allJPA) {
|
||||
medicalTests.add(commonServices.getPOJOforMedicalTestJPA(item, 1));
|
||||
}
|
||||
|
||||
return medicalTests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID) {
|
||||
return this.loadMedicalTestForFamilyDoctor(familyDoctorID, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID) {
|
||||
return this.loadMedicalTestForSpecialistDoctor(specialistDoctorID, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID, int patientID) {
|
||||
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
|
||||
String extraQuery = "";
|
||||
|
||||
if(patientID > 0) {
|
||||
extraQuery = " and q.patient.id=:patientID";
|
||||
}
|
||||
|
||||
TypedQuery<MedicalTestJPA> query = entman.createQuery(
|
||||
"SELECT q from MedicalTestJPA q where q.patient.familyDoctor.id=:familyDoctorID " + extraQuery + " order by q.id desc",
|
||||
MedicalTestJPA.class);
|
||||
if(patientID > 0) {
|
||||
query.setParameter("patientID", patientID);
|
||||
}
|
||||
query.setParameter("familyDoctorID", familyDoctorID);
|
||||
|
||||
List<MedicalTestJPA> allJPA = query.getResultList();
|
||||
|
||||
for (MedicalTestJPA item : allJPA) {
|
||||
medicalTests.add(commonServices.getPOJOforMedicalTestJPA(item, 1));
|
||||
}
|
||||
|
||||
return medicalTests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, int patientID) {
|
||||
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
|
||||
String extraQuery = "";
|
||||
|
||||
if(patientID > 0) {
|
||||
extraQuery = " and q.patient.id=:patientID";
|
||||
}
|
||||
|
||||
TypedQuery<MedicalTestJPA> query = entman.createQuery(
|
||||
"SELECT q from MedicalTestJPA q where q.specialistDoctor.id=:specialistDoctorID " + extraQuery + " order by q.id desc",
|
||||
MedicalTestJPA.class);
|
||||
|
||||
if(patientID > 0) {
|
||||
query.setParameter("patientID", patientID);
|
||||
}
|
||||
query.setParameter("specialistDoctorID", specialistDoctorID);
|
||||
|
||||
List<MedicalTestJPA> allJPA = query.getResultList();
|
||||
|
||||
for (MedicalTestJPA item : allJPA) {
|
||||
medicalTests.add(commonServices.getPOJOforMedicalTestJPA(item, 1));
|
||||
}
|
||||
|
||||
return medicalTests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PatientTO> loadPatientsForSpecialistDoctor(int specialistDoctorID) {
|
||||
List<PatientTO> medicalTests = new ArrayList<PatientTO>();
|
||||
|
||||
TypedQuery<PatientJPA> query = entman.createQuery(
|
||||
"SELECT distinct q.patient from MedicalTestJPA q where q.specialistDoctor.id=:specialistDoctorID",
|
||||
PatientJPA.class);
|
||||
|
||||
query.setParameter("specialistDoctorID", specialistDoctorID);
|
||||
|
||||
List<PatientJPA> allJPA = query.getResultList();
|
||||
|
||||
for (PatientJPA item : allJPA) {
|
||||
medicalTests.add(commonServices.getPOJOforPatientJPA(item, 1));
|
||||
}
|
||||
|
||||
return medicalTests;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PatientTO> loadPatientsForFamilyDoctor(int familyDoctorID) {
|
||||
List<PatientTO> medicalTests = new ArrayList<PatientTO>();
|
||||
|
||||
TypedQuery<PatientJPA> query = entman.createQuery(
|
||||
"SELECT distinct q.patient from MedicalTestJPA q where q.patient.familyDoctor.id=:familyDoctorID",
|
||||
PatientJPA.class);
|
||||
|
||||
query.setParameter("familyDoctorID", familyDoctorID);
|
||||
|
||||
List<PatientJPA> allJPA = query.getResultList();
|
||||
|
||||
for (PatientJPA item : allJPA) {
|
||||
medicalTests.add(commonServices.getPOJOforPatientJPA(item, 1));
|
||||
}
|
||||
|
||||
return medicalTests;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
package ejb.medicalTest;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ejb.Remote;
|
||||
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import TO.QuestionTO;
|
||||
import TO.SpecialistDoctorTO;
|
||||
import common.MedicalTestType;
|
||||
@@ -62,8 +65,23 @@ public interface MedicalTestFacadeRemote {
|
||||
// ********************************************************************* MEDICAL
|
||||
// TEST
|
||||
|
||||
public List<MedicalTestTO> loadMedicalTestForPatient(int patientID);
|
||||
|
||||
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID);
|
||||
|
||||
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID);
|
||||
|
||||
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID, int patientID);
|
||||
|
||||
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, int patientID);
|
||||
|
||||
public List<PatientTO> loadPatientsForSpecialistDoctor(int specialistDoctorID);
|
||||
|
||||
public List<PatientTO> loadPatientsForFamilyDoctor(int familyDoctorID);
|
||||
|
||||
/**
|
||||
* Añadir una prueba médica a un paciente
|
||||
* Dado que será añadida por el médico especialista en sesión no hace falta más información.
|
||||
*
|
||||
* @param idMedicalTest
|
||||
* @param date
|
||||
@@ -71,14 +89,14 @@ public interface MedicalTestFacadeRemote {
|
||||
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
|
||||
* @param observations
|
||||
*/
|
||||
public void addMedicalTest(int id, Date date, long time, MedicalTestType testType, String observations);
|
||||
public void addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations);
|
||||
|
||||
/**
|
||||
* Recuperar una prueba médica por ID
|
||||
*
|
||||
* @param idMedicalTest
|
||||
*/
|
||||
public void getMedicalTest(int idPatient);
|
||||
public MedicalTestTO getMedicalTest(int idPatient);
|
||||
|
||||
/**
|
||||
* Añadir una imagen a una prueba médica
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package jpa;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
@@ -36,7 +37,7 @@ public class MedicalTestJPA implements Serializable {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private Date date;
|
||||
private long time;
|
||||
private LocalTime time;
|
||||
private String observations;
|
||||
private String highresimage;
|
||||
@Enumerated(EnumType.STRING)
|
||||
@@ -56,7 +57,7 @@ public class MedicalTestJPA implements Serializable {
|
||||
super();
|
||||
}
|
||||
|
||||
public MedicalTestJPA(int id, Date date, long time, String observations, String highresimage, MedicalTestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
|
||||
public MedicalTestJPA(int id, Date date, LocalTime time, String observations, String highresimage, MedicalTestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.time = time;
|
||||
@@ -83,11 +84,11 @@ public class MedicalTestJPA implements Serializable {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
public LocalTime getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
public void setTime(LocalTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,194 @@
|
||||
package managedbean.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.component.html.HtmlSelectOneMenu;
|
||||
import javax.faces.event.AjaxBehaviorEvent;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import org.primefaces.event.SelectEvent;
|
||||
|
||||
@Named("MedicalTestMBean")
|
||||
@RequestScoped
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@Named("mt")
|
||||
@ViewScoped
|
||||
public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private int userID;
|
||||
private UserType userType;
|
||||
private List<MedicalTestTO> medicalTests;
|
||||
private MedicalTestTO selected;
|
||||
private PatientTO patSelected;
|
||||
private boolean addNewMode = false;
|
||||
|
||||
public MedicalTestMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Inicialización de variables y propiedades van aquí.
|
||||
this.userType = SessionUtils.getUserType();
|
||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||
|
||||
// Como realizar llamadas al EJB Remoto
|
||||
// this.getRemoteManagerSystemAdmin().MetodoEJB
|
||||
this.selected = null;
|
||||
this.patSelected = null;
|
||||
|
||||
this.loadMedicalTests();
|
||||
this.getPatients();
|
||||
}
|
||||
|
||||
public void addMedicalTest() {
|
||||
getRemoteManagerMedicalTest().addMedicalTest(this.selected.getPatient().getId(), userID,
|
||||
this.selected.getDate(), this.selected.getTime(), this.selected.getType(),
|
||||
this.selected.getObservations());
|
||||
}
|
||||
|
||||
public void addImage() {
|
||||
getRemoteManagerMedicalTest().addImage(this.selected.getId(), this.selected.getHighresimage());
|
||||
}
|
||||
|
||||
public void updateImage() {
|
||||
getRemoteManagerMedicalTest().updateImage(this.selected.getId(), this.selected.getHighresimage());
|
||||
}
|
||||
|
||||
public void removeImage() {
|
||||
getRemoteManagerMedicalTest().removeImage(this.selected.getId());
|
||||
}
|
||||
|
||||
public MedicalTestTO getSelected() {
|
||||
return this.selected;
|
||||
}
|
||||
|
||||
public void setSelected(MedicalTestTO selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public PatientTO getPatSelected() {
|
||||
return this.patSelected;
|
||||
}
|
||||
|
||||
public void setPatSelected(PatientTO s) {
|
||||
this.patSelected = s;
|
||||
}
|
||||
|
||||
public void loadMedicalTests() {
|
||||
if (userType == UserType.PATIENT) {
|
||||
// Cargar las pruebas para el paciente en sesión
|
||||
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForPatient(userID);
|
||||
} else if (userType == UserType.SPECIALIST_DOCTOR) {
|
||||
// Cargar las pruebas que el doctor especialista ha creado
|
||||
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForSpecialistDoctor(userID);
|
||||
} else if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Cargar las pruebas para los pacientes del doctor de familia en sesión
|
||||
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID);
|
||||
} else {
|
||||
// Nothing todo
|
||||
this.medicalTests = new ArrayList<MedicalTestTO>();
|
||||
}
|
||||
System.out.println(this.medicalTests);
|
||||
}
|
||||
|
||||
public List<PatientTO> getPatients() {
|
||||
if (userType == UserType.SPECIALIST_DOCTOR) {
|
||||
// Cargar los pacientes a los que ha añadido pruebas médicas el médico especialista
|
||||
return getRemoteManagerMedicalTest().loadPatientsForSpecialistDoctor(userID);
|
||||
} else if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Cargar los pacientes del médico de familia que tiene pruebas médicas hechas
|
||||
return getRemoteManagerMedicalTest().loadPatientsForFamilyDoctor(userID);
|
||||
} else {
|
||||
// Nothing todo
|
||||
return new ArrayList<PatientTO>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MedicalTestTO> getMedicalTests() {
|
||||
return this.medicalTests;
|
||||
}
|
||||
|
||||
public void setMedicalTests(List<MedicalTestTO> list) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/*************************************************** METODOS PARA LA VISTA */
|
||||
private Integer patIdSelected = -1;
|
||||
public void setPatIdSelected(Integer value) {
|
||||
this.patIdSelected = value;
|
||||
this.addNewMode = false;
|
||||
}
|
||||
|
||||
public Integer getPatIdSelected() {
|
||||
return this.patIdSelected;
|
||||
}
|
||||
|
||||
public String getTitlePanel() {
|
||||
String res;
|
||||
if (userType == UserType.PATIENT) {
|
||||
// Cargar las pruebas para el paciente en sesión
|
||||
res = "Realizadas al paciente: " + SessionUtils.getloggedOnUser().getName();
|
||||
} else if (userType == UserType.SPECIALIST_DOCTOR) {
|
||||
// Cargar las pruebas que el doctor especialista ha creado
|
||||
res = "Solicitadas por el médico especialista: " + SessionUtils.getloggedOnUser().getName();
|
||||
} else if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Cargar las pruebas para los pacientes del doctor de familia en sesión
|
||||
res = "Pacientes del médico de familia: " + SessionUtils.getloggedOnUser().getName();
|
||||
} else {
|
||||
// Nothing todo
|
||||
res = "Error";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public boolean isPatSelector() {
|
||||
return !(userType == UserType.PATIENT);
|
||||
}
|
||||
|
||||
public void onSelectPatient(AjaxBehaviorEvent event) {
|
||||
this.selected = null;
|
||||
if (userType == UserType.SPECIALIST_DOCTOR) {
|
||||
// Cargar las pruebas que el doctor especialista ha creado
|
||||
medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForSpecialistDoctor(userID, this.patIdSelected);
|
||||
} else if (userType == UserType.FAMILY_DOCTOR) {
|
||||
// Cargar las pruebas para los pacientes del doctor de familia en sesión
|
||||
medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID, this.patIdSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSelectMT(SelectEvent event) {
|
||||
this.selected = (MedicalTestTO) event.getObject();
|
||||
this.addNewMode = false;
|
||||
}
|
||||
|
||||
public void addMT() {
|
||||
this.selected = new MedicalTestTO();
|
||||
this.selected.setId(-1);
|
||||
this.selected.setObservations("");
|
||||
this.addNewMode = true;
|
||||
}
|
||||
|
||||
public boolean isAddNewMode() {
|
||||
return addNewMode;
|
||||
}
|
||||
|
||||
public void setAddNewMode(boolean addNewMode) {
|
||||
this.addNewMode = addNewMode;
|
||||
}
|
||||
|
||||
public boolean getViewCreate() {
|
||||
return addNewMode;
|
||||
}
|
||||
|
||||
public boolean getViewEdit() {
|
||||
return !addNewMode && this.selected != null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user