create or replace trigger TR_SF_SF_BRZHXX_UPDINS before insert or update on "SD_SF"."SF_BRZHXX" for each row declare Vcounter number(5); Vyyid00 XT_YYXX00.YYID00%type; ls_JKZDQF varchar2(10); ls_FBBH00 BM_BRXXB0.FBBH00%type; begin select SF_SF_GETYYID00() YYID00 into Vyyid00 from dual; if Vyyid00='220019' then if inserting or (updating and :new.yxqfje<15) then --铁路医保的病人允许欠10.00 select count(*) into Vcounter from bm_brxxb0 a,ic_ybbrlb b where brid00=:new.brid00 and a.fbbh00=b.fbbh00 and b.yblb00=a.yblb00 and b.ybzxlb='Z'; if Vcounter>0 then select count(*) into Vcounter from bm_brxxb0 a,ic_ybbrlb b where brid00=:new.brid00 and a.fbbh00=b.fbbh00 and b.yblb00=a.yblb00 and b.ybzxlb='Z' and a.ybbrlb in ('4','5','7'); if Vcounter>0 then--铁路医保的离休病人允许欠15元 :new.yxqfje:=15; else :new.yxqfje:=10;--铁路医保的普通病人允许欠10元 end if; end if; end if; /*elsif Vyyid00 in ('225088','225898','226521') then--泉州人民医院,德化医院,漳浦中医院 if inserting or (updating and :new.yxqfje<10) then --医保的病人允许欠10.00 select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00=3; if Vcounter>0 then :new.yxqfje:=10; end if; end if;*/ elsif Vyyid00 in ('225785') then--蓬壶 if inserting or (updating and :new.yxqfje<6) then --医保的病人允许欠5.00 select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00=3; if Vcounter>0 then :new.yxqfje:=6; end if; end if; elsif Vyyid00 in ('222211') then--平潭 if inserting or (updating and :new.yxqfje<8) then --医保的病人允许欠8.00 select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00=3; if Vcounter>0 then :new.yxqfje:=8; end if; end if; elsif Vyyid00 in ('227320') then-- 邵武市妇幼保健院 if inserting or (updating and :new.yxqfje<8) then --医保的病人允许欠8.00 select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00=3; if Vcounter>0 then :new.yxqfje:=8; end if; end if; if :new.ybzhye<>0 then :new.ybzhye:=0; end if; --zhr 2008.10.31 邵武妇幼医院由于售卡/换卡都不收卡费,但要求账户冻结4元钱 if inserting then select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00<>3; if Vcounter>0 then :new.tyje00:=4; end if; end if; elsif Vyyid00 in ('220034') then --煤矿中心医院 if inserting or (updating and :new.yxqfje<10) then --医保的病人允许欠10.00 select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00=3; if Vcounter>0 then :new.yxqfje:=10; end if; end if; elsif Vyyid00 in ('224465') then --沙县医院 if inserting then --医保的病人允许欠6.00 --or (updating and :new.yxqfje<6) select max(FBBH00) into ls_FBBH00 from bm_brxxb0 a where brid00=:new.brid00; if ls_FBBH00 = 3 then --:new.yxqfje:=6; Vcounter := 0; elsif ls_FBBH00 = 4 then --离休病人,卡押金为0 :new.tyje00:=0; else :new.tyje00:=5; end if; end if; elsif Vyyid00 in ('227318') then --邵武人民医院 --zhr 2008.10.31 由于售卡/换卡都不收卡费,但要求账户冻结4元钱 if inserting then select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00 and a.fbbh00<>3; if Vcounter>0 then :new.tyje00:=4; end if; end if; elsif Vyyid00 in ('225085') then --医大附二医院 if inserting or (updating and :new.yxqfje<50) then --所有病人欠费20(之前要求离休的病人允许欠60.00) --select count(*) into Vcounter from bm_brxxb0 a where brid00=:new.brid00; -- and a.fbbh00=16; --if Vcounter>0 then --:new.yxqfje:=50; :new.yxqfje:=0; --end if; end if; elsif :old.yxqfje=:new.yxqfje then :new.yxqfje:=SF_SF_GETYXQFJE(:new.BRID00); /* --建卡时自动允许欠费方式和金额,格式如 3,10,用逗号格式 第一位表示方式 0不允许 1所有病人 2医保病人 3离休病人 4优待病人 5医保(新农合除外) 6新农合(医保除外) 逗号后表示金额 select nvl(max(trim(VALUE0)),'0,0') into ls_JKZDQF from XT_XTCS00 where NAME00='SF_JKZDQF'; if substrb(ls_JKZDQF,1,1)='1' then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); elsif inserting and substrb(ls_JKZDQF,1,1)='2' then select count(*) into Vcounter from BM_BRXXB0 where BRID00=:new.BRID00 and FBBH00=3; if Vcounter>0 then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; elsif inserting and substrb(ls_JKZDQF,1,1)='3' then if SF_SF_LXBR00(:new.BRID00)='1' then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; elsif inserting and substrb(ls_JKZDQF,1,1)='4' then select count(*) into Vcounter from BM_BRXXB0 where BRID00=:new.BRID00 and SFYD00='1' and FBBH00=3; if Vcounter>0 then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; elsif inserting and substrb(ls_JKZDQF,1,1)='5' then select count(*) into Vcounter from BM_BRXXB0 a,IC_YBBRLB B where A.FBBH00= B.FBBH00 and A.YBLB00 = B.YBLB00 and BRID00=:new.BRID00 and A.FBBH00=3 and B.SFXNH0<>'1' and B.SFXNH0<>'4'; if Vcounter>0 then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; elsif inserting and substrb(ls_JKZDQF,1,1)='6' then select count(*) into Vcounter from BM_BRXXB0 a,IC_YBBRLB B where A.FBBH00= B.FBBH00 and A.YBLB00 = B.YBLB00 and BRID00=:new.BRID00 and A.FBBH00=3 and (B.SFXNH0='1' or B.SFXNH0='4'); if Vcounter>0 then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; elsif inserting and substrb(ls_JKZDQF,1,1)='7' then select count(*) into Vcounter from BM_BRXXB0 a,IC_YBBRLB B where A.FBBH00= B.FBBH00 and A.YBLB00 = B.YBLB00 and BRID00=:new.BRID00 and A.FBBH00=3 and (B.SFXNH0<>'1' and B.SFXNH0<>'4' or nvl(a.sfjzfp,'0')='1'); if Vcounter>0 then :new.yxqfje:=to_number(substrb(ls_JKZDQF,3,3)); end if; end if; */ end if; end;