Creando un MT
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.primefaces.event.SelectEvent;
|
||||
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import common.MedicalTestType;
|
||||
import common.UserType;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
@@ -87,10 +88,12 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
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);
|
||||
this.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
|
||||
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID);
|
||||
this.medicalTests = getRemoteManagerMedicalTest().loadMedicalTestForFamilyDoctor(userID,
|
||||
this.patIdSelected);
|
||||
} else {
|
||||
// Nothing todo
|
||||
this.medicalTests = new ArrayList<MedicalTestTO>();
|
||||
@@ -121,7 +124,7 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
|
||||
/*************************************************** METODOS PARA LA VISTA */
|
||||
private Integer patIdSelected = -1;
|
||||
private int patIdSelected = -1;
|
||||
|
||||
public void setPatIdSelected(Integer value) {
|
||||
this.patIdSelected = value;
|
||||
@@ -132,22 +135,8 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
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 isSpecialistDoctor() {
|
||||
return this.userType == UserType.SPECIALIST_DOCTOR;
|
||||
}
|
||||
|
||||
public boolean isPatSelector() {
|
||||
@@ -156,13 +145,8 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
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);
|
||||
}
|
||||
this.loadMedicalTests();
|
||||
|
||||
}
|
||||
|
||||
public void onSelectMT(SelectEvent event) {
|
||||
@@ -175,9 +159,11 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
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.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Atención!",
|
||||
"Debe elegir un paciente al que añadir la prueba médica.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,11 +176,46 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
|
||||
public boolean getViewCreate() {
|
||||
return addNewMode;
|
||||
return addNewMode && userType == UserType.SPECIALIST_DOCTOR;
|
||||
}
|
||||
|
||||
public boolean getViewEdit() {
|
||||
return !addNewMode && this.selected != null;
|
||||
}
|
||||
|
||||
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) {
|
||||
MedicalTestType mt;
|
||||
if (val.equals(MedicalTestType.BLOOD_TEST)) {
|
||||
mt = MedicalTestType.BLOOD_TEST;
|
||||
} else if (val.equals(MedicalTestType.CT_SCAN)) {
|
||||
mt = MedicalTestType.CT_SCAN;
|
||||
} else {
|
||||
mt = MedicalTestType.MAGNETIC_RESONANCE_IMAGING;
|
||||
}
|
||||
this.selected.setType(mt);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.loadMedicalTests();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user