BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: KUNPAT(UBON) ที่ มิถุนายน 02, 2009, 09:24:03 AM
-
ผมออกแบบรายงาน"CUSTOM- IPDรายงานการใช้ANTIBIOTICในกล่มโรคติดเชื้อทางเดินหายใจระบุแพทย์แยกรายดือน" โดยใช้คำสั่งนี้ครับ แต่รายงานไม่ออกเป็นcrosstab ทำให้อ่านยากมากตามรูปข้างล่างครับ
set @t1 = unix_timestamp('2007-10-01');
set @t2 = unix_timestamp('2008-09-30');
select "IPDนพ.พรเจริญ เจียมบุญศรี" as doctor,op.icode,di.name, year(op.vstdate)+543 year, case month(op.vstdate)
when '1' then 'มกราคม'
when '2' then 'กุมภาพันธ์'
when '3' then 'มีนาคม'
when '4' then 'เมษายน'
when '5' then 'พฤษภาคม'
when '6' then 'มิถุนายน'
when '7' then 'กรกฎาคม'
when '8' then 'สิงหาคม'
when '9' then 'กันยายน'
when '10' then 'ตุลาคม'
when '11' then 'พฤศจิกายน'
when '12' then 'ธันวาคม'
end as month, sum(op.qty) as sum_qty ,di.strength,di.units,di.unitcost,sum(op.qty)*di.unitcost as total
from opitemrece op
left outer join drugitems di on op.icode=di.icode
left outer join an_stat a on op.an=a.an
where unix_timestamp(op.vstdate) between @t1 and @t2 and di.antibiotic='y' and op.doctor='014' and a.pdx in ('j00','j02','j028','j029','j03','j038','j039','j05','j050','j051','j06','j060','j068','j069','j10','j100','j101','j108','j11','j110','j111','j118','j20','j200','j201','j202','j203','j204','j205','j206','j207','j208','j209','j30','j300','j301','j302','j303','j304','j31','j310','j311','j312')
group by year(op.vstdate), month(op.vstdate),di.strength,di.units,di.unitcost
-
ขอความช่วยเหลือจากผู้รู้ทุกท่านผมอยากปรับตารางนี้ให้เป็นแบรูปข้างล่างนี้(CrossTab)เพื่อความสะดวกในการใช้งานแต่ไม่ได้สักที ช่วยผมหน่อยครับ
-
รูปแบบนี้ครับ ช่วยเสนอแนะด้วยครับ ทำมานานแล้วไม่สำเร็จซักที
ปริมาณการใช้ANTIBIOTIC มค กพ มีค เมย พค มิย รวม
1..Amoxycillin 500 mg tab sumQTY … … … … … ........
2.Amoxycillin 250 mg tab … … … … … … ........
3.Cotrimoxazole tba … … … … … … ... ........
4.Cotrimoxazole susp 60 ml … … … … … … ...........
-
ต้องรายงานการใช้ antibiotic ทุกตัวเลยเหรอครับ ผมว่าใช้เงื่อนไข therapeutic group จะง่ายกว่านะครับ โดยการ join drugitems เข้าไปเชื่อมกับ opitemrece โดย icode แล้วค่อยนับยอดจากเงื่อนไข therapeutic group ครับ แต่ต้อง set ค่า therapeutic group ให้เป็น antibiotic ก่อน ลองทดสอบดูก่อนนะครับ ??? ???
-
ผมใช้เงื่อนไขจากคอลัมภ์ antibiotic ใน drugitems และแยกกลุ่มโรคโดยใช้PDX ในAN_stat และVN_STAT ซึ่งได้ข้อมูลครบถ้วนครับ แต่เวลาแสดงผลไม่สามารถเรียงข้อมูลให้อ่านง่าย ผมลองใช้ CROSSTABใน REPORT DESIGNER แล้ว แต่ตารางที่ได้ไม่ถูกต้อง อาจเกิดจากSQLที่ใช้ จึงต้องขอความช่วยเหลือเพื่อปรับตารางให้ถูกต้อง หรือปรับคำสั่งให้เหมาะสมครับ >:( >:( >:( >:(
-
select a.dx_doctor,dr.name,concat(d.name,' ',d.strength) as drug
,d.units,d.unitcost
,if(month(o.vstdate)=1,sum(o.qty),0) as 'mo1'
,if(month(o.vstdate)=2,sum(o.qty),0) as 'mo2'
,if(month(o.vstdate)=3,sum(o.qty),0) as 'mo3'
,if(month(o.vstdate)=4,sum(o.qty),0) as 'mo4'
,if(month(o.vstdate)=5,sum(o.qty),0) as 'mo5'
,if(month(o.vstdate)=6,sum(o.qty),0) as 'mo6'
,if(month(o.vstdate)=7,sum(o.qty),0) as 'mo7'
,if(month(o.vstdate)=8,sum(o.qty),0) as 'mo8'
,if(month(o.vstdate)=9,sum(o.qty),0) as 'mo9'
,if(month(o.vstdate)=10,sum(o.qty),0) as 'mo10'
,if(month(o.vstdate)=11,sum(o.qty),0) as 'mo11'
,if(month(o.vstdate)=12,sum(o.qty),0) as 'mo12'
,sum(o.qty) as qty
,sum(o.sum_price) as sum_price
from opitemrece o
left join drugitems d on o.icode=d.icode
left join an_stat a on o.an=a.an
left join doctor dr on a.dx_doctor=dr.code
where o.vstdate between '2008-1-1' and '2008-12-31'
and d.antibiotic='Y'
and left(a.pdx,1)='J'
group by a.dx_doctor,o.icode
order by a.dx_doctor,o.icode
แบบนี้พอไหวมั๊ยคับ อาจจะเพี้ยนถ้าไม่ใช่ปีเดียวกัน
ตอนทำรายงานก้อ summary group จาก dx_doctor เอาคับ
-
ขอบคุณครับ กำลังTESTอยู่ครับ ;D ;D ;D ;D
-
ทำเสร็จแล้วเอามาแบ่งบ้างนะครับ
-
หายไปหลายวัน เพราะไปลองปรับใช้ครับ เลยพบปัญหาตามภาพครับ
1.พญ.ขวัญชนก จ่ายamoxy500 cap เฉพาะเดือนมกราคม51 3000เม็ด แต่เดือนอื่นเป็น0หมด
2.ผมทดลองQureyแยกดูพบว่าหมอมีรายการจ่ายทุกเดือนแต่รายงานที่ออกมาจะมีบางเดือนเท่านั้น ??? ???
ผู้รู้ทุกท่านช่วยหน่อยครับอาจมีความผิดพลาดในSQL ข้อมูลที่ได้เลยไม่ถูกต้อง
ปล.ถ้าเสร็จจะได้แจกกันเสียทีครับผม >:( >:( >:( >:(
-
ท่าน WORAVET ช่วยอีกทีครับ มืดแปดด้านเลย
-
อยากรู้เหมือนกันว่าพลาดตรงไหน
เพราะถ้าได้รายงานต้นแบบตัวนี้เอาไปประยุกต์กับรายงานได้เยอะทีเดียว
-
มาติดตามความคืบหน้าครับ
เป็นกำลังใจให้คับ
:D ;)
-
select a.dx_doctor,dr.name,o.icode,concat(d.name,' ',d.strength) as drug
,d.units,d.unitprice,d.unitcost
,sum(if(month(o.vstdate)=1,o.qty,0)) as 'mo1'
,sum(if(month(o.vstdate)=2,o.qty,0)) as 'mo2'
,sum(if(month(o.vstdate)=3,o.qty,0)) as 'mo3'
,sum(if(month(o.vstdate)=4,o.qty,0)) as 'mo4'
,sum(if(month(o.vstdate)=5,o.qty,0)) as 'mo5'
,sum(if(month(o.vstdate)=6,o.qty,0)) as 'mo6'
,sum(if(month(o.vstdate)=7,o.qty,0)) as 'mo7'
,sum(if(month(o.vstdate)=8,o.qty,0)) as 'mo8'
,sum(if(month(o.vstdate)=9,o.qty,0)) as 'mo9'
,sum(if(month(o.vstdate)=10,o.qty,0)) as 'mo10'
,sum(if(month(o.vstdate)=11,o.qty,0)) as 'mo11'
,sum(if(month(o.vstdate)=12,o.qty,0)) as 'mo12'
,sum(o.qty) as qty
,sum(o.sum_price) as sum_price
from opitemrece o
left join drugitems d on o.icode=d.icode
left join an_stat a on o.an=a.an
left join doctor dr on a.dx_doctor=dr.code
where o.vstdate between '2008-1-1' and '2008-12-31'
and d.antibiotic='Y'
and left(a.pdx,1)='J'
group by a.dx_doctor,o.icode
order by a.dx_doctor,o.icode
ขอโทษทีคับ sum ผิดที่ เห็นได้ค่าเลยไม่ได้ตรวจสอบ
ลองดูคับผม
*****
ราคารวมผมว่าน่าจะเป็น unitprice มากกว่า unitcost นะคับ
-
;D ;Dขอบคุณท่าน WERAVET มากๆครับ ทำเสร็จแล้ว เหมือนยกภูเขาออกจากอก
ใครอยากทดลองใช้ load ได้เลยครับ ;D ;D
-
แปลกครับรายงานนี้ใช้งานในEND USER REPORT ไม่ได้มันฟ้องERROR และถ้าในคำสั่งรูปแบบเดียวกันในรายงานนี้จะมีปัญหาเหมือนกันหมด(ในREPORT DESIGNER ไม่มีปัญหา)
-
กำหนด parameter ผิด ต้องกำหนดใหม่คับ
-
หมายถึงการกำหนดค่าvariableให้สามารถเลือกวันที่ได้ใช่ไหมครับ ตามfilemผมPOSTไว้ผมลองใช้การกำหนดค่าวันที่2แบบ แต่ERRORเหมือนเดิม รบกวนท่านWoravetตรวจสอบparameterในfilemผมส่งไปว่าผิดตรงไหนจะเป็นพระคุณอย่างสูงครับ :-\ :-\
-
หมายถึงการกำหนดค่าvariableให้สามารถเลือกวันที่ได้ใช่ไหมครับ ตามfilemผมPOSTไว้ผมลองใช้การกำหนดค่าวันที่2แบบ แต่ERRORเหมือนเดิม รบกวนท่านWoravetตรวจสอบparameterในfilemผมส่งไปว่าผิดตรงไหนจะเป็นพระคุณอย่างสูงครับ :-\ :-\
แก้ไขให้แล้วครับ ลืมกำหนด parameter ครับ