begin
if old.icd10 <> new.icd10 then
INSERT INTO log_opddx(visit_id,new_icd10 ,column_name, old_value, new_value, provider, log_time)
VALUES(new.visit_id, new.icd10, 'icd10', old.icd10, new.icd10, new.staff_id, NOW());
end if;
if old.dxt_id <> new.dxt_id then
INSERT INTO log_opddx(visit_id, new_icd10,column_name, old_value, new_value, provider, log_time)
VALUES(new.visit_id, new.icd10, 'dxt_id', old.dxt_id, new.dxt_id, new.staff_id, NOW());
end if;
if old.dxg_id <> new.dxg_id then
INSERT INTO log_opddx(visit_id, new_icd10,column_name, old_value, new_value, provider, log_time)
VALUES(new.visit_id, new.icd10,'dxg_id', old.dxg_id, new.dxg_id, new.staff_id, NOW());
end if;
end
begin
if old.visit_id <> new.visit_id then
INSERT INTO log_ipd_reg(visit_id, auto_id, column_name, old_value, new_value, provider, log_time)
VALUES(new.visit_id, old.auto_id, 'visit_id', old.visit, new.visit_id, new.staff_id, NOW());
end if;
if old.adm_id <> new.adm_id then
INSERT INTO log_ipd_reg(visit_id, auto_id, column_name, old_value, new_value, provider, log_time)
VALUES(new.visit, old.auto_id, 'adm_id', old.adm_id, new.adm_id, new.staff_id, NOW());
end if;
if old.is_cancel <> new.is_cancel then
INSERT INTO log_ipd_reg(visit_id, auto_id, column_name, old_value, new_value, provider, log_time)
VALUES(new.visit_id, old.auto_id, 'is_cancel', old.is_cancel, new.is_cancel, new.staff_id, NOW());
end if;
end
create trigger tri_up_log_work
AFTER update ON work
FOR EACH ROW
begin
insert into log_work values(old.work_id,old.work_name,new.work_name,old.work_content,new.work_content,'update',now(),'user');
end;
create trigger update_ipd_reg
AFTER update ON work
FOR EACH ROW
begin
insert into log_ipd_reg values(old.work_id,old.work_name,new.work_name,old.work_content,new.work_content,'update',now(),'user');
end;
ไม่มีความคิดเห็น:
แสดงความคิดเห็น