Ver pruebas médicas casi funcionando al completo: falta cargar imagen real
Crear prueba medica: formulario comenzado.
This commit is contained in:
@@ -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í.
|
||||
|
||||
// Como realizar llamadas al EJB Remoto
|
||||
// this.getRemoteManagerSystemAdmin().MetodoEJB
|
||||
this.userType = SessionUtils.getUserType();
|
||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||
|
||||
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