BMS-HOSxP Community

HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: kitisak ที่ พฤศจิกายน 22, 2009, 10:28:41 AM

หัวข้อ: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: kitisak ที่ พฤศจิกายน 22, 2009, 10:28:41 AM
 ;D ;D เรียน อ.ทุกท่านครับ  ขอเทคนิคนิดนึงครับ   ไม่ทราบว่ามี วิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ ปัจจุบันผมได้ทำResync-VNไปทีละวันครับ  ขอบคุณล่วงหน้าครับ  ;D ;D
หัวข้อ: Re: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: เกื้อกูล ครับ.. ที่ พฤศจิกายน 22, 2009, 10:43:42 AM
ไปที่เมนู  Tools -------> Miscelleneous-------> CheckDB--------> Advance-------->  Vn Check ---------> Reset  Vn Counter ---------> จากนั้นเลือก Re Generat VN-STST  รอไปเรื่อย ๆ จนหมดฐานข้อมูลที่มี  ถ้าหลายปี และวันละ 500 record  คงรอนานเป็นวัน ๆ ครับ  แต่ระบบทำต่อให้เรื่อย  ๆ ขึ้นอยู่กับขีดความสามารถของเครื่องแม่ข่ายด้วยครับ....การปรับแต่ง  Mysql  ก็มีผล  น่าจะทำเมื่อมีการ Upgrade  Structure ครับ....(ความเห็นส่วนตัว) ที่เหลือรอ อาจารย์ท่านอื่น ๆ comment ครับ....ผมแค่เกริ่นให้ทราบเบื้องต้น.... ;D ;D :D :D
หัวข้อ: Re: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: kitisak ที่ พฤศจิกายน 22, 2009, 11:26:48 AM
ไปที่เมนู  Tools -------> Miscelleneous-------> CheckDB--------> Advance-------->  Vn Check ---------> Reset  Vn Counter ---------> จากนั้นเลือก Re Generat VN-STST  รอไปเรื่อย ๆ จนหมดฐานข้อมูลที่มี  ถ้าหลายปี และวันละ 500 record  คงรอนานเป็นวัน ๆ ครับ  แต่ระบบทำต่อให้เรื่อย  ๆ ขึ้นอยู่กับขีดความสามารถของเครื่องแม่ข่ายด้วยครับ....การปรับแต่ง  Mysql  ก็มีผล  น่าจะทำเมื่อมีการ Upgrade  Structure ครับ....(ความเห็นส่วนตัว) ที่เหลือรอ อาจารย์ท่านอื่น ๆ comment ครับ....ผมแค่เกริ่นให้ทราบเบื้องต้น.... ;D ;D :D :D

ขอบคุณครับ อ.kuakool  มากมายครับ

     และขอคำชี้แนะจากอาจารย์ท่านอื่นต่อด้วยนะครับ ;D ;D
หัวข้อ: Re: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: manoi ที่ พฤศจิกายน 22, 2009, 13:56:51 PM
ลองเอา code นี้ไปวางไว้ในระบบ script แล้ว เรียกใช้งานครับ

var fhospitalcode:string;
begin

 fhospitalcode := getsqldata('select hospitalcode from opdconfig');

hosxp_getdataset('delete from vn_stat where vn not in (select vn from ovst)');
  hosxp_getdataset('insert ignore into vn_stat (vn,hn,vstdate,pttype,spclty) select vn,hn,vstdate,pttype,spclty from ovst ');
  hosxp_getdataset('update ignore vn_stat set hn = (select hn from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set vstdate = (select vstdate from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set spclty = (select spclty from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set pttype = (select pttype from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set hospmain = (select hospmain from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set hospsub = (select hospsub from ovst where ovst.vn = vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set pttype_in_region = "Y" where (hospmain="'
    + fhospitalcode + '" or hospsub="' + fhospitalcode +
    '") and pttype in (select pttype from pttype where region_type = 1 or region_type is null) ');
  hosxp_getdataset('update ignore vn_stat set pttype_in_region = "N" where (hospmain<>"'
    + fhospitalcode + '" and hospsub<>"' + fhospitalcode +
    '") and pttype in (select pttype from pttype where region_type = 1 or region_type is null) ');

  hosxp_getdataset('update ignore vn_stat set pdx = (select icd10 from ovstdiag where ovstdiag.vn = vn_stat.vn and ovstdiag.diagtype="1" ) ');
  hosxp_getdataset('update ignore vn_stat set main_pdx = (select substring(icd10,1,3) from ovstdiag where ovstdiag.vn = vn_stat.vn and ovstdiag.diagtype="1" ) ');
  hosxp_getdataset('update ignore vn_stat set income = (select sum(sum_price) as income from opitemrece where opitemrece.vn = vn_stat.vn ) ');
  hosxp_getdataset('update ignore vn_stat set sex = (select sex from patient where patient.hn = vn_stat.hn  ) ');
  hosxp_getdataset('update ignore vn_stat set cid = (select replace(cardno,"-","") from ptcardno where ptcardno.hn = vn_stat.hn and ptcardno.cardtype="01" ) ');
  hosxp_getdataset('update ignore vn_stat set pcode = (select pcode from pttype where pttype.pttype = vn_stat.pttype) ');
  hosxp_getdataset('update ignore vn_stat set aid = (select concat(chwpart,amppart,tmbpart) from patient where patient.hn = vn_stat.hn) ');
  hosxp_getdataset('update ignore vn_stat set inc01 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="01" ) ');
  hosxp_getdataset('update ignore vn_stat set inc02 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="02" ) ');
  hosxp_getdataset('update ignore vn_stat set inc03 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="03" ) ');
  hosxp_getdataset('update ignore vn_stat set inc04 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="04" ) ');
  hosxp_getdataset('update ignore vn_stat set inc05 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="05" ) ');
  hosxp_getdataset('update ignore vn_stat set inc06 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="06" ) ');
  hosxp_getdataset('update ignore vn_stat set inc07 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="07" ) ');
  hosxp_getdataset('update ignore vn_stat set inc08 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="08" ) ');
  hosxp_getdataset('update ignore vn_stat set inc09 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="09" ) ');
  hosxp_getdataset('update ignore vn_stat set inc10 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="10" ) ');
  hosxp_getdataset('update ignore vn_stat set inc11 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="11" ) ');
  hosxp_getdataset('update ignore vn_stat set inc12 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="12" ) ');
  hosxp_getdataset('update ignore vn_stat set inc13 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="13" ) ');
  hosxp_getdataset('update ignore vn_stat set inc14 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="14" ) ');
  hosxp_getdataset('update ignore vn_stat set inc15 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="15" ) ');
  hosxp_getdataset('update ignore vn_stat set inc16 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="16" ) ');
  hosxp_getdataset('update ignore vn_stat set inc17 = (select sum(sum_price) as income from opitemrece,income where opitemrece.vn = vn_stat.vn and opitemrece.income = income.income and income.income_group="17" ) ');

  hosxp_getdataset('update ignore vn_stat set count_in_year = (select count(vn) from ovst where ovst.hn = vn_stat.hn and substring(ovst.vn,1,2) = substring(vn_stat.vn,1,2) and ovst.vn < vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set count_in_month = (select count(vn) from ovst where ovst.hn = vn_stat.hn and substring(ovst.vn,1,4) = substring(vn_stat.vn,1,4) and ovst.vn < vn_stat.vn) ');
  hosxp_getdataset('update ignore vn_stat set count_in_day = (select count(vn) from ovst where ovst.hn = vn_stat.hn and substring(ovst.vn,1,6) = substring(vn_stat.vn,1,6) and ovst.vn < vn_stat.vn) ');

end;
หัวข้อ: Re: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: kitisak ที่ พฤศจิกายน 22, 2009, 14:10:41 PM
ขอบคุณ อ.mn มากครับ อาจารย์  ;D ;D
หัวข้อ: Re: มีวิธีการ Resync-VN ทั้งหมดในครั้งเดียวใหมครับ
เริ่มหัวข้อโดย: kungkung ที่ พฤศจิกายน 22, 2009, 21:42:31 PM
 :D  ขอบคุณมากครับ  :D