รบกวนขอชุดคำสั่งได้หรือเปล่าครับ ผมลองแล้วไม่ได้ครับ
ทดสอบตามนี้ครับ..
select r.vn,r.hn,r.refer_number,r.refer_date,r.due_date,r.pmh,r.hpi,r.lab_text,r.pre_diagnosis,r.pdx,r.treatment_text,r.other_text,
concat(h.hosptype," ",h.name) as refer_hospital_name,
concat(pt.pname,pt.fname," ",pt.lname) as fullname,
pt.cid,pt.addrpart,pt.moopart,pt.road,t1.full_name,
t1.name as chwname,t2.name as ampname,t3.name as tmbname,
a.age_y as aage_y,a.pttypeno as pttno,
ptt.name as pttname,
c.name as refer_cause_name,
i1.name as icd101name,
s.name as rfrcs_name,
d.name as doctorname
from referout r
left outer join patient pt on pt.hn=r.hn
left outer join icd101 i1 on i1.code=r.pdx
left outer join doctor d on r.doctor = d.code
left outer join vn_stat a on r.vn = a.vn
left outer join pttype ptt on ptt.pttype= a.pttype
left outer join hospcode h on h.hospcode = r.hospcode
left outer join refer_cause c on c.id = r.refer_cause
left outer join rfrcs s on s.rfrcs = r.rfrcs
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 referout_id ='42221' and r.rfrcs is not null and r.refer_cause is not null and r.refer_write_staff is not null