ที่ผมเพิ่มคำสั่งมา ที่เป็นสีแดงครับ มันขึ้น Error ตามที่ส่งมานี้ครับ ซึ่งไม่เข้าใจเลยครับ ใครเข้าใจกรุณา อธิบายให้ด้วยครับ หรือว่าต้องแก้ตรงไหนบ้างครับ ใกล้เส้นตายเข้าไปทุกทีแล้วครับ
รบกวนด้วยครับ
//==============================================================================
// Report ER , 19 accident type
// @Author Nattapong Roadmuang
// @Since 2010 March 16
// @HOSxP 3.53.3.9
// @DBMS MySQL 5.1.3
// @OS Microsoft Windows Se7en
//==============================================================================
unit ImnukeReport;
procedure main;
var d1,d2:tdatetime;
ds1,ds2:string;
hosp_chwpart,hosp_amppart,hospcode:String;
sql_condition:array[1..19] of String;
moo_condition:array[1..19] of string;
i:integer;begin
// SQL Condition of accident type
sql_condition[1] := ' ov.icd10 between "V01" and "V899"';
sql_condition[2] := ' ov.icd10 between "W00" and "W199"';
sql_condition[3] := ' ov.icd10 between "W20" and "W499"';
sql_condition[4] := ' ov.icd10 between "W50" and "W649"';
sql_condition[5] := ' ov.icd10 between "W65" and "W749"';
sql_condition[6] := ' ov.icd10 between "W75" and "W849"';
sql_condition[7] := ' ov.icd10 between "W85" and "W999"';
sql_condition[8] := ' ov.icd10 between "X00" and "X099"';
sql_condition[9] := ' ov.icd10 between "X10" and "X199"';
sql_condition[10] := ' ov.icd10 between "X20" and "X299"';
sql_condition[11] := ' ov.icd10 between "X30" and "X399"';
sql_condition[12] := ' ov.icd10 between "X40" and "X499"';
sql_condition[13] := ' ov.icd10 between "X50" and "X579"';
sql_condition[14] := ' ov.icd10 between "X58" and "X599"';
sql_condition[15] := ' ov.icd10 between "X60" and "X849"';
sql_condition[16] := ' ov.icd10 between "X85" and "Y099"';
sql_condition[17] := ' ov.icd10 between "Y10" and "Y339"';
sql_condition[18] := ' ov.icd10 between "Y35" and "Y369"';
sql_condition[19] := ' ov.icd10 = "Y34"';
moo_condition[1] := '"01","1"';
moo_condition[2] := '"02","2"';
moo_condition[3] := '"03","3"';
moo_condition[4] := '"04","4"';
moo_condition[5] := '"05","5"';
moo_condition[6] := '"06","6"';
moo_condition[7] := '"07","7"';
moo_condition[8] := '"08","8"';
moo_condition[9] := '"09","9"';
moo_condition[10] := '"10"';
moo_condition[11] := '"11"';
moo_condition[12] := '"12"';
moo_condition[13] := '"13"';
moo_condition[14] := '"14"';
moo_condition[15] := '"15"';
moo_condition[16] := '"16"';
moo_condition[17] := '"17"';
moo_condition[18] := '"18"';
moo_condition[19] := '"19"'; // Get date
if not getdaterange() then exit;
d1:=date_result1();
d2:=date_result2();
ds1:=formatdatetime('yyyy-mm-dd',d1);
ds2:=formatdatetime('yyyy-mm-dd',d2);
// Initial tempreport
zquery.sql.text:='delete from tempreport where id = "Imnuke" ';
zquery.execsql;
// Initial hospital data
hospcode := getsqldata('select hospitalcode from opdconfig');
hosp_chwpart := getsqldata('select chwpart from hospcode where hospcode="' + hospcode + '"');
hosp_amppart := getsqldata('select amppart from hospcode where hospcode="' + hospcode + '"');
// Get All tmbpart in amp
fcds2.close;
fcds2.datarequest('select chwpart,amppart,tmbpart,addressid,name as tmbname from thaiaddress '+
'where chwpart="'+hosp_chwpart+'" and amppart="'+hosp_amppart+'" and codetype="3"');
fcds2.open;
fcds2.first;
// Initial accident type
fcds3.close;
fcds3.datarequest('select er_accident_type_id,er_accident_type_name from er_accident_type');
fcds3.open;
//village moo
fcds4.close;
fcds4.datarequest('select v.village_id,v.address_id,v.village_moo from village v '+
'left outer join vn_stat vn v.address_id=vn.aid '+
'left outer join patient p on p.hn=vn.hn '+
'where p.chwpart="'+hosp_chwpart+'" and p.amppart="'+hosp_amppart+'"');
fcds4.open; // Initial dataset
fcds.close;
fcds.datarequest('select * from tempreport where id = "Imnuke" ');
fcds.open;
fcds.first;
while not fcds2.eof do // chwpart & amppart
begin
fcds4.first;
while not fcds4.eof do
begin while not fcds3.eof do // Accident type
begin
fcds.insert;
fcds['id']:='Imnuke';
fcds['name'] := fcds3['er_accident_type_name'];
fcds['mon1'] := fcds3['er_accident_type_id'];
fcds['name1'] := fcds2['chwpart'];
fcds['name2'] := fcds2['amppart'];
fcds['name3'] := fcds2['tmbpart'];
fcds['name4'] := fcds2['addressid'];
fcds['name5'] := fcds2['tmbname'];
fcds['name7'] := fcds4['village_name']; fcds['name6'] := getsqldata('select count(*) from ovstdiag ov,vn_stat v '+
' where ov.vn=v.vn and v.vstdate between "'+ds1+'" and "'+ds2+'"'+
'
and v.moopart="'+moo_condition[fcds4['village_moo']]+'" and v.aid="'+fcds2['addressid']+'" and '+sql_condition[fcds3['er_accident_type_id']]);
fcds.post;
fcds3.next;
end;
end; fcds2.next;
end;
// Finally
fcds.datarequest('select * from tempreport where id = "Imnuke" ');
applyupdate_fcds();
end;
end.