รอรับการแก้ไขจาก อ เหมือนกันครับ
ลองดูตัวนี้พี่
var
fvn,fcomputername,fdepartment,fhn, scrcl, sgfr,sLastCr, sLastCrDate : string;
crcl, gfr, bw, LastCr, age_y, sex, a, factor : double;
LastCrDate : date;
cc:integer;
begin
fvn:= GetGlobalValue('VN');
fdepartment := GetGlobalValue('CURRENT_DEPCODE');
fhn:=getsqldata('select hn from ovst where vn = "'+fvn+'"');
if getsqldata('select depcode from kskdepartment where depcode in (select depcode from depcode_vn_script_allow) '+
' and depcode="'+fdepartment+'"')=''+fdepartment+'' then
bw:=getsqldata('select bw from opdscreen where hn="'+fhn+'" order by vn desc limit 1');
{ select lh.hn,lh.vn,lh.order_date,lo.lab_order_result from lab_head lh, lab_order lo
where lh.lab_order_number=lo.lab_order_number and lo.lab_items_code=
(select lab_items_code from lab_items where lab_items_name=
(select sys_value from sys_var where sys_name="lab_link_cr" limit 1))
order by lh.order_date desc, lh.order_time desc limit 10000
}
LastCr:=getsqldata('select creatinine from opdscreen where hn="'+fhn+'" '+
' and creatinine>0 '+
' order by vn desc limit 1');
sLastCr:=FormatFloat('#.##', LastCr);
LastCrDate:=getsqldata('select vstdate from opdscreen where hn="'+fhn+'" '+
' and creatinine>0 '+
' order by vn desc limit 1');
sLastCrDate:=FormatDatetime('d/mm/yyyy',LastCrDate);
age_y:=getsqldata('select age_y from vn_stat where vn="'+fvn+'"');
if getsqldata('select sex from patient where hn="'+fhn+'" ')=1 then
gfr:=141*exp(-1.209*ln(LastCr/0.9))*exp(age_y*ln(0.993))
else
gfr:=144*exp(-1.209*ln(LastCr/0.7))*exp(age_y*ln(0.993));
sgfr:=FormatFloat('#.##', gfr);
sgfr:=FormatFloat('#.##', gfr);
sLastCr:=FormatFloat('#.##', LastCr);
sLastCrDate:=FormatDatetime('d/mm/yyyy',LastCrDate);
if getsqldata('select count(lo.lab_order_result) as cc from lab_head lh, lab_order lo '+
' where lh.lab_order_number=lo.lab_order_number and lo.lab_items_code=(select lab_items_code from lab_items where lab_items_name= '+
'(select sys_value from sys_var where sys_name="lab_link_cr" limit 1)) '+
' and lh.hn="'+fhn+'"')>0 then
{ }
begin
if gfr>=100 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (äµ»¡µÔ áÅÐ GFR »¡µÔ)')
else if gfr>=90 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 1 äµ¼Ô´»¡µÔ áÅÐ GFR »¡µÔËÃ×Íà¾ÔèÁ¢Öé¹ ¤ÇõÃǨ Cr «éÓ·Ø¡ 6 à´×͹ éÒ¾º Albumin ã¹»ÑÊÊÒÇÐ)')
else if gfr>=60 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 2 äµ¼Ô´»¡µÔ GFR Å´ÅàÅ硹éÍ µÔ´µÒÁÍÂèÒ¹éÍ·ء 6 à´×͹ ËÃ×Í ·Ø¡ 12 à´×͹éÒäµ·ÓÒ¹¤·Õè áÅÐäÁ辺â»ÃµÕ¹ã¹»ÑÊÊÒÇÐ)')
else if gfr>=30 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 3 äµ¼Ô´»¡µÔ GFR ŴŻҹ¡ÅÒ µÔ´µÒÁÍÂèÒ¹éÍ·ء 6 à´×͹ ËÃ×Í ·Ø¡ 12 à´×͹éÒäµ·ÓÒ¹¤·Õè áÅÐäÁ辺â»ÃµÕ¹ã¹»ÑÊÊÒÇÐ)')
else if gfr>=15 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 4 äµ¼Ô´»¡µÔÁÒ¡ GFR Å´ÅÁÒ¡ µÔ´µÒÁÍÂèÒ¹éÍ·ء 3 à´×͹ ËÃ×Í ·Ø¡ 6 à´×͹ éÒÃдѺ¡Ò÷ÓÒ¹¢Í䵤·Õè ) ')
else if gfr>=10 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 5 äµÇÒÂÃÐÂÐÊØ´·éÒ GFR Å´ÅÁÒ¡·ÕèÊØ´ µÔ´µÒÁÍÂèÒ¹éÍ·ء 3 à´×͹ )')
else if gfr<10 then
showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' áÅмŠCr = '+FloatToStr(sLastCr)+' (ÃÐÂзÕè 5 äµÇÒÂÃÐÂÐÊØ´·éÒ GFR Å´ÅÁÒ¡·ÕèÊØ´ ¤ÇÃä´éÃѺ¡ÒÃ¿Í¡äµ )');
end;
end;
end;