ผมจะนำข้อมูลจากตาราง er_emergency_level มาใส่แทนความเร่งด่วน แก้คำสั่งให้หน่อยครับ
select o1.*,v1.*,s.*,pe.*,concat(p.pname,p.fname,' ',p.lname) as patient_name,
p.drugallergy,p.clinic as patient_clinic,p.nationality,p.hometel as pt_tel,
p2.pttype as pttype_pttype,p2.name as pttype_name,p2.pcode as pttype_pcode,
p2.requirecode as pttype_requirecode,p2.require_hcode as pttype_require_hcode,
oo.vn as observe_vn,oo.observe_id,oo.send_date_time as observe_intime,
oo.leave_date_time as observe_outtime,oo.symptom as observe_symptom,
oo.nurse_activity as observe_activity,oo.note as observe_note,
oo.ward as observe_ward,pp.name as pt_priority_name,pw.name as pt_walk_name,
concat(help3_icode,' # ',if(help3_qty is null,'',help3_qty)) as help3_drug_name,
iaq.vn as admit_vn,w1.name as admit_ward,es.vn as eye_vn,es.*,s.vn as opdscreen_vn,e3.name,e1.*
from ovst o1
left outer join vn_stat v1 on v1.vn = o1.vn
left outer join opdscreen s on s.vn = o1.vn
left outer join pe_image pe on pe.vn = o1.vn
left outer join opd_observe oo on oo.vn = o1.vn
left outer join patient p on p.hn = o1.hn
left outer join pttype p2 on p2.pttype = v1.pttype
left outer join pt_priority pp on pp.id = o1.pt_priority
left outer join pt_walk pw on pw.walk_id = s.walk_id
left outer join ipt_admit_queue iaq on iaq.vn = o1.vn
left outer join ward w1 on w1.ward = iaq.request_ward
left outer join eye_screen es on es.vn = o1.vn
left outer join er_regist e1 on e1.vn = o1.vn
left outer join er_emergency_type e3 on e3.er_emergency_type = e1.er_emergency_type
where o1.vn = '550511174539'