แสดงกระทู้

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - woravet

หน้า: 1 2 [3] 4 5 ... 9
101
ผมทำ store function แล้ว ภาษาไทยรู้สึกว่าจะเป็น utf8 ไม่ใช่ tis620
ทั้งที่กำหนด returns เป้น tis620 แล้ว

102
select o.vstdate
,sum(sum_price) 'total'
,sum(if(paidst='00',sum_price,0)) 'Paidst00'
,sum(if(paidst='01',sum_price,0)) 'Paidst01'
,sum(if(paidst='02',sum_price,0)) 'Paidst02'
,sum(if(paidst='03',sum_price,0)) 'Paidst03'
,sum(if(paidst='04',sum_price,0)) 'Paidst04'
from opitemrece o
where vstdate between '2012-10-1' and '2012-10-31'
and vn is not null
group by vstdate

***ดูตาราง PAIDST ประกอบ***

103
การเขียน SQL Script / Re: CMI แยกตามสิทธิ์
« เมื่อ: มิถุนายน 20, 2013, 15:56:23 PM »
select p2.pttype_spp_name name
,avg(adjrw) cmi
from ipt i
left join pttype p1 on i.pttype=p1.pttype
left join pttype_spp p2 on p2.pttype_spp_id-p1.pttype_spp_id
where dchdate between '2012-10-1' and '2013-4-30'
group by p2.pttype_spp_id

104
การเขียน SQL Script / Re: การดึงคนไข้ URI+AGE
« เมื่อ: มิถุนายน 18, 2013, 14:22:23 PM »
select v.hn,pt.pname,pt.fname,pt.lname,count(v.hn) cc
,cast(group_concat(distinct v.vstdate) as char(200)) date
from vn_stat v
left join patient pt on pt.hn=v.hn
left join ovstdiag odx on odx.vn=v.vn
where v.vstdate between '2012-10-1' and '2013-9-30'
and odx.icd10 in ('B053', 'H650')
group by v.hn
having cc>1
เพิ่ม icd10 เอานะคับ

105
order_date ไม่ใช่อยู่ที่ตาราง lab_head เหรอ

106
select year(a.nextdate)+543 year,month(a.nextdate) month
,count(a.vn) 'case'
,count(if(a.patient_visit='Y',a.vn,null)) 'confirm'
,count(if(a.patient_visit<>'Y' or a.patient_visit is null,a.vn,null)) 'no'
from oapp a
where a.nextdate between '2012-10-1' and '2013-9-30'
group by year,month

107
ประมาณนี้มั๊ย
select k.department,count(distinct o.hn) 'case',count(o.hn) 'visit'
from ovst o
left join kskdepartment k on k.depcode=o.main_dep
where o.vstdate between '2012-10-1' and '2013-9-30'
group by o.main_dep
*****
แต่ถ้าเป็น UnitCost คงไม่ใช่

108
select count(nb.an) 'target'
,sum(apgar1<=7 or has_asphyxia='Y') 'result'
,sum(apgar1<=7 or has_asphyxia='Y')/count(nb.an)*1000 'percent'
from ipt_newborn nb
where nb.born_date between '2012-10-1' and '2013-9-30'

109
ตรวจสอบฟิล์ด death ของ patient ดูว่าเป็น Y หรือไม่
เพราะอาจเกิดจากการ update ข้อมูล
หรือตายนอกสถานพยาบาล


110
ต้องเปิดโปรแกรม HOSxP ด้วย
เพราะบางฟังก์ชันอยู่ในนั้น

112
ต้องกาเพิ่มจุด ติดต่อครับ ต้องไปเพิ่มที่ไหนครับ ขอความช่วยเหลือด้วยครับ

113
คุณลงที่อยู่นอกเขตรึป่าว
ตาราง person_address

114
ลองเอาข้อมูลแต่ละรายที่ว่า error มาดูคับ
เพราะ library โรคของ โปรแกรม TGrp อาจไม่ตรงกัน
*****
- Error Code
1     No Principal Diagnosis
2     Invalid Principal Diagnosis
3     Unacceptable Principal Diagnosis
4     Principal Diagnosis not valid for age
5     Principal Diagnosis not valid for sex
6     Age error
7     Ungroupable due to sex error
8     Ungroupable due to discharge type error
9     Length of stay error
10   Ungroupable due to admission weight error

- Warning Code
1   SDx ใช้ไม่ได้ หรือซ้ำกับ PDx หรือซ้ำกันเอง
2   SDx ไม่เหมาะกับอายุ หรือเป็นรหัสซึ่งเหมาะกับบางช่วงอายุแต่ไม่มีข้อมูลอายุ
4   SDx ไม่เหมาะกับเพศ หรือเป็นรหัสสำหรับเพศใดเพศหนึ่ง แต่ไม่มีข้อมูลเพศ
8   Proc ใช้ไม่ได้ หรือซ้ำกันเอง
16   Proc ไม่เหมาะกับเพศ หรือเป็นรหัสสำหรับเพศใดเพศหนึ่ง แต่ไม่มีข้อมูลเพศ
32   ไม่มีข้อมูลเพศ หรือใช้รหัสนอกเหนือจากที่กำหนด
64   ไม่มีประเภทการจำหน่ายออกจากโรงพยาบาล หรือใช้รหัสนอกเหนือจากที่กำหนด
128   ไม่มีวันที่ และ/หรือ เวลา ที่รับไว้ในรพ. หรือ มีแต่ไม่ถูกต้อง
256   ไม่มีวันที่ และ/หรือ เวลา ที่จำหน่ายออกจากรพ. หรือ มีแต่ไม่ถูกต้อง

115
Report Exchange / Re: รายงาน Refer IN แยก รพช... พอจะมีไหมคับ
« เมื่อ: เมษายน 29, 2013, 11:12:14 AM »
select r.hospcode,h.name,h.chwpart,h.amppart,count(r.vn) cc
from referin r
left join hospcode h on h.hospcode=r.hospcode
where r.refer_date between '2013-1-1' and '2013-1-31'
group by r.hospcode
order by h.chwpart,h.amppart,r.hospcode
*****
ใน web น่าจะมีรายงาน refer อยู่นะ

116
ลองแบบนี้มั๊ย
select a.hospsub,ifnull(h.name,'อื่นๆ') name
,count(distinct a.hn) 'case',count(a.hn) 'visit'

,concat(count(distinct if(a.age_y between 0 and 2,a.hn,null)),'/'
,count(if(a.age_y between 0 and 2,a.hn,null))) age_0_2

,concat(count(distinct if(a.age_y between 3 and 5,a.hn,null)),'/'
,count(if(a.age_y between 3 and 5,a.hn,null))) age_3_5

,concat(count(distinct if(a.age_y between 6 and 12,a.hn,null)),'/'
,count(if(a.age_y between 6 and 12,a.hn,null))) age_6_12

,concat(count(distinct if(a.age_y between 13 and 59,a.hn,null)),'/'
,count(if(a.age_y between 13 and 59,a.hn,null))) age_13_59

,concat(count(distinct if(a.age_y>=60,a.hn,null)),'/'
,count(if(a.age_y>=60,a.hn,null))) age_60_more

from (select d.vn,d.hn,v.age_y,v.aid
,if(v.hospsub='' or v.hospsub is null,(select hospitalcode from opdconfig)
,if(v.hospsub in (select hcode from pcu_child),v.hospsub,'99999')) hospsub
from dtmain d
left join vn_stat v on d.vn=v.vn
where d.vstdate between '2013-1-1' and '2013-1-31') a
left join hospcode h on h.hospcode=a.hospsub
group by a.hospsub


117
Report Exchange / Re: ขอความช่วยเหลือค่ะ
« เมื่อ: เมษายน 24, 2013, 12:06:53 PM »
แบบนี้ได้มั๊ย

118
select a.hn,pt.pname,pt.fname,pt.lname
,a.vstdate,a.clinic,c.name clinicname,a.app_user
,cast(replace(replace(a.note2,char(13),','),char(10),'') as char(100)) Lab
from oapp a
left join patient pt on a.hn=pt.hn
left join clinic c on c.clinic=a.clinic
where a.nextdate between '2013-1-1' and '2013-1-10'
and a.note2 is not null
order by a.hn

119
ให้ set security ของ folder HOSxP ให้เป้น full control

120
Run Report ที่ไหน บน HOSxP หรือ Report Design
ถ้า run ที่ report design ต้องเปิด HOSxP ด้วย
เพราะที่อยู่ ผมใช้ func GetPatientAddress()

121
ลืมแนบไฟล์

123
เป็นแค่คำสั่งเท่านั้น
ถ้าจะสร้าง report ก้อต้องไปกำหนด pararmeter ด้วย
*****
แก้ตรง order by ด้วย
*****
woravet12@hotmail.com

124
แบบนี้ไหวมั๊ย
*****
select a.pdx,b.name
,sum(a.vstdate between '2009-10-1' and '2010-9-30') 'Y2553'
,sum(a.vstdate between '2010-10-1' and '2011-9-30') 'Y2554'
,sum(a.vstdate between '2011-10-1' and '2012-9-30') 'Y2555'
from vn_stat a
left join icd101 b on a.pdx=b.code
where a.vstdate between '2009-10-1' and '2012-9-30'
and a.age_y between 40 and 60
group by a.pdx
order by y2552 desc
limit 50

125
ไม่แสดง preview หน้าขาวๆ ได้มั๊ยคับ

126
เนื่องจากถ้าไม่มีข้อมูล รายงานจะขึ้นกระดาษขาวๆ
ผมอยากได้ว่า ถ้าไม่มีข้อมูล ให้มี popup ขึ้นมา
แล้วออกจากรายงาน

127
ใช้ข้อมูล report ใน report design
ทำไมใช้ recordcount ไม่ได้
*****
หรือมี func นับ record อย่างไรใน rerpot design

128
select a.spclty,s.name,sum(a.sex=1) Male,sum(a.sex=2) FeMale
from an_stat a
left join spclty s on a.spclty=s.spclty
where a.regdate between "2011-10-01" and "2012-09-30"
group by a.spclty

129
อีก 1 รายงาน
*****
ผมไม่ค่อยได้เขียนเป็นรายงาน
ส่วนใหญ่จะทำเป็นคำสั่ง

130
Report Exchange / Re: ขอแบบฟอร์มรายงานสรุปงานเอ็กซเรย์
« เมื่อ: กุมภาพันธ์ 28, 2013, 15:32:53 PM »
select count(distinct a.vn) 'Total'

,count(distinct if(a.depcode='001',a.vn,null)) 'Room_Doctor1'
,count(distinct if(a.depcode='002',a.vn,null)) 'Room_Doctor2'
,count(distinct if(a.depcode='028',a.vn,null)) 'Room_Doctor3'
,count(distinct if(a.depcode='011',a.vn,null)) 'Room_ER'
,count(distinct if(a.depcode='027',a.vn,null)) 'Room_Screen'
,count(distinct if(a.depcode not in ('001','002','028','011','027'),a.vn,null)) 'Room_Other'

,count(distinct if(length(a.vn)>9,a.vn,null)) 'OPD'
,count(distinct if(length(a.vn)=9,a.vn,null)) 'IPD'

,sum(a.film_id=1) 'Film10X12'
,sum(a.film_id=2) 'Film14X14'
,sum(a.film_id=3) 'Film14X1'

,sum(a.film_id=1 and a.damage_id>0) 'Lost10X12'
,sum(a.film_id=2 and a.damage_id>0) 'Lost14X14'
,sum(a.film_id=3 and a.damage_id>0) 'Lost14X17'

,sum(a.damage_id=1) 'Damage1'
,sum(a.damage_id=2) 'Damage2'
,sum(a.damage_id=3) 'Damage3'
,sum(a.damage_id=4) 'Damage4'
,sum(a.damage_id=5) 'Damage5'
,sum(a.damage_id=6) 'Damage6'
,sum(a.damage_id=7) 'Damage7'
,sum(a.damage_id=8) 'Damage8'
,sum(a.damage_id=9) 'Damage9'

from (select x1.xray_order_number no,x1.vn,x1.hn
,if(length(x1.vn)=9,x1.vn,'') 'AN',ifnull(r1.xn,r2.xn) XN
,date(x1.order_date_time) date
,ifnull(rf1.film_id,rf2.film_id) film_id
,ifnull(rf1.damage_id,rf2.damage_id) damage_id
,k.depcode,k.department
from xray_head x1
left join xray_report r1 on x1.vn=r1.vn
left join xray_report r2 on x1.vn=r2.an
left join xray_report_film rf1 on r1.xn=rf1.xn
left join xray_report_film rf2 on r2.xn=rf2.xn
left join kskdepartment k on x1.department_list regexp k.department
where date(x1.order_date_time) between '2013-1-1' and '2013-1-31') a
แบบนี้ได้มั๊ย

131
ลองทดสอบ โปรแกรมเครื่องส่งตรวจ(ลงทะเบียน)ด้วยตนเอง แล้วขึ้น Error

132
select o.icode,concat(d.name,' ',d.strength) drug,d.units
,sum(o.qty) 'Total'
,sum(o.sum_price) 'Sum_Price'
,sum(if(o.vn is not null,o.qty,0)) 'OPD'
,sum(if(o.vn is not null,o.sum_price,0)) 'OPD_Price'
,sum(if(o.an is not null,o.qty,0)) 'IPD'
,sum(if(o.an is not null,o.sum_price,0)) 'IPD_Price'
from opitemrece o
left join drugitems d on d.icode=o.icode
where o.rxdate between '2013-1-1' and '2013-1-31'
and d.name is not null
group by o.icode
order by d.name

133
ของ OPD
select o.main_dep,k.department
,count(distinct o.hn) 'case'
,count(o.hn) 'visit'
,sum(v.income) 'income'
from ovst o
left join vn_stat v on o.vn=v.vn
left join kskdepartment k on k.depcode=o.main_dep
where o.vstdate between '2013-1-1' and '2013-1-31'
group by o.main_dep

ของ IPD ไม่มีแยกแบบ department น่าจะมีแค่ spclty กับ ward

134
การเขียน SQL Script / Re: SQL Query ช่วงอายุ
« เมื่อ: กุมภาพันธ์ 06, 2013, 11:28:40 AM »
select 'ช่วงอายุ 9-12 เดือน' as 'age'
,count(distinct v.hn) 'case'
,count(v.hn) 'visit'
from vn_stat v
where v.vstdate between '2013-1-1' and '2013-1-31'
and concat(lpad(v.age_y,2,'0'),lpad(v.age_m,2,'0'),lpad(v.age_d,2,'0')) between '000900' and '001200'
union
select 'ช่วงอายุ 12-18 เดือน' as 'age'
,count(distinct v.hn) 'case'
,count(v.hn) 'visit'
from vn_stat v
where v.vstdate between '2013-1-1' and '2013-1-31'
and concat(lpad(v.age_y,2,'0'),lpad(v.age_m,2,'0'),lpad(v.age_d,2,'0')) between '010001' and '010600'
union
select 'ช่วงอายุ 18-24 เดือน' as 'age'
,count(distinct v.hn) 'case'
,count(v.hn) 'visit'
from vn_stat v
where v.vstdate between '2013-1-1' and '2013-1-31'
and concat(lpad(v.age_y,2,'0'),lpad(v.age_m,2,'0'),lpad(v.age_d,2,'0')) between '010601' and '020000'
union
select 'ช่วงอายุ 24-48 เดือน' as 'age'
,count(distinct v.hn) 'case'
,count(v.hn) 'visit'
from vn_stat v
where v.vstdate between '2013-1-1' and '2013-1-31'
and concat(lpad(v.age_y,2,'0'),lpad(v.age_m,2,'0'),lpad(v.age_d,2,'0')) between '020001' and '040000'
แบบของคุณ Armds ก้อดีเหมือนกัน



135
ลองตรวจสอบ Ovst ของ HN นี้
ว่ามี vsttime เป็น null มั๊ย
ให้ทำการลบ หรอแก้ไขซะ

136
เนื่องจาก rw=0 ให้คลิ๊กขวาเพื่อทำการ cal DRGs
ก้อแล้วแต่ว่าจะ All หรือ this patient
ถ้า All ควรกำหนดช่วงเวลาให้สั้นๆหน่อย
เดี๋ยวจะอืด จนถึง Error เอา

137
select v.main_pdx,i.name
,count(distinct v.hn) 'cc',count(v.hn) 'visit'
from er_regist er
left join ovst o on o.vn=er.vn
left join vn_stat v on o.vn=v.vn
left join icd101 i on i.code=v.main_pdx
where er.vstdate between '2013-1-1' and '2013-1-31'
and (o.visit_type='O' or dayofweek(er.vstdate) in (1,7)
or er.vstdate in (select holiday_date from holiday))
group by v.main_pdx
order by visit desc,cc desc
limit 30
ระวังคำจำกัดความของคำว่าง นอกเวลาราชการ หมายถึงอะไรกันแน่
ผมใช้ visit_type , dayofweek และ holiday
ลองดูคับ

139
แบบนี้ได้มั๊ย
*****
email/MSN:woravet12@hotmail.com

140
select o.vn
,o.vstdate
,o.pttype,p1.name pttypename
,inc.income_group,inc.name income_name
,sum(if(o.paidst='01',o.sum_price,0)) 'Reim'
,sum(if(o.paidst<>'01',o.sum_price,0)) 'Non_reim'
from opitemrece o
left join income inc on inc.income=o.income
left join pttype p1 on o.pttype=p1.pttype
where o.vn=551225091856
group by o.vn,inc.income_group
เปลี่ยนรหัส paidst เอาหล่ะกัน อาจไม่เหมือนกัน
reim=เบิกได้  non_reim=เบิกไม่ได้

141
ลองแก้ไขดูครับ

142
Report Exchange / Re: ช่วยดูรายงานให้หน่อยครับ
« เมื่อ: ธันวาคม 24, 2012, 15:34:46 PM »
select 'Intime' as type
,count(if((h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'case53'
,count(distinct if((h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'
union
select 'OutTime' as type
,count(if(not (h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'case53'
,count(distinct if(not (h.holiday_date is null or o.visit_type='I'),o.hn,null)) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'
union
select 'Total' as type
,count(o.hn) 'case53'
,count(distinct o.hn) 'visit53'
from ovst o
left join holiday h on h.holiday_date=o.vstdate
where o.vstdate between '2009-10-1' and '2010-9-30'

143
แก้เป็นแบบนี้คับ
no:=JD-JD5;
  if no=0 then no:=1 else no:=no+1;
  lstep:=false;
  if no>0 then lstep:=true;
  m:=5;
  lcheck:=True;
  lwork:=False;
  i:=0;
  while not lwork do
    begin
      i:=i+1;
      n:=no;
      nmod:=m mod 2;
      if nmod=1 then _day:=29 else _day:=30;
      if (m=7) and (_index=2) then _day:=_day+1;
      if (no>=0) and (no<=_day) then lwork:=true;
      if not lwork then
        begin
          if lstep then no:=no-_day else no:=no+_day;
          if lstep then m:=m+1 else m:=m-1;
//          showmessage(inttostr(m)+'-'+inttostr(_index)+'-'+booltostr(lcheck)+#13+inttostr(nmod)+'-'+inttostr(_day)+#13+inttostr(n)+'-'+inttostr(no));
          if (m=9) and (_index=1) and (lcheck) then
            begin
              lcheck:=False;
              m:=8;
            end;
          if m<1 then m:=12;
          if m>12 then m:=1;
        end;
      if i>12 then lwork:=true;
    end;
    if no=0 then no:=_day;
    cthaiday:=formatdatetime('dddd',nowdate);
    ram:='';
    if no<16 then ram:='&cent;&Ouml;&eacute;&sup1; '+inttostr(no) else ram:='&aacute;&Atilde;&Aacute; '+inttostr(no-15);
    ram:=ram+' &curren;&egrave;&Oacute;';
    cthaimonth:=inttostr(m) //'&agrave;&acute;&times;&Iacute;&sup1; '+inttostr(m);

144
Report Exchange / Re: ช่วยดูรายงานให้หน่อยครับ
« เมื่อ: ธันวาคม 24, 2012, 15:25:44 PM »
อาจเกิดจากการเรียงลำดับเหตุการณ์ผิด
ดูจาก CalcOrder
*****
ระวังการใช้หน่วยคน หรือการใช้ distinct() ของละเหตุการณ์
อาจไม่ใช่ ผลรวมทั้งหมด

145
select er.vstdate,ifnull(h.day_name,date_format(er.vstdate,'%W')) 'dayname'
,count(er.vn) cc
from er_regist er
left join ovst o on er.vn=o.vn
left join holiday h on h.holiday_date=er.vstdate
where er.vstdate between '2012-1-1' and '2012-1-31'
and (dayofweek(er.vstdate) in (1,7)
or o.visit_type='O'
or h.holiday_date is not null)
group by er.vstdate

146
ลองตรวจสอบตาราง ovst  ว่า HN นี้มี vsttime เป็น null รึป่าว
ถ้ามี ให้ลบ หรือทำการแก้ไข

147
ตารางสังวัตสร 2401-2560

148
ลองตรวจสอบตาราง ovst ,vn_stat ว่า HN นี้มี vsttime เป็น null รึป่าว
ถ้ามี ให้ลบ หรือทำการแก้ไข

149
ตัวอย่าง-ใบรับรองการเกิด
error ตรงคำนวณค่ามาสเกณฑ์(_mas)
ที่ต้อง +25 ไม่รู้เพราะอะไร
คำนวณได้แค่ 2401-2559
หาค่าตารางสังวัตสร (ผมตั้งชื่อว่า sws) ได้แค่นี้

150
ผมทำวันจัทรคติใน report
ได้ผลไม่ตรงกับทำใน Script บน HOSxP
บางคำสั่งใน script ไม่สามารถใช้บน report design ได้

หน้า: 1 2 [3] 4 5 ... 9