BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: โรงพยาบาลอัมพวา ที่ กันยายน 29, 2011, 14:30:34 PM

หัวข้อ: ขอรายงานหน่อยครับท่าน
เริ่มหัวข้อโดย: โรงพยาบาลอัมพวา ที่ กันยายน 29, 2011, 14:30:34 PM
ขอรายงานผู้ป่วยไม่มาตามนัด  เอาแบบมีที่อยู่ด้วย อ่ะครับ ตามที่มีอยู่ ในโปรแกรมแล้วอ่ะครับ เพิ่ม ที่อยู่
เอาเป็น คิวรี่ก็ได้นะครับ




select pt.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as ptname,  c.name as clinic_name, o.doctor, d.name as doctor_name,
concat(pt.addrpart," ? ",pt.moopart," ?.",t3.name," ?.",t2.name," ?.",t1.name) as fulladdressname,
 o.hn,o.vstdate,o.nextdate,o.nexttime,o.note,o.vn,k.department,  count(v.hn) as visit_count
  from oapp o
  left outer join patient pt on pt.hn=o.hn
  left outer join clinic c on c.clinic=o.clinic
  left outer join doctor d on d.code=o.doctor
  left outer join kskdepartment k on k.depcode = o.depcode
  left outer join ovst v on v.vstdate=o.nextdate
  left outer join thaiaddress t1 on t1.chwpart=pt.chwpart and
     t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart and
     t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart and
     t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
  and v.hn=o.hn  where o.nextdate between '2011-08-01'  and '2011-08-31'
  and o.hn not in (select hn from ovst
  where vstdate between  '2011-08-01' and '2011-08-31' )
  group by  o.oapp_id,pt.pname,pt.fname,pt.lname,c.name,o.doctor,d.name ,  o.hn,o.vstdate,o.nextdate,o.nexttime,o.note,o.vn,k.department
ผม ลองเขียนรัยได้แตที่อยู่ไม่ขึ้น
หัวข้อ: Re: ขอรายงานหน่อยครับท่าน
เริ่มหัวข้อโดย: ไม่เสียสละ ชัยชนะไม่เกิด ที่ กันยายน 29, 2011, 15:05:07 PM
ทำไมมันรันนานมากเลยครับ
หัวข้อ: Re: ขอรายงานหน่อยครับท่าน
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ กันยายน 29, 2011, 15:11:22 PM
ขอรายงานผู้ป่วยไม่มาตามนัด  

ผมว่า แปลก ๆ นะ  ไม่มาตามนัด กับ ขาดนัด

เช่น นัด25 ก.ย. 54 แต่มาตรวจ 28 ต.ค 54 ก็ถือว่าไม่มาตามนัด  แต่จะใช้ o.hn not in xxxx-xx-xx and xxxx-xx-yy ไม่น่าจะได้ครับ...เพราะอาจมาตรวจก่อนหรือหลังวันนัดไม่เกิน 1-7 วัน และไม่ถือว่าขาดยา...

น่าจะต้องกำหนดเพิ่มเติมว่าเป็นรายงานขาดนัดเลยทีเดียว

ถ้าไม่มาตามนัด อาจต้องเป็น o.nextdate <> vstdate and vstdate > o.nextdate ประมาณนี้ครับ..หรือถ้ามาก่อนนัดสัก 3 วัน (เผื่อติดธุระ ) จะกลายเป็น vstdate < nextdate
ซึ่ีงต้องมี บวก/ลบ ของวันที่อนุโลมได้ว่าไม่ขาดยาและไม่ขาดนัด  คงต้องเพิมนิยาม  ไม่มาตามนัดเกิน 7 วัน จะได้ว่า( vstdate > nextdate และ>=7  day
หัวข้อ: Re: ขอรายงานหน่อยครับท่าน
เริ่มหัวข้อโดย: niyomstd ที่ กันยายน 29, 2011, 15:16:15 PM
ตาม อ.เกื้อ เลยครับ
ลองนำ sql นี้ไปทดสอบดูครับ

  select concat(p.pname,p.fname,'  ',p.lname) as ptname,p.informaddr,
c.name as clinic_name, o.doctor, d.name as doctor_name,
 o.hn,o.vstdate,o.nextdate,o.nexttime,o.note,o.vn,k.department
 from oapp o  left outer join patient p on p.hn=o.hn
 left outer join clinic c on c.clinic=o.clinic
 left outer join doctor d on d.code=o.doctor
 left outer join kskdepartment k on k.depcode = o.depcode
 left outer join ovst v on v.vstdate=o.nextdate and v.hn=o.hn
 where o.nextdate between '2011-09-29' and '2011-09-29'
  and o.hn not in (select hn from ovst where vstdate between  '2011-09-29' and '2011-09-29' )
  group by  o.oapp_id,p.pname,p.fname,p.lname,c.name,o.doctor,d.name ,
   o.hn,o.vstdate,o.nextdate,o.nexttime,o.note,o.vn,k.department
หัวข้อ: Re: ขอรายงานหน่อยครับท่าน
เริ่มหัวข้อโดย: woravet ที่ กันยายน 29, 2011, 15:36:12 PM
select a.hn,p.pname,p.fname,p.lname
,a.nextdate
,c.name as clinic,k.department,a.doctor, d.name as doctorname
,concat(p.addrpart,' ม.',p.moopart,' ',t.full_name) address
from oapp a
left join patient p on a.hn=p.hn
left join clinic c on c.clinic=a.clinic
left join doctor d on d.code=a.doctor
left join kskdepartment k on k.depcode = a.depcode
left join thaiaddress t on t.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
where a.nextdate between '2011-9-1' and '2011-9-30'
and (a.patient_visit<>'Y' or a.patient_visit is null)
group by a.hn,a.nextdate