ผู้เขียน หัวข้อ: ขอความช่วยเหลือ SQL หน่อยครับ ไม่ค่อยเก่งครับ  (อ่าน 2428 ครั้ง)

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

ออฟไลน์ the205

  • Full Member
  • ***
  • กระทู้: 199
  • the205
  • Respect: 0
    • ดูรายละเอียด
    • http://www.pthos.org
1. ต้องการดึงรายงานเกี่ยวกับผู้ป่วย HIV ครับ จาก ICD-10 ผู้ป่วยนอก และใน
รหัส ICD -10  คือ B24  ที่มารักษา 2 ครั้งขึ้นไป และยังมีชีวิตอยู่ ครับ 

HN l ชื่อ-สกุล l เพศ l อายุ l ที่อยู่ l มาครั้งสุดท้าย l


******************************************************
ขอรบกวนช่วยหน่อยนะครับไม่เก่ง SQL ครับ
รพ.โพนทอง  จ.ร้อยเอ็ด 043-572424
Start : ส.ค.2548  รพ.60 เตียง
ServerA :  IBM Xeon Xseries236  Ram 4G
Server B: IBM Xeon SystemX3200   Ram 4G
MYSQL 5.1.22-rc ,HOSXP v.3.55.7.14
Centos 5 , Client50

แยกเก็บภาพ scan http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=10169.0

mysql http://hosxp.net/index.php?option=com_smf&Itemid=28&topic=11513.0

ออฟไลน์ woravet

  • Sr. Member
  • ****
  • กระทู้: 409
  • Respect: +12
    • ดูรายละเอียด
Re: ขอความช่วยเหลือ SQL หน่อยครับ ไม่ค่อยเก่งครับ
« ตอบกลับ #1 เมื่อ: ธันวาคม 28, 2007, 17:05:52 PM »
0
ผู้ป่วยนอก น่าจะเป็น
select p.hn,p.pname,p.fname,p.lname,p.sex,p.birthday
,p.addrpart,p.moopart,p.tmbpart,p.amppart,p.chwpart,max(o.vstdate) as vstdate
from patient p
left join ovst o on p.hn=o.hn
left join ovstdiag o1 on o.vn=o1.vn
where o1.icd10 between 'b20' and 'b24'
and p.hn not in (select hn from death)
group by p.hn
having count(o.hn)>2
****
ผู้ป่วยใน น่าจะ
select p.hn,p.pname,p.fname,p.lname,p.sex,p.birthday
,p.addrpart,p.moopart,p.tmbpart,p.amppart,p.chwpart,max(o.regdate) as regdate
from patient p
left join ipt o on p.hn=o.hn
left join iptdiag o1 on o.an=o1.an
where o1.icd10 between 'b20' and 'b24'
and p.hn not in (select hn from death)
group by p.hn
having count(o.hn)>2

พอจะใช้ได้มั๊ยครับ
รพ.บึงสามัคคี จ.กำแพงเพชร
*********************
อ.สุชัยและคณะ ขึ้นระบบ 29 ตค.49(Linux+Fedara 5)
*********************
ปัจจุบัน
HOSxP version 3.53.4.27
Server:Windows XP SP2,MySQL 5
Client ประมาณ 15 เครื่อง