BMS-HOSxP Community

HOSxP => การเขียน SQL Script => ข้อความที่เริ่มโดย: yukiplee ที่ กรกฎาคม 10, 2013, 15:24:28 PM

หัวข้อ: ตรวจ CBC
เริ่มหัวข้อโดย: yukiplee ที่ กรกฎาคม 10, 2013, 15:24:28 PM
ห้อง LAB ขอรายงาน จำนวนผู้ตรวจ CBC,UA  ไปทั้งหมดกี่ครั้งครับ รบกวนผู้รู้ทุกท่านคับ ขอบคุณครัฟ
หัวข้อ: Re: ตรวจ CBC
เริ่มหัวข้อโดย: mini ที่ กรกฎาคม 16, 2013, 11:16:53 AM
ลองเอาไปปรับดูค่ะ :D

select h.*
 from vn_stat v, ovst o, patient p,lab_head h,lab_order_service s
 where v.vn=o.vn and p.hn=o.hn and o.vn=h.vn and h.lab_order_number=s.lab_order_number
 and  o.vstdate not in (select holiday_date from holiday)
  and o.vstdate  between '2013-06-01' and  '2013-06-31'
 and s.lab_order_type='PROFILE' and s.lab_code in (1)
หัวข้อ: Re: ตรวจ CBC
เริ่มหัวข้อโดย: woravet ที่ กรกฎาคม 16, 2013, 12:28:16 PM
select order_date
,count(vn) Total
,sum(sub_group_list regexp '12' or sub_group_list regexp '81' or sub_group_list regexp '87' ) CBC
,sum(sub_group_list regexp '33' or sub_group_list regexp '89' ) UA
from lab_head lh
where lh.order_date between '2013-1-1' and '2013-1-31'
group by order_date
แก้รหัส CBC กับ UA เอานะ
อย่าง CBC ผมมี 3 รหัส UA มี 2 รหัส
หัวข้อ: Re: ตรวจ CBC
เริ่มหัวข้อโดย: udomchok ที่ กรกฎาคม 22, 2013, 01:28:39 AM
แบบไม่ซับซ้อน

เปลี่ยนชื่อ LAB ตามที่ ร.พ. ใช้นะครับ
select los.lab_name, count(los.lab_order_number) as times, lh.department
from lab_order_service los
join lab_head lh on lh.lab_order_number=los.lab_order_number
where los.lab_name in ("CBC","Urine Exam") and lh.order_date between "2013-01-01" and "2013-03-31"
group by los.lab_name, lh.department
หัวข้อ: Re: ตรวจ CBC
เริ่มหัวข้อโดย: fayrider. ที่ ตุลาคม 10, 2013, 12:44:24 PM
แบบไม่ซับซ้อน

เปลี่ยนชื่อ LAB ตามที่ ร.พ. ใช้นะครับ
select los.lab_name, count(los.lab_order_number) as times, lh.department
from lab_order_service los
join lab_head lh on lh.lab_order_number=los.lab_order_number
where los.lab_name in ("CBC","Urine Exam") and lh.order_date between "2013-01-01" and "2013-03-31"
group by los.lab_name, lh.department

ขอบคุณมากเลยค่ะอาจารย์  จะลองนำคำสั่งนี้ไปปรับใช้ค่ะ >"<