ต้องการแสดงชื่อ ICD-10 ที่เป็นโรคหัวใจ
จากคำสั่ง
select pt.cid,pt.hn, concat(pt.pname,pt.fname," ",pt.lname) as fullname,pt.birthday,concat(pt.addrpart," ËÁÙè ",pt.moopart," µ.",t3.name," Í.",t2.name," ¨.",t1.name) as fulladdressname,
pt.moopart, ov.age_y,ic.name,ic0.name,ic1.name,ic2.name,ic3.name,ic4.name,ic5.name
from ovst ovst
left outer join patient pt on pt.hn=ovst.hn
left outer join vn_stat ov on ov.vn=ovst.vn
left outer join icd101 ic on ic.code=ov.pdx
left outer join icd101 ic0 on ic0.code=ov.dx0
left outer join icd101 ic1 on ic1.code=ov.dx1
left outer join icd101 ic2 on ic2.code=ov.dx2
left outer join icd101 ic3 on ic3.code=ov.dx3
left outer join icd101 ic4 on ic4.code=ov.dx4
left outer join icd101 ic5 on ic5.code=ov.dx5
left outer join thaiaddress t1 on t1.chwpart=pt.chwpart
and t1.amppart="00" and t1.tmbpart="00"
left outer join thaiaddress t2 on t2.chwpart=pt.chwpart
and t2.amppart=pt.amppart and t2.tmbpart="00"
left outer join thaiaddress t3 on t3.chwpart=pt.chwpart
and t3.amppart=pt.amppart and t3.tmbpart=pt.tmbpart
where ov.vstdate between "2009-07-01" and "2009-07-31"
and ov.aid="960507"
and ov.moopart in ('1','01','2','02','3','03')
and ((ov.pdx >= "i30" AND ov.pdx <= "i529") OR (ov.pdx >= "i20" AND
ov.pdx <= "i289") OR (ov.pdx >= "i05" AND ov.pdx <= "i099") OR
(ov.dx0 >= "i30" AND ov.dx0 <= "i529") OR (ov.dx0 >= "i20" AND
ov.dx0 <= "i289") OR (ov.dx0 >= "i05" AND ov.dx0 <= "i099") OR
(ov.dx1 >= "i30" AND ov.dx1 <= "i529") OR (ov.dx1 >= "i20" AND
ov.dx1 <= "i289") OR (ov.dx1 >= "i05" AND ov.dx1 <= "i099") OR
(ov.dx2 >= "i30" AND ov.dx2 <= "i529") OR (ov.dx2 >= "i20" AND
ov.dx2 <= "i289") OR (ov.dx2 >= "i05" AND ov.dx2 <= "i099") OR
(ov.dx3 >= "i30" AND ov.dx3 <= "i529") OR (ov.dx3 >= "i20" AND
ov.dx3 <= "i289") OR (ov.dx3 >= "i05" AND ov.dx3 <= "i099") OR
(ov.dx4 >= "i30" AND ov.dx4 <= "i529") OR (ov.dx4 >= "i20" AND
ov.dx4 <= "i289") OR (ov.dx4 >= "i05" AND ov.dx4 <= "i099") OR
(ov.dx5 >= "i30" AND ov.dx5 <= "i529") OR (ov.dx5 >= "i20" AND
ov.dx5 <= "i289") OR (ov.dx5 >= "i05" AND ov.dx5 <= "i099"))
group by ov.hn
order by pt.moopart,pt.hn