1. คำสั่งตรวจสอบการทำหัตถการหญิงหลังคลอด ต้องทำหัตถการครบทั้ง 5 รหัส("9007712","9007713","9007714","9007716","9007730")
Free schedule เบิกผ่านข้อมูล 43 แฟ้ม สปสช.

คำสั่ง SQL = SELECT h2.hn,h2.service_date,CONCAT(p.pname,p.fname," ",p.lname) as ptname,v.age_y,
group_CONCAT(h3.health_med_organ_code,h4.health_med_operation_type_code,h5.health_med_operation_item_code) as ICD10TM_Code,
count(h5.health_med_operation_item_code)as จำนวนหัตถการ,hmc.name,hp.health_med_provider_full_name,
v.pdx,v.dx0,v.dx1,v.dx2,v.dx3,v.dx4,v.dx5
from health_med_service_operation h1
left OUTER JOIN health_med_service h2 on h2.health_med_service_id=h1.health_med_service_id
LEFT OUTER JOIN health_med_organ h3 on h3.health_med_organ_id=h1.health_med_organ_id
LEFT OUTER JOIN health_med_operation_type h4 on h4.health_med_operation_type_id=h1.health_med_operation_type_id
LEFT OUTER JOIN health_med_operation_item h5 on h5.health_med_operation_item_id=h1.health_med_operation_item_id
LEFT OUTER JOIN health_med_provider hp on hp.health_med_provider_id=h1.health_med_provider_id
LEFT OUTER JOIN health_med_service_type h6 on h6.health_med_service_type_id=h2.health_med_service_type_id
LEFT OUTER JOIN health_med_service_result h7 on h7.health_med_service_result_id=h2.health_med_service_result_id
LEFT OUTER JOIN vn_stat v on v.vn=h2.vn
LEFT OUTER JOIN patient p on p.hn=h2.hn
left OUTER JOIN thaiaddress t on t.addressid=v.aid
LEFT OUTER JOIN health_med_operation_code hmc ON
hmc.icd10tm=CONCAT(h3.health_med_organ_code,h4.health_med_operation_type_code,h5.health_med_operation_item_code)
WHERE CONCAT(h3.health_med_organ_code,h4.health_med_operation_type_code,h5.health_med_operation_item_code)
in("9007712","9007713","9007714","9007716","9007730") and h2.service_date between '2019-10-01' and '2020-09-30'
group by h2.vn order by h2.service_date, h2.service_time,h2.hn,6

 

                                    วิธีการใช้งาน SQL QUERY HOSxP