BMS-HOSxP Community
HOSxP => Report Exchange => ข้อความที่เริ่มโดย: perfectk ที่ กันยายน 27, 2011, 18:49:39 PM
-
คืออยาก แก้ไข code รายงานหลัก SYSTEM-DENT-DOCTOR-SUMMARY-2 ให้แสดงจำนวนผู้ที่มาทำฟัน แยกตามประเภทเวลาทำงาน ในเวลา นอกเวลา ได้ครับ
และ อยาก แยกรายละเอียด ตรง อุดฟัน ให้แสดงแยก เป็น แต่ละ class ว่ามีคนไข้เท่าไหร่ครับ
ขอบคุณครับ
-
code ที่อยู่ในรายงานหลักครับ ไม่ทราบว่าต้อง แก้ตรงไหนบ้างครับ
//SQL
select * from tempreport where id = "{onlineid}"
and num1>0
order by name,name2
//Script
unit MyIPDReport;
function getsqlsubquerydata(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;
fonlineid:string;
i:integer;
money1:currency;
begin
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);
fonlineid:=report_value(1);
zquery.sql.text:='delete from tempreport where id = "'+fonlineid+'" ';
zquery.execsql;
fcds.close;
fcds.datarequest('select * from tempreport where id = "'+fonlineid+'" limit 0 ');
fcds.open;
fcds2.close;
fcds2.datarequest('select * from doctor ');
fcds2.open;
setprogressbar(0,fcds2.recordcount);
fcds2.first;
i:=0;
while not fcds2.eof do
begin
i:=i+1;
setprogressbar(i,fcds2.recordcount);
fcds3.close;
fcds3.datarequest('select t.code,t.name,count(m.vn) as vn_count ,sum(m.tcount) as t_count'+
' , sum(m.scount) as s_count '+
' from dttm t '+
' left outer join dtmain m on m.tmcode=t.code '+
' and m.doctor="'+fcds2.fieldbyname('code').asstring+'" '+
' and m.vstdate between "'+ds1+'" and "'+ds2+'" '+
' group by t.code,t.name ');
fcds3.open;
while not fcds3.eof do
begin
fcds.insert;
fcds['id']:=fonlineid;
fcds['reportname']:='CUSTOM-Doctor1';
try
fcds['name']:=fcds2['name'];
fcds['name2']:=fcds3['code'];
fcds['name3']:=fcds3['name'];
fcds['num1']:=fcds3['vn_count'];
fcds['num2']:=fcds3['t_count'];
fcds['num3']:=fcds3['s_count'];
except end;
fcds['date1']:=d1;
fcds['date2']:=d2;
if fcds.fieldbyname('num1').asinteger>0 then
fcds.post else
fcds.cancel;
fcds3.next;
end;
fcds.datarequest('select * from tempreport where id = "'+fonlineid+'" limit 0 ');
applyupdate_fcds();
fcds2.next;
end;
fcds3.close;
fcds.datarequest('select * from tempreport where id = "'+fonlineid+'" limit 0 ');
applyupdate_fcds();
end;
end.
-
พอจะตอบได้เป็นข้อๆนะครับ
1.แยกผู้ป่วยในเวลานอกเวลาน่าจะใช้ข้อมูลจากหน้าส่งตรวจดีไหมครับที่ตาราง ovst ฟิลด์ visit_type นะครับจะดีกว่า ตรงหน้าที่ส่งมาเป็นหน้าที่แสดงการ login เวลาเขียน code อาจจะลำบากกว่านะ (ความเห็นผมคนเดียว)
2.กรณีจะแยกว่าอุดฟันแต่ละประเภทเท่าไหร่นั้น ดูแล้วหัตถการน่าจะเป็นรายการเดียวกันเลยเก็บรวมไม่ได้แยกออกมาเป็นแต่ละรายการหรือเปล่า น่าจะเก็บแยกอย่างที่ต้องการไม่ได้ ถ้าไม่อย่างนั้นต้องเพิ่มรายการใน dttm แยกเป็น I,III,V ต่างหากเป็น 3 รายการนะครับ นอกเสียจากมี icd10 กำกับอีกชั้นว่าอะไรคือ I,III,V เพราะดูจาก code ใช้ group by t.code,t.name ก็ควรจะต้องแยก ถ้าไม่แยกต้องพิมพ์รายการหัตถการเข้าไปเอง แล้วหาตัวช่วยอย่างที่บอก โดยใช้ variable ช่วย
3.ส่วน code นั้้นอยากทราบว่าการแยกในเวลานอกเวลา จะให้สามารถเลือกได้ก่อนประมวลผลหรือไม่ หรือว่าต้องการแยกไปอยู่ในตัวรายงานเป็นฟิลด์ว่า นอกเวลาในเวลา อย่างไรอธิบายให้ละเอียดครับจะได้ตอบได้ตรงประเด็น
ปล.ผมไม่เก่งมากนะครับ รอท่านผู้รู้ท่านอื่นให้ความเห็นด้วย แต่ขอร่วมแชร์เผื่อช่วยได้ครับ
-
ข้อ 3 อยากได้ไปรวมอยู่ในตัวรายงานเลยก็ได้ครับ ไม่ต้องเลือกก่อนประมวณผลก็ได้ครับ
ขอบคุณครับ