日期:2014-05-17 浏览次数:20715 次
public List getPatientsListByUid(final VPlist vplist,final int pageNo,final int pageSize,final int ulevel) {
try {
if (vplist!=null && vplist.getUid()>0) {
List list = getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
//String hql = "from TPatients where uid=? order by pstate,pctime";
String hql = null;
Query query =null;
if(ulevel==2){
hql = "from VPlist where uid=? order by pstate,pctime";
query = session.createQuery(hql);
query.setInteger(0, vplist.getUid());
}else if(ulevel==9){
hql = "from VPlist where hunitid=? and pstate = 2 order by pstate,pctime";
query = session.createQuery(hql);
query.setInteger(0, vplist.getHunitid());
}else if(ulevel==99){
hql = "from VPlist where pstate = 2 order by pstate,pctime";
query = session.createQuery(hql);
}
int first = pageSize*(pageNo-1);
query.setFirstResult(first);
query.setMaxResults(pageSize);
return query.list();
}
});
return list;
}else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public List getPatientsSearchByPnumber(final int uid,final int ulevel,final int sel_City,final int sel_Hunit,
final int state,final int name_pnumber,final String n_p_value,final int pageSize,final int pageNo){
try{
List list = getHibernateTemplate().executeFind(new HibernateCallback(){
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
StringBuffer sb = new StringBuffer("from VPlist where");
if(sel_City>=0){
sb.append(" areaId = "+sel_City+" and");
}if(sel_Hunit>=0){
sb.append(" hunitid = "+sel_Hunit+" and");
}if(state>=0 && ulevel==2){
sb.append(" pstate = "+state+" ");
}if(name_pnumber==1){
sb.append(" pnumber = '"+n_p_value+"' and");
}if(name_pnumber==2){
sb.append(" gsName = '"+n_p_value+"' and");
}if(ulevel==9 || ulevel==99){
sb.append(" pstate = 2 and");
}else{
sb.append(" uid = "+uid);
}
String hql = sb.toString();
System.out.println(hql);
Query query = session.createQuery(hql);
int first = pageSize*(pageNo-1);
query.setFirstResult(first);
query.setMaxResults(pageSize);
return query.l