CREATE OR REPLACE PROCEDURE P_YJYY( sqdh varchar2, --申请单号 yysj varchar2, --预约时间[YYYY-MM-DD HH:II:SS] jczysx varchar2, --检查注意事项 jcdd varchar2, --检查地点 UpdateFlag varchar2 default '0' --操作状态 0增加 1修改 2取消 ) as -- MODIFICATION HISTORY -- Person Date Comments -- qiulf 2021.07.06 created 医技业务预约 by YJ-20210706-001 -- qiulf 2021.09.08 增加时候修改YJ_YW0000.JKZT00 by MZSF-20210820-001 LS_YYID00 YJ_YYBRB0.YYID00%type; LS_YYRQ00 YJ_YYBRB0.YYRQ00%type; LS_YYSJ00 YJ_YYBRB0.YYSJ00%type; LS_CZY000 BM_YGBM00.YGBH00%type; LS_CZYXM0 BM_YGBM00.ZWXM00%type; VFHBZ00 number(10); Verror varchar2(300); ResultValue number; ResultReason varchar2(400); Pbrlxdh BM_BRXXB0.BRDH00%type; Ecustom Exception; begin if sqdh is null then Verror := '申请单号为空!'; raise Ecustom; end if; begin select nvl(YYID00,0) into LS_YYID00 from YJ_YW0000 where YJDJH0=sqdh; exception when others then Verror := '申请单号不存在!'; raise Ecustom; end; select max(MC0000) into LS_CZY000 from BM_TYZD00 where ZDMC00='PACS接口字典' and BH0000='PACSYYJK_CZY000'; if LS_CZY000 is null then Verror := '未配置操作员!'; raise Ecustom; end if; select max(ZWXM00) into LS_CZYXM0 from BM_YGBM00 where YGBH00=LS_CZY000; if LS_CZYXM0 is null then Verror := '配置的操作员在BM_YGBM00表中不存在!'; raise Ecustom; end if; if yysj is not null then LS_YYRQ00 := substr(yysj,1,4)||substr(yysj,6,2)||substr(yysj,9,2); LS_YYSJ00 := substr(yysj,12,5); else LS_YYRQ00 := to_char(sysdate,'YYYYMMDD'); --预约日期格式YYYYMMDD in char default '', LS_YYSJ00 := to_char(sysdate,'HH24:MI'); end if; if UpdateFlag = '0' then if LS_YYID00 > 0 then Verror := '项目已经预约, 不能再次预约!'; raise Ecustom; end if; elsif UpdateFlag = '1' then if nvl(LS_YYID00,0) <= 0 then Verror := '申请单未预约, 不能修改!'; raise Ecustom; end if; --else --2 -- if nvl(LS_YYID00,0) <= 0 then -- Verror := '申请单未预约, 不能取消!'; -- raise Ecustom; -- end if; end if; SP_YJ_JCYYDJ( LS_YYID00, --预约ID 可空 in char default '0', sqdh, --医技单据号 不能空 in char, jczysx, --注意事项 in char, LS_YYRQ00, --预约日期格式YYYYMMDD in char default '', LS_YYSJ00, --预约时间 格式 09:00 in char default '', '0', --预约序号 in char default '0', LS_CZYXM0, --操作人姓名 in char, '0', --0:预约确认,1病区读取确认 in char, '', --PACS检查申请单号 in char, ResultValue, --错误代码 0成功 1错误 out number , ResultReason, --错误描述 out char, '', --同时登记编号 in char, LS_YYRQ00||substr(LS_YYSJ00,1,2), --预约时段 in char, '', --显示预约序号 in char, 0, --号表ID in number default 0, 'N', --急诊标志 in char default 'N', UpdateFlag --操作状态 0增加 1修改 2取消 in char default '0', ); if ResultValue = 1 then Verror := ResultReason; raise Ecustom; end if; if UpdateFlag = '0' then SP_YJ_JKZTGX_MTYW('1010',sqdh,1,LS_CZY000,0,VFHBZ00,Verror); if VFHBZ00= 0 then raise Ecustom; end if; end if; commit; exception when no_data_found then ResultValue:=-1; ResultReason:='数据没有找到!*'||sqlerrm; rollback; raise_application_error(-20001,ResultReason); when Ecustom then ResultValue:=-1; rollback; ResultReason:=Verror; raise_application_error(-20002,ResultReason); when others then ResultValue:=-1; rollback; ResultReason:=substrb(nvl(sqlerrm, '原因不明出错'),1,80); raise_application_error(-20002,ResultReason); end;