Metodos para busqueda y filtrado de pacientes de forma paginada.
This commit is contained in:
@@ -221,6 +221,42 @@ public class CommonFacadeBean implements CommonFacadeRemote, CommonFacadeLocal {
|
||||
|
||||
return allFDTOs;
|
||||
}
|
||||
|
||||
public List<PatientTO> listPatientsPaged(int pageNumber, int pageSize) {
|
||||
return this.listPatientsFiltered(null, pageNumber, pageSize);
|
||||
}
|
||||
|
||||
public List<PatientTO> listPatientsFiltered(String searchTerm, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT p FROM PatientJPA p %s order by p.name, p.surname";
|
||||
String strFilter = "";
|
||||
if (searchTerm == null)
|
||||
searchTerm = "";
|
||||
else
|
||||
searchTerm = Utils.normalizeTerm(searchTerm);
|
||||
|
||||
if (searchTerm.length() > 0) {
|
||||
strFilter = "WHERE lower(p.name) LIKE :searchTerm OR lower(p.surname) LIKE :searchTerm";
|
||||
}
|
||||
|
||||
TypedQuery<PatientJPA> query = entman.createQuery(String.format(strQuery, strFilter), PatientJPA.class);
|
||||
|
||||
if (searchTerm.length() > 0)
|
||||
query.setParameter("searchTerm", "%" + searchTerm + "%");
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
List<PatientJPA> allPAsJPA = query.getResultList();
|
||||
List<PatientTO> allPATOs = new ArrayList<PatientTO>();
|
||||
|
||||
for (PatientJPA item : allPAsJPA) {
|
||||
allPATOs.add(this.getPOJOforPatientJPA(item, 0));
|
||||
}
|
||||
|
||||
return allPATOs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método que convierte un objecto de tipo MedicalSpecialtyJPA (JPA) a su equivalente MedicalSpecialtyTO (Tranfer Object)
|
||||
|
||||
@@ -45,6 +45,10 @@ public interface CommonFacadeLocal {
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<PatientTO> listPatientsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<PatientTO> listPatientsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientTO findPatientByCode(String code);
|
||||
|
||||
@@ -36,6 +36,10 @@ public interface CommonFacadeRemote {
|
||||
|
||||
public List<FamilyDoctorTO> listFamilyDoctorsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public List<PatientTO> listPatientsPaged(int pageNumber, int pageSize);
|
||||
|
||||
public List<PatientTO> listPatientsFiltered(String searchTerm, int pageNumber, int pageSize);
|
||||
|
||||
public PatientTO findPatientById(int patientId);
|
||||
|
||||
public PatientTO findPatientByCode(String code);
|
||||
@@ -45,13 +49,13 @@ public interface CommonFacadeRemote {
|
||||
public FamilyDoctorTO findFamilyDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByCode(String code);
|
||||
|
||||
|
||||
public FamilyDoctorTO findFamilyDoctorByNif(String searchValue);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorById(int ProfessionalNumberId);
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByCode(String code);
|
||||
|
||||
|
||||
public SpecialistDoctorTO findSpecialistDoctorByNif(String searchValue);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user