ผู้เขียน หัวข้อ: แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ  (อ่าน 3513 ครั้ง)

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

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +10
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ
« เมื่อ: กุมภาพันธ์ 08, 2007, 10:40:26 AM »
0
ดูจาก code ของ SYSTEM-OPD-RG504 พบว่ารายงานออกมาซ้ำตาม id ในตารางของ rpt_504_code ที่ 1 idมีกลุ่มโรค มากกว่า 1 record ขึ้นไป  เช่น กลุ่มโรคที่ 21 (ตามเอกสารที่แนบมาครับ)
Yindee And Tan

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +10
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
Re: แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ
« ตอบกลับ #1 เมื่อ: กุมภาพันธ์ 08, 2007, 10:48:45 AM »
0
ส่งภาพมาให้ดูครับ
Yindee And Tan

ออฟไลน์ manoi

  • Hero Member
  • *****
  • กระทู้: 8,669
  • Respect: +170
    • ดูรายละเอียด
    • HOSxP Community Center
Re: แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ
« ตอบกลับ #2 เมื่อ: กุมภาพันธ์ 08, 2007, 19:15:00 PM »
0
ไม่ซ้ำครับ

ลองตรวจสอบตาราง rpt_504_name ดูนะครับ ว่ามีรายการซ้ำกันหรือไม่ หรือเอา report นี้ไป import ครับ
HOSxP Project Manager / Cheif Developer / BMS MD

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +10
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
Re: แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ
« ตอบกลับ #3 เมื่อ: กุมภาพันธ์ 08, 2007, 20:30:48 PM »
0
ใช้งานได้แล้วครับ
ขอบคุณครับ อ.mn
Yindee And Tan

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +10
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
Re: แจ้ง SYSTEM-OPD-RG504 ออกรายงานมาซ้ำ
« ตอบกลับ #4 เมื่อ: กุมภาพันธ์ 08, 2007, 21:22:14 PM »
0
เจอสาเหตุแล้วครับ เป็นที่ code ในรายงานผมเองครับ
code เดิมครับ
unit MyIPDReport;

var uc30_pcode : string;
  uc_pcode : string;
  foreign_pcode : string;
  other_pcode : 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;

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;
fonlineid:string;
 

begin

   if not getdaterange() then exit;
   d1:=date_result1();
   d2:=date_result2();
   
   setstatuslabel('Processing...');
   
   
   
   if getsqldata('select count(*) as cc from rpt_504_code')=0 then
   fcds.datarequest('EXEC INSERT INTO rpt_504_code (id, code1, code2) VALUES '+
   ' (1,''A00'',''B9999''), '+
   ' (2,''C00'',''D4899''), '+
   ' (3,''D50'',''D8999''), '+
   '  (4,''E00'',''E9099''), '+
  '  (5,''F00'',''F9999''), '+
  '  (6,''G00'',''G9999''), '+
  '  (7,''H00'',''H5999''), '+
  '  (8,''H60'',''H9599''), '+
  '  (9,''I00'',''I9999''), '+
  '  (10,''J00'',''J9999''), '+
  '  (11,''K00'',''K939''), '+
  '  (12,''L00'',''L9999''), '+
  '  (13,''M00'',''M9999''), '+
  '  (14,''N00'',''N9999''), '+
  '  (15,''O00'',''O9999''), '+
  '  (16,''P00'',''P9699''), '+
  '  (17,''Q00'',''Q9999''), '+
  '  (18,''R00'',''R9999''), '+
  '  (19,''X40'',''X4999''), '+       
  '  (20,''V01'',''V9999''), '+
  '  (21,''W00'',''Y9999'') ');
 
  if getsqldata('select count(*) as cc from rpt_504_name')=0 then
  fcds.datarequest('EXEC INSERT INTO rpt_504_name (id, name1, name2) VALUES '+
  ' (1,''âäµÔ´àª×éÍáÅлÃÊÔµ'',''Certain infectious and parasitic diseases''), '+
  ' (2,''à¹×éͧ͡ (ÃÇÁÁÐàÃç§)'',''Neoplasms''),  '+
  ' (3,''âäàÅ×Í´áÅÐÍÇÑÂÇÐÊÃéÒ§àÅ×Í´'',''Diseases of the blood and blood forming organs and certain disorders involving the immune mechanism''), '+
  ' (4,''âäà¡ÕèÂǡѺµèÍÁäÃé·èÍ âÀª¹Ò¡Òà áÅÐàÁµÐºÍÅÔÊÑÁ'',''Endocrine, nutritional and metabolic diseases''), '+
  ' (5,''ÀÒÇÐá»Ã»Ãǹ·Ò§¨ÔµáÅоĵԡÃÃÁ'',''Mental and behavioural disorders''), '+
  ' (6,''âäÃкº»ÃÐÊÒ·'',''Diseases of the nervous system''), '+
  ' (7,''âäµÒÃÇÁÊèǹ»ÃСͺ¢Í§µÒ'',''Diseases of the eye and adnexa''),  '+
  ' (8,''âäËÙáÅлØèÁ¡¡ËÙ'',''Diseases of the ear and mastoid process''), '+
  ' (9,''âäÃкºäËÅàÇÕ¹àÅ×Í´'',''Diseases of the circulatory system''),  '+
  ' (10,''âäÃкºËÒÂã¨'',''Diseases of the respiratory system''), '+
  ' (11,''âäÃкºÂèÍÂÍÒËÒà ÃÇÁâä㹪èͧ»Ò¡'',''Diseases of the digestive system''), '+
  ' (12,''âä¼ÔÇ˹ѧáÅÐà¹×éÍàÂ×èÍãµé¼ÔÇ˹ѧ'',''Diseases of the skin and subcutaneous tissue''),  '+
  ' (13,''âäÃкº¡ÅéÒÁà¹×éÍ ÃÇÁâ¤Ã§ÃèÒ§ áÅÐà¹×éÍÂÖ´àÊÃÔÁ'',''Diseases of the musculoskeletal system and connective tissue''), '+
  ' (14,''âäÃкºÊ׺¾Ñ¹¸ØìÃèÇÁ»ÑÊÊÒÇÐ'',''Diseases of the genitourinary system''),  '+
  ' (15,''ÀÒÇÐá·Ã¡ã¹¡ÒõÑ駤ÃÃÀì¡ÒäÅÍ´'',''Complication of pregnancy, childbirth and the puerperium''), '+
  ' (16,''ÀÒÇмԴ»¡µÔ¢Í§·Òá·Õèà¡Ô´¢Öé¹ã¹ÃÐÂлÃÔ¡Ó˹´'',''Certain conditions originating in the perinatal period''),  '+
  ' (17,''ÃÙ»ÃèÒ§¼Ô´»¡µÔáÅСÓà¹Ô´'',''Congenital malformations, deformations and chromosomal abnormalities''),  '+
  ' (18,''ÍÒ¡ÒÃ, ÍÒ¡ÒÃáÊ´§áÅÐÊÔ觼Դ»¡µÔ·Õ辺ä´é¨Ò¡¡ÒõÃǨ·Ò§¤ÅÕ¹Ô¡ áÅзҧËéͧ»¯ÔºÑµÔ¡ÒÃ'',''Symptoms, signs and abnormality clinical and laboratory findings, not elsewhere classified''),  '+
  ' (19,''¡ÒÃà»ç¹¾ÔÉáÅмŷÕèµÒÁÁÒ'',''Poisoning, toxic effect, and their sequelae''), '+
  ' (20,''ÍغѵÔà˵بҡ¡Òâ¹Êè§ áÅмŷÕèµÒÁÁÒ'',''Transport accidents and their sequelae''),  '+
  ' (21,''ÊÒà˵بҡÀÒ¹͡Í×è¹æ ·Õè·ÓãËé»èÇÂËÃ×͵ÒÂ'',''Other external causes of morbidity and mortality'')  ');

   
   
   uc30_pcode :='"UC","UA"';
   uc_pcode := '"AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","UB"';
   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);


   fonlineid:=report_value(1);
  // fonlineid:=get_onlineid ;
   //showmessage(fonlineid);
   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 r.*,c.* '+
    ' from rpt_504_name  r '+
    ' left outer join rpt_504_code c on c.id=r.id ');
   fcds2.open;


   
   i:=0;
   
   
   
   
   fcds2.first;
   while not fcds2.eof do
   begin
   
     setstatuslabel('Processing... '+fcds2['name1']);
   i:=i+1;
   setprogressbar(i,fcds2.recordcount);
   fcds.insert;
   fcds['id']:=fonlineid;
   fcds['reportname']:='CUSTOM-RG504';
   
   fcds['name1']:=fcds2['name1'];
   fcds['name2']:=fcds2['name2'];

   fcds['num1']:=fcds2['id'];
   
   fcds['mon1']:=GetICDRangeCount_UC30_InRegion(fcds2['code1'],fcds2['code2'],d1,d2);
   fcds['mon2']:=GetICDRangeCount_UC30_OutRegion(fcds2['code1'],fcds2['code2'],d1,d2);
   
   fcds['mon3']:=GetICDRangeCount_UC_InRegion(fcds2['code1'],fcds2['code2'],d1,d2);
   fcds['mon4']:=GetICDRangeCount_UC_OutRegion(fcds2['code1'],fcds2['code2'],d1,d2);
   
   fcds['mon5']:=GetICDRangeCount_Other(fcds2['code1'],fcds2['code2'],d1,d2);
   fcds['mon6']:=GetICDRangeCount_Foreign(fcds2['code1'],fcds2['code2'],d1,d2);
   
   fcds['mon7']:=fcds['mon1']+fcds['mon2']+fcds['mon3']+fcds['mon4']+fcds['mon5']+fcds['mon6']  ;
   
 
   

   fcds['date1']:=d1;
   fcds['date2']:=d2;
 
   fcds.post;
 

   fcds.datarequest('select * from tempreport where id = '''+fonlineid+''' ');
   applyupdate_fcds();
   
     fcds2.next;
   end;
   
   setstatuslabel('Done.');

end;

end.

code ใหม่ของ อ.mn
unit MyIPDReport;

var uc30_pcode : string;
  uc_pcode : string;
  foreign_pcode : string;
  other_pcode : 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;

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;
fonlineid:string;

 

begin

   if not getdaterange() then exit;
   d1:=date_result1();
   d2:=date_result2();
   
   setstatuslabel('Processing...');
   
   
   
   if getsqldata('select count(*) as cc from rpt_504_code')=0 then
   fcds.datarequest('EXEC INSERT INTO rpt_504_code (id, code1, code2) VALUES '+
   ' (1,''A00'',''B9999''), '+
   ' (2,''C00'',''D4899''), '+
   ' (3,''D50'',''D8999''), '+
   '  (4,''E00'',''E9099''), '+
  '  (5,''F00'',''F9999''), '+
  '  (6,''G00'',''G9999''), '+
  '  (7,''H00'',''H5999''), '+
  '  (8,''H60'',''H9599''), '+
  '  (9,''I00'',''I9999''), '+
  '  (10,''J00'',''J9999''), '+
  '  (11,''K00'',''K939''), '+
  '  (12,''L00'',''L9999''), '+
  '  (13,''M00'',''M9999''), '+
  '  (14,''N00'',''N9999''), '+
  '  (15,''O00'',''O9999''), '+
  '  (16,''P00'',''P9699''), '+
  '  (17,''Q00'',''Q9999''), '+
  '  (18,''R00'',''R9999''), '+
  '  (19,''X40'',''X4999''), '+       
  '  (20,''V01'',''V9999''), '+
  '  (21,''W00'',''Y9999'') ');
 
  if getsqldata('select count(*) as cc from rpt_504_name')=0 then
  fcds.datarequest('EXEC INSERT INTO rpt_504_name (id, name1, name2) VALUES '+
  ' (1,''âäµÔ´àª×éÍáÅлÃÊÔµ'',''Certain infectious and parasitic diseases''), '+
  ' (2,''à¹×éͧ͡ (ÃÇÁÁÐàÃç§)'',''Neoplasms''),  '+
  ' (3,''âäàÅ×Í´áÅÐÍÇÑÂÇÐÊÃéÒ§àÅ×Í´'',''Diseases of the blood and blood forming organs and certain disorders involving the immune mechanism''), '+
  ' (4,''âäà¡ÕèÂǡѺµèÍÁäÃé·èÍ âÀª¹Ò¡Òà áÅÐàÁµÐºÍÅÔÊÑÁ'',''Endocrine, nutritional and metabolic diseases''), '+
  ' (5,''ÀÒÇÐá»Ã»Ãǹ·Ò§¨ÔµáÅоĵԡÃÃÁ'',''Mental and behavioural disorders''), '+
  ' (6,''âäÃкº»ÃÐÊÒ·'',''Diseases of the nervous system''), '+
  ' (7,''âäµÒÃÇÁÊèǹ»ÃСͺ¢Í§µÒ'',''Diseases of the eye and adnexa''),  '+
  ' (8,''âäËÙáÅлØèÁ¡¡ËÙ'',''Diseases of the ear and mastoid process''), '+
  ' (9,''âäÃкºäËÅàÇÕ¹àÅ×Í´'',''Diseases of the circulatory system''),  '+
  ' (10,''âäÃкºËÒÂã¨'',''Diseases of the respiratory system''), '+
  ' (11,''âäÃкºÂèÍÂÍÒËÒà ÃÇÁâä㹪èͧ»Ò¡'',''Diseases of the digestive system''), '+
  ' (12,''âä¼ÔÇ˹ѧáÅÐà¹×éÍàÂ×èÍãµé¼ÔÇ˹ѧ'',''Diseases of the skin and subcutaneous tissue''),  '+
  ' (13,''âäÃкº¡ÅéÒÁà¹×éÍ ÃÇÁâ¤Ã§ÃèÒ§ áÅÐà¹×éÍÂÖ´àÊÃÔÁ'',''Diseases of the musculoskeletal system and connective tissue''), '+
  ' (14,''âäÃкºÊ׺¾Ñ¹¸ØìÃèÇÁ»ÑÊÊÒÇÐ'',''Diseases of the genitourinary system''),  '+
  ' (15,''ÀÒÇÐá·Ã¡ã¹¡ÒõÑ駤ÃÃÀì¡ÒäÅÍ´'',''Complication of pregnancy, childbirth and the puerperium''), '+
  ' (16,''ÀÒÇмԴ»¡µÔ¢Í§·Òá·Õèà¡Ô´¢Öé¹ã¹ÃÐÂлÃÔ¡Ó˹´'',''Certain conditions originating in the perinatal period''),  '+
  ' (17,''ÃÙ»ÃèÒ§¼Ô´»¡µÔáÅСÓà¹Ô´'',''Congenital malformations, deformations and chromosomal abnormalities''),  '+
  ' (18,''ÍÒ¡ÒÃ, ÍÒ¡ÒÃáÊ´§áÅÐÊÔ觼Դ»¡µÔ·Õ辺ä´é¨Ò¡¡ÒõÃǨ·Ò§¤ÅÕ¹Ô¡ áÅзҧËéͧ»¯ÔºÑµÔ¡ÒÃ'',''Symptoms, signs and abnormality clinical and laboratory findings, not elsewhere classified''),  '+
  ' (19,''¡ÒÃà»ç¹¾ÔÉáÅмŷÕèµÒÁÁÒ'',''Poisoning, toxic effect, and their sequelae''), '+
  ' (20,''ÍغѵÔà˵بҡ¡Òâ¹Êè§ áÅмŷÕèµÒÁÁÒ'',''Transport accidents and their sequelae''),  '+
  ' (21,''ÊÒà˵بҡÀÒ¹͡Í×è¹æ ·Õè·ÓãËé»èÇÂËÃ×͵ÒÂ'',''Other external causes of morbidity and mortality'')  ');

   
   
   uc30_pcode :='"UC","UA"';
   uc_pcode := '"AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","UB"';
   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);


   fonlineid:=report_value(1);
  // fonlineid:=get_onlineid ;
   //showmessage(fonlineid);
   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 r.* '+
    ' from rpt_504_name  r '+
    '  ');
   fcds2.open;

   
   i:=0;
   
   
 
   
   fcds2.first;
   while not fcds2.eof do
   begin
   
     setstatuslabel('Processing... '+fcds2['name1']);
   i:=i+1;
   setprogressbar(i,fcds2.recordcount);
   fcds.insert;
   fcds['id']:=fonlineid;
   fcds['reportname']:='CUSTOM-RG504';
   
   fcds['name1']:=fcds2['name1'];
   fcds['name2']:=fcds2['name2'];

   fcds['num1']:=fcds2['id'];
   
   
   fcds3.close;
   fcds.datarequest('select * from rpt_504_code where id = '+fcds2.fieldbyname('id').asstring);
   fcds3.open;
   
   fcds['mon1']:=0;
   fcds['mon2']:=0;
   fcds['mon3']:=0;
   fcds['mon4']:=0;
   fcds['mon5']:=0;
   fcds['mon6']:=0;
   fcds['mon7']:=0;
   
   while not fcds3.eof do
   begin
   
   
   fcds['mon1']:=fcds['mon1']+GetICDRangeCount_UC30_InRegion(fcds3['code1'],fcds3['code2'],d1,d2);
   fcds['mon2']:=fcds['mon2']+GetICDRangeCount_UC30_OutRegion(fcds3['code1'],fcds3['code2'],d1,d2);
   
   fcds['mon3']:=fcds['mon3']+GetICDRangeCount_UC_InRegion(fcds3['code1'],fcds3['code2'],d1,d2);
   fcds['mon4']:=fcds['mon4']+GetICDRangeCount_UC_OutRegion(fcds3['code1'],fcds3['code2'],d1,d2);
   
   fcds['mon5']:=fcds['mon5']+GetICDRangeCount_Other(fcds3['code1'],fcds3['code2'],d1,d2);
   fcds['mon6']:=fcds['mon6']+GetICDRangeCount_Foreign(fcds3['code1'],fcds3['code2'],d1,d2);
   
   fcds['mon7']:=fcds['mon1']+fcds['mon2']+fcds['mon3']+fcds['mon4']+fcds['mon5']+fcds['mon6']  ;
   
   fcds3.next;
   
   end;
   
   fcds['mon7']:=fcds['mon1']+fcds['mon2']+fcds['mon3']+fcds['mon4']+fcds['mon5']+fcds['mon6']  ;
   
   fcds['date1']:=d1;
   fcds['date2']:=d2;
 
   fcds.post;
 

   fcds.datarequest('select * from tempreport where id = '''+fonlineid+''' ');
   applyupdate_fcds();
   
     fcds2.next;
   end;
   
   
   
   setstatuslabel('Done.');

end;

end.
Yindee And Tan