BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: gweeped ที่ มิถุนายน 01, 2012, 09:26:22 AM

หัวข้อ: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: gweeped ที่ มิถุนายน 01, 2012, 09:26:22 AM
คืออยากหาจำนวนครั้งของผู้ป่วยที่มารับบริการ เฉพาะ diag อ่ะคะ
เช่น ผู้ป่วยที่มีโรค F123 ระหว่าง วันที่ วว-ดด-ปป ถึง วว-ดด-ปป

ลำดับ   HN       ชื่อ                       จำนวนครั้งที่มารับบริการ
1      xxxxxx    น.ส  กอไก่ ขอไข่          3
2      yyyyyy    นาย  งองู จอจาน           2
3      zzzzzzz    นาง  ลอลิง นอหนู          4

จำนวนครั้งในที่นี่คือนับเฉพาะที่มารับบริการเพราะ F123 ช่วงวันที่ที่กำหนดเท่านั้นนะฮะ
     
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: dusit ที่ มิถุนายน 01, 2012, 09:45:56 AM
คืออยากหาจำนวนครั้งของผู้ป่วยที่มารับบริการ เฉพาะ diag อ่ะคะ
เช่น ผู้ป่วยที่มีโรค F123 ระหว่าง วันที่ วว-ดด-ปป ถึง วว-ดด-ปป

ลำดับ   HN       ชื่อ                       จำนวนครั้งที่มารับบริการ
1      xxxxxx    น.ส  กอไก่ ขอไข่          3
2      yyyyyy    นาย  งองู จอจาน           2
3      zzzzzzz    นาง  ลอลิง นอหนู          4

จำนวนครั้งในที่นี่คือนับเฉพาะที่มารับบริการเพราะ F123 ช่วงวันที่ที่กำหนดเท่านั้นนะฮะ
     

โค๊ด: [Select]

แบบนี้ไหมครับ

select hn,count(hn) As cc,pdx from vn_stat where pdx like "F123%" and
 vstdate between "2012-05-01" and "2012-05-30" group by hn order by cc Desc
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ มิถุนายน 01, 2012, 09:55:47 AM
select p.hn,concat(p.pname,p.fname,"  ",p.lname) as pat,count(v.vn) as aa from vn_stat v
left outer join patient p on p.hn=v.hn
where v.pdx between"I00" and "I999" and v.vstdate between"2012-01-01" and "2012-05-31"
group by hn
order by hn
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: gweeped ที่ มิถุนายน 01, 2012, 09:59:24 AM
ถ้าแบบนี้จำนวนครั้งจะถูกมั้ยฮะ


select pt.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as  ptname    , count(v.vn) as aa
from vn_stat ov ,patient pt ,ovst vt
where  ov.vn=vt.vn and pt.hn=ov.hn and ov.vstdate between "2012-05-01" and  "2012-05-31" and ov.hn=pt.hn
 and ( (ov.pdx = "F123")
 or (ov.dx0 = "F123")
 or (ov.dx1 = "F123")
 or (ov.dx2 = "F123")
 or (ov.dx3 = "F123")
 or (ov.dx4 = "F123")
 or (ov.dx5 = "F123")
)

group by   pt.hn
order by   pt.hn
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ มิถุนายน 01, 2012, 10:13:08 AM
ถ้าแบบนี้จำนวนครั้งจะถูกมั้ยฮะ


select pt.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as  ptname    , count(v.vn) as aa
from vn_stat ov ,patient pt ,ovst vt
where  ov.vn=vt.vn and pt.hn=ov.hn and ov.vstdate between "2012-05-01" and  "2012-05-31" and ov.hn=pt.hn
 and ( (ov.pdx = "F123")
 or (ov.dx0 = "F123")
 or (ov.dx1 = "F123")
 or (ov.dx2 = "F123")
 or (ov.dx3 = "F123")
 or (ov.dx4 = "F123")
 or (ov.dx5 = "F123")
)

group by   pt.hn
order by   pt.hn


เอารหัสโรคทั้งหมด จาก ovstdiag ง่ายกว่านะคัรบ..ไม่สนใจ โรคหลัก โรครอง...เอาทุกประเภท ที่มีรหัสICD10 ตามต้องการ
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: jameborn ที่ มิถุนายน 01, 2012, 11:10:01 AM
select p.hn,concat(p.pname,p.fname,'  ',p.lname) as  ptname
,odx.icd10,count(distinct o.vn) CC,max(o.vstdate) lastdate
from ovst o
left join patient p on p.hn=o.hn
left join vn_stat v on v.vn=o.vn
left join ovstdiag odx on o.vn=odx.vn
where  o.vstdate between "2012-01-01" and  "2012-05-31"
and odx.icd10 between 'F20' and 'F2099'
group by p.hn
order by p.hn

หรือจะประมาณนี้ เปลี่ยนรหัสโรคเอาหล่ะกัน
หัวข้อ: Re: ขอคำแนะนำการนับจำนวนครั้งของการมารับบริการของผู้ป่วยด้วยฮะ
เริ่มหัวข้อโดย: gweeped ที่ มิถุนายน 01, 2012, 12:45:35 PM
ถ้าแบบนี้จำนวนครั้งจะถูกมั้ยฮะ


select pt.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as  ptname    , count(v.vn) as aa
from vn_stat ov ,patient pt ,ovst vt
where  ov.vn=vt.vn and pt.hn=ov.hn and ov.vstdate between "2012-05-01" and  "2012-05-31" and ov.hn=pt.hn
 and ( (ov.pdx = "F123")
 or (ov.dx0 = "F123")
 or (ov.dx1 = "F123")
 or (ov.dx2 = "F123")
 or (ov.dx3 = "F123")
 or (ov.dx4 = "F123")
 or (ov.dx5 = "F123")
)

group by   pt.hn
order by   pt.hn


เอารหัสโรคทั้งหมด จาก ovstdiag ง่ายกว่านะคัรบ..ไม่สนใจ โรคหลัก โรครอง...เอาทุกประเภท ที่มีรหัสICD10 ตามต้องการ

งั้นเอาแบบนี้น่าจะใช่แล้ว ขอบคุณฮะ  :D

select pt.hn,concat(pt.pname,pt.fname,'  ',pt.lname) as  ptname    , count(ov.vn) as aa
from vn_stat ov ,patient pt ,ovst vt , ovstdiag od
where  ov.vn=vt.vn and pt.hn=ov.hn  and  od.vn=vt.vn
 and ov.vstdate between "2012-05-01" and  "2012-05-31" and ov.hn=pt.hn
 and od.icd10 = "F1122"

group by   pt.hn
order by   pt.hn