select d.icode,concat(d.name,' ',d.strength) as drug_ ,concat(pt.pname,pt.fname," ",pt.lname) as fullname,
concat(pt.addrpart," ËÁÙè ",pt.moopart," µ.",t3.name," Í.",t2.name," ¨.",t1.name) as fulladdressname,
o.an,qty,year(rxdate)-year(birthday) as age,rxdate,o.order_no,o.drugusage,dr.shortlist
from opitemrece o
left outer join drugitems d on d.icode = o.icode
left outer join patient pt on pt.hn=o.hn
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
left outer join drugusage dr on dr.drugusage=o.drugusage
where vstdate between '2009-05-01' and '2009-07-31' and o.sub_type =1
and o.icode in('1000106','1000107','1000108','1481221','1000238','1000239','1483784')
and o.qty <> '0'
order by d.icode,vstdate