CREATE OR REPLACE PROCEDURE SP_ZY_FPFFBZ0_ADDUPD ( Popflag in varchar2, --操作类别 1进入 2退出 3审核 Pzyid00 in number, --病人住院ID Pffbzbm in varchar2, --付费单病种编码 Pczy000 in number default 0, --操作员 Pczyks0 in number default 0, --操作员科室 Pcommit in varchar2 default 'N', --是否提交 Pzxcgbz out number, --执行成功标志 1成功 0失败 Ptsxx00 out varchar2, --执行结果提示信息,成功的情况下也可能有警告信息 Pxxxx00 out varchar2 --执行结果详细信息,成功的情况下也可能有警告信息,一般用来显示参数等指标 ) -- MODIFICATION HISTORY -- Person Date Comments -- dsm 2018.08.03 create -- dsm 2019.08.30 增加BZBMLB 审核标志 for BQ-20190822-002 as ls_FBBH00 ZY_BRXXB0.FBBH00%type; ls_YBZXLB ZY_BRXXB0.YBZXLB%type; ls_YBBRLB ZY_BRXXB0.YBBRLB%type; ls_DBZCWF ZY_BRZHXX.DBZCWF%type; --单病种超标床位费 ls_DBZHCF ZY_BRZHXX.DBZHCF%type; --单病种另收材料费 --ls_CWZGBZ BM_YBBRLB.CWZGBZ%type; --床位最高标准 ls_DBZMC0 ZY_BRXXB0.DBZMC0%type; --单病种名称 ls_BZGJBM varchar2(200); --单病种允许另收耗材的国家编码前缀组合,用逗号分隔 ls_CZRQ00 char(8); ls_CZSJ00 char(8); ls_Count0 number(10); Ecustom exception; ls_brid00 zy_brxxb0.brid00%type; LS_SFJZFP ZY_BRXXB0.SFJZFP%type; ls_DBZBM0 ZY_BRXXB0.DBZBM0%type; LS_BZBMLB BM_DBZDEB.BZBMLB%type; begin Pzxcgbz:=0; ls_CZRQ00:= to_char(sysdate,'yyyymmdd'); ls_CZSJ00:= to_char(sysdate,'hh24:mi:ss'); begin select FBBH00,SF_ZY_SFQYDBZJK(zyid00),YBBRLB,brid00,nvl(SFJZFP,'0'),nvl(DBZBM0,' ') into ls_FBBH00,ls_YBZXLB,ls_YBBRLB,ls_brid00 ,ls_SFJZFP,ls_DBZBM0 from ZY_BRXXB0 where ZYID00 = Pzyid00; exception when no_data_found then Ptsxx00:='找不到该aa住院病人信息'||to_char(Pzyid00); Pxxxx00:='找不到该aa住院病人信息zyid00='||to_char(Pzyid00); raise Ecustom; end; if ls_DBZBM0<>' ' then select BZBMLB into LS_BZBMLB from BM_DBZDEB where DBZBM0=ls_DBZBM0 and rownum=1; --xgh else LS_BZBMLB:='0'; end if; if Popflag ='1' then --进入病种 if ls_SFJZFP not in ('1','Y') then Ptsxx00:='非精准扶贫病人不能进入扶贫病种'||to_char(Pzyid00); Pxxxx00:='非精准扶贫病人不能进入扶贫病种zyid00='||to_char(Pzyid00); raise Ecustom; end if; --2019.10.18增加 if LS_BZBMLB='0' and nvl(ls_DBZBM0,' ')<>' ' then Ptsxx00:='请先退出单病种,再进入扶贫病种'||to_char(Pzyid00); Pxxxx00:='请先退出单病种,再进入扶贫病种zyid00='||to_char(Pzyid00); raise Ecustom; end if; select BZBMLB into LS_BZBMLB from BM_DBZDEB where DBZBM0=Pffbzbm and rownum=1; --xgh select count(*) into ls_Count0 from zy_brxxb0 where ZYID00 = Pzyid00 and dbzbm0 is not null; if ls_Count0 >0 and LS_BZBMLB='0' then Ptsxx00:='该病人已有进入单病种,不能再操作进入扶贫病种'; return; end if; /* if ls_Count0 >0 and LS_BZBMLB='1' then Ptsxx00:='该病人已有进入扶贫病种,不能再操作进入扶贫病种'; return; end if; */ begin select dbzmc0 into ls_DBZMC0 from BM_dbzdeb where DBZBM0 = Pffbzbm and BZBMLB='1' and rownum=1; --xgh; exception when no_data_found then Ptsxx00:='找不到该病种对应费别的字典信息'; Pxxxx00:='找不到该病种对应费别的字典信息zyid00='||to_char(Pzyid00); raise Ecustom; end; --------------------------------------------- update ZY_BZBMRZ set DQBZ00='0' where ZYID00=Pzyid00 and BZBMLB='1'; insert into ZY_BZBMRZ(ID0000,ZYID00,DBZBM0,CZBZ00,CZY000,BZBMLB) values(SQ_ZY_BZBMRZ_ID0000.nextval, Pzyid00,Pffbzbm,Popflag,Pczy000,'1'); -- update ZY_BRXXB0 set DBZBM0 = nvl(DBZBM0,Pffbzbm),DBZMC0 = nvl(DBZMC0,ls_DBZMC0) where ZYID00 = Pzyid00; --xgh 下 if Pffbzbm='0' then update ZY_BRXXB0 set DBZBM0 = null ,DBZMC0 = ls_DBZMC0 where ZYID00 = Pzyid00; else --xgh 上 --update ZY_BRXXB0 set DBZBM0 = nvl(DBZBM0,Pffbzbm),DBZMC0 = nvl(DBZMC0,ls_DBZMC0) where ZYID00 = Pzyid00; update ZY_BRXXB0 set DBZBM0 = Pffbzbm,DBZMC0 = ls_DBZMC0 where ZYID00 = Pzyid00; end if;--xgh update ZY_BRXXB0 set BZBMLB='1' where ZYID00 = Pzyid00; elsif Popflag = '2' then --退出扶贫病种 if ls_BZBMLB='0' then Ptsxx00:='退出错误,此病人是单病种病人'; Pxxxx00:='退出错误,此病人是单病种病人zyid00='||to_char(Pzyid00); raise Ecustom; end if; update ZY_BRXXB0 set DBZBM0 =null,DBZMC0 = null,BZBMLB=null where ZYID00 = Pzyid00; update ZY_BZBMRZ set DQBZ00='0' where ZYID00=Pzyid00 and BZBMLB='1'; --update ZY_BRZHXX set DBZCWF = 0,DBZHCF = 0 where brid00 = ls_brid00; elsif Popflag = '3' then --退出扶贫病种审核 update ZY_BZBMRZ set DQBZ00='0' where ZYID00=Pzyid00 and BZBMLB='1'; insert into ZY_BZBMRZ(ID0000,ZYID00,DBZBM0,CZBZ00,CZY000) values(SQ_ZY_BZBMRZ_ID0000.nextval, Pzyid00,Pffbzbm,Popflag,Pczy000); end if; Pzxcgbz := 1; if Pcommit = 'Y' then commit; end if; exception when no_data_found then raise_application_error(-20001,substrb('数据没有找到!*'||sqlerrm,1,120)); when Ecustom then raise_application_error(-20010,substrb(Ptsxx00||'!*',1,120)); when others then raise_application_error(-20266,substrb(nvl(sqlerrm, '原因不明出错')||'!*',1,120)); end;