select r.*,concat(p.pname,p.fname," ",p.lname) as ptname ,i.*, w.name as ward_name,p.*,
y.name as pttype_name
from yindee_ipd_profile_print r
left outer join ipt i on i.an = r.an
left outer join patient p on p.hn = i.hn
left outer join ward w on w.ward = i.ward
left outer join pttype y on y.pttype = i.pttype
where r.an = "000028583"
order by orderstatus,med_plan_number