Mejoras en la gestión de pruebas médicas (filtros de búsqueda)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user