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
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 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 "2010-10-01" and "2010-10-31"
and ov.aid="960501"
and ov.moopart ="2"
and ( (ov.pdx = "E10")
or (ov.dx0 = "E10")
or (ov.dx1 = "E10")
or (ov.dx2 = "E10")
or (ov.dx3 = "E10")
or (ov.dx4 = "E10")
or (ov.dx5 = "E10")
or (ov.pdx = "E11")
or (ov.dx0 = "E11")
or (ov.dx1 = "E11")
or (ov.dx2 = "E11")
or (ov.dx3 = "E11")
or (ov.dx4 = "E11")
or (ov.dx5 = "E11")
or (ov.pdx = "E109")
or (ov.dx0 = "E109")
or (ov.dx1 = "E109")
or (ov.dx2 = "E109")
or (ov.dx3 = "E109")
or (ov.dx4 = "E109")
or (ov.dx5 = "E109")
or (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 = "E129")
or (ov.dx0 = "E129")
or (ov.dx1 = "E129")
or (ov.dx2 = "E129")
or (ov.dx3 = "E129")
or (ov.dx4 = "E129")
or (ov.dx5 = "E129")
or (ov.pdx = "E139")
or (ov.dx0 = "E139")
or (ov.dx1 = "E139")
or (ov.dx2 = "E139")
or (ov.dx3 = "E139")
or (ov.dx4 = "E139")
or (ov.dx5 = "E139")
or (ov.pdx = "E149")
or (ov.dx0 = "E149")
or (ov.dx1 = "E149")
or (ov.dx2 = "E149")
or (ov.dx3 = "E149")
or (ov.dx4 = "E149")
or (ov.dx5 = "E149") )
group by ov.hn
order by pt.moopart,pt.hn
อยากทราบว่าคำสั่งนี้สามารถใช้ได้ไหมครับ เพราะว่ามีบางคนที่เป็นเบาหวานแต่ยังไม่ได้ลงในทะเบียนคลีนิคเบาหวานอีก ก็เลยอยากดึงจากผลวินิจฉัยที่แพทย์สรุป และอยากทราบคำสั่งที่ใช้ในการดึงกับผู้ป่วยเบาหวานที่มีภาวพแทรกซ้อน