Búsqueda de especialista por especialidad

This commit is contained in:
Roberto Orden Erena
2019-12-26 18:43:16 +01:00
parent c7de5401ad
commit 87da9ccbf1
6 changed files with 167 additions and 4 deletions

View File

@@ -13,6 +13,7 @@ import javax.persistence.TypedQuery;
import TO.LoggedUserTO;
import TO.MedicalSpecialtyTO;
import TO.QuestionTO;
import TO.SpecialistDoctorTO;
import common.MedicalTestType;
import common.QuestionStatus;
import common.UserType;
@@ -20,6 +21,7 @@ import ejb.common.CommonFacadeLocal;
import jpa.FamilyDoctorJPA;
import jpa.PatientJPA;
import jpa.QuestionJPA;
import jpa.SpecialistDoctorJPA;
import managedbean.common.SessionUtils;
/**
@@ -229,7 +231,21 @@ public class MedicalTestFacadeBean implements MedicalTestFacadeRemote {
* @param speciality
*/
@Override
public void findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality) {
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality) {
List<SpecialistDoctorTO> pendingQuestions = new ArrayList<SpecialistDoctorTO>();
TypedQuery<SpecialistDoctorJPA> query = entman.createQuery(
"SELECT q from SpecialistDoctorJPA q where q.medicalSpecialty.name=:spec order by q.medicalSpecialty.name asc, q.surname asc",
SpecialistDoctorJPA.class);
query.setParameter("spec", speciality.getName());
List<SpecialistDoctorJPA> allJPA = query.getResultList();
for (SpecialistDoctorJPA item : allJPA) {
pendingQuestions.add(commonServices.getPOJOforSpecialistDoctorJPA(item, 1));
}
return pendingQuestions;
}
}

View File

@@ -7,6 +7,7 @@ import javax.ejb.Remote;
import TO.MedicalSpecialtyTO;
import TO.QuestionTO;
import TO.SpecialistDoctorTO;
import common.MedicalTestType;
/**
@@ -114,5 +115,5 @@ public interface MedicalTestFacadeRemote {
*
* @param speciality
*/
public void findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality);
public List<SpecialistDoctorTO> findSpecialistDoctorByMedicalSpeciality(MedicalSpecialtyTO speciality);
}

View File

@@ -125,7 +125,7 @@ public class AuthorizationFilter implements Filter {
authorized = true;
if (reqURI.indexOf("/medicaltest/MedicalTests") > 0)
authorized = true;
if (reqURI.indexOf("/medicaltest/SearchSpecialistBySpecialty") > 0)
if (reqURI.indexOf("/medicaltest/SearchSpecialist") > 0)
authorized = true;
if (reqURI.indexOf("/profile/UpdateProfile") > 0)
authorized = true;

View File

@@ -86,7 +86,7 @@ public class MenuMBean implements Serializable {
}
if (tipoUsuario == UserType.PATIENT)
subMenu.addElement(createMenuItem("Buscar especialista...", "fa fa-heartbeat", "/medicaltest/MedicalTests", null));
subMenu.addElement(createMenuItem("Buscar especialista...", "fa fa-heartbeat", "/medicaltest/SearchSpecialist", null));
model.addElement(subMenu);
}

View File

@@ -0,0 +1,90 @@
package managedbean.medicalTest;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.SelectEvent;
import TO.MedicalSpecialtyTO;
import TO.SpecialistDoctorTO;
import common.Constants;
import common.UserType;
import managedbean.common.ManagedBeanBase;
import managedbean.common.SessionUtils;
@Named("sspec")
@ViewScoped
public class SearchSpecialistMBean extends ManagedBeanBase implements Serializable {
private static final long serialVersionUID = 1L;
private int userID;
private UserType userType;
private List<SpecialistDoctorTO> listDoctors;
private List<MedicalSpecialtyTO> medicalSpecialitiesList;
private MedicalSpecialtyTO medicalSpeciality;
private String lastUIQueryMS;
public SearchSpecialistMBean() {
}
@PostConstruct
public void init() {
// Inicialización de variables y propiedades van aquí.
this.userType = SessionUtils.getUserType();
this.userID = Integer.valueOf(SessionUtils.getUserId());
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesPaged(0,
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
this.medicalSpeciality = null;
this.lastUIQueryMS = "";
this.listDoctors = new ArrayList<SpecialistDoctorTO>();
}
public void onSelect(SelectEvent event) {
System.out.println("onSelect");
this.medicalSpeciality = (MedicalSpecialtyTO) event.getObject();
System.out.println(this.medicalSpeciality);
this.listDoctors = getRemoteManagerMedicalTest()
.findSpecialistDoctorByMedicalSpeciality(this.medicalSpeciality);
}
public List<MedicalSpecialtyTO> completeMedicalSpeciality(String query) {
if (query != null && query.equals(this.lastUIQueryMS) == false) {
this.lastUIQueryMS = query;
// Recuperamos las 200 primeras coincidencias
this.medicalSpecialitiesList = this.getRemoteManagerCommon().listMedicalSpecialitiesFiltered(query, 0,
Constants.MAX_ITEMS_AUTOCOMPLETE_SEARCH);
}
return this.medicalSpecialitiesList;
}
public List<TO.SpecialistDoctorTO> getListDoctors() {
return listDoctors;
}
public void setListDoctors(List<TO.SpecialistDoctorTO> listDoctors) {
this.listDoctors = listDoctors;
}
public List<MedicalSpecialtyTO> getMedicalSpecialitiesList() {
return medicalSpecialitiesList;
}
public void setMedicalSpecialitiesList(List<MedicalSpecialtyTO> medicalSpecialitiesList) {
this.medicalSpecialitiesList = medicalSpecialitiesList;
}
public MedicalSpecialtyTO getMedicalSpeciality() {
return medicalSpeciality;
}
public void setMedicalSpeciality(MedicalSpecialtyTO medicalSpecialty) {
this.medicalSpeciality = medicalSpecialty;
}
}