ผู้เขียน หัวข้อ: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0  (อ่าน 9633 ครั้ง)

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

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
กรณีที่ทำระยะเวลารอคอยแยกตามช่วงแต่ละจุดบริการ อาจจะมีผู้ป่วยไม่ได้รับบริการบางจุด เช่น ผู้ป่วยรวมทั้งหมด 100 คน ไม่รอรับยา 50 คน ต้องการเฉลี่ยโดยไม่นับรวม 50คนที่ไม่รอรับยาครับ ขอบคุณครับ
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #1 เมื่อ: พฤษภาคม 20, 2013, 11:45:09 AM »
0
คงต้องเพิ่มกำหนดเงื่อนไข  ต้องเป็น vn ที่ผานห้องยา ครับ  จะได้มีถึง 50 คน ก่อนนำมาเฉลีย
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #2 เมื่อ: พฤษภาคม 20, 2013, 12:43:32 PM »
0
นี่เป็นตัวอย่างรายงานครับพี่เกื้อ แต่ว่าตรงช่องที่คำนวณเวลาของแต่ละจุดบริการจะมีค่าว่างๆออกมา เราเพราะคนไข้ไม่ผ่านจุดนั้น จะไม่นำตรงนี้มาคำนวณเวลาเฉลี่ยจะทำอย่างไรครับ ขอบคุณครับ
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #3 เมื่อ: พฤษภาคม 20, 2013, 14:19:51 PM »
0
อาจ ต้อง vn ที่ช่องที่ต้องการ is not null  ครับ  กำหนดไปเลย  ว่า time ในช่องกำหนด <>"" and is  not null
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #4 เมื่อ: พฤษภาคม 20, 2013, 16:14:04 PM »
0
ทำไปในเงื่อนไขหลักๆไม่ได้ครับ จะตัดคนไข้ทิ้งไปเยอะ แต่สงสัยคงต้องใส่ใน variable ครับ พบปัญหาเพิ่มเติมคือว่าถ้าเลือกช่วงเวลามากๆหลายๆวันจะขึ้น range check error
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #5 เมื่อ: พฤษภาคม 22, 2013, 09:45:02 AM »
0
ทำไปในเงื่อนไขหลักๆไม่ได้ครับ จะตัดคนไข้ทิ้งไปเยอะ แต่สงสัยคงต้องใส่ใน variable ครับ พบปัญหาเพิ่มเติมคือว่าถ้าเลือกช่วงเวลามากๆหลายๆวันจะขึ้น range check error

กลุ่มเป้าหมายสำคัญ คือ  กล่มที่ได้รับบริการ...ครบอย่างน้อยกี่ขึ้นตอน นั่นคือ คำตอบ ของการออกแบบชุดคำสั่ง ถ้าบอกว่า จะเอาผ่านห้องยา ว่า ทุกรายเฉลี่ยรับบริการกี่นาที ตั้งแต่เข้ามารพ. ต้องยอมตัดข้อมูลส่วนที่ไม่ได้ไปรับยาออกครับ มิเช่นนั้น เวลาเฉลี่ยต่อราย จะคลาดเคลื่อน แต่ควรวิเคราะห์แบบรายเดือน หรือ รายไตรมาส ครับ..เฉพาะวันทำการ ห้ามเอา vstdate ที่ตรงกับวันในตาราง holiday เพราะจะคลาดเคลื่อนสูงครับ
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #6 เมื่อ: พฤษภาคม 26, 2013, 11:34:36 AM »
0
select time_format(sec_to_time(sum(time_to_sec(service3))),"%H:%i:%s") from service_time
where vstdate between "2011-10-01" and "2011-10-31"
เขียนคำสั่งแบบนี้ ถ้าใช้แค่ sum สามารถรวมได้ แต่จะแปลงกลับมาเป็นชั่วโมงนาทีจะออกมาเป็น 838:59:59  ครับ เป็นกับหลายๆฟิลด์ครับ ขอบคุณครับ ไม่แน่ใจว่าทำอะไรผิดหรือเปล่า
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #7 เมื่อ: พฤษภาคม 26, 2013, 13:46:15 PM »
0
select time_format(sec_to_time(sum(time_to_sec(service3))),"%H:%i:%s") from service_time
where vstdate between "2011-10-01" and "2011-10-31"
เขียนคำสั่งแบบนี้ ถ้าใช้แค่ sum สามารถรวมได้ แต่จะแปลงกลับมาเป็นชั่วโมงนาทีจะออกมาเป็น 838:59:59  ครับ เป็นกับหลายๆฟิลด์ครับ ขอบคุณครับ ไม่แน่ใจว่าทำอะไรผิดหรือเปล่า
select time_format(sec_to_time(sum(time_to_sec(service3))/3600),"%H:%i:%s") from service_time
where vstdate between "2011-10-01" and "2011-10-31" กรณีนี้หารด้วย 3600 จะได้ชั่วโมงออกมา เหมือนจะได้คำตอบด้วยตัวเอง พยายามค้นหาหลายสูตรมากมายนะครับ แต่ผิดถูกอย่างไรอยากรบกวนพี่ๆช่วยอธิบายหลักการและเหตุผลเพิ่มเติมให้ด้วยครับ เผื่อจะได้เข้าใจมากกว่านี้ ขอบคุณครับ
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ เกื้อกูล ครับ..

  • Hero Member
  • *****
  • กระทู้: 12,611
  • Respect: +169
    • ดูรายละเอียด
    • โรงพยาบาลปากท่อ
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #8 เมื่อ: พฤษภาคม 26, 2013, 15:09:00 PM »
0
เงื่อนไขที่เขียน สรุปว่า วันหยุดเสาร์ อาทิตย์ หรือ นักขัตฤกษ์  ก็จะนับใช่ไหมคัรบ อย่างนั้น ระยะเวลารอคอยก็จะน้อยลง  เพราะชัด ๆ ว่า ว่าหยุด บริการได้เร็วกว่าวันธรรมดา  ด้วยจำนวนผู้รับบริการ และลักษณะบริการที่ไม่สามารถซับซ้อนได้  นอกจากนัดมา F/U ในวันทำการ ครับ
Implement  HOSxP  Start 2548 ---> NOW!
Station : 130 Client   V.3 Version  3.67.1.XX
Server  : CENTOS  +MySQL maria 10.x.x

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #9 เมื่อ: พฤษภาคม 27, 2013, 08:00:51 AM »
0
ตอนนี้ได้คำตอบของการหาเวลาแล้วครับ แล้วก็แยกแต่ละช่วงเวลาอย่างละเอียดต่อไป รอบนี้จะเหนื่อยครั้งเดียว และจะส่งเข้ามาให้พี่ๆช่วยตรวจอีกครั้งครับ
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ yokyai

  • Hero Member
  • *****
  • กระทู้: 1,462
  • Respect: +9
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #10 เมื่อ: พฤษภาคม 27, 2013, 11:16:32 AM »
0
set @d1="2011-10-01";
set @d2="2012-09-30";
select month(v.vstdate) as "VMONTH",v.vstdate,v.vn,v.hn
,count(v.vn) as "CountVisitAll"
,e.CountVisitER,e.ErTime
,la.CountVisitLab,la.LabReceiveTime,la.LabReportTime,la.LabAllTime
,x.CountVisitXray,x.XrayExaminedTime
,ss.*
,s1.*
from vn_stat v
left join (select vn as "ssvn",month(vstdate) as "MONTH",vstdate
,sum(if(service3_dep is not null and service4_dep is not null
and service5_dep is not null
and service6_dep is not null
and service7_dep is not null
and service11_dep is not null
and service12_dep is not null
and service19_dep is not null
and service7_dep="019",1,0)) as "CountVisitAllProcess"
,sum(if(service3_dep is not null
and service4_dep is not null
and service5_dep is not null
and service6_dep is not null
and service7_dep is null
and service11_dep is not null
and service12_dep is not null
and service19_dep is not null
and service19_dep="030",1,null)) as "CountVisittoRx"
,sum(if(service3_dep is not null
and service4_dep is not null
and service5_dep is not null
and service6_dep is null
and service7_dep is null
and service11_dep is not null
and service12_dep is not null
and service19_dep is null,1,null)) as "CountVisittoExam"
,sum(if(service3_dep is not null
and service4_dep is not null
and service5_dep is null
and service6_dep is null
and service7_dep is null
and service11_dep is not null
and service12_dep is null
and service19_dep is null,1,null)) as "CountVisittoScreen"
from service_time
where vstdate between @d1 and @d2
group by MONTH) ss on ss.ssvn=v.vn

left join(select vn as "evn",vstdate,month(vstdate) as "EMONTH",count(vn) as "CountVisitER"
,sec_to_time(mod(sum(timediff(finish_time,enter_er_time)),86400)) as "ErTime"
from er_regist
where vstdate between @d1 and @d2 group by EMONTH) e on e.vstdate=v.vstdate

left join(select vn as "lavn",hn as "lahn",order_date,count(vn) as "CountVisitLab",month(order_date) as "LMONTH"
,sec_to_time(mod(sum(timediff(receive_time,order_time)),86400)) as "LabReceiveTime"
,sec_to_time(mod(sum(timediff(report_time,receive_time)),86400)) as "LabReportTime"
,sec_to_time(mod(sum(timediff(report_time,order_time)),86400)) as "LabAllTime"
from lab_head
where order_date between  @d1 and @d2 group by LMONTH) la on la.order_date=v.vstdate

left join(select vn as "xvn",month(request_date) as "XMONTH",vn,request_date,examined_date,report_date,count(vn) as "CountVisitXray"
,sec_to_time(abs(timediff(examined_time,request_time))) as "XrayExaminedTime"
from xray_report
where request_date between @d1 and @d2
group by XMONTH) x on x.request_date=v.vstdate

left join(select vn as "vn1",vstdate,month(vstdate) as "SMONTH"
,sec_to_time(mod(abs(sum(time_to_sec(service3)-time_to_sec(service20))),86400)) as totaltimetoregist
,sec_to_time(mod(abs(sum(time_to_sec(service4)-time_to_sec(service3))),86400))  as waitforscreen
,sec_to_time(mod(abs(sum(time_to_sec(service11)-time_to_sec(service4))),86400)) as totaltimetoscreen
,sec_to_time(mod(abs(sum(time_to_sec(service5)-time_to_sec(service11))),86400)) as waitfordoctor
,sec_to_time(mod(abs(sum(time_to_sec(service12)-time_to_sec(service5))),86400)) as totaltimetodoctor
,sec_to_time(mod(abs(sum(time_to_sec(service6)-time_to_sec(service12))),86400)) as waitforrx
,sec_to_time(mod(abs(sum(time_to_sec(service19)-time_to_sec(service6))),86400)) as totaltimetorxmode2
,sec_to_time(mod(abs(sum(time_to_sec(service7)-time_to_sec(service19))),86400)) as totaltimetofinance
,sec_to_time(mod(abs(sum(time_to_sec(service12)-time_to_sec(service3))),86400)) as vsttimetofinishexam
,sec_to_time(mod(abs(sum(time_to_sec(service19)-time_to_sec(service3))),86400)) as vsttimetofinishrx
,sec_to_time(mod(abs(sum(time_to_sec(service7)-time_to_sec(service3))),86400)) as vsttimetofinishfinance
,sec_to_time(mod(abs(sum(time_to_sec(service19)-time_to_sec(service6))),86400)) as finishexamtostartrx
,sec_to_time(mod(abs(sum(time_to_sec(service19)-time_to_sec(service12))),86400)) as finishexamtofinishrx
from service_time
where vstdate between @d1 and @d2
group by SMONTH) s1 on v.vn=s1.vn1

left join service_time s on v.vn=s.vn
where  v.vstdate between @d1 and @d2
group by  VMONTH


แบบนี้ไม่มี Range Check Error แต่อาจจะผิดพลาดได้กรณีค่าตัวลบอาจมากกว่าตัวตั้งต้องลองทดสอบทีละรายการต่อไปครับ แต่เบื้องต้นได้มาแบบนี้ครับ แปลกจริงครับบางตาราง JOIN ด้วย VN ไม่มีค่าต้อง JOIN ด้วย date ที่เป็นเงื่อนไขแทนครับ ตอนนี้เหลือตรงแลบที่อาจจะต้องแก้ไขการ  JOIN และเพิ่ม LEFT JOIN มาอีกจะลองดู แล้วจะรบกวนให้ช่วยทำสอบครับว่าถูกต้องหรือเปล่าครับ ขอบคุณครับ
« แก้ไขครั้งสุดท้าย: พฤษภาคม 27, 2013, 11:24:03 AM โดย yokyai »
Sakaowrat Choocherd(Administrator) Information Technologist
Bangyai Hospital(30 beds)
HOSxP = 16_May_2008
Master and Slave : DELL-R730 Server Intel Xeon 8Core(2Units)
,Ram64 GB,HDD600(10k)x4,Raid5,CentOS 7.0 64 bit
,MySQL 10.1.10-MariaDB
(3 March 2016) With BMSxTraBackupGUI

ออฟไลน์ jingjoe13

  • Newbie
  • *
  • กระทู้: 4
  • Respect: 0
    • ดูรายละเอียด
Re: ต้องการเฉลี่ยเวลารอคอยไม่รวมค่าว่างหรือ 0
« ตอบกลับ #11 เมื่อ: ตุลาคม 14, 2013, 11:53:21 AM »
0
รบกวนเจ้าของรายงานอีกนิดนะครับ  ผมมือใหม่ SQL ครับ ยังไม่ชำนาญจะขอรบกวนนิดนึงครับ ว่า
ถ้าในช่อง  "รวมเวลารับบริการ" เราจะนับได้เปล่าครับ ว่า รวมแล้ว ใครใช้ เาลา เกินกำหนด  1ชั่วโมง 30 นาที กี่ คน ไม่เกินเวลาที่กำหลดกี่คน แยกมาสรุปท้ายรายงานนะครับ ต้องทำยังไงครับ