วิธีการ clear ฐานข้อมูล 43 แฟ้ม ในโปรแกรม DHDC (กันลืม)
ในการเคลียร์ฐานข้อมูล 43 แฟ้ม นั้นให้ท่านเข้าระบบ ในฐานะผู้ดูแลระบบ จากนั้นก็เข้าไปตามลิงค์ ตัวอย่าง http://yourweb/dhdc/frontend/web/index.php?r=ajax/truncate
อย่าลืม ก่อนที่จะทำการ clear ฐานข้อมูล 43 แฟ้มนั้น ท่านจะต้อง backup database ให้เรียบร้อยก่อนเพื่อกันความผิดพลาดและในส่วนของตาราง error_xxx ให้ ลบ แบบ manual เอาครับ
คำสั่ง สำหรับล้าง table_err ดังนี้
truncate table err_*; หรือไล่ทีละตารางก็ได้ truncate table err_xxx; เป็นต้น
หากต้องการลบในแต่ละตารางก็สามารถสั่งคำสั่งโดยตรง ดังนี้
truncate table person ;
truncate table address ;
truncate table death ;
truncate table chronic ;
truncate table card ;
truncate table home ;
truncate table village ;
truncate table disability ;
truncate table provider ;
truncate table women ;
truncate table drugallergy ;
truncate table functional ;
truncate table icf ;
truncate table service ;
truncate table diagnosis_opd ;
truncate table drug_opd ;
truncate table procedure_opd ;
truncate table charge_opd ;
truncate table surveillance ;
truncate table accident ;
truncate table chronicfu ;
truncate table labfu ;
truncate table admission ;
truncate table diagnosis_ipd ;
truncate table drug_ipd ;
truncate table procedure_ipd ;
truncate table charge_ipd ;
truncate table appointment ;
truncate table dental ;
truncate table rehabilitation ;
truncate table ncdscreen ;
truncate table fp ;
truncate table prenatal ;
truncate table anc ;
truncate table labor ;
truncate table postnatal ;
truncate table newborn ;
truncate table newborncare ;
truncate table epi;
truncate table nutrition ;
truncate table specialpp ;
truncate table community_activity ;
truncate table community_service ;
truncate table care_refer ;
truncate table clinical_refer ;
truncate table drug_refer ;
truncate table investigation_refer ;
truncate table procedure_refer;
truncate table refer_history;
truncate table refer_result;
ส่วนคิวรี่นี้เอาไว้สำหรับลบข้อมูลเฉพาะรายรพ.สต. ให้เปลี่ยนค่า ‘xxxxx’ เป็นรหัสรพ.สต.ของท่าน
SET @hospcode :=’xxxxx’;
DELETE FROM person WHERE person.HOSPCODE=@hospcode;
DELETE FROM address WHERE address.HOSPCODE=@hospcode;
DELETE FROM death WHERE death.HOSPCODE=@hospcode;
DELETE FROM card WHERE card.HOSPCODE=@hospcode;
DELETE FROM drugallergy WHERE drugallergy.HOSPCODE=@hospcode;
DELETE FROM home WHERE home.HOSPCODE=@hospcode;
DELETE FROM service WHERE service.HOSPCODE=@hospcode;
DELETE FROM appointment WHERE appointment.HOSPCODE=@hospcode;
DELETE FROM accident WHERE accident.HOSPCODE=@hospcode;
DELETE FROM diagnosis_opd WHERE diagnosis_opd.HOSPCODE=@hospcode;
DELETE FROM procedure_opd WHERE procedure_opd.HOSPCODE=@hospcode;
DELETE FROM drug_opd WHERE drug_opd.HOSPCODE=@hospcode;
DELETE FROM charge_opd WHERE charge_opd.HOSPCODE=@hospcode;
DELETE FROM admission WHERE admission.HOSPCODE=@hospcode;
DELETE FROM diagnosis_ipd WHERE diagnosis_ipd.HOSPCODE=@hospcode;
DELETE FROM procedure_ipd WHERE procedure_ipd.HOSPCODE=@hospcode;
DELETE FROM drug_ipd WHERE drug_ipd.HOSPCODE=@hospcode;
DELETE FROM charge_ipd WHERE charge_ipd.HOSPCODE=@hospcode;
DELETE FROM surveillance WHERE surveillance.HOSPCODE=@hospcode;
DELETE FROM women WHERE women.HOSPCODE=@hospcode;
DELETE FROM fp WHERE fp.HOSPCODE=@hospcode;
DELETE FROM epi WHERE epi.HOSPCODE=@hospcode;
DELETE FROM nutrition WHERE nutrition.HOSPCODE=@hospcode;
DELETE FROM prenatal WHERE prenatal.HOSPCODE=@hospcode;
DELETE FROM anc WHERE anc.HOSPCODE=@hospcode;
DELETE FROM labor WHERE labor.HOSPCODE=@hospcode;
DELETE FROM postnatal WHERE postnatal.HOSPCODE=@hospcode;
DELETE FROM newborn WHERE newborn.HOSPCODE=@hospcode;
DELETE FROM newborncare WHERE newborncare.HOSPCODE=@hospcode;
DELETE FROM dental WHERE dental.HOSPCODE=@hospcode;
DELETE FROM specialpp WHERE specialpp.HOSPCODE=@hospcode;
DELETE FROM ncdscreen WHERE ncdscreen.HOSPCODE=@hospcode;
DELETE FROM chronic WHERE chronic.HOSPCODE=@hospcode;
DELETE FROM chronicfu WHERE chronicfu.HOSPCODE=@hospcode;
DELETE FROM labfu WHERE labfu.HOSPCODE=@hospcode;
DELETE FROM community_service WHERE community_service.HOSPCODE=@hospcode;
DELETE FROM disability WHERE disability.HOSPCODE=@hospcode;
DELETE FROM icf WHERE icf.HOSPCODE=@hospcode;
DELETE FROM functional WHERE functional.HOSPCODE=@hospcode;
DELETE FROM rehabilitation WHERE rehabilitation.HOSPCODE=@hospcode;
DELETE FROM village WHERE village.HOSPCODE=@hospcode;
DELETE FROM community_activity WHERE community_activity.HOSPCODE=@hospcode;
DELETE FROM provider WHERE provider.HOSPCODE=@hospcode;
หวังว่าจะเป็นประโยชน์ไม่มากก็น้อยครับ