Creando un MT

This commit is contained in:
Roberto Orden Erena
2019-12-29 10:20:16 +01:00
parent 47caa1fc54
commit 9cd602f8cf
4 changed files with 98 additions and 64 deletions

View File

@@ -69,9 +69,9 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
qjpa.setFamilyDoctor(pat.getFamilyDoctor());
entman.persist(qjpa);
return "ok";
} else {
return "No tienes médico de familia elegido, por favor acude a la sección 'Gestionar Perfil' -> 'Cambiar médico de familia'";
}
@@ -156,22 +156,29 @@ 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 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);
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);
MedicalTestJPA mt = new MedicalTestJPA(0, date, time, observations, null, testType, pat, specDoctor);
entman.persist(mt);
return "ok";
} catch (Exception ex) {
return ex.getMessage();
}
}
/**
@@ -188,10 +195,10 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
return resp;
}
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();
}
@@ -205,7 +212,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
public void addImage(int idMedicalTest, String image) {
MedicalTestJPA mt = this.getMedicalTestJPA(idMedicalTest);
mt.setHighresimage(image);
entman.persist(mt);
}
@@ -227,7 +234,7 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
public void removeImage(int idMedicalTest) {
MedicalTestJPA mt = this.getMedicalTestJPA(idMedicalTest);
mt.setHighresimage(null);
entman.persist(mt);
}
@@ -295,20 +302,20 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
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) {
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) {
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);
@@ -326,16 +333,16 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
public List<MedicalTestTO> loadMedicalTestForSpecialistDoctor(int specialistDoctorID, int patientID) {
List<MedicalTestTO> medicalTests = new ArrayList<MedicalTestTO>();
String extraQuery = "";
if(patientID > 0) {
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) {
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);

View File

@@ -89,7 +89,7 @@ public interface MedicalTestFacadeRemote {
* @param testType Pudiera llegar a ser: Análisis de sangre, resonancias magnéticas y TAC
* @param observations
*/
public void addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations);
public String addMedicalTest(int patientID, int doctorSpecialistID, Date date, LocalTime time, MedicalTestType testType, String observations);
/**
* Recuperar una prueba médica por ID