ผู้เขียน หัวข้อ: รบกวน อาจารย์กับท่านadmin เซียนๆทั้งหลายครับ  (อ่าน 2779 ครั้ง)

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

ออฟไลน์ Zulkiflee

  • Jr. Member
  • **
  • กระทู้: 81
  • Respect: 0
    • ดูรายละเอียด
คุณหมออยากได้รายงานเกี่ยวการสั่งยาใน1ใบสั่งยาแล้วมียาในกลุ่ม N-Said ซ้ำกัน ซึ่งยาในกลุ่มนี้จะประกอบด้วย
1.diclofenac tab 2.ibuprofen 200mg 3.ibuprofen 400 mg  4.indomethanacin cap  5.mefenamic acid cap
6.naproxen tab 7.celecoxib cap  8.etoricoxib(arcoxia)tab  9.froctafenine tab   10.aspirin 81 mg
11.aspirin  300 mg  12.diclofenac inj  13.nabumetone tab   14.parecoxib
ถ้ามียาใน 14 ข้อนี้ ในใบสังยาเดียวกันคือซ้ำกัน เช่น มี dicolfenac แล้วก็มี aspirin 300 mg  ถือว่าซ้ำกัน ใน 1000 ใบสั่งยาล่าสุด มีกี่ใบที่มียาในกลุ่มนี้มากว่า 1 รายการ 
ช่วยหน่อยน่ะครับ พี่ๆน้องๆ hosxp
โรงพยาบาลสุไหงโก-ลก จังหวัดนราธิวาส linux centos

ออฟไลน์ chitvichai

  • Full Member
  • ***
  • กระทู้: 103
  • Respect: +5
    • ดูรายละเอียด
    • รพ.เมืองปาน
Re: รบกวน อาจารย์กับท่านadmin เซียนๆทั้งหลายครับ
« ตอบกลับ #1 เมื่อ: เมษายน 23, 2012, 14:44:53 PM »
0
ต้องหา icode ของยาในกลุ่ม n-said มาก่อนแล้วค่อยรัน sql ดังนี้
อ้างถึง
select o.hn,o.vn,sum(icode in (
'icode 1.diclofenac tab',
'icode 2.ibuprofen 200mg',
'icode 3.ibuprofen 400 mg', 
'icode 4.indomethanacin cap', 
'icode 5.mefenamic acid cap',
'icode 6.naproxen tab',
'icode 7.celecoxib cap',
'icode 8.etoricoxib(arcoxia)tab',
'icode 9.froctafenine tab',   
'icode 10.aspirin 81 mg',
'icode 11.aspirin  300 mg', 
'icode 12.diclofenac inj', 
'icode 13.nabumetone tab',   
'icode 14.parecoxib')) as `n-said`
from opitemrece o
where o.vstdate between '2011-10-01' and '2012-03-31' and o.vn is not null
group by o.hn,o.vn
having    `n-said`>1
order by o.hn,o.vn desc

หรือ

กำหนดใน ทะเบียนเวชภัณฑ์ของยาว่าอยู่ใน category 'n-said' ซึ่งย่อมาจาก 'NON-STEROIDAL ANTI-INFLAMMATORIES'

อ้างถึง
select o.hn,o.vn,sum(icode in (select d.icode from drugitems d where d.drugcategory like '%NON-STEROIDAL ANTI-INFLAMMATORIES%')) as `n-said`
from opitemrece o
where o.vstdate between '2011-10-01' and '2012-03-31' and o.vn is not null
group by o.hn,o.vn
having    `n-said`>1
order by o.hn,o.vn desc
[/quot]
« แก้ไขครั้งสุดท้าย: เมษายน 23, 2012, 14:54:21 PM โดย chitvichai »
โรงพยาบาลเมืองปาน (ขนาด 30 เตียง) จังหวัดลำปาง โทร 054-276345-6
Master Server : HP Proliant DL360G7 Ram DDR3 1333 ECC 2x2 GB  HDD 2x146 GB  CentOS 6.2 Linux MySQL 5.5.11
Slave Server I : Acer Altos G540 Ram DDR2 667 ECC 2x1 GB HDD 2x146 GB Redhat Ent 5.2 Linux Mysql 5.1.29
Slave Server II : คอมประกอบ Ram DDR2 667  2x2 GB HDD SATA 160 GB Endian Firewall Community release 2.4.1 Mysql 5.5.24
Client : Windows XP Sp2
ขึ้นระบบ 1 มิ.ย.50