This commit is contained in:
Alejandro Linares Amado
2019-12-29 22:10:38 +01:00
9 changed files with 353 additions and 272 deletions

View File

@@ -1,10 +1,7 @@
<?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"
<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">
@@ -15,33 +12,41 @@
<h:form id="frmMT">
<p:panel id="mainPanel" header="Pruebas médicas">
<f:facet name="actions">
<h:commandLink rendered="#{mt.specialistDoctor}"
action="#{mt.addMT}" immediate="true" update="frmMT"
styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
<h:commandLink rendered="#{mt.specialistDoctor}" action="#{mt.addMT}" immediate="true" update="frmMT" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
<h:outputText styleClass="ui-icon pi pi-plus" />
</h:commandLink>
<h:commandLink rendered="#{mt.patSelector}" action="#{mt.clearFilteredPatient}" immediate="true" update="frmMT" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
<h:outputText styleClass="ui-icon pi pi-times-circle" title="Quitar filtro y ver todos los registros" />
</h:commandLink>
</f:facet>
<p:selectOneMenu rendered="#{mt.specialistDoctor}" 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,frmNEW,frmImage" />
<o:converter converterId="omnifaces.ListConverter"
list="#{mt.medicalTests}" />
<p:autoComplete rendered="#{mt.patSelector}" id="filterPatient" widgetVar="filterPatient" dropdown="true" value="#{mt.patientFilterSelected}" completeMethod="#{mt.completePatientFilter}" var="p"
itemLabel="#{p.displayName}" itemValue="#{p}" forceSelection="true" placeholder="Seleccione un paciente o teclee para buscar...">
<o:converter converterId="omnifaces.ListConverter" list="#{mt.patientWithTestList}" />
<f:selectItem itemLabel="Ver todos" itemValue="">
<p:column headerText="Num. Prof.">
<h:outputText value="Ver todos" />
</p:column>
</f:selectItem>
<p:column headerText="Num. Prof.">
<h:outputText value="#{p.personalIdentificationCode}" />
</p:column>
<p:column headerText="Nombre">
<h:outputText value="#{p.name}" />
</p:column>
<p:column headerText="Apellidos">
<h:outputText value="#{p.surname}" />
</p:column>
<p:ajax event="itemSelect" listener="#{mt.onSelectPatient}" update="medicalTestList" />
<p:ajax event="change" listener="#{mt.onChangePatient}" update="medicalTestList" />
</p:autoComplete>
<p:orderList id="medicalTestList" value="#{mt.medicalTests}" var="el" itemValue="#{el}" controlsLocation="none" responsive="true">
<p:ajax event="select" listener="#{mt.onSelectMT}" update="frmNEW,frmImage" />
<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;" />
<h:outputText rendered="#{mt.patientFilterSelected == null}" value="#{el.patient.displayName}" style="font-size: 0.8em !important; font-style: italic;" />
</p:column>
</p:orderList>
</p:panel>
@@ -49,76 +54,109 @@
</div>
<div class="ui-g-7 ui-md-7">
<h:form id="frmImage" enctype="multipart/form-data">
<p:panel rendered="#{mt.viewEdit}" id="detailPanel"
header="Detalle de prueba médica">
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Sí" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="pi pi-times" />
</p:confirmDialog>
<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 class="ui-g-3">Fecha:</div>
<div class="ui-g-9">
<h:outputText value="#{mt.selected.date}" />
</div>
<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 class="ui-g-3">Hora:</div>
<div class="ui-g-9">
<h:outputText value="#{mt.selected.time}" />
</div>
<div class="ui-g-4 ui-md-4">Observaciones:</div>
<div class="ui-g-8 ui-md-8">
<h:outputText escape="false" value="#{mt.selected.observations}"></h:outputText>
<div class="ui-g-3">Observaciones:</div>
<div class="ui-g-9">
<h:outputText escape="false" value="#{mt.selected.observations}" />
</div>
<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 class="ui-g-3">Tipo de prueba:</div>
<div class="ui-g-9">
<h:outputText value="#{mt.selected.type.testTypeName}" />
</div>
<div class="ui-g-4 ui-md-4">Imagen de alta resolución:</div>
<div class="ui-g-8 ui-md-8">
<div class="ui-g-12 ui-md-12">
<p:fileUpload rendered="#{mt.specialistDoctor}" value="#{mt.imageUpload}" mode="simple" skinSimple="true" />
<p:commandButton rendered="#{mt.specialistDoctor}" value="Subir imagen" ajax="false" action="#{mt.addImage}" update="frmImage"/>
</div>
<div class="ui-g-12 ui-md-12">
<img src="#{mt.selected.highresimage}" style="max-width: 300px !important;"></img>
</div>
<div class="ui-g-12 ui-md-12">
<p:commandButton rendered="#{mt.specialistDoctor}" action="#{mt.removeImage}"
disabled="#{mt.selected.highresimage == null}"
value="Eliminar" icon="pi pi-delete" update="frmImage"/>
</div>
<div class="ui-g-12">
<p:outputPanel rendered="#{mt.selected.type != 'BLOOD_TEST'}">
<div class="ui-g ui-fluid">
<div class="ui-g-3">Imagen de alta resolución:</div>
<div class="ui-g-5">
<p:fileUpload rendered="#{mt.specialistDoctor}" value="#{mt.imageUpload}" mode="simple" skinSimple="true" />
</div>
<div class="ui-g-2">
<p:commandButton rendered="#{mt.specialistDoctor}" value="Subir" icon="pi pi-upload" ajax="false" action="#{mt.addImage}" update="frmImage" />
</div>
<div class="ui-g-2">
<p:commandButton rendered="#{mt.specialistDoctor}" value="Eliminar" icon="pi pi-trash" action="#{mt.removeImage}" disabled="#{mt.selected.highresimage == null}"
update="frmImage">
<p:confirm header="Confirme la eliminación" message="¿Está seguro de que desea eliminar la imagen?" icon="pi pi-exclamation-triangle" />
</p:commandButton>
</div>
<div class="ui-g-12 ui-md-12" style="align-content: center; text-align: center;">
<img src="#{mt.selected.highresimage}" style="max-width: 300px !important;" />
</div>
</div>
</p:outputPanel>
</div>
</div>
</p:panel>
</h:form>
<h:form id="frmNEW">
<p:panel rendered="#{mt.viewCreate}" id="createPanel"
header="Detalle de prueba médica">
<p:growl id="mesgs" showDetail="true" closable="true" autoupdate="true" />
<p:panel rendered="#{mt.viewCreate}" id="createPanel" header="Añadir una nueva 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 class="ui-g-3">Paciente:</div>
<div class="ui-g-9">
<p:autoComplete id="addTestPatient" dropdown="true" value="#{mt.patSelected}" completeMethod="#{mt.completePatient}" var="p" itemLabel="#{p.displayName}" itemValue="#{p}"
forceSelection="true" placeholder="Seleccione un paciente o teclee para buscar..." required="true"
requiredMessage="Por favor, seleccione un paciente al cual aádir la prueba.">
<o:converter converterId="omnifaces.ListConverter" list="#{mt.patientList}" />
<p:column headerText="Num. Prof.">
<h:outputText value="#{p.personalIdentificationCode}" />
</p:column>
<p:column headerText="Nombre">
<h:outputText value="#{p.name}" />
</p:column>
<p:column headerText="Apellidos">
<h:outputText value="#{p.surname}" />
</p:column>
</p:autoComplete>
</div>
<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 class="ui-g-3">Fecha:</div>
<div class="ui-g-9">
<p:datePicker id="fecha" value="#{mt.selected.date}" pattern="dd/MM/yyyy" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
requiredMessage="Especifique la fecha de la prueba médica" />
</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 class="ui-g-3">Hora:</div>
<div class="ui-g-9">
<p:datePicker id="hora" value="#{mt.selected.time}" timeOnly="true" pattern="HH:mm" showIcon="true" showButtonBar="true" autocomplete="true" required="true"
requiredMessage="Especifique la hora de la prueba médica">
<f:convertDateTime type="localTime" pattern="HH:mm" />
</p:datePicker>
</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.medicalTestTypeSelected}">
<f:selectItems value="#{mt.medicalTestTypes}" var="el"
itemLabel="#{el.testTypeName}" itemValue="#{el.name}" />
<div class="ui-g-3">Observaciones:</div>
<div class="ui-g-9">
<p:textEditor value="#{mt.selected.observations}" required="true" requiredMessage="Debe indicar las observaciones de la prueba" />
</div>
<div class="ui-g-3">Tipo de prueba:</div>
<div class="ui-g-9">
<p:selectOneMenu id="selUsertype" value="#{mt.selected.type}" required="true" unselectable="false" requiredMessage="Debe especificar un tipo de prueba médica">
<f:selectItems value="#{mt.medicalTestTypes}" var="item" itemLabel="#{item.testTypeName}" />
</p:selectOneMenu>
</div>
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-4 ui-md-4">
<p:commandButton value="Guardar" action="#{mt.save}"
icon="pi pi-save" update="frmMT,frmImage,frmNEW" />
<div class="ui-g-4 ui-md-5" />
<div class="ui-g-4 ui-md-2">
<p:commandButton value="Guardar" action="#{mt.save}" icon="pi pi-save" update="frmMT,frmImage,frmNEW" />
</div>
<div class="ui-g-4 ui-md-4"></div>
<div class="ui-g-4 ui-md-5" />
</div>
</p:panel>
</h:form>

View File

@@ -35,15 +35,20 @@
</p:column>
<p:column style="width:80px; text-align: center;" headerText="Eliminar">
<p:commandLink onclick="if (! confirm('¿Seguro que quiere borrar el CAP?')) return false" ajax="true" action="#{ManageHealthCareCenters.deleteDataById(cap.id)}" update=":frmListCAPs:mesgsList frmListCAPs" process="frmListCAPs">
<span title="Borrar" class="fa fa-remove"/>
</p:commandLink>
<p:commandLink class="pi pi-trash" actionListener="#{ManageHealthCareCenters.deleteDataById(cap.id)}" update=":frmListCAPs:mesgsList frmListCAPs">
<p:confirm header="Eliminar" message="¿Está seguro de que quiere borrar el centro?" icon="pi pi-exclamation-triangle"/>
</p:commandLink>
</p:column>
<f:facet name="paginatorBottomLeft">
<p:commandButton type="button" icon="pi pi-refresh" onclick="PF('dtCAP').getPaginator().setPage(0);" />
</f:facet>
</p:dataTable>
<p:confirmDialog global="true">
<p:commandButton value="Sí" type="button" styleClass="ui-confirmdialog-yes" icon="pi pi-check"/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="pi pi-times"/>
</p:confirmDialog>
</div>
</p:panel>
</h:form>

View File

@@ -86,14 +86,11 @@
</p:dataTable>
<div class="ui-g-12 ui-g-nopad">
<div class="ui-g-4 ui-md-4" />
<div class="ui-g-2 ui-md-2 ">
</div>
<div class="ui-g-4 ui-md-5" />
<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-5" />
</div>
</div>
</p:panel>

View File

@@ -71,15 +71,11 @@
</p:dataTable>
<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="Consultar" update="frmVisitList" action="#{VisitList.showData}" icon="pi pi-check" />
</div>
<div class="ui-g-4 ui-md-5" />
<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-5" />
</div>
</div>
</p:panel>

View File

@@ -17,6 +17,7 @@ import TO.QuestionTO;
import TO.SpecialistDoctorTO;
import common.MedicalTestType;
import common.QuestionStatus;
import common.Utils;
import ejb.common.CommonFacadeLocal;
import jpa.MedicalTestJPA;
import jpa.PatientJPA;
@@ -24,12 +25,10 @@ import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA;
/**
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los
* métodos de la capa de negocio que implementan la logica de negocio y la
* interacción con la capa de persistencia.
* EJB Session Bean Class para la Practica 2, Ejercicio 1 (ISCSD) Implementa los métodos de la capa de negocio que implementan la logica de negocio y la interacción con la capa de
* persistencia.
*
* Tanto los pacientes como los médicos deben acceder a la vista de pruebas
* médicas.
* Tanto los pacientes como los médicos deben acceder a la vista de pruebas médicas.
*
* @author rorden
*
@@ -96,9 +95,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
// 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);
TypedQuery<QuestionJPA> query = entman.createQuery(
"SELECT q from QuestionJPA q where q.familyDoctor.id=:docId order by q.status desc, q.title asc",
QuestionJPA.class);
TypedQuery<QuestionJPA> 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);
@@ -117,9 +114,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
// 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);
TypedQuery<QuestionJPA> query = entman.createQuery(
"SELECT q from QuestionJPA q where q.patient.id=:patientId order by q.status desc, q.title asc",
QuestionJPA.class);
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.patient.id=:patientId order by q.status desc, q.title asc", QuestionJPA.class);
// query.setParameter("status", QuestionStatus.PENDING);
query.setParameter("patientId", userId);
@@ -140,8 +135,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
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);
TypedQuery<QuestionJPA> query = entman.createQuery("SELECT q from QuestionJPA q where q.id=:idquestion", QuestionJPA.class);
query.setParameter("idquestion", idQuestion);
@@ -156,29 +150,23 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
/**
* Añadir pruebas médicas a una cita
*
* Dado que será añadida por el médico especialista en sesión no hace falta más
* información.
* Dado que será añadida por el médico especialista en sesión no hace falta más información.
*
* @param patientiID
* @param date
* @param time
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias
* magnéticas y TAC
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
* @param observations
*/
public String addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time,
MedicalTestType testType, String observations) {
try {
SpecialistDoctorJPA specDoctor = entman.find(SpecialistDoctorJPA.class, doctorSpecialistID);
PatientJPA pat = entman.find(PatientJPA.class, patientID);
public MedicalTestTO addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations) throws Exception {
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);
MedicalTestJPA mt = new MedicalTestJPA(date, time, observations, null, testType, pat, specDoctor);
entman.persist(mt);
return "ok";
} catch (Exception ex) {
return ex.getMessage();
}
entman.persist(mt);
return this.commonServices.getPOJOforMedicalTestJPA(mt, 1);
}
/**
@@ -197,8 +185,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
}
private MedicalTestJPA getMedicalTestJPA(int idMedicalTest) {
TypedQuery<MedicalTestJPA> query = entman
.createQuery("SELECT q from MedicalTestJPA q where q.id=:idMedicalTest", MedicalTestJPA.class);
TypedQuery<MedicalTestJPA> query = entman.createQuery("SELECT q from MedicalTestJPA q where q.id=:idMedicalTest", MedicalTestJPA.class);
query.setParameter("idMedicalTest", idMedicalTest);
return query.getSingleResult();
}
@@ -239,8 +226,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
}
public Long getSpecialistDoctorByMedicalSpecialityCount(int specialityId) {
TypedQuery<Long> query = entman.createQuery(
"SELECT count(1) from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId", Long.class);
TypedQuery<Long> query = entman.createQuery("SELECT count(1) from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId", Long.class);
query.setParameter("specId", specialityId);
return query.getSingleResult();
@@ -251,13 +237,11 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
*
* @param speciality
*/
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber,
int pageSize) {
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(int specialityId, int pageNumber, int pageSize) {
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId order by q.medicalSpecialty.name asc, q.surname asc",
SpecialistDoctorJPA.class);
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.id=:specId order by q.medicalSpecialty.name asc, q.surname asc", SpecialistDoctorJPA.class);
query.setParameter("specId", specialityId);
if (pageSize > 0) {
@@ -278,9 +262,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
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);
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);
@@ -304,18 +286,17 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
}
@Override
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID, int patientID) {
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID, Integer patientID) {
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
String extraQuery = "";
if (patientID > 0) {
if (patientID != null) {
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) {
.createQuery("SELECT q from MedicalTestJPA q where q.patient.familyDoctor.id=:familyDoctorID " + extraQuery + " order by q.id desc", MedicalTestJPA.class);
if (patientID != null) {
query.setParameter("patientID", patientID);
}
query.setParameter("familyDoctorID", familyDoctorID);
@@ -330,19 +311,18 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
}
@Override
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, int patientID) {
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, Integer patientID) {
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
String extraQuery = "";
if (patientID > 0) {
if (patientID != null) {
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);
.createQuery("SELECT q from MedicalTestJPA q where q.specialistDoctor.id=:specialistDoctorID " + extraQuery + " order by q.id desc", MedicalTestJPA.class);
if (patientID > 0) {
if (patientID != null) {
query.setParameter("patientID", patientID);
}
query.setParameter("specialistDoctorID", specialistDoctorID);
@@ -356,42 +336,73 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
return medicalTests;
}
@Override
public List<PatientTO> loadPatientsForSpecialistDoctor(int specialistDoctorID) {
List<PatientTO> medicalTests = new ArrayList<PatientTO>();
public List<PatientTO> loadPatientsForSpecialistDoctor(int specialistDoctorID, String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT distinct q.patient from MedicalTestJPA q where q.specialistDoctor.id=:specialistDoctorID %s order by q.patient.name, q.patient.surname";
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.normalizeTerm(searchTerm);
TypedQuery<PatientJPA> query = entman.createQuery(
"SELECT distinct q.patient from MedicalTestJPA q where q.specialistDoctor.id=:specialistDoctorID",
PatientJPA.class);
if (searchTerm.length() > 0) {
strFilter = "and lower(q.patient.name) LIKE :searchTerm OR lower(q.patient.surname) LIKE :searchTerm";
}
TypedQuery<PatientJPA> query = entman.createQuery(String.format(strQuery, strFilter), PatientJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
query.setParameter("specialistDoctorID", specialistDoctorID);
List<PatientJPA> allJPA = query.getResultList();
for (PatientJPA item : allJPA) {
medicalTests.add(commonServices.getPOJOforPatientJPA(item, 1));
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
return medicalTests;
List<PatientJPA> allJPA = query.getResultList();
List<PatientTO> patsTO = new ArrayList<PatientTO>();
for (PatientJPA item : allJPA) {
patsTO.add(commonServices.getPOJOforPatientJPA(item, 1));
}
return patsTO;
}
@Override
public List<PatientTO> loadPatientsForFamilyDoctor(int familyDoctorID) {
List<PatientTO> medicalTests = new ArrayList<PatientTO>();
public List<PatientTO> loadPatientsForFamilyDoctor(int familyDoctorID, String searchTerm, int pageNumber, int pageSize) {
String strQuery = "SELECT distinct q.patient from MedicalTestJPA q where q.patient.familyDoctor.id=:familyDoctorID %s order by q.patient.name, q.patient.surname";
TypedQuery<PatientJPA> query = entman.createQuery(
"SELECT distinct q.patient from MedicalTestJPA q where q.patient.familyDoctor.id=:familyDoctorID",
PatientJPA.class);
String strFilter = "";
if (searchTerm == null)
searchTerm = "";
else
searchTerm = Utils.normalizeTerm(searchTerm);
if (searchTerm.length() > 0) {
strFilter = "and lower(q.patient.name) LIKE :searchTerm OR lower(q.patient.surname) LIKE :searchTerm";
}
TypedQuery<PatientJPA> query = entman.createQuery(String.format(strQuery, strFilter), PatientJPA.class);
if (searchTerm.length() > 0)
query.setParameter("searchTerm", "%" + searchTerm + "%");
query.setParameter("familyDoctorID", familyDoctorID);
List<PatientJPA> allJPA = query.getResultList();
for (PatientJPA item : allJPA) {
medicalTests.add(commonServices.getPOJOforPatientJPA(item, 1));
if (pageSize > 0) {
query.setFirstResult(pageNumber * pageSize);
query.setMaxResults(pageSize);
}
return medicalTests;
List<PatientJPA> allJPA = query.getResultList();
List<PatientTO> patsTO = new ArrayList<PatientTO>();
for (PatientJPA item : allJPA) {
patsTO.add(commonServices.getPOJOforPatientJPA(item, 1));
}
return patsTO;
}
}

View File

@@ -66,22 +66,21 @@ public interface MedicalTestFacadeRemote {
// 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);
public List<MedicalTestTO> loadMedicalTestForFamilyDoctor(int familyDoctorID, Integer patientID);
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, Integer patientID);
public List<PatientTO> loadPatientsForSpecialistDoctor(int specialistDoctorID, String searchTerm, int pageNumber, int pageSize);
public List<PatientTO> loadPatientsForFamilyDoctor(int familyDoctorID, String searchTerm, int pageNumber, int pageSize);
/**
* 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.
* 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
@@ -89,7 +88,7 @@ public interface MedicalTestFacadeRemote {
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
* @param observations
*/
public String addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations);
public MedicalTestTO addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations) throws Exception;
/**
* Recuperar una prueba médica por ID

View File

@@ -57,8 +57,7 @@ public class MedicalTestJPA implements Serializable {
super();
}
public MedicalTestJPA(int id, Date date, LocalTime time, String observations, String highresimage, MedicalTestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
this.id = id;
public MedicalTestJPA(Date date, LocalTime time, String observations, String highresimage, MedicalTestType type, PatientJPA patient, SpecialistDoctorJPA specialistDoctor) {
this.date = date;
this.time = time;
this.observations = observations;

View File

@@ -11,12 +11,12 @@ import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.UploadedFile;
import TO.MedicalTestTO;
import TO.PatientTO;
import common.Constants;
import common.MedicalTestType;
import common.UserType;
import managedbean.common.ManagedBeanBase;
@@ -33,8 +33,14 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
private List<MedicalTestTO> medicalTests;
private MedicalTestTO selected;
private PatientTO patSelected;
private PatientTO patientFilterSelected;
private boolean addNewMode = false;
private UploadedFile imageUpload;
private List<PatientTO> patientList;
private List<PatientTO> patientWithTestList;
private String lastUIQuery;
private String lastUIQueryPatFilter;
private List<MedicalTestType> medicalTestTypes;
public MedicalTestMBean() {
}
@@ -43,34 +49,48 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
public void init() {
this.userType = SessionUtils.getUserType();
this.userID = Integer.valueOf(SessionUtils.getUserId());
this.medicalTestTypes = new ArrayList<MedicalTestType>();
this.medicalTestTypes.add(MedicalTestType.BLOOD_TEST);
this.medicalTestTypes.add(MedicalTestType.CT_SCAN);
this.medicalTestTypes.add(MedicalTestType.MAGNETIC_RESONANCE_IMAGING);
this.selected = null;
this.patSelected = null;
this.lastUIQuery = "";
this.lastUIQueryPatFilter = "";
switch (userType) {
case ADMINISTRATOR:
case PATIENT:
this.patientList = null;
this.patientWithTestList = null;
break;
case SPECIALIST_DOCTOR:
this.patientList = this.getRemoteManagerCommon().listPatientsPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.patientWithTestList = this.getRemoteManagerMedicalTest().loadPatientsForSpecialistDoctor(userID, null, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
break;
case FAMILY_DOCTOR:
this.patientList = null;
this.patientWithTestList = this.getRemoteManagerMedicalTest().loadPatientsForFamilyDoctor(userID, null, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
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() {
if(this.imageUpload != null ) {
String content = "data:"+imageUpload.getContentType()+";base64," + Base64.getEncoder().encodeToString(imageUpload.getContents());
System.out.println("FILE Content base64: ");
System.out.println(content);
this.selected.setHighresimage(content);
if (this.imageUpload != null) {
String content = "data:" + imageUpload.getContentType() + ";base64," + Base64.getEncoder().encodeToString(imageUpload.getContents());
System.out.println("FILE Content base64: ");
System.out.println(content);
this.selected.setHighresimage(content);
getRemoteManagerMedicalTest().addImage(this.selected.getId(), content);
this.loadMedicalTests();
this.imageUpload = null;
}else {
System.out.println("IMAGEN SUBIDA ES NULA");
} else {
System.out.println("IMAGEN SUBIDA ES NULA");
}
}
public UploadedFile getImageUpload() {
return imageUpload;
}
@@ -102,35 +122,68 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
}
public void loadMedicalTests() {
if (userType == UserType.PATIENT) {
Integer patId = null;
if (this.patientFilterSelected != null)
patId = this.patientFilterSelected.getId();
switch (userType) {
case PATIENT:
// Cargar las pruebas para el paciente en sesión
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForPatient(userID);
} else if (userType == UserType.SPECIALIST_DOCTOR) {
break;
case SPECIALIST_DOCTOR:
// Cargar las pruebas que el doctor especialista ha creado
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForSpecialistDoctor(userID,
this.patIdSelected);
} else if (userType == UserType.FAMILY_DOCTOR) {
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForSpecialistDoctor(userID, patId);
break;
case FAMILY_DOCTOR:
// Cargar las pruebas para los pacientes del doctor de familia en sesión
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID,
this.patIdSelected);
} else {
// Nothing todo
this.medicalTests = new ArrayList<MedicalTestTO>();
}
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID, patId);
break;
case ADMINISTRATOR:
this.medicalTests = null;
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Operación no válida para el tipo de usuario actual.");
break;
}
}
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<PatientTO> completePatient(String query) {
if (query != null && query.equals(this.lastUIQuery) == false) {
this.lastUIQuery = query;
// Recuperamos las xxx primeras coincidencias
this.patientList = this.getRemoteManagerCommon().listPatientsFiltered(query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.patientList;
}
public List<PatientTO> completePatientFilter(String query) {
if (query != null && query.equals(this.lastUIQueryPatFilter) == false) {
this.lastUIQueryPatFilter = query;
switch (userType) {
case SPECIALIST_DOCTOR:
// Cargar los pacientes a los que ha añadido pruebas médicas el médico especialista
this.patientWithTestList = this.getRemoteManagerMedicalTest().loadPatientsForSpecialistDoctor(userID, query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
break;
case FAMILY_DOCTOR:
// Cargar los pacientes del médico de familia que tiene pruebas médicas hechas
this.patientWithTestList = this.getRemoteManagerMedicalTest().loadPatientsForFamilyDoctor(userID, query, 0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
break;
case ADMINISTRATOR:
case PATIENT:
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Operación no válida para el tipo de usuario actual.");
this.patientWithTestList = null;
break;
}
}
return this.patientWithTestList;
}
public List<PatientTO> getPatientList() {
return patientList;
}
public List<PatientTO> getPatientWithTestList() {
return patientWithTestList;
}
public List<MedicalTestTO> getMedicalTests() {
@@ -141,18 +194,6 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
// Nothing to do
}
/*************************************************** METODOS PARA LA VISTA */
private int patIdSelected = -1;
public void setPatIdSelected(Integer value) {
this.patIdSelected = value;
this.addNewMode = false;
}
public Integer getPatIdSelected() {
return this.patIdSelected;
}
public boolean isSpecialistDoctor() {
return this.userType == UserType.SPECIALIST_DOCTOR;
}
@@ -161,10 +202,20 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
return !(userType == UserType.PATIENT);
}
public void onSelectPatient(AjaxBehaviorEvent event) {
public void clearFilteredPatient() {
this.selected = null;
this.patientFilterSelected = null;
this.loadMedicalTests();
}
public void onChangePatient(AjaxBehaviorEvent event) {
this.selected = null;
this.loadMedicalTests();
}
public void onSelectPatient(SelectEvent event) {
this.selected = null;
this.loadMedicalTests();
}
public void onSelectMT(SelectEvent event) {
@@ -173,16 +224,13 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
}
public void addMT() {
if (this.patIdSelected != -1) {
this.selected = new MedicalTestTO();
this.selected.setId(-1);
this.selected.setObservations("");
this.selected.setType(MedicalTestType.BLOOD_TEST);
this.addNewMode = true;
} else {
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Atención!",
"Debe elegir un paciente al que añadir la prueba médica.");
}
// Si hay un paciente filtrado en la busqueda de pruebas, lo seleccionamos para la prueba a añadir.
this.patSelected = this.patientFilterSelected;
this.selected = new MedicalTestTO();
this.selected.setId(-1);
this.selected.setObservations("");
this.selected.setType(MedicalTestType.BLOOD_TEST);
this.addNewMode = true;
}
public boolean isAddNewMode() {
@@ -202,44 +250,32 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
}
public List<MedicalTestType> getMedicalTestTypes() {
ArrayList<MedicalTestType> list = new ArrayList<MedicalTestType>();
list.add(MedicalTestType.BLOOD_TEST);
list.add(MedicalTestType.CT_SCAN);
list.add(MedicalTestType.MAGNETIC_RESONANCE_IMAGING);
return list;
}
public String getMedicalTestTypeSelected() {
return this.selected.getType().getName();
}
public void setMedicalTestTypeSelected(String val) {
System.out.println("********************************");
System.out.println(val);
System.out.println("********************************");
MedicalTestType mt;
if (val.equals("BLOOD_TEST")) {
mt = MedicalTestType.BLOOD_TEST;
} else if (val.equals("CT_SCAN")) {
mt = MedicalTestType.CT_SCAN;
} else {
mt = MedicalTestType.MAGNETIC_RESONANCE_IMAGING;
}
this.selected.setType(mt);
System.out.println("********************************");
System.out.println(this.selected.getType());
System.out.println("********************************");
return this.medicalTestTypes;
}
public void save() {
String res = getRemoteManagerMedicalTest().addMedicalTest(this.patIdSelected, userID, this.selected.getDate(),
this.selected.getTime(), this.selected.getType(), this.selected.getObservations());
if (res.equals("ok")) {
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Éxito", "Guardado correctamente");
} else {
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error", res);
try {
MedicalTestTO mt = this.getRemoteManagerMedicalTest().addMedicalTest(this.patSelected.getId(), this.userID, this.selected.getDate(), this.selected.getTime(),
this.selected.getType(), this.selected.getObservations());
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Éxito", String.format("La prueba médica se ha guardado correctamente, el identificador asignado es: %d", mt.getId()));
// Volvemos al modo añadir (limpiamos el formulario).
this.addMT();
this.loadMedicalTests();
} catch (Exception ex) {
this.manageException(ex);
}
this.loadMedicalTests();
}
public PatientTO getPatientFilterSelected() {
return patientFilterSelected;
}
public void setPatientFilterSelected(PatientTO patientFilterSelected) {
this.patientFilterSelected = patientFilterSelected;
}
}