ผู้เขียน หัวข้อ: อยากได้คำสั่งตรวจสอบการฉีดยาแต่ไม่ลงยาที่ฉีด  (อ่าน 3594 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ s.pookhao

  • Newbie
  • *
  • กระทู้: 2
  • Respect: 0
    • ดูรายละเอียด
อยากได้ sql ตรวจสอบคนที่มีการทำหัตถการฉีดยาDT / ฉีดยา PCEC แต่ไม่ลง Vaccine

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: อยากได้คำสั่งตรวจสอบการฉีดยาแต่ไม่ลงยาที่ฉีด
« ตอบกลับ #1 เมื่อ: สิงหาคม 04, 2016, 14:34:44 PM »
0
อยากได้ sql ตรวจสอบคนที่มีการทำหัตถการฉีดยาDT / ฉีดยา PCEC แต่ไม่ลง Vaccine

ลองดูนะ
select er.vn,er.vstdate,v.vsttime,v.hn,concat(p.pname,p.fname,space(1),p.lname) as ptname,i.name as vaccine_order
,if(ovc.person_vaccine_id is null,'No','Yes') as yn,pv.vaccine_name,sc.cc
,if(ovc.person_vaccine_id is null,0,1) as yy
,if(ovc.person_vaccine_id is null,1,0) as nn,d2.name as doctor_name
from er_regist er
inner join ovst v on v.vn = er.vn
left join patient p on p.hn = v.hn
left join ovst_vaccine ovc on ovc.vn = er.vn
left join opitemrece op on op.vn = er.vn
left join drugitems i on i.icode = op.icode
left join opdscreen sc on sc.vn = er.vn
left join person_vaccine pv on pv.person_vaccine_id = ovc.person_vaccine_id
left join doctor d on d.code = er.er_doctor
inner join er_regist_oper eo on eo.vn=er.vn and eo.er_oper_code in(----------รหัสกิจกรรมหัตการห้องฉุกเฉินที่ชี้บ่งว่าคือฉีดวัคซิน A B C D)
left outer join doctor d2 on d2.code=eo.doctor
where er.vstdate between "2016-05-18" and "2016-07-31"
and i.drugcategory like กลุ่มวัคซิน'
and (pv.vaccine_name is null or pv.vaccine_name="")
group by er.vn,op.icode
order by er.vstdate,er.vn

ประมาณนี้ แนว ๆ นี้ครับ  ลองไปปรับใช้ดูนะ
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x