Nuevos metodos EJB para componente de visitas.
This commit is contained in:
@@ -11,9 +11,14 @@ import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import TO.VisitTO;
|
||||
import common.HashUtils;
|
||||
import common.QuestionStatus;
|
||||
import common.Utils;
|
||||
import ejb.common.CommonFacadeLocal;
|
||||
import jpa.FamilyDoctorJPA;
|
||||
import jpa.MedicalSpecialtyJPA;
|
||||
import jpa.QuestionJPA;
|
||||
import jpa.SpecialistDoctorJPA;
|
||||
import jpa.VisitJPA;
|
||||
|
||||
/**
|
||||
@@ -60,4 +65,69 @@ public class VisitFacadeBean implements VisitFacadeRemote {
|
||||
return listTO;
|
||||
}
|
||||
|
||||
public Long getVisitsCount(Integer patientId, Date date) {
|
||||
String strQuery = "SELECT count(1) from VisitJPA v %s";
|
||||
String strFilter = "";
|
||||
if (patientId != null)
|
||||
strFilter = " and v.patient.id=:patientId ";
|
||||
if (date != null)
|
||||
strFilter += " and v.date=:date ";
|
||||
|
||||
if (strFilter.length() > 0) {
|
||||
strQuery = String.format(strQuery, "WHERE 1=1 " + strFilter);
|
||||
}
|
||||
|
||||
TypedQuery<Long> query = entman.createQuery(strQuery, Long.class);
|
||||
|
||||
if (patientId != null)
|
||||
query.setParameter("patientId", patientId);
|
||||
if (date != null)
|
||||
query.setParameter("date", date);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize) {
|
||||
String strQuery = "SELECT v from VisitJPA v %s order by v.patient, v.date";
|
||||
String strFilter = "";
|
||||
if (patientId != null)
|
||||
strFilter = " and v.patient.id=:patientId ";
|
||||
if (date != null)
|
||||
strFilter += " and v.date=:date ";
|
||||
|
||||
if (strFilter.length() > 0) {
|
||||
strQuery = String.format(strQuery, "WHERE 1=1 " + strFilter);
|
||||
}
|
||||
|
||||
TypedQuery<VisitJPA> query = entman.createQuery(strQuery, VisitJPA.class);
|
||||
|
||||
if (patientId != null)
|
||||
query.setParameter("patientId", patientId);
|
||||
if (date != null)
|
||||
query.setParameter("date", date);
|
||||
|
||||
if (pageSize > 0) {
|
||||
query.setFirstResult(pageNumber * pageSize);
|
||||
query.setMaxResults(pageSize);
|
||||
}
|
||||
|
||||
List<VisitJPA> allJPA = query.getResultList();
|
||||
List<VisitTO> listTO = new ArrayList<VisitTO>();
|
||||
|
||||
for (VisitJPA item : allJPA) {
|
||||
listTO.add(commonServices.getPOJOforVisitJPA(item, 1));
|
||||
}
|
||||
|
||||
return listTO;
|
||||
}
|
||||
|
||||
|
||||
public VisitTO getVisit(int id) throws Exception {
|
||||
VisitJPA vi = entman.find(VisitJPA.class, id);
|
||||
if (vi == null) {
|
||||
throw new Exception("No se encuentra la visita con identificador: " + String.valueOf(id));
|
||||
}
|
||||
|
||||
return this.commonServices.getPOJOforVisitJPA(vi, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,10 @@ public interface VisitFacadeRemote {
|
||||
public Long getScheduledVisitsCount(int familyDoctorId, Date date);
|
||||
|
||||
public List<VisitTO> listAllScheduledVisitsPaged(int familyDoctorId, Date date, int pageNumber, int pageSize);
|
||||
|
||||
public Long getVisitsCount(Integer patientId, Date date);
|
||||
|
||||
public List<VisitTO> listVisitsPaged(Integer patientId, Date date, int pageNumber, int pageSize);
|
||||
|
||||
public VisitTO getVisit(int id) throws Exception;
|
||||
}
|
||||
Reference in New Issue
Block a user