ผู้เขียน หัวข้อ: ขอความช่วยเหลือเรื่องรายงานคับ  (อ่าน 2635 ครั้ง)

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

ออฟไลน์ niyomstd

  • Hero Member
  • *****
  • กระทู้: 1,270
  • Respect: +15
    • ดูรายละเอียด
    • โรงพยาบาลแม่เมาะ
ขอความช่วยเหลือเรื่องรายงานคับ
« เมื่อ: กันยายน 20, 2011, 09:24:00 AM »
0
ขอความช่วยเหลือ เรื่องรายงานครับ
เนื่องจากผลรวมของภาวะแทรกซ้อนไม่ตรงกับ ผลรวมจริง ไม่ทราบว่าจะต้องแก้ไข script ในส่วนไหนครับ
พอดีผมทำการเพิ่มในส่วนของ ตำบลที่ รพ.รับผิดขอบเข้าไปแต่ตรงผลรวมภาวะแทรกซ้อนมันเำีพี้ยนครับ
ขอบคุณครับ

ตาม script ที่แนบพร้อมตัวรายงานนะครับ :) :) :)
unit MyIPDReport;

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;

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;
clinic,cln_cor:string;
visit_hn : string;

begin
   //showmessage('เกี่ยวกับรายงาน'+#13+'Custom OPD-NK2');

   clinic:='';
   clinic:= getpickuplist('select name from clinic where chronic="Y" order by name');
   if clinic='' then exit;

   pttype_name:=clinic;

   clinic:=getsqldata('select clinic from clinic where name="'+clinic+'"');


   if not getdaterange() then exit;
   d1:=date_result1();
   d2:=date_result2();

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

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


   visit_hn:=getsqlsubquerydata('select hn from clinicmember where clinic="'+clinic+'" and regdate between "'+ds1+'" and "'+ds2+'" ');
  // visit_hn := getsqlsubquerydata('select distinct hn from ovst where vstdate between "'+ds1+'" and "'+ds2+'" and hn in ('+
  //    visit_hn+') ');

   zquery.sql.text:='delete from tempreport where id = "CUSTOM-CHRONIC2" ';
   zquery.execsql;
   fcds.close;
   fcds.datarequest('select * from tempreport where id = "CUSTOM-CHRONIC2" ');
   fcds.open;

   fcds2.close;

   fcds2.datarequest('select * from clinic_cormobidity where clinic = "'+clinic+'"  '+
   ' order by cormobidity');
   fcds2.open;
   setstatuslabel('Open result : '+inttostr(fcds2.recordcount)+' Records');
   fcds2.first;

   i:=0;
   i:=1;
   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=1;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= pttype_name+' รวม';
   fcds['mon1']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y < 40 and sex ="1" and aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon2']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 40 and age_y <=49 and aid="520204" and sex ="1" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 50 and age_y <=59 and aid="520204" and sex ="1" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 60 and sex ="1" and aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where sex ="1" and aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon6']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');


   fcds.post;


   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=2;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= pttype_name+' รวม';
   fcds['mon1']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y < 40 and sex ="2" and aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon2']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 40 and age_y <=49 and aid="520204" and sex ="2" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 50 and age_y <=59 and aid="520204" and sex ="2" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where age_y >= 60 and sex ="2" and aid="520204" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc from vn_stat '+
      ' where  aid="520204" and sex ="2" and vstdate  between "'+ds1+'" and "'+ds2+'" '+
      ' and hn in ('+visit_hn+')');



   fcds.post;

   i:=2;

   cln_cor:=getsqlsubquerydata('select distinct hn from clinic_cormobidity_list where clinic="'+clinic+'"');

   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=1;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= 'ไม่มีภาวะแทรกซ้อน  เก่า';
   
   fcds['mon1']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y<40 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');     
   fcds['mon2']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where age_y >=40 and age_y<=49 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=50 and age_y<=59 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=60 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon6']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');

   fcds.post;

   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=2;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= 'ไม่มีภาวะแทรกซ้อน  เก่า';
   fcds['mon1']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y<40 and sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon2']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where age_y >=40 and age_y<=49 and aid="520204" and sex="2" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=50 and age_y<=59 and aid="520204" and sex="2" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=60 and sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  (new_case is NULL or new_case="N" or new_case="")'+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');


   fcds.post;


   i:=3;

   cln_cor:=getsqlsubquerydata('select distinct hn from clinic_cormobidity_list where clinic="'+clinic+'"');

   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=1;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= 'ไม่มีภาวะแทรกซ้อน  ใหม่';
   fcds['mon1']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y<40 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon2']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where age_y >=40 and age_y<=49 and aid="520204" and sex="1" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=50 and age_y<=59 and aid="520204" and sex="1" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=60 and sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where sex="1" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon6']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');

   fcds.post;

   fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=2;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= 'ไม่มีภาวะแทรกซ้อน  ใหม่';
   fcds['mon1']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y<40 and sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon2']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where age_y >=40 and age_y<=49 and aid="520204" and sex="2" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon3']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=50 and age_y<=59 and aid="520204" and sex="2" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon4']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where  age_y >=60 and sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');
   fcds['mon5']:= getsqldata('select count(hn)as cc  '+
      ' from vn_stat '+
      ' where sex="2" and aid="520204" and vstdate between  "'+ds1+'" and "'+ds2+'" '+
      ' and hn in(select hn from clinicmember where clinic="'+clinic+'" and  new_case="Y" '+
      ' and regdate between "'+ds1+'" and "'+ds2+'" )  '+
      ' and  hn not in ('+cln_cor+')');


   fcds.post;


   while not fcds2.eof do
   begin
    i:=i+1;
    setprogressbar(i,fcds2.recordcount);
     fcds.insert;
   fcds['id']:='CUSTOM-CHRONIC2';
   fcds['reportname']:='CUSTOM-CHRONIC2';
  // fcds['name']:=fcds2['vn'];
   fcds['name1']:=pttype_name;
   fcds['num']:=1;
   fcds['num2']:=i;
   fcds['date3']:=d1;
   fcds['date4']:=d2;

   fcds['name2']:= fcds2['name'];
       
   fcds['mon1']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y <40 and sex="1" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon2']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 40 and age_y <= 49 and sex="1" and aid="520204" and  vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon3']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 50 and age_y <= 59 and aid="520204" and sex="1" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon4']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 60 and sex="1" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon5']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  sex="1" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon6']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');



   //fcds['date1']:=d1;
   //fcds['date2']:=d2;


   fcds.post;


    fcds.insert;
    fcds['id']:='CUSTOM-CHRONIC2';
    fcds['reportname']:='CUSTOM-CHRONIC2';
    fcds['num']:=2;
    fcds['num2']:=i;
    fcds['date3']:=d1;
    fcds['date4']:=d2;

    fcds['mon1']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y <40 and sex="2" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon2']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 40 and age_y <= 49 and aid="520204" and sex="2" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon3']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 50 and age_y <= 59 and sex="2" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon4']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  age_y >= 60 and sex="2" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');
   fcds['mon5']:= getsqldata('select count(hn)as cc   '+
      ' from vn_stat  '+
      ' where  sex="2" and aid="520204" and vstdate between "'+ds1+'" and "'+ds2+'"  '+
      ' and hn in (select cl.hn from clinic_cormobidity_list cl,clinic_cormobidity cc   '+
      ' where cl.cormobidity=cc.cormobidity and cc.clinic ="'+clinic+'" '+
      ' and cc.name ="'+fcds2['name']+'"  and cl.begin_date between "'+ds1+'" and "'+ds2+'" )');

    fcds.post;
   fcds2.next;
   end;

   fcds.datarequest('select * from tempreport where id = "CUSTOM-CHRONIC2" ');
   applyupdate_fcds();

end;

end.
นิยม  สีทองแดง
โรงพยาบาลแม่เมาะ  ลำปาง(รพช.30 เตียง)
เริ่มใช้ HOSxP 2 เมษายน 2551
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Master :  CentOS

ออฟไลน์ niyomstd

  • Hero Member
  • *****
  • กระทู้: 1,270
  • Respect: +15
    • ดูรายละเอียด
    • โรงพยาบาลแม่เมาะ
Re: ขอความช่วยเหลือเรื่องรายงานคับ
« ตอบกลับ #1 เมื่อ: กันยายน 20, 2011, 10:03:59 AM »
0
เทพ script ช่วยหน่อยครับ  ;D ;D :D
นิยม  สีทองแดง
โรงพยาบาลแม่เมาะ  ลำปาง(รพช.30 เตียง)
เริ่มใช้ HOSxP 2 เมษายน 2551
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Master :  CentOS

ออฟไลน์ golf_win

  • Hero Member
  • *****
  • กระทู้: 3,481
  • Respect: +112
    • ดูรายละเอียด
Re: ขอความช่วยเหลือเรื่องรายงานคับ
« ตอบกลับ #2 เมื่อ: กันยายน 20, 2011, 10:46:02 AM »
0
น่าจะเปลี่ยนไปใช้ clinic โรคเรื้อรังแบบใหม่มากกว่าครับ นับยอดก็ง่ายกว่าครับ
โรงพยาบาลเจ็ดเสมียน จังหวัดราชบุรี
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

ออฟไลน์ niyomstd

  • Hero Member
  • *****
  • กระทู้: 1,270
  • Respect: +15
    • ดูรายละเอียด
    • โรงพยาบาลแม่เมาะ
Re: ขอความช่วยเหลือเรื่องรายงานคับ
« ตอบกลับ #3 เมื่อ: กันยายน 20, 2011, 10:47:31 AM »
0
น่าจะเปลี่ยนไปใช้ clinic โรคเรื้อรังแบบใหม่มากกว่าครับ นับยอดก็ง่ายกว่าครับ
อ.golf_win มีวิธีหรือมี script มั้ยคับ ;) ;)
นิยม  สีทองแดง
โรงพยาบาลแม่เมาะ  ลำปาง(รพช.30 เตียง)
เริ่มใช้ HOSxP 2 เมษายน 2551
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Master :  CentOS