select hn from ovst where vstdate='2007-09-17' and oqueue=562
select count(*) as cc from oapp where nextdate = '2007-09-17' and doctor = '002'
select count(*) as cc from oapp where nextdate = '2007-09-17' and doctor = '002' and patient_visit='Y'
select v.hn as hn,l.lab_count,xh.confirm_all,l.report_count,v.pt_priority as pt_priority,v.vn as vn,v.oqueue as oqueue,v.cur_dep_time as cur_dep_time,count(s.vn) as svn_count, count(r.vn) as rx_count,count(r1.vn) as pay_count , count(t.vn) as finance_count , concat(p.pname,p.fname,' ',p.lname) as ptname from ovst v left outer join patient p on p.hn=v.hn left outer join pq_screen s on s.vn=v.vn left outer join rx_operator r on r.vn=v.vn left outer join rcpt_print t on t.vn=v.vn left outer join lab_status l on l.vn = v.vn left outer join xray_head xh on xh.vn = v.vn left outer join rx_operator r1 on r1.vn=v.vn and r1.pay='Y' where v.vstdate='2007-09-17' and v.hn='370030864' group by v.hn,l.lab_count,xh.confirm_all,l.report_count,v.pt_priority,v.vn,v.oqueue,v.cur_dep_time,p.pname,p.fname,p.lname order by v.pt_priority desc, v.cur_dep_time
select distinct v.hn,concat(p.fname,' ',p.lname) as name from ovst v left outer join patient p on p.hn=v.hn where v.vstdate = '2007-09-17' and v.cur_dep='040'
select concat(r.rx_time,' - ',o.rx_queue,' - ',p.pname,p.fname,' ',p.lname,' : ',p.hn) as name from patient p,ovst o,rx_doctor r where p.hn=o.hn and o.vstdate='2007-09-17' and r.vn=o.vn and r.doctor='002' order by r.rx_time desc