ผู้เขียน หัวข้อ: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ  (อ่าน 2432 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ nut

  • Full Member
  • ***
  • กระทู้: 198
  • Respect: 0
    • ดูรายละเอียด
ปกติคำสั่งนี้รายงานจะออกมาทุก 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")
)
 
Mr.nutthasit  Romsri  Chumphae Hospital 
Mail tonoromsri@hotmail.com 
Hosxp  3.56.1.30 
Server: CentOS 5.2  64 bit ram 10 G Mysql 5.1.30 64 bit
Slave  : CentOS 5.2  64 bit ram   4 G Mysql 5.1.30 64 bit

ออฟไลน์ woravet

  • Sr. Member
  • ****
  • กระทู้: 409
  • Respect: +12
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
« ตอบกลับ #1 เมื่อ: มีนาคม 05, 2009, 14:18:28 PM »
0
แบบนี้ไหวมั๊ย
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 ไหนก้อเพิ่มเองนะคับ
รพ.บึงสามัคคี จ.กำแพงเพชร
*********************
อ.สุชัยและคณะ ขึ้นระบบ 29 ตค.49(Linux+Fedara 5)
*********************
ปัจจุบัน
HOSxP version 3.53.4.27
Server:Windows XP SP2,MySQL 5
Client ประมาณ 15 เครื่อง

ออฟไลน์ armds

  • Hero Member
  • *****
  • กระทู้: 1,084
  • armds
  • Respect: +10
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
« ตอบกลับ #2 เมื่อ: มีนาคม 05, 2009, 14:44:41 PM »
0
ลองดูตามนี้ครับ  เลือกเฉพาะที่มาครั้งล่าสุด  ของแต่ละคนครับ
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
โรงพยาบาลสมเด็จพระยุพราชด่านซ้าย จ.เลย
ขนาด 60 เตียง นวก. คอมพิวเตอร์ ขึ้นระบบ ปี 2548
ขอบคุณ อ.ชัยพร อ.สุชัย อ.เดชา อ.doreamon อ.naj อ.ขวด และอ.ในเว็บ hosxp.net ทุกท่าน

ออฟไลน์ nut

  • Full Member
  • ***
  • กระทู้: 198
  • Respect: 0
    • ดูรายละเอียด
Re: ช่วยดูคำสั่งให้หน่อยครับ รบกวน อ. ทุกท่าน ครับ
« ตอบกลับ #3 เมื่อ: มีนาคม 05, 2009, 15:45:51 PM »
0
ขอบคุณมากครับ
Mr.nutthasit  Romsri  Chumphae Hospital 
Mail tonoromsri@hotmail.com 
Hosxp  3.56.1.30 
Server: CentOS 5.2  64 bit ram 10 G Mysql 5.1.30 64 bit
Slave  : CentOS 5.2  64 bit ram   4 G Mysql 5.1.30 64 bit