ผู้เขียน หัวข้อ: รานงานคนไข้ทะเบียนเบาหวานและความดันที่คุม BP น้อยกว่า 140/90 ย้อนหลัง 2 ครั้ง  (อ่าน 3440 ครั้ง)

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

ออฟไลน์ xycop

  • Full Member
  • ***
  • กระทู้: 157
  • Respect: +1
    • ดูรายละเอียด
    • โรงพยาบาลบ้านโป่ง
ช่วยดู code หน่อยครับ ประมวลผลนานมากกกกกก

set @d1 = '2015-01-11';
set @d2 = '2015-01-11';

select *
from
(select v.hn,concat(p.pname,p.fname,space(3),p.lname) as ptname, v.aid,
(select sc1.bps
 from opdscreen sc1
 where sc1.vstdate between  @d1 and @d2 and sc1.hn = v.hn  and  sc1.bps<>"" and sc1.bps<>"0"  and sc1.bps is not null
 order by sc1.vstdate desc limit 0,1)+0 as bps,
 (select sc2.bps
 from opdscreen sc2
 where sc2.vstdate between   @d1 and @d2 and sc2.hn = v.hn  and  sc2.bps<>"" and sc2.bps<>"0"  and sc2.bps is not null
 order by sc2.vstdate desc limit 1,1)+0 as bps1
 ,

(select sc3.bpd
 from opdscreen sc3
 where sc3.vstdate between   @d1 and @d2 and sc3.hn = v.hn  and  sc3.bpd<>"" and sc3.bpd<>"0"  and sc3.bpd is not null
 order by sc3.vstdate desc limit 0,1)+0 as bpd,
 (select sc4.bpd
 from opdscreen sc4
 where sc4.vstdate between  @d1 and @d2 and sc4.hn = v.hn  and  sc4.bpd<>"" and sc4.bpd<>"0"  and sc4.bpd is not null
 order by sc4.vstdate desc limit 1,1)+0 as bpd1

from vn_stat v
left join patient p on p.hn = v.hn
left join opdscreen sc on sc.vn = v.vn
where v.vstdate between @d1 and @d2
and v.hn in  (select hn from clinicmember where clinic="001" and hn in (select hn from clinicmember     where clinic='002' ))
group by v.hn
order by v.aid desc ,p.pname,p.fname,p.lname
) as ttemp
where bps<="140" and bps1<="140" and  bpd<="90" and bpd1<="90"
ธันยา สุระคำแหง ตำแหน่งนักวิชาการคอมพิวเตอร์ โรงพยาบาลบ้านโป่ง จังหวัดราชบุรี
e-mail  xycop@hotmail.com       Mobile  08-1540-0022

ออฟไลน์ golf_pk

  • Jr. Member
  • **
  • กระทู้: 72
  • ขอบคุณสังคมแห่งการแบ่งปัน สังคม hosxp
  • Respect: 0
    • ดูรายละเอียด
    • https://www.pkhos.moph.go.th
ถ้า 3 ครั้งละครับ จะเขียนโค้ดอย่างไรดี
- วิรัตน์  ศรีวิโรจน์
- โรงพยาบาลปากคาด อ.ปากคาด จ.บึงกาฬ
- https://www.pkhos.moph.go.th
- ขนาด 30 เตียง 
- ขึ้นระบบ HOSxP เดือน เมษายน 2552
กำลังศึกษา ขอคำชี้แนะหน่อยนะครับ

กำลังศึกษาระบบฐานข้อมูล  ต้องการคำชีแนะจากอาจารย์ครับ  ขอรบกวนหน่อยนะครับ