ผู้เขียน หัวข้อ: ขอความช่วยเหลือ เพิ่มโค๊ส รายงานสรุปยอดตามสิทธิ์การรักษา ให้แยกแผนกตรงไหนครับ  (อ่าน 3411 ครั้ง)

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

ออฟไลน์ Farbrinet

  • Full Member
  • ***
  • กระทู้: 146
  • Respect: 0
    • ดูรายละเอียด
unit MyIPDReport;

var uc30_pcode : string;
  uc_pcode : string;
  foreign_pcode : string;
  other_pcode : string;
  icdx1,icdx2,ix2:string;
  fonlineid : string;

function getsqlsubquerydatax(sql:string):string;
begin
  result:='';
  zquery.close;
  zquery.sql.text:=sql;
  zquery.open;
  zquery.first;
    while not zquery.eof do
    begin
       if result='' then result:=''''+zquery.fields[0].asstring+'''' else
       result:=result+','''+zquery.fields[0].asstring+'''';

       zquery.next;
    end;
  zquery.close;
    if result='' then result:='''''';

end;

function GetICDRangeCount_UC30_InRegion(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      uc30_pcode+') and v.pttype_in_region="Y" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
 
  end;
end;

function GetICDRangeCount_UC30_OutRegion(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      uc30_pcode+') and v.pttype_in_region="N" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

function GetICDRangeCount_UC_InRegion(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      uc_pcode+') and v.pttype_in_region="Y" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

function GetICDRangeCount_UC_OutRegion(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      uc_pcode+') and v.pttype_in_region="N" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
 
end;

function GetICDRangeCount_Other(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      other_pcode+')  ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

function GetICDRangeCount_Foreign(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" and v.pcode in ('+
      foreign_pcode+')  ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

function GetICDRangeCount_Distinct_HN(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
    result:=getsqldata('select count(distinct v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

function GetICDRangeCount_HN(icd1,icd2:string;bd1,bd2:TDateTime):integer;
begin
  result:=0;
  try
   result:=getsqldata('select count(v.hn) as cc from vn_stat v,ovstdiag o where v.vstdate between "'+formatdatetime('yyyy-mm-dd',bd1)+'" '+
    ' and "'+formatdatetime('yyyy-mm-dd',bd2)+'" and v.vn=o.vn and o.icd10 between "'+icd1+'" and "'+icd2+'" ');
  except
    on e:exception do
    begin
      showmessage(e.message);
    end;
  end;
end;

procedure ProcessReport(n1,n2:string;i,i1,i2:integer;td1,td2:tdatetime);
begin
   setstatuslabel('Processing... '+n2);
   fcds.insert;
   fcds['id']:=fonlineid;
   fcds['reportname']:='CUSTOM-RGx2';
   
   fcds['name1']:=n1;

   fcds['num1']:=i;
   fcds['name2']:=n2;
   
   
   fcds['mon1']:=i1;
   fcds['mon2']:=i2;
   
   
   
 
   

   fcds['date1']:=td1;
   fcds['date2']:=td2;
 
   fcds.post;
 

   fcds.datarequest('select * from tempreport where id = '''+fonlineid+''' ');
   applyupdate_fcds();


end;


procedure main;
var d1,d2:tdatetime;
people_distinct_count1 : integer;
people_count1 : integer;
ds1,ds2:string;
pttype_list1 : string;
pttype,pttype_name:string;
hospcode_list:string;
money1:currency;
i:integer;



 

begin

   if not getdaterange() then exit;
   d1:=date_result1();
   d2:=date_result2();
   
   fonlineid:=report_value(1);
   
   icdx1:='J00';
   icdx2:='J99';
   
   
  // if not inputquery('ICD10 begin code ','code',icdx1) then exit;
  // if not inputquery('ICD10 end code ','code',icdx2) then exit;
   
  // ix2:=icdx2;
  // icdx2:=icdx2+'99';
   
   setstatuslabel('Processing...');
   
   
   
   
   uc30_pcode :='"UC"';
   uc_pcode := '"AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK"';
   foreign_pcode := '"AL"';
   other_pcode := getsqlsubquerydata('select pcode from pttype where pcode not in ('+uc30_pcode+','+uc_pcode+','+foreign_pcode+') ');

 

   

  // showmessage(formatdatetime('yyyy-mm-dd',d1)+' - '+
   //  formatdatetime('yyyy-mm-dd',d2));

   ds1:=formatdatetime('yyyy-mm-dd',d1);
   ds2:=formatdatetime('yyyy-mm-dd',d2);


 
   zquery.sql.text:='delete from tempreport where id = '''+fonlineid+''' ';
   zquery.execsql;
   fcds.close;
   fcds.datarequest('select * from tempreport where id = '''+fonlineid+''' ');
   fcds.open;
   
   fcds2.close;
   fcds2.datarequest('select a.pcode,c.name as pttype_name,count(a.an) as pt_count, '+
   ' sum(a.admdate) as admdate_count '+ 
   ' from an_stat a '+
   
   ' left outer join pcode c on c.code = a.pcode '+
   ' where a.dchdate between "'+ds1+'" and "'+ds2+'" '+
   ' group by a.pcode,c.name order by a.pcode ');
   fcds2.open;
   fcds2.first;
   i:=0;
   while not fcds2.eof do
   begin
     i:=i+1;
     setprogressbar(i,fcds2.recordcount);
     processreport(vartostr(fcds2['pcode']),vartostr(fcds2['pttype_name']),i,fcds2['pt_count'],fcds2['admdate_count'],d1,d2);
     fcds2.next;
   end;
   
   
   
   

   
   
   
 
   
   setstatuslabel('Done.');

end;

end.


ขอความช่วยเหลือจากอาจารย์ด้วยนะครับ ว่าต้องเพิ่ม ให้เลือกตึกผู้ป่วยตรงไหนครับ รายงานนี้ออกทุกตึกผู้ป่วยเลย
Janewit  Khanthawut โรงพยาบาลหนองบัวแดง จังหวัดชัยภูมิ
โรงพยาบาลชุมชน ขนาด 60 เตียง ***BMS ขึ้นระบบให้คับ นำทีมโดย น้องตั๊ก***
ดูแล 1 โรงพยาบาลและ 13 สอ.
Server1 : IBM x3500 XeonE5310 Ram 8 G SAS HDD 73 Gb Raid 1 CentOS 5.3 MySQL 5.1
Server2 : HP ML350 G6 E5520 2.26GHz Quad Core  Ram 10 G SAS HDD 146x3 Gb Raid 5 CentOS 6.3   MySQL 5.5
HosxP version  3.56.11.19
Cliant : Windows 7,XP,2003 Server
System Begin : 13 July 2007 (2550)
HosXP_PCU Version 3.55.X.X
LIS By อินเตอร์ คอร์ปอเรชั่น
OPD SCAN By Go2win

"ไม่มีอะไรที่ดีที่สุด มีเพียงแต่ดีกว่าเดิมเท่านั้น"

<img src=http://www.pfsense.org/templates/modular_plazza/images/logo.PNG>

ออฟไลน์ pop_hosxp

  • Hero Member
  • *****
  • กระทู้: 3,128
  • Respect: +38
    • ดูรายละเอียด
    • Phanomphrai Hospital
ตัวนี้เป็นรายงานของผู้ป่วยนอกนะครับ ไม่ใช่ผู้ป่วยใน จะเลือกตึก หรือเลือกแผนกที่รับบริการของผู้ป่วย
pop434241@gmail.com
รพ.พนมไพร จ.ร้อยเอ็ด www.phanomphrai.net

ออฟไลน์ Farbrinet

  • Full Member
  • ***
  • กระทู้: 146
  • Respect: 0
    • ดูรายละเอียด
เป็นของผุ้ป่วยในไม่ใช่เหรอครับ ผมเข้าไป copy จาก Script report desing น่าจะถูกตัวแล้วครับชื่อ SYSTEM-IPD-PTTYPE ต้องการให้เลือกว่าจะสรุปเป็นตึกผู้ป่วยหญิงหรือชายได้ด้วย และทั้งสองที่ครับ
Janewit  Khanthawut โรงพยาบาลหนองบัวแดง จังหวัดชัยภูมิ
โรงพยาบาลชุมชน ขนาด 60 เตียง ***BMS ขึ้นระบบให้คับ นำทีมโดย น้องตั๊ก***
ดูแล 1 โรงพยาบาลและ 13 สอ.
Server1 : IBM x3500 XeonE5310 Ram 8 G SAS HDD 73 Gb Raid 1 CentOS 5.3 MySQL 5.1
Server2 : HP ML350 G6 E5520 2.26GHz Quad Core  Ram 10 G SAS HDD 146x3 Gb Raid 5 CentOS 6.3   MySQL 5.5
HosxP version  3.56.11.19
Cliant : Windows 7,XP,2003 Server
System Begin : 13 July 2007 (2550)
HosXP_PCU Version 3.55.X.X
LIS By อินเตอร์ คอร์ปอเรชั่น
OPD SCAN By Go2win

"ไม่มีอะไรที่ดีที่สุด มีเพียงแต่ดีกว่าเดิมเท่านั้น"

<img src=http://www.pfsense.org/templates/modular_plazza/images/logo.PNG>

ออฟไลน์ Kab_Moo

  • Jr. Member
  • **
  • กระทู้: 89
  • Respect: 0
    • ดูรายละเอียด
Mae - ai Hospital
http://www.maeaihospital.com/
HOSXp version : 3.55.1.19
Server Master :Dell PowerEdge R310 X3440 2.53GHz RAM 16GB 320GB SAS10000rpm Raid-0  Centos 5.4 64Bit
Server Slave :Dell PowerEdge R310 X3440 2.53GHz  RAM 4GB 320GB SAS 10000rpm  Oracle Linux U1 64Bit
Image Server : Dell PowerEdge R310 X3440 2.53GHz RAM 8GB 500GB SATA 7200rpm Raid-1  Linux Centos 6 64Bit

-ขึ้นระบบ : 6 ธันวาคม 2553 จาก BMS Team