CREATE OR REPLACE PROCEDURE sp_outp_ys_jcsqwh_sf --过程说明 ( pyjdjh0 in out number , --操作的医技单据号 pzlxmid in number , --诊疗项目id pghid00 in number , --挂号id Pzdid00 in varchar2 , --诊断id Pzdmc00 in varchar2 , --诊断名称 pzxmid0 in varchar2 , --子项目id串,如果没有传入参数,表示使用所有明细项 pmzzybz in varchar2 , --门诊住院标志 pjzbz00 in varchar2 , --急诊标志 pkdys00 in number , --开单医生 pkdksbh in number , --开单科室编号 pyjksbh in number , --医技科室编号 psl0000 in number , --数量 pbz0000 in varchar2 , --备注,部位名称 popflag in number , --操作内容 2增加 1修改 3删除 Pczy000 in number , --操作员id号 Psm0000 in varchar2 , --说明 Pzxjg00 out varchar2 , --执行结果提示 Pzxbz00 out number , --传出参数说明,传回的是同组号 Pcommit in varchar2 default 'N' ,--是否提交 pbrid00 in varchar2 , --病人ID PBH0000 in varchar2 default '', -- 特殊病种编号 PBWBH00 in varchar2 default '' -- 部位编号 ) AS -- MODIFICATION HISTORY -- Person Date Comments -- chenqw 2010.03.26 增加特殊病种参数。 -- csf 2010.04.30 除了医保病人,存后直接记账,按参数控制 -- dsm 2014.04.01 增加部位参数 for MZYS-20140331-001 -- hetf 2018.09.05 增加SJLY00判断 -- dsm 2020.07.15 修改时医技单据号不变 v_counter number; v_fbbh00 number; LS_PSFJGSM CHAR(255) ; --收费结果说明 VPSFSFCG NUMBER ; --收费是否成功,1:成功,0:失败 Vsysdate date; --日期变量 Vcounter number(10); --计数器变量 Vzxmid0 varchar2(255); --子项目id Vyw0000 yj_yw0000%rowtype; --医技单 Vzlxmjc bm_zlzd00.zlxmjc%type; --诊疗项目简称 Vczyxm0 bm_ygbm00.zwxm00%type; --操作员姓名 Vparams varchar2(255); --参数变量 vmc0000 bm_tsbzb0.mc0000%type default ''; --名称变量 Verrmsg varchar2(255); --错误提示变量 Vtmpstr varchar2(255); --错误提示变量 Ecustom exception; --错误变量 Vybzxlb bm_tsbzb0.ybzxlb%type; --医保执行类别 Vyblb00 bm_brxxb0.yblb00%type; --医保类别 Vfbbh00 bm_brxxb0.fbbh00%type; --费别编号 YS_BCHZJJZ Char(1);--保存后是否直接记账 cursor Cjyzxm0 is select zxmid0 from VW_YS_YWMXXM WHERE SJXMID=pzlxmid and gdxmbz='Y' ; begin vmc0000:= '' ; Vsysdate:=sysdate; Vparams :='sp_ys_jcsqwh('||nvl(to_char(pyjdjh0),'null')|| ','||nvl(to_char(pzlxmid),'null')||','||nvl(to_char(pghid00),'null')||','||Pzdid00||','||Pzdmc00|| ','||pzxmid0||','||pmzzybz||','||pjzbz00||','||nvl(to_char(pkdys00),'null')|| ','||nvl(to_char(pkdksbh),'null')||','||nvl(to_char(pyjksbh),'null')||','||nvl(to_char(psl0000),'null')|| ','||nvl(to_char(popflag),'null')||','||nvl(to_char(Pczy000),'null')||',pzxjg00,pzxbz00,'''||Pcommit||''')'; if pyjdjh0<>null and pOpflag<>'1' then select count(*) into v_counter from YJ_YW0000 where YJDJH0=Pyjdjh0 and SJLY00='1'; if v_counter<>1 then Verrmsg:='单据号为'||to_char(pyjdjh0)||'的医技不是本系统所开!'; RAISE Ecustom; end if; end if; if pOpflag='3' then--删除或修改 begin --合法性判定 Verrmsg:='找不到yjdjh0='||to_char(Pyjdjh0)||'的申请单'; SELECT * into Vyw0000 FROM YJ_YW0000 WHERE YJDJH0=Pyjdjh0 and SJLY00='1'; if Vyw0000.XMZT00='2' then Verrmsg:='该单据已经收费,不能删除或修改'; Raise Ecustom; elsif Vyw0000.XMZT00='3' or Vyw0000.XMZT00='4' then Verrmsg:='该单据已经执行,不能删除或修改'; Raise Ecustom; elsif Vyw0000.XMZT00='6' and pOpflag='1' then Verrmsg:='该单据已经作废,不能修改'; Raise Ecustom; end if; exception when others then Verrmsg:='该单据已经不存在'; Raise Ecustom; end; end if; if pOpflag='3' then Delete YJ_YWJJ00 where YJDJH0=pyjdjh0 and exists(select 1 from YJ_YW0000 where YJDJH0=pyjdjh0 and SJLY00='1'); Delete YJ_YWMX00 where YJDJH0=pyjdjh0 and exists(select 1 from YJ_YW0000 where YJDJH0=pyjdjh0 and SJLY00='1'); Delete YJ_YW0000 where YJDJH0=pyjdjh0 and SJLY00='1'; if pcommit='Y' then commit; end if; return; end if; if pbh0000 is not null then select yblb00,fbbh00 into Vyblb00, Vfbbh00 from bm_brxxb0 where brid00=Pbrid00; select ybzxlb into Vybzxlb from IC_YBBRLB where yblb00=Vyblb00 and fbbh00=Vfbbh00; select nvl(mc0000,'') into vmc0000 from bm_tsbzb0 where trim(bh0000)=trim(pbh0000) and ybzxlb=Vybzxlb; end if ; --取操作员姓名 Verrmsg:='找不到yggh00='||to_char(Pczy000)||'的员工'; select zwxm00 into Vczyxm0 from bm_ygbm00 where ygbh00=pczy000; if pzxmid0='' or pzxmid0 is null then Vzxmid0:=' '; else Vzxmid0:=pzxmid0; end if; if Vzxmid0=' ' then --前台参数没有传参数,重新取字典定义固定的子项目作为 for zxm in Cjyzxm0 Loop if Vzxmid0=' ' then Vzxmid0:=to_char(zxm.zxmid0); else Vzxmid0:=Vzxmid0||','||to_char(zxm.zxmid0); end if; end loop; if Vzxmid0='' then Verrmsg:='没有选中子项目,不能保存'; Raise ECustom; end if; end if; if Vzxmid0=' ' then Vzxmid0:=to_char(pzlxmid); end if; if Popflag='2' or Popflag='1' then--增加 if pyjdjh0 is null then select SQ_YJ_YW0000_YJDJH0.NEXTVAL into pyjdjh0 from dual where rownum=1; end if; insert into yj_yw0000 (yjdjh0 , yjksbh, mzzybz, zyghid, zlxmid, kdys00, kdksbh, lrxm00, jzbz00, zdid00 , zdmc00, xmzt00, BWMC00, sl0000,sm0000,BH0000,mc0000,BWBH00,SJLY00)--, zyzbid) values (pyjdjh0,pyjksbh,pmzzybz,pghid00,pzlxmid,pkdys00,pkdksbh,Vczyxm0,pjzbz00, pzdid00,pzdmc00,'0' ,pbz0000,psl0000,psm0000,pBH0000,vmc0000,PBWBH00,'1');--,pzyzbid); elsif Popflag='1' then update yj_yw0000 set yjksbh=pyjksbh,zlxmid=pzlxmid, kdys00=pkdys00,kdksbh=pkdksbh, lrxm00=Vczyxm0,jzbz00=pjzbz00, zdid00=pzdid00,zdmc00=pzdmc00, BWMC00=pbz0000,sl0000=psl0000, sm0000=psm0000,bh0000= pBH0000 , mc0000=vmc0000, BWBH00=PBWBH00 where yjdjh0=pyjdjh0 and SJLY00='1'; Delete YJ_YWJJ00 where YJDJH0=pyjdjh0 and exists(select 1 from YJ_YW0000 where YJDJH0=pyjdjh0 and SJLY00='1'); Delete YJ_YWMX00 where YJDJH0=pyjdjh0 and exists(select 1 from YJ_YW0000 where YJDJH0=pyjdjh0 and SJLY00='1'); end if; sp_outp_execute_sql('insert into yj_ywmx00 (id0000,yjdjh0,zlxmid)'|| ' select SQ_YJ_YWMX00_ID0000.NEXTVAL,'||to_char(pyjdjh0)||',ZLXMID'|| ' from bm_zlzd00 where zlxmid in ('||Vzxmid0||')'); SF_OUTP_YJ_YWJJ_NOCOMMIT(pyjdjh0,1);--计价 if pcommit='Y' then commit; end if; select count(*) into v_counter from xt_xtcs00 where trim(name00)='YS_FYZLDSFZJJZ' and trim(value0)='Y'; select nvl(max(trim(VALUE0)),'N') into YS_BCHZJJZ from xt_xtcs00 where trim(name00)='YS_BCHZJJZ'; select fbbh00 into v_fbbh00 from bm_brxxb0 where brid00=to_number(pbrid00); if(v_counter>0 and v_fbbh00=1) or (YS_BCHZJJZ='Y' and v_fbbh00<>'3') then SP_OUTP_YJ_YWSF00(pyjdjh0,pyjksbh,pkdys00,LS_PSFJGSM,VPSFSFCG); end if; exception when no_data_found then raise_application_error(-20099,substrb('数据没有找到!*'||Verrmsg||Vparams,1,160)); when Ecustom then raise_application_error(-20010,substrb(Verrmsg||'!*'||Vparams,1,160)); when others then raise_application_error(-20002,substrb(nvl(sqlerrm, '原因不明出错')||'!*'||Vparams,1,100)); end ;