select ov.*, substring(concat(oost.name,' [',sp.department,']'),1,150) as ovstname,
odx.icd10 as icdcode, vk.vn as lock_vn,pt.birthtime, substring(icd1.name,1,100) as icdname
, concat(odx.icd10,' ',ix.name) as pdxname ,pt.birthday, pty.pcode, st.name as ovstist_name
, concat(pt.pname,' ',pt.fname,' ',pt.lname) as ptname, oapp.nextdate as ndate,vt.age_y,vt.age_m,vt.age_d
, vt.cid,c.complete,vt.pttype_in_region,vt.inc_drug,vt.count_in_day+1 as count_in_day , od.rw from ovst ov
left outer join patient pt on pt.hn=ov.hn
left outer join ovstdiag odx on odx.vn=ov.vn and odx.diagtype='1'
left outer join kskdepartment sp on sp.depcode=ov.cur_dep
left outer join ovstost oost on oost.ovstost=ov.ovstost
left outer join icd101 icd1 on icd1.code=odx.icd10
left outer join icd101 ix on ix.code=substring(odx.icd10,1,3)
left outer join pttype pty on pty.pttype=ov.pttype
left outer join vn_lock vk on vk.vn = ov.vn
left outer join ovstist st on st.ovstist = ov.ovstist
left outer join vn_stat vt on vt.vn=ov.vn
left outer join ovst_drgs od on od.vn = ov.vn
left outer join oapp on oapp.vn=ov.vn and oapp.app_no=1
left outer join vn_opd_complete c on c.vn=ov.vn where (ov.vstdate='2008-05-24' ) order by ov.vsttime
เปลียนวันที่