Merge branch 'master' of http://pdp-pds.eimt.uoc.edu/pds19-grupo2/myhealth.git
This commit is contained in:
@@ -181,7 +181,7 @@ public class AuthorizationFilter implements Filter {
|
||||
|
||||
}
|
||||
|
||||
resp.sendRedirect(req.getContextPath() + "/home.xhtml");
|
||||
resp.sendRedirect(req.getContextPath() + "/login.xhtml");
|
||||
} catch (Exception e) {
|
||||
if (Exceptions.is(e, PersistenceException.class) == true) {
|
||||
if (ses != null)
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MenuMBean implements Serializable {
|
||||
subMenu = new DefaultSubMenu("Administración del sistema", "fa fa-wrench");
|
||||
|
||||
subMenu.addElement(createMenuItem("Gestionar especialidades", "fa fa-file-text-o", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(createMenuItem("Centros At. Primaria", "fa fa-hospital-o", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(createMenuItem("Centros At. Primaria", "fa fa-hospital-o", "/systemAdmin/ManageHealthCareCenters", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
subMenu.addElement(createMenuItem("Ver médicos de un CAP", "fa fa-medkit", "/systemAdmin/ManageSpecialties", null));
|
||||
subMenu.addElement(new DefaultSeparator());
|
||||
|
||||
@@ -1,27 +1,245 @@
|
||||
package managedbean.medicalTest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.event.AjaxBehaviorEvent;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import org.primefaces.event.FileUploadEvent;
|
||||
import org.primefaces.event.SelectEvent;
|
||||
import org.primefaces.model.UploadedFile;
|
||||
|
||||
@Named("MedicalTestMBean")
|
||||
@RequestScoped
|
||||
import TO.MedicalTestTO;
|
||||
import TO.PatientTO;
|
||||
import common.MedicalTestType;
|
||||
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;
|
||||
private UploadedFile imageUpload;
|
||||
|
||||
public MedicalTestMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
// Inicialización de variables y propiedades van aquí.
|
||||
this.userType = SessionUtils.getUserType();
|
||||
this.userID = Integer.valueOf(SessionUtils.getUserId());
|
||||
|
||||
// Como realizar llamadas al EJB Remoto
|
||||
// this.getRemoteManagerSystemAdmin().MetodoEJB
|
||||
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() {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
public UploadedFile getImageUpload() {
|
||||
return imageUpload;
|
||||
}
|
||||
|
||||
public void setImageUpload(UploadedFile imageUpload) {
|
||||
this.imageUpload = imageUpload;
|
||||
}
|
||||
|
||||
public void removeImage() {
|
||||
this.selected.setHighresimage(null);
|
||||
getRemoteManagerMedicalTest().removeImage(this.selected.getId());
|
||||
this.loadMedicalTests();
|
||||
}
|
||||
|
||||
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,
|
||||
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.patIdSelected);
|
||||
} else {
|
||||
// Nothing todo
|
||||
this.medicalTests = new ArrayList<MedicalTestTO>();
|
||||
}
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
public boolean isPatSelector() {
|
||||
return !(userType == UserType.PATIENT);
|
||||
}
|
||||
|
||||
public void onSelectPatient(AjaxBehaviorEvent event) {
|
||||
this.selected = null;
|
||||
this.loadMedicalTests();
|
||||
|
||||
}
|
||||
|
||||
public void onSelectMT(SelectEvent event) {
|
||||
this.selected = (MedicalTestTO) event.getObject();
|
||||
this.addNewMode = false;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAddNewMode() {
|
||||
return addNewMode;
|
||||
}
|
||||
|
||||
public void setAddNewMode(boolean addNewMode) {
|
||||
this.addNewMode = addNewMode;
|
||||
}
|
||||
|
||||
public boolean getViewCreate() {
|
||||
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) {
|
||||
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("********************************");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,10 +100,15 @@ public class QuestionsMBean extends ManagedBeanBase implements Serializable {
|
||||
}
|
||||
|
||||
public void addNewQuestion() {
|
||||
getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
||||
this.create();
|
||||
this.loadQuestions();
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
||||
String result = getRemoteManagerMedicalTest().askQuestion(userID, this.selected.getTitle(), this.selected.getMessage());
|
||||
if(result == "ok") {
|
||||
this.create();
|
||||
this.loadQuestions();
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Datos guardados", "La pregunta se registrado correctamente en el sistema.");
|
||||
} else {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Error", result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isShowPanelDetail() {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class LoginMBean extends ManagedBeanBase {
|
||||
|
||||
// logout event, invalidate session
|
||||
public String logout() {
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su ssesión. Hasta la vista");
|
||||
this.addFacesMessageKeep(FacesMessage.SEVERITY_INFO, "Sessión cerrada", "Ha cerrado correctament su sesión. Hasta la vista");
|
||||
|
||||
SessionUtils.DestroySession();
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
package managedbean.systemAdmin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.faces.view.ViewScoped;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.primefaces.event.RowEditEvent;
|
||||
import org.primefaces.model.LazyDataModel;
|
||||
import org.primefaces.model.SortOrder;
|
||||
|
||||
import TO.PrimaryHealthCareCenterTO;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
|
||||
@Named("ManageHealthCareCenters")
|
||||
@ViewScoped
|
||||
public class ManageHealthCareCentersMBean extends ManagedBeanBase implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String location;
|
||||
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
|
||||
private LazyDataModel<PrimaryHealthCareCenterTO> lazyDataModelCAPsList;
|
||||
|
||||
public ManageHealthCareCentersMBean() {
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.lazyDataModelCAPsList = new LazyDataModel<PrimaryHealthCareCenterTO>() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public List<PrimaryHealthCareCenterTO> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
|
||||
Long totalRowCount = getRemoteManagerSystemAdmin().getCAPCount();
|
||||
this.setRowCount(totalRowCount.intValue());
|
||||
|
||||
return getRemoteManagerSystemAdmin().listCAPsPaged((first / pageSize), pageSize);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public LazyDataModel<PrimaryHealthCareCenterTO> getlazyDataModelCAPsList() {
|
||||
return lazyDataModelCAPsList;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(String location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
private void showPrimaryHealthCareCenterData(PrimaryHealthCareCenterTO cap) {
|
||||
this.primaryHealthCareCenter = cap;
|
||||
|
||||
if (cap == null) {
|
||||
this.id = null;
|
||||
this.name = "";
|
||||
this.location = "";
|
||||
} else {
|
||||
this.id = cap.getId();
|
||||
this.name = cap.getName();
|
||||
this.location = cap.getLocation();
|
||||
}
|
||||
}
|
||||
|
||||
public PrimaryHealthCareCenterTO getPrimaryHealthCareCenter() {
|
||||
return primaryHealthCareCenter;
|
||||
}
|
||||
|
||||
public void setPrimaryHealthCareCenter(PrimaryHealthCareCenterTO value) {
|
||||
this.primaryHealthCareCenter = value;
|
||||
}
|
||||
|
||||
public void onRowEdit(RowEditEvent event) {
|
||||
int error = 0;
|
||||
|
||||
if (((PrimaryHealthCareCenterTO) event.getObject()).getName() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getName().trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Nombre no relleno", "Por favor, escriba un nombre para el centro.");
|
||||
error++;
|
||||
}
|
||||
if (((PrimaryHealthCareCenterTO) event.getObject()).getLocation() == null || ((PrimaryHealthCareCenterTO) event.getObject()).getLocation().trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Localización no rellena", "Por favor, escriba una localización.");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().updateHealthCareCenter(((PrimaryHealthCareCenterTO) event.getObject()).getId(), ((PrimaryHealthCareCenterTO) event.getObject()).getName(),
|
||||
((PrimaryHealthCareCenterTO) event.getObject()).getLocation());
|
||||
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
FacesMessage msg = new FacesMessage("CAP editado", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onRowCancel(RowEditEvent event) {
|
||||
FacesMessage msg = new FacesMessage("Edición cancelada", ((PrimaryHealthCareCenterTO) event.getObject()).getName());
|
||||
FacesContext.getCurrentInstance().addMessage(null, msg);
|
||||
}
|
||||
|
||||
public void deleteDataById(Integer id) throws IOException {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().deleteHealthCareCenter(id);
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "El CAP se ha borrado", "Los datos del Centro de Atención Primaria se han borrado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void insertData() {
|
||||
int error = 0;
|
||||
|
||||
if (name == null || name.trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Nombre no relleno", "Por favor, escriba un nombre para el centro.");
|
||||
error++;
|
||||
}
|
||||
if (location == null || location.trim().length() == 0) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "Localización no rellena", "Por favor, escriba una localización.");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (this.getRemoteManagerSystemAdmin().findHealthCareCenterByName(name) != null) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_WARN, "CAP ya existente", "El CAP ya se encuentra en la base de datos");
|
||||
error++;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
this.getRemoteManagerSystemAdmin().insertHealthCareCenter(name, location);
|
||||
this.showPrimaryHealthCareCenterData(null);
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos del Centro de Atención Primaria se han guardado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ import javax.inject.Named;
|
||||
|
||||
import TO.LoggedUserTO;
|
||||
import TO.MedicalSpecialtyTO;
|
||||
import common.Constants;
|
||||
import managedbean.common.ManagedBeanBase;
|
||||
import managedbean.common.SessionUtils;
|
||||
|
||||
@@ -51,7 +50,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
}
|
||||
|
||||
private void refreshFormData() {
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0, Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
|
||||
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listAllMedicalSpecialities();
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
@@ -118,9 +117,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
MedicalSpecialtyTO ms = this.getRemoteManagerSystemAdmin().updateSpecialty(this.medicalSpecialty.getId(), this.medicalSpecialty.getName(),
|
||||
this.medicalSpecialty.getDescription());
|
||||
|
||||
this.getRemoteManagerSystemAdmin().updateSpecialty(this.medicalSpecialty.getId(), this.medicalSpecialty.getName(),this.medicalSpecialty.getDescription());
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
@@ -149,7 +146,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los especialidad se ha borrado", "Los datos de la especialidad se han borrado correctamente.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "La especialidad se ha borrado", "Los datos de la especialidad se han borrado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
}
|
||||
@@ -175,8 +172,7 @@ public class ManageSpecialitiesMBean extends ManagedBeanBase implements Serializ
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
MedicalSpecialtyTO ms = this.getRemoteManagerSystemAdmin().insertSpecialty(name, description);
|
||||
|
||||
this.getRemoteManagerSystemAdmin().insertSpecialty(name, description);
|
||||
this.showSpecialtyData(null);
|
||||
this.refreshFormData();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user