เอาแบบง่ายๆก่อนนะครับไม่มีเวลาสร้างฟอร์มให้
select h.lab_order_number,h.vn,h.hn,h.order_date ,h.order_time,h.receive_time as receive,h.report_time as report ,
h.confirm_report,d.name as doctor_name,v.age_y,a.age_y, concat(pt.pname,pt.fname,' ',pt.lname) as ptname ,
o1.lab_order_result as HIV_result , h.lab_receive_number ,li.lab_items_code,li.lab_items_name ,h.order_note
from lab_head h
left outer join patient pt on pt.hn=h.hn
left outer join lab_order o1 on o1.lab_order_number=h.lab_order_number and o1.confirm="Y"
and o1.lab_order_result<>"" and o1.lab_order_result is not NULL
left outer join lab_order o2 on o2.lab_order_number=h.lab_order_number and o2.confirm="Y"
and o2.lab_order_result <> "Not Found"
left outer join vn_stat v on v.vn=h.vn
left outer join an_stat a on a.an=h.vn
left outer join doctor d on d.code=h.doctor_code
left outer join lab_items li on o1.lab_items_code=li.lab_items_code
where h.order_date between "2009-06-01" and "2009-06-31" and li.lab_items_name like "%HIV%" and (v.pttype in(
89,90) or a.pttype in(
89,90))
group by h.lab_receive_number
โดย
89,90 คือระหัสสิทธิ์ที่ต้องการในเขต/นอกเขตแยกคนละฟอร์มนะครับ
เอาไปเป้นแนวทางพัฒนาครับ