ลองเพิ่ม group by d1.icode น่าจะแก้ปัญหาได้นะครับ
select d1.*,v1.*,o1.*,concat(opa.agent," ",opa.symptom) as drugallergy,concat(d1.line1,d1.line2,d1.line3)as drugfull
from doctor_order_print d1
left outer join vn_stat v1 on v1.vn=d1.vn
left outer join ovst o1 on o1.vn=d1.vn
left outer join opd_allergy opa on opa.hn=v1.hn
where d1.vn="521030163017" and d1.print_server="hosxp_boy"
group by d1.icode
order by d1.bed_no,d1.item_no