sql ReAdmit แยก ward แยกแผนก
Post By : tharatip
IP Address : 125.26.115.46
select a.an,a.regdate,a.dchdate,a.lastvisit,
a.pdx,a.age_y,
i.name as pdxname,
concat(p.pname,"",p.fname," ",p.lname) as ptname,
a.ward,w.name,a.spclty ,s.name
from an_stat a
left outer join patient p on p.hn=a.hn
left outer join icd101 i on i.code=substring(a.pdx,1,3)
left outer join ward w on w.ward=a.ward
left outer join spclty s on s.spclty=a.spclty
where a.dchdate between "2011-01-01" and "2011-01-31" and
a.lastvisit <= 7
ใส่จำนวนวันที่ต้องการ
Message!
หากต้องการตอบกระทู้ Webboard กรุณาเข้าใช้ระบบก่อนนะค่ะ..กระทู้ตอบกลับ
select a.hn,a.an,b.an,concat(p.pname,p.fname," ",p.lname)as ptname,b.pdx as old_pdx,a.pdx,a.dx0,a.dx1,a.dx2,a.dx3,a.dx4,a.dx5,
a.regdate,a.dchdate,b.regdate,b.dchdate,a.age_y,a.age_m,a.age_d,a.aid,w.name,i.name as pdxname,a.lastvisit
from an_stat a
left outer join an_stat b on a.hn=b.hn and a.pdx=b.pdx and a.an>b.an
left outer join patient p on a.hn=p.hn
left outer join icd101 i on i.code=a.pdx
left outer join ipt ip on ip.an=a.an
left outer join ward w on w.ward=a.ward
where (a.dchdate between "2011-01-01" and "2011-03-31" ) and a.lastvisit <= "28"
and ((to_days(a.regdate))-(to_days(b.dchdate)))<="28"
and a.pdx is not null and a.pdx<>"" and a.pdx not like "Z%" and a.old_diagnosis="Y"
order by a.an
Readmit ด้วย Diag เดิม
Post โดย : tharatip Date: 1468-07-25 17:25:44 ip: 125.26.118.231