ผู้เขียน หัวข้อ: รบกวนช่วยดู Query ให้ทีครับ  (อ่าน 4875 ครั้ง)

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

ออฟไลน์ [-_เอ็ม_-]

  • Hero Member
  • *****
  • กระทู้: 1,472
  • [-- Developer มือใหม่ --]
  • Respect: +3
    • ดูรายละเอียด
    • โรงพยาบาลบรบือ
รบกวนช่วยดู Query ให้ทีครับ
« เมื่อ: พฤษภาคม 30, 2012, 10:59:46 AM »
0
ช่วยดูด้วยครับ พอดีว่า วิธีกิน / ใช้ยา ไม่แสดงเป็นบางรายการครับ

#####################################

select i.vn, i.hn,i.icode,i.qty,d.units,
concat(u.name1, ' ', u.name2, ' ', u.name3) as detail_use
from opitemrece i
left join drugitems d on d.icode=i.icode
left join drugusage u on u.drugusage=i.drugusage
left join ovstdiag o on o.vn = i.vn
left join patient pt on pt.hn = i.hn
where
(
   o.icd10 in(" + icd + ")
or
   o.icd103 in(" + icd + "))
and pt.hn=o.hn and pt.cid <> '' and SUBSTR(pt.cid,1) <> 0
and o.vstdate BETWEEN '2012-05-18' and '2012-05-18'
and i.income='03' and i.vn is not null
group by i.vn

#####################################
###### [- นิวัฒน์ <M> นัดสถาพร -] ######
   << นักวิชาการคอมพิวเตอร์ รพ.บรบือ >>
<< Rajabhat Mahasarakham University >>
------------------------------------------------------------------------------

ออฟไลน์ Adeno Benzoate

  • Sr. Member
  • ****
  • กระทู้: 256
  • May You Always Find Happiness in All You Do
  • Respect: 0
    • ดูรายละเอียด
    • Langu Hospital
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #1 เมื่อ: พฤษภาคม 30, 2012, 11:07:07 AM »
0
เจ้าหน้าที่ไม่ได้ลงวิธีใช้ใน visit นั้นๆ หรือเปล่าครับ
https://www.languhospital.com/
https://www.facebook.com/languhos
ขึ้นระบบ 04/11/2552
PowerEdge R440
Processor Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz
32GiB System Memory
479GB PERC H730P Adp

ออฟไลน์ [-_เอ็ม_-]

  • Hero Member
  • *****
  • กระทู้: 1,472
  • [-- Developer มือใหม่ --]
  • Respect: +3
    • ดูรายละเอียด
    • โรงพยาบาลบรบือ
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #2 เมื่อ: พฤษภาคม 30, 2012, 11:11:23 AM »
0
บางตัวก็ตามนั้นครับ แต่บางตัวดูแล้วก็มีวิธีใช้อยู่ครับ
###### [- นิวัฒน์ <M> นัดสถาพร -] ######
   << นักวิชาการคอมพิวเตอร์ รพ.บรบือ >>
<< Rajabhat Mahasarakham University >>
------------------------------------------------------------------------------

ออฟไลน์ Adeno Benzoate

  • Sr. Member
  • ****
  • กระทู้: 256
  • May You Always Find Happiness in All You Do
  • Respect: 0
    • ดูรายละเอียด
    • Langu Hospital
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #3 เมื่อ: พฤษภาคม 30, 2012, 11:23:36 AM »
0
มีวิธีใช้ ในตารางไหนครับ ระหว่าง opitemrece.drugusage หรือ drugusage.drugusage

บางทียาอาจจะกำหนดวิธีใช้ไว้ก็จริง แต่พอเจ้าหน้าที่ key ข้องมูล อาจจะลบวิธีใช้ออกแล้วไม่ได้ใส่ใหม่ก็ได้ครับ
https://www.languhospital.com/
https://www.facebook.com/languhos
ขึ้นระบบ 04/11/2552
PowerEdge R440
Processor Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz
32GiB System Memory
479GB PERC H730P Adp

ออฟไลน์ [-_เอ็ม_-]

  • Hero Member
  • *****
  • กระทู้: 1,472
  • [-- Developer มือใหม่ --]
  • Respect: +3
    • ดูรายละเอียด
    • โรงพยาบาลบรบือ
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #4 เมื่อ: พฤษภาคม 30, 2012, 11:26:45 AM »
0
join ตาราง opitemrece field drugusage กับ ตาราง drugusage field drugusage เพื่อเอาวิธีใช้ มาแสดงครับ
###### [- นิวัฒน์ <M> นัดสถาพร -] ######
   << นักวิชาการคอมพิวเตอร์ รพ.บรบือ >>
<< Rajabhat Mahasarakham University >>
------------------------------------------------------------------------------

ออฟไลน์ golf_win

  • Hero Member
  • *****
  • กระทู้: 3,481
  • Respect: +112
    • ดูรายละเอียด
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #5 เมื่อ: พฤษภาคม 30, 2012, 11:29:22 AM »
0
select i.vn, i.hn,i.icode,i.qty,d.units,
if(i.drugusage<>"",concat(u.name1, ' ', u.name2, ' ', u.name3),concat(u1.name1, ' ', u1.name2, ' ', u1.name3)) as usuge
from opitemrece i
left join drugitems d on d.icode=i.icode
left join drugusage u on u.drugusage=i.drugusage
left join sp_use u1 on u1.sp_use=i.sp_use
left join ovstdiag o on o.vn = i.vn
left join patient pt on pt.hn = i.hn
where
(o.icd10 in ("+icd+") or o.icd103 in ("+icd+"))
and pt.hn=o.hn and pt.cid <> '' and SUBSTR(pt.cid,1) <> 0
and o.vstdate BETWEEN '2012-05-01' and '2012-05-18'
and i.income='03' and i.vn is not null
group by i.vn
โรงพยาบาลเจ็ดเสมียน จังหวัดราชบุรี
Start 19-1-51    35 station
HOSxP  3.59.5.18 Activate License
Tel. 032-305096-7 ต่อ 118
Web. http://csmhos.thaiddns.com:8080
         http://csmhos.thaieasydns.com:8080

ออฟไลน์ Adeno Benzoate

  • Sr. Member
  • ****
  • กระทู้: 256
  • May You Always Find Happiness in All You Do
  • Respect: 0
    • ดูรายละเอียด
    • Langu Hospital
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #6 เมื่อ: พฤษภาคม 30, 2012, 11:47:57 AM »
0
join ตาราง opitemrece field drugusage กับ ตาราง drugusage field drugusage เพื่อเอาวิธีใช้ มาแสดงครับ


อันนั้นเข้าใจครับ

ลองไปดูในตาราง Opitemrece นะครับว่า field drugusage ว่างหรือเปล่า
https://www.languhospital.com/
https://www.facebook.com/languhos
ขึ้นระบบ 04/11/2552
PowerEdge R440
Processor Intel(R) Xeon(R) Silver 4210R CPU @ 2.40GHz
32GiB System Memory
479GB PERC H730P Adp

ออฟไลน์ realaerm

  • Full Member
  • ***
  • กระทู้: 152
  • Aerm
  • Respect: +1
    • ดูรายละเอียด
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #7 เมื่อ: พฤษภาคม 30, 2012, 13:34:12 PM »
0
ช่วยดูด้วยครับ พอดีว่า วิธีกิน / ใช้ยา ไม่แสดงเป็นบางรายการครับ

#####################################

select i.vn, i.hn,i.icode,i.qty,d.units,
concat(u.name1, ' ', u.name2, ' ', u.name3) as detail_use
from opitemrece i
left join drugitems d on d.icode=i.icode
left join drugusage u on u.drugusage=i.drugusage
left join ovstdiag o on o.vn = i.vn
left join patient pt on pt.hn = i.hn
where
(
   o.icd10 in(" + icd + ")
or
   o.icd103 in(" + icd + "))
and pt.hn=o.hn and pt.cid <> '' and SUBSTR(pt.cid,1) <> 0
and o.vstdate BETWEEN '2012-05-18' and '2012-05-18'
and i.income='03' and i.vn is not null
group by i.vn

#####################################

เป็นไปได้ 2 อย่างครับ
1.คำสั่ง concat ใช้ต้องระวังเรื่องค่าว่าง หากมีตัวใดตัวหนึ่งที่เราเอามา concat กันเป็นค่าว่าง ผลที่ได้จะเป็นค่าว่างทั้งหมด ต้องเขียน if ดักครับ

2.วิธีใช้ยามี 2 แบบนะครับ
    1.แบบ code จากในโปรแกรม ซึ่งก็คือฟิว drugusage ใน opitemrece
    2.แบบ กำหนดเอง เวลาคียวิธีใช้ยาแบบกำหนดเอง ข้อมูลในฟิล drugusage ของ opitemrece จะว่าง แล้วจะมีอยู่ในฟิว sp_use ของ ตาราง opitemrece แทนครับ (สังเกตุได้ว่าวิธีใช้ที่กำหนดเองจะมี > อยุ่ข้างหน้าวิธีใช้นั้น)

ลองตรวจสอบดูว่าวิธีใช้ยาดังกล่าวเป็นแบบไหนแล้วใช้วิธีดึงแบบนั้นครับ
---------------------------------------------------------
Mr. Sitichart  Wongyuttanapong
Inventory  Team
---------------------------------------------------------
Bangkok  Medical  Software  Co,.Ltd
---------------------------------------------------------

ออฟไลน์ realaerm

  • Full Member
  • ***
  • กระทู้: 152
  • Aerm
  • Respect: +1
    • ดูรายละเอียด
Re: รบกวนช่วยดู Query ให้ทีครับ
« ตอบกลับ #8 เมื่อ: พฤษภาคม 30, 2012, 13:37:17 PM »
0
select i.vn, i.hn,i.icode,i.qty,d.units,
if(i.drugusage<>"",concat(u.name1, ' ', u.name2, ' ', u.name3),concat(u1.name1, ' ', u1.name2, ' ', u1.name3)) as usuge
from opitemrece i
left join drugitems d on d.icode=i.icode
left join drugusage u on u.drugusage=i.drugusage
left join sp_use u1 on u1.sp_use=i.sp_use
left join ovstdiag o on o.vn = i.vn
left join patient pt on pt.hn = i.hn
where
(o.icd10 in ("+icd+") or o.icd103 in ("+icd+"))
and pt.hn=o.hn and pt.cid <> '' and SUBSTR(pt.cid,1) <> 0
and o.vstdate BETWEEN '2012-05-01' and '2012-05-18'
and i.income='03' and i.vn is not null
group by i.vn

หรือใช้คำสั่งนี้ครับ :)
---------------------------------------------------------
Mr. Sitichart  Wongyuttanapong
Inventory  Team
---------------------------------------------------------
Bangkok  Medical  Software  Co,.Ltd
---------------------------------------------------------