select ov.vn,ov.hn,ov.vstdate,concat(pt.pname,' ',pt.fname,' ',pt.lname) as ptname,pt.cid,ptty.name,pttyno.pttypeno,op.icode,v.age_y,
concat(d.name,' ',d.strength) as drugname,if(concat(su.name1," ",su.name2)<>"",concat(su.name1," ",su.name2),concat(du.name1,' ',du.name2,' ',du.name3)) as use_name,
os.bps,os.bpd,os.bmi,os.bw,os.cc,os.hpi,os.pe,os.height,
concat(h.hosptype,' ',h.name) as send_to_pcu_name, cl.name as clinic_name, cm.begin_year, cm.number, cm.subtype,
ic0.name as diag_name,ic1.name as diag_name0,ic2.name as diag_name1,ic3.name as diag_name2,ic4.name as diag_name3,vi.ptnote,v.pdx, v.dx0, v.dx1, v.dx2, v.dx3
from ovst ov
left outer join patient pt on pt.hn=ov.hn
left outer join pttypeno pttyno on pttyno.hn=ov.hn
left outer join pttype ptty on ptty.pttype=pttyno.pttype
left outer join opitemrece op on op.vn=ov.vn
left outer join drugitems d on d.icode=op.icode
left outer join drugusage du on du.drugusage=op.drugusage
left outer join sp_use su on su.sp_use = op.sp_use
left outer join opdscreen os on os.vn=ov.vn
left outer join clinicmember cm on cm.hn = ov.hn
left outer join hospcode h on h.hospcode = cm.send_to_pcu_hcode
left outer join clinic cl on cl.clinic = cm.clinic
left outer join vn_stat v on v.vn=ov.vn
left outer join icd101 ic0 on ic0.code = v.pdx
left outer join icd101 ic1 on ic1.code = v.dx0
left outer join icd101 ic2 on ic2.code = v.dx1
left outer join icd101 ic3 on ic3.code = v.dx2
left outer join icd101 ic4 on ic4.code = v.dx3
left outer join visit_note vi on vi.vn=v.vn
where ov.hn='0000015' and cl.clinic ="002" and op.icode like "10%"
ผิด ถูก ไม่รู้ครับ
และไม่รู้ว่าจะแยกเอาเฉพาะยาคลินิกได้ยังไง
ลองดู ทำเสร็จแล้วเอามาแบ่งมั้ง