ผมลองก่อนนะครับ ไงก็ เดี๋ยวแจ้งอีกที เหอๆๆ ยุ่งตั้งแต่วันจันทร์เลย 555+
PCU-FORM-DOCTOR-RxOrder-1
select o.*,v1.*,o1.*,s1.name as spclty_name,p1.drugallergy,p1.nationality,p1.citizenship,
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,
concat(p1.addrpart," หมู่ ",p1.moopart," ",t.full_name)as pt_address,' โทร. ',
if((p1.hometel is null or p1.hometel = ''),' - ',p1.hometel) as patient_address_tel ,
concat(p1.pname,p1.fname," ",p1.lname)as ptname ,
o.qty,o.unitprice,o.sum_price ,sd.name as s_name ,if(du.shortlist is null,(select concat(name1," ",name2," ",name3)as sp from sp_use where sp_use = o.sp_use),du.shortlist)as usage_name
from ovst o1
left outer join vn_stat v1 on v1.vn = o1.vn
left outer join patient p1 on p1.hn = o1.hn
left outer join thaiaddress t on t.addressid =v1.aid
left outer join spclty s1 on s1.spclty = o1.spclty
left outer join pttype p2 on p2.pttype = v1.pttype
left outer join opitemrece o on o.vn =o1.vn
left outer join s_drugitems sd on sd.icode = o.icode
left outer join drugitems di on di.icode = o.icode
left outer join drugusage du on du.drugusage =o.drugusage
where o1.vn = '520720102140' order by sd.income,di.therapeuticgroup,sd.name
PCU-FORM-DOCTOR-OPDCARD-1
select o1.*,v1.*,s.*,pe.*,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,
'โทร. ',
if((p.hometel is null or p.hometel = ''),' - ',p.hometel) as
patient_address_tel,
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,x1.vn as xray_vn,
oa.*,oa.vn as oapp_vn,ro.vn as
refer_vn,ro.refer_date,ro.refer_point,ro.hospcode as
refer_hospcode,
concat(if(hc1.hosptype is null,'',hc1.hosptype),if(hc1.name is
null,'',hc1.name)) as refer_hospname,
iaq.vn as admit_vn,w1.name as admit_ward ,
concat(p.pname,p.fname," ",p.lname)as ptname,
concat(p.addrpart," หมู่ ",p.moopart," ",t.full_name)as pt_address
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 oapp oa on oa.vn = o1.vn
left outer join patient p on p.hn = o1.hn
left outer join thaiaddress t on t.addressid =v1.aid
left outer join xray_head x1 on x1.vn = o1.vn
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 referout ro on ro.vn = o1.vn
left outer join hospcode hc1 on hc1.hospcode = ro.hospcode
left outer join ipt_admit_queue iaq on iaq.vn = o1.vn
left outer join ward w1 on w1.ward = iaq.request_ward
where o1.vn = '520616102630'
ดูให้ด้วยครับ