depart := GetPickupList('select "ALL" union select "IPD" union select "OPD" union select "DBA" ');
if depart='IPD' then
begin
ChangeReportSQL('SELECT pt.hn, Concat(pt.pname,pt.fname," ",pt.lname) as ptname, pt.birthday, '+
' pt.deathday, c1.name1 AS name504 ,pt.sex, i1.name AS icdname, d.*, pt.cid,d.death_date,d.an , '+
' dp.death_place_name,dp.death_place_id,s.name '+
' FROM death d LEFT OUTER JOIN '+
' patient pt ON pt.hn = d.hn LEFT OUTER JOIN '+
' rpt_504_name c1 ON c1.id = pt.death_code504 LEFT OUTER JOIN '+
' icd101 i1 ON i1.code = pt.death_diag LEFT OUTER JOIN '+
' death_place dp ON dp.death_place_id = d.death_place LEFT OUTER JOIN '+
' sex s ON s.code = pt.sex '+
' WHERE d.death_date BETWEEN "'+ds1+'" and "'+ds2+'" AND d.an <> "" ')
end;
if depart='OPD' then
begin
ChangeReportSQL('SELECT pt.hn, Concat(pt.pname, pt.fname, " ", pt.lname) AS ptname, pt.birthday,'+
' pt.deathday, c1.name1 AS name504 ,pt.sex, i1.name AS icdname, d.*, pt.cid,d.death_date,d.an , '+
' dp.death_place_name,dp.death_place_id,s.name '+
' FROM death d LEFT OUTER JOIN'+
' patient pt ON pt.hn = d.hn LEFT OUTER JOIN'+
' rpt_504_name c1 ON c1.id = pt.death_code504 LEFT OUTER JOIN'+
' icd101 i1 ON i1.code = pt.death_diag LEFT OUTER JOIN'+
' death_place dp ON dp.death_place_id = d.death_place LEFT OUTER JOIN '+
' sex s ON s.code = pt.sex'+
' WHERE d.death_date BETWEEN "'+ds1+'" and "'+ds2+'" AND d.an ="" and dp.death_place_id = "1" ')
end;
if depart='DBA' then
begin
ChangeReportSQL(' SELECT pt.hn, Concat(pt.pname, pt.fname, " ", pt.lname) AS ptname, pt.birthday,'+
' pt.deathday, c1.name1 AS name504 ,pt.sex, i1.name AS icdname, d.*, pt.cid,d.death_date,d.an , '+
' dp.death_place_name,dp.death_place_id,s.name '+
' FROM death d LEFT OUTER JOIN'+
' patient pt ON pt.hn = d.hn LEFT OUTER JOIN'+
' rpt_504_name c1 ON c1.id = pt.death_code504 LEFT OUTER JOIN'+
' icd101 i1 ON i1.code = pt.death_diag LEFT OUTER JOIN'+
' death_place dp ON dp.death_place_id = d.death_place LEFT OUTER JOIN '+
' sex s ON s.code = pt.sex'+
' WHERE d.death_date BETWEEN "'+ds1+'" and "'+ds2+'" AND d.an ="" and dp.death_place_id = "2" ')
end;
if depart='ALL' then
begin
ChangeReportSQL(' SELECT pt.hn, Concat(pt.pname, pt.fname, " ", pt.lname) AS ptname, pt.birthday,'+
' pt.deathday, c1.name1 AS name504 ,pt.sex, i1.name AS icdname, d.*, pt.cid,d.death_date,d.an , '+
' dp.death_place_name,dp.death_place_id,s.name '+
' FROM death d LEFT OUTER JOIN'+
' patient pt ON pt.hn = d.hn LEFT OUTER JOIN'+
' rpt_504_name c1 ON c1.id = pt.death_code504 LEFT OUTER JOIN'+
' icd101 i1 ON i1.code = pt.death_diag LEFT OUTER JOIN'+
' death_place dp ON dp.death_place_id = d.death_place LEFT OUTER JOIN '+
' sex s ON s.code = pt.sex'+
' WHERE d.death_date BETWEEN "'+ds1+'" and "'+ds2+'" ');
ผมทำสัญลักษณ์ให้ดูนะครับ น่าจะผิดตรงเครื่องหมาย ' ' ครับ ต้องใช้ ""