BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: nut ที่ มีนาคม 05, 2009, 10:12:28 AM

หัวข้อ: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
เริ่มหัวข้อโดย: nut ที่ มีนาคม 05, 2009, 10:12:28 AM
ปกติคำสั่งนี้รายงานจะออกมาทุก visit ครับ ผมต้องการ visit ล่าสุดของแต่ละคนครับ ต้องแก้คำสั่งอย่างไรครับ รบกวน อ. ทุกท่านครับ
select pt.*,ov.*
from vn_stat ov ,patient pt ,ovst ovst
where  ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2007-01-01" and  "2009-12-31" and ov.hn=pt.hn
 and ov.aid="400508"
 and ov.age_y>= 0
 and ov.age_y<= 200
 and ( (ov.pdx = "E119")
 or (ov.dx0 = "E119")
 or (ov.dx1 = "E119")
 or (ov.dx2 = "E119")
 or (ov.dx3 = "E119")
 or (ov.dx4 = "E119")
 or (ov.dx5 = "E119")
 or (ov.pdx = "I10")
 or (ov.dx0 = "I10")
 or (ov.dx1 = "I10")
 or (ov.dx2 = "I10")
 or (ov.dx3 = "I10")
 or (ov.dx4 = "I10")
 or (ov.dx5 = "I10")
)
 
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
เริ่มหัวข้อโดย: woravet ที่ มีนาคม 05, 2009, 14:18:28 PM
แบบนี้ไหวมั๊ย
select p.hn,p.pname,p.fname,p.lname
,v.pdx,v.dx0,v.dx1,v.dx2,v.dx3,v.dx4,v.dx5
,p.last_visit,max(v.vstdate) as maxdate
from patient p
left join vn_stat v on p.hn=v.hn
left join ovstdiag d on v.vn=d.vn
where v.vstdate between '2009-1-1' and '2009-1-31'
and (d.icd10='E119' or d.icd10='I10')
group by p.hn
order by p.hn
อยากได้ field ไหนก้อเพิ่มเองนะคับ
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
เริ่มหัวข้อโดย: armds ที่ มีนาคม 05, 2009, 14:44:41 PM
ลองดูตามนี้ครับ  เลือกเฉพาะที่มาครั้งล่าสุด  ของแต่ละคนครับ
select pt.*,ov.*
from vn_stat ov ,patient pt ,ovst ovst
where  ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2007-01-01" and  "2009-12-31" and ov.hn=pt.hn
 and ov.aid="400508"
 and ov.age_y>= 0
 and ov.age_y<= 200
 and ( (ov.pdx = "E119")
 or (ov.dx0 = "E119")
 or (ov.dx1 = "E119")
 or (ov.dx2 = "E119")
 or (ov.dx3 = "E119")
 or (ov.dx4 = "E119")
 or (ov.dx5 = "E119")
 or (ov.pdx = "I10")
 or (ov.dx0 = "I10")
 or (ov.dx1 = "I10")
 or (ov.dx2 = "I10")
 or (ov.dx3 = "I10")
 or (ov.dx4 = "I10")
 or (ov.dx5 = "I10")
)
group by pt.last_visit  order by pt.last_visit desc
หัวข้อ: Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
เริ่มหัวข้อโดย: nut ที่ มีนาคม 05, 2009, 15:45:51 PM
ขอบคุณมากครับ