CREATE OR REPLACE TRIGGER TR_YJ_YW0000_JCPT AFTER UPDATE ON SD_YJ.YJ_YW0000 REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW declare V_COUNT number; V_COUNT1 number; V_COUNT2 number; V_LBBH00 BM_ZLZD00.LBBH00%type; V_JCLBID BM_ZLZD00.JCLBID%type; V_XMZT00 varchar2(2); V_FSCJ00 YJ_DFSSQD.FSCJ00%type; V_JSXT00 YJ_DFSSQD.JSXT00%type; E_custom exception; ls_error varchar2(100); -- MODIFICATION HISTORY -- Person Date Comments -- yanghq 2019.12.26 create; begin --select LBBH00,nvl(JCLBID,0) into V_LBBH00,V_JCLBID from BM_ZLZD00 where ZLXMID=:new.ZLXMID; --insert into t_yhq_temp(aa,bb,cc)values(:new.YJDJH0,':new.ZLXMID:'||:new.ZLXMID||',:new.BBZT00:'||:new.BBZT00||',:old.BBZT00:'||:old.BBZT00|| --':new.JKZT00:'||:new.JKZT00||',:new.XMZT00:'||:new.XMZT00||',V_LBBH00:'||V_LBBH00||',V_JCLBID:'||V_JCLBID,sysdate); ---------------------------------------------------------------------------------------------------------------------------------------------- -->未知退出 if nvl(:new.ZLXMID,0)=0 then return; end if; --未知 if :new.BBZT00<>:old.BBZT00 then return; end if; --未知 if nvl(:new.BBZT00,'0')<>'0' then --LIS,PACS执行更新状态时,不触发到这个表 return ; end if; --未知 if nvl(:new.JKZT00,'0')<>'0' then --LIS,PACS执行更新状态时,不触发到这个表 return ; end if; ---------------------------------------------------------------------------------------------------------------------------------------------- if :new.YJLRBZ<>'T' and :new.XMZT00 not in('2','3') then --项目状态,'0'申请'1'计价'2'已收费'3'已执行'4'已报告'5'疑退'6'作废 return; end if; if :new.YJLRBZ='T' and :new.XMZT00 not in('2','3','4') then return; end if; V_XMZT00:= :new.XMZT00; select count(*) into V_COUNT from XT_XTCS00 where NAME00='YJ_ESBFWDZKS' and instr('|'||trim(VALUE0)||'|','|'||:new.YJKSBH||'|')>0; if V_COUNT=0 then return; end if; select LBBH00,nvl(JCLBID,0) into V_LBBH00,V_JCLBID from BM_ZLZD00 where ZLXMID=:new.ZLXMID; if V_LBBH00 not in(3,4) and V_JCLBID not in(17,999,4,2,1,301) and :new.YJLRBZ<>'T' then return; end if; select count(*) into V_COUNT1 from YJ_DFSSQD where YJDJH0=:new.YJDJH0 and FSBZ00 in('0','2') and XMZT00=:new.XMZT00; select count(*) into V_COUNT2 from YJ_YFSSQD where YJDJH0=:new.YJDJH0 and XMZT00=:new.XMZT00; if (V_COUNT1>0 or V_COUNT2>0) and :new.ZLXMID=:old.ZLXMID then return; end if; ---------------------------------------------------------------------------------------------------------------------------------------------- if :new.YJLRBZ<>'T' then if V_LBBH00=4 then V_FSCJ00:='Test_Form_Update'; V_JSXT00:='LIS'; elsif V_LBBH00=3 then V_FSCJ00:='Examine_Form_Update'; V_JSXT00:='PACS'; end if; if V_JCLBID=17 then V_FSCJ00:='Pathological_Form_Update'; V_JSXT00:='PIS'; elsif V_JCLBID=999 then V_FSCJ00:='Examine_Form_Update_MUSE'; V_JSXT00:='MUSE'; end if; end if; -->门诊 if :new.MZZYBZ='0' then if :new.YJLRBZ='T' and V_LBBH00 in(3,9) then V_FSCJ00:='Examine_Form_Send_PEIS'; V_JSXT00:='PACS'; /*if :new.yjdjh0=38292710 then ls_error:='2@'||V_FSCJ00; raise E_custom; end if; */ if :new.SL0000<0 then V_FSCJ00:='Examine_Form_Update_PEIS'; V_JSXT00:='PACS'; end if; if V_JCLBID=999 then V_FSCJ00:='Examine_Form_Send_PEIS_MUSE'; V_JSXT00:='MUSE'; if :new.SL0000<0 then V_FSCJ00:='Examine_Form_Update_PEIS_MUSE'; V_JSXT00:='MUSE'; end if; end if; end if; if :old.XMZT00<>'4' and :new.XMZT00='4' and :new.YJLRBZ='T' and V_JCLBID<>999 then--体检的危机值确认触发 V_FSCJ00:='Examine_Critical_Confirm_PEIS'; V_JSXT00:='PACS'; end if; if :new.YJLRBZ='T' and :new.XMZT00='2' then--体检的收费后不发送,执行后才发送 if V_FSCJ00 in('Examine_Form_Send_PEIS','Examine_Form_Send_PEIS_MUSE') then return; end if; end if; --住院 elsif :new.MZZYBZ='1' then if V_FSCJ00 not in('Examine_Form_Update_MUSE','Test_Form_Update','Pathological_Form_Update','Examine_Form_Update') then return; end if; end if; if V_JSXT00 is null then return; end if; ---------------------------------------------------------------------------------------------------------------------------------------------- --非体检的申请单暂时不写入发送表 if not :new.YJLRBZ='T' and V_FSCJ00 not in('Test_Form_Update','Examine_Form_Update_MUSE','Pathological_Form_Update' ,'Examine_Form_Update') then return; end if; ---------------------------------------------------------------------------------------------------------------------------------------------- insert into YJ_DFSSQD(ID0000,YJDJH0,XMZT00,FSBZ00,FSCJ00,JSXT00,JSMK00,CZBZ00,ZLXMID) values(SQ_YJ_DFSSQD_ID0000.nextval,:new.YJDJH0,V_XMZT00,'0',V_FSCJ00,V_JSXT00,'','1',:new.ZLXMID); exception when E_custom then raise_application_error(-20020, ls_error||NVL(SQLERRM, '原因不明出错!*')); when others then raise_application_error(-20020, NVL(SQLERRM, '原因不明出错!*')); end;