BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: xycop ที่ กุมภาพันธ์ 25, 2015, 14:36:20 PM

หัวข้อ: รานงานคนไข้ทะเบียนเบาหวานและความดันที่คุม BP น้อยกว่า 140/90 ย้อนหลัง 2 ครั้ง
เริ่มหัวข้อโดย: xycop ที่ กุมภาพันธ์ 25, 2015, 14:36:20 PM
ช่วยดู 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"
หัวข้อ: Re: รานงานคนไข้ทะเบียนเบาหวานและความดันที่คุม BP น้อยกว่า 140/90 ย้อนหลัง 2 ครั้ง
เริ่มหัวข้อโดย: golf_pk ที่ กรกฎาคม 22, 2015, 14:02:56 PM
ถ้า 3 ครั้งละครับ จะเขียนโค้ดอย่างไรดี