BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: Bond_007 ที่ กรกฎาคม 31, 2013, 11:50:29 AM

หัวข้อ: สอบถามการเขียน vn_pre_script
เริ่มหัวข้อโดย: Bond_007 ที่ กรกฎาคม 31, 2013, 11:50:29 AM
ได้ลองหัดเขียนครับ  แต่ปัญหาคือ ส่วนที่ผมเพิ่มใหม่ไม่ออกครับ ต้องไปแก้ที่ตรงไหนครับ
var
  fvn,fcomputername,fdepartment,fhn, scrcl, sgfr, sLastCrDate,fvn1,fcomputername1,fdepartment1,fhn1 : string;
  crcl, gfr, bw, LastCr, age_y, sex, a, factor : double;
  LastCrDate : date;
  cc:integer;

    total: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 ("001","002","003","004","005","006","007","008","103","022","014","112") and depcode="'+fdepartment+'"')=''+fdepartment+'' then

      bw:=getsqldata('select bw from opdscreen where hn="'+fhn+'" order by vn desc limit 1');

      LastCr:=getsqldata('select 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="155" and lh.hn="'+fhn+'" '+
      ' order by lh.order_date desc, lh.order_time desc limit 1');

      LastCrDate:=getsqldata('select lh.order_date from lab_head lh, lab_order lo '+
      ' where lh.lab_order_number=lo.lab_order_number and lo.lab_items_code="155" and lh.hn="'+fhn+'" '+
      ' order by lh.order_date desc, lh.order_time desc limit 1');

      age_y:=getsqldata('select age_y from vn_stat where vn="'+fvn+'"');

      //factor:=getsqldata('select if(sex=1,1,0.85) as factor from patient where hn="'+fhn+'"');

      factor:=getsqldata('select if(sex=1,1,0.742) as factor from patient where hn="'+fhn+'"');

      //crcl:=(140-age_y)*bw*factor/(72*LastCr);

      gfr:=186*exp(-1.154*ln(LastCr))*exp(-0.203*ln(age_y))*factor;

      ///scrcl:=FormatFloat('#.##', crcl);

      sgfr:=FormatFloat('#.##', gfr);

      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="155" and lh.hn="'+fhn+'"')>0 then

       begin
       if gfr>=90 then
    showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' (ÃÐÂзÕè 1 äµ»¡µÔ)')
       else if gfr>=60 then
    showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' (ÃÐÂзÕè 2 äµ¼Ô´»¡µÔ GFR Å´ÅàÅ硹éÍÂ)')
       else if gfr>=30 then
    showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' (ÃÐÂзÕè 3 äµ¼Ô´»¡µÔ GFR ŴŻҹ¡ÅÒ)')
       else if gfr>=15 then
    showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' (ÃÐÂзÕè 4 äµ¼Ô´»¡µÔÁÒ¡ GFR Å´ÅÁÒ¡)')
       else if gfr<15 then
    showmessage('GFR ÅèÒÊØ´ (àÁ×èÍ '+sLastCrDate+') ¢Í¤¹ä¢éÃÒ¹Õé = '+FloatToStr(sgfr)+' (ÃÐÂзÕè 5 äµÇÒÂÃÐÂÐÊØ´·éÒ GFR Å´ÅÁÒ¡·ÕèÊØ´)');
       end;
  end;





//total : double;

//////////////////////////////////////////////////////////////ส่วนที่เขียนใหม่ครับ

 begin
     fvn1:= GetGlobalValue('VN');
  fdepartment1 := GetGlobalValue('CURRENT_DEPCODE');
  total := getsqldata('select sum(sum_price)as cc from opitemrece where pttype = "28" and vn = "'+fvn1+'" ');


     if  total > 250 then
       showmessage('¤èÒÂÒà¡Ô¹ 250');
   end;
        end;


end;

     end.


หัวข้อ: Re: สอบถามการเขียน vn_pre_script
เริ่มหัวข้อโดย: usa0823 ที่ กรกฎาคม 31, 2013, 15:16:29 PM
//begin
     fvn1:= GetGlobalValue('VN');
  fdepartment1 := GetGlobalValue('CURRENT_DEPCODE');
  total := getsqldata('select sum(sum_price)as cc from opitemrece where pttype = "28" and vn = "'+fvn1+'" ');


     if  total > 250 then
       showmessage('¤èÒÂÒà¡Ô¹ 250');
  // end;
   //     end;


end;