CREATE OR REPLACE PROCEDURE SP_SST_YYQR( id0000 in varchar2, --预约队列标识 cardno in varchar2, --卡号 cartype in number, --IC卡类型 custname out varchar2, --病人姓名 groupname out varchar2, --医生姓名 qno000 out varchar2, --预约号 czsj00 out varchar2, --就诊日期 yyksmc out varchar2, --预约科室 hzsj00 out varchar2, --候诊时间 outstr out varchar2 --错误信息 ) AS LS_BRID00 BM_BRXXB0.BRID00%type; LS_BRID01 BM_BRXXB0.BRID00%type; as_YHMSG0 varchar2(2550); as_SYSMSG varchar2(2550); ls_YYZT00 SF_YYBRB0.YYZT00%type; LS_CARDNO IC_YHXX00.ICKH00%type; LS_KMH000 IC_YHXX00.KMH000%type; LS_BRXM00 SF_YYBRB0.BRXM00%type; LS_YYBZ00 YS_HBHZXH.YYBZ00%type;--预约标志 '1'普通'2'优待 '3'预约 '4'电话 '5'分诊 '6'网络 LS_GHID00 SF_YYBRB0.GHID00%type; LS_YYH000 SF_YYBRB0.YYH000%type; LS_BRDH00 SF_YYBRB0.BRDH00%type; begin select SF_SST_GETICKH00(cardno,cartype) into LS_CARDNO from dual; begin select BRID00,KMH000 into LS_BRID00,LS_KMH000 from IC_YHXX00 where ICKH00 =LS_CARDNO and ZT0000=1; exception WHEN NO_DATA_FOUND THEN outstr:='IC卡号:'||LS_CARDNO||'在本院IC_YHXX00表中未找到,请联系管理员!'; raise NO_DATA_FOUND; end; begin select nvl(BRID00,0),YYZT00,GHID00,YYH000,BRDH00,BRXM00 into LS_BRID01,ls_YYZT00,LS_GHID00,LS_YYH000,LS_BRDH00,LS_BRXM00 from SF_YYBRB0 where YYID00=id0000 ; end; if LS_BRID01=0 then ----SP_SST_MZYY_ZJYYDJ --更新预约病人信息 update SF_YYBRB0 set brid00=LS_BRID00,KMH000=LS_KMH000,ICKH00=LS_CARDNO where YYID00=id0000 ; --更新医生号表侯诊序号 update YS_HBHZXH set BRID00=LS_BRID00,YYID00=id0000,BRXM00=LS_BRXM00 where GHHBID=LS_GHID00 and HZXH00=LS_YYH000; --YYBZ00 --update SF_YSGHHB set YYXHS0=YYXHS0+1,TQYYS0=TQYYS0+1 where GHHBID = P_PBLSH; --更新病人电话号码 --update BM_BRXXB0 set BRDH00=nvl(LS_BRDH00,BRDH00) where BRID00=LS_BRID00; end if; outstr:=' '; if ls_YYZT00='0' then SP_YY_YYZYGH_DGBR(ls_BRID00,to_number(id0000),outstr,as_SYSMSG); end if; if nvl(outstr,' ')=' ' then select BRXM00 Custname, --病人姓名 YYYSXM groupname, --医生队列 YYH000 qno000, --预约号码 YYRQ00 visitdatetime, --就诊时间 YYKSMC||'('||(select ckmc00 from sf_ysghhb b,bm_ckbm00 c where b.ghhzck=c.ckbh00 and b.ghhbid=a.ghhbid)||')', (select nvl(HZQSSJ,1) from YS_HBHZXH where GHHBID=a.GHHBID and HZXH00=a.YYH000) HZSJ00 into Custname,groupname,qno000,czsj00,yyksmc,hzsj00 from SF_YYBRB0 a where YYID00=id0000; update SF_YYBRB0 set HZDYCS=NVL(HZDYCS,0)+1 where YYID00=id0000 ; end if; --sp_yy_yyzygh; exception when others then outstr:=outstr||','||SqlErrm||as_SYSMSG; RAISE_APPLICATION_ERROR(-20020,'确认失败'||','||SqlErrm||as_SYSMSG); end; / create or replace procedure SP_YY_YYZYGH_DGBR( P_BRID00 in number, --输入病人id P_YYID00 in number, --输入预约id as_YHMSG0 out varchar, --存储过程提示的中文错误信息 as_SYSMSG out varchar, --系统提示的错误信息 Pcommit in varchar2 default 'Y' --是否提交 ) AS LS_YYH000 SF_YYBRB0.YYH000%type;--预约号 LS_YYKSBH SF_YYBRB0.YYKSBH%type;--预约科室编号 LS_YYYSBH SF_YYBRB0.YYYSBH%type;--预约医生编号 LS_GHHBID SF_YYBRB0.GHHBID%type;--挂号号表id ls_YYZT00 SF_YYBRB0.YYZT00%TYPE;--预约状态 ls_BZ0000 SF_YYBRB0.BZ0000%TYPE;--预约备注 as_GHH000 SF_BRXXB0.GHH000%TYPE;--门诊挂号号,供前台程序打印挂号单时使用 v_count NUMBER(3); --计数器 Pzxcgbz number(1); --过程执行成功标识 v_LogStr varchar(500); -- MODIFICATION HISTORY -- person date comments -- qks 2013.02.22 预约费处理 转为过程 SP_YJ_GHYYSF -- qks 2013.02.25 增加入参Pcommit -- zhangwz 2014.02.25 解决院内预约(SF_YYBRB0.BRID00>0的记录)前台不能进行到场确认的问题. -- zhagnwz 2014.07.24 预约备注也要往SF_HZBR00.BZ0000写数据 -- huanglw 2018.06.04 过程加上SP_TRANSLOG MZYS9-20180531-002 -- ---------- ---------- -------------------------------------------------------------- begin v_LogStr:='SP_YY_YYZYGH_DGBR(' ||to_char(P_BRID00)||',' ||to_char(P_YYID00)||',' ||as_YHMSG0||',' ||as_SYSMSG||',' ||Pcommit||')'; SP_TRANSLOG(sysdate,'SP_YY_YYZYGH_DGBR',0,0,v_LogStr); begin SELECT a.YYH000,a.YYKSBH,a.YYYSBH,a.GHHBID,a.YYZT00,a.BZ0000 into LS_YYH000,LS_YYKSBH,LS_YYYSBH,LS_GHHBID,LS_YYZT00,ls_BZ0000 from SF_YYBRB0 a,IC_YHXX00 b where a.YYRQ00=to_char(sysdate,'YYYYMMDD') and a.YYZT00='0' and a.BRID00=b.BRID00 and b.ZT0000='1' and a.BRID00=P_BRID00 and a.YYID00=P_YYID00; exception when others then as_YHMSG0:='找不到待取号的预约信息!'; as_SYSMSG:=sqlerrm||'SELECT a.YYID00,a.YYH000,a.YYKSBH,a.YYKSMC,a.YYYSBH,a.YYYSXM,a.GHLB00,a.BRXM00,a.YYYGBH,a.YYYGXM,a.CZYBM0,a.GHHBID'|| ' from SF_YYBRB0 a,IC_YHXX00 b where a.YYRQ00=to_char(sysdate,''YYYYMMDD'') and a.YYZT00=''0'' and a.BRID00=b.BRID00'|| ' and b.ZT0000=''1'' and a.BRID00='||to_char(P_BRID00)|| ' and a.YYID00='||to_char(P_YYID00); rollback; return; end; if LS_YYZT00='0' then --将预约信息改为确认状态(提前修改,锁住改记录) -- update SF_YYBRB0 set YYZT00='1' where YYID00=P_YYID00 and YYZT00='0'; SP_SF_BRXXB0_BRGH00(P_BRID00,-99999,ls_YYKSBH,ls_YYYSBH,ls_GHHBID,'N',3,LS_YYH000,'N',as_GHH000,ls_YYYSBH,ls_YYKSBH,'N',Pzxcgbz,as_YHMSG0,as_SYSMSG,0,0,'0','N',ls_BZ0000); if Pzxcgbz<>1 then Rollback; return; end if; update SF_YYBRB0 set GHID00=to_number(as_GHH000), YYZT00='1' where YYID00=P_YYID00 and YYZT00 IN ('0','1','3') ; end if; if Pcommit = 'Y' then commit; end if; end; / create or replace procedure SP_SF_BRXXB0_BRGH00( -- MODIFICATION HISTORY -- Person Date Comments ---lintj 2012.08.03 create ---yangy 2012.08.14 增加插入挂号费和诊察费以及挂号总金额 --zhangwz 2012.08.18 去除对 '该挂号类别没有维护项目,请联系管理员!' 的限制,因为有免挂号以及预约号。 --zhanghr 2013.03.06 排队叫号部分重新做了整理 --zhangwz 2013.03.19 -99999 的预挂号在 Vxzhzxh='Y' 的情况下进行简单的算 SF_HZBR00.HZSJD0 -- qks 2013.04.01 院内保留明细号:Vhzlb00值要改为3 -- qks 2013.04.08 增加入参Pcwts00(自助机接口修改) -- qks 2013.04.22 增加入参Psflnyx:八十岁优先,改为从前台传入一起控制 -- zhanghr 2013.05.09 重要来人短信通知 -- zhangwz 2013.05.22 简单算 SF_HZBR00.HZSJD0 的时候如果是超出排班截止时间的话按参数 MZHS_HZSJDXRGZ 定义显示最后统一显示的时间,而不是现在的以排班截止时间进行统一显示。 -- qks 2013.10.14 增加字段SF_BRXXB0.YBLB00 -- qks 2014.02.24 修改Vbrxm00定义;12580的VIP预约类型:在专家特诊室自动判断不能挂50元的专诊特诊号,只允许挂主任号 -- zhangwz 2014.02.25 解决院内读卡预约(SF_YYBRB0.BRID00>0的记录)前台不能进行到场确认的问题. -- zhangwz 2014.04.01 现场排队操作的时候增加写入中间表数据 SF_YYZJB0 用于后续相关数据到前置机的功能。 -- qks 2014.05.15 VIP预约就诊病人,对应预约出诊的医生不允许给VIP预约就诊病人挂“专家”号; -- zhangwz 2014.05.27 挂号生成费用的时候增加判断是否厦门口腔医院模式 -- zhangwz 2014.06.16 排班表增加YSYGBH=0的科室排班数据,过程进行相应的修改(根据工号去医生或者是操作员姓名的时候使用异常处理) -- zhangwz 2014.07.11 判断有无预挂号的时候区分科室排班or个人排班进行获取 -- zhangwz 2014.07.24 候诊病人预挂号的时候增加入参Pbz0000用于标识预挂号备注 -- zhangwz 2014.08.28 增加参数控制如果预约病人过了预约时间做到场确认那么SF_HZBR00.DLXH00是否为已经排队的最后一个号码 -- zhaoxz 2015.09.19 增加SF_BRXXB0.BXLB00入参 -- qks 2016.02.26 增加参数MZHS_XCQHGZ控制:病人不允许在同个科室取2个排队号,老专家门诊除外 -- zhaoxz 2016.03.01 修改Pbz0000,Pbxlb00的入参顺序 MZYS9-20160301-001 -- qks 2016.03.03 需改SF_HZBR00.JZRQ00,JZSJ00两个字段值 by MZSF9-20160303-001 -- qks 2016.03.09 省人民医院:老专家门诊候诊队列科室跟就诊医生登录科室不一致 by MZHS9-20160310-001 -- qks 2016.05.30 已经停诊的不允许取现场号或预约号; by MZHS9-20160530-001 -- zhaoxz 2016.07.04 新增小儿加收项目判断 MZYS9-20160704-001 -- zhaoxz 2016.07.05 小儿加收项目新增6周岁限制 MZYS9-20160705-001 -- zhaoxz 2016.07.25 新增初复诊入参 MZYS9-20160725-001 -- jlg 2016.09.19 增加在候诊时挂非预约号的处理 MZHS9-20160824-001 -- qks 2016.12.29 增加参数MZHS_SFLNYX控制是否老年优先就诊 MZHS9-20161227-001 -- wusq 2017.01.12 增加参数V_value0 by MZHS9-20161214-001 -- qks 2017.02.03 解决预约号被门诊护士工作站现场取走问题; by MZHS9-20170203-001 -- qks 2017.03.16 增加参数MZHS_EKQHXZNL:儿科取号是否限制年龄; by MZHS9-20170311-002 -- qks 2017.03.17 增加参数MZHS_QHSFXZZHKYE:取号是否限制部分患者账户可用额; by MZHS9-20170311-001 -- linyj 2017.06.27 厦门莲花医院,优待病人0金额收费 增加Vydlsf0、Vsfydxm、Vyjzhje by MZYS9-20170524-001 -- linyj 2017.06.29 厦门莲花医院,小儿加收增加替换原有项目功能 MZYS9-20170629-001 -- qks 2017.09.08 院内保留号取号时无法选择优先,改为允许设置成优先; by MZHS9-20170831-001 2、 -- qks 2017.12.27 修正:优先号SF_HZBR00.DLXH00=-99问题;以及新增参数YS_ZSGHSFZJ控制正式挂号后是否直接诊结; for MZSF9-20171227-001 -- qks 2018.01.05 要求门诊过诊病人也可以重新取号; for MZHS9-20180105-001 -- liwm 2018.06.07 门诊收费存储过程统一添加调用参数日志 for MZSF9-20180604-003 -- qks 2018.11.14 三伏灸接口:当默认的医生当天有正常排班时,调用该接口会出错; for MZSF9-20181114-001 -- linshu 2020.05.25 增加入参Psfjzlb for MZHS9-20200518-004 -- linshu 2020.09.02 不允许已预约未确认病人同一个医生的现场号 by MZHS9-20200826-001 Pbrid00 in number , --ID号 Pghlb00 in number , --挂号类别 Pghks00 in number , --挂号科室 Pjzys00 in number , --就诊医生 Pghhbid in number , --挂号号表ID Psfyd00 in varchar2 , --是否优待 Phzlb00 in number , --候诊类别 Phzxh00 in number , --候诊序号 Psfzz00 in varchar2 , --是否转诊 Pghh000 in out varchar2 , --挂号号 Pczy000 in number , --操作员 Pczyks0 in number , --操作员科室 Pcommit in varchar2 default 'N' , --是否提交 Pzxcgbz out number , --执行成功标志 1成功 0失败 Ptsxx00 out varchar2 , --执行结果提示信息,成功的情况下也可能有警告信息 Pxxxx00 out varchar2 , --执行结果详细信息,成功的情况下也可能有警告信息,一般用来显示参数等指标 Pghfje0 in number default 0 , --挂号费金额 Pzcfje0 in number default 0 , --诊察费金额 Pcwts00 in varchar2 default '0' , --错误提示 0报错提示 1不提示直接退出 Psflnyx in varchar2 default 'N' , --是否老年优先就诊(>=80岁) Pbxlb00 in varchar2 default '' , --保险类别 Pbz0000 in varchar2 default '' , --候诊病人预挂号备注 Psfxejs in varchar2 default 'N' , --是否小儿加收BM_GHXMDY.XEJSXM Psfcz00 in varchar2 default '0' , --初复诊 SF_BRXXB0.SFCZ00 Psfjzlb in varchar2 default '0' --是否急诊(预约挂号) ) as Vsfyd00 char(1); Vfjdjbz char(1); --Vbrxm00 varchar2(20); Vbrxm00 BM_BRXXB0.BRXM00%type; Vczyxm0 varchar2(20); Vjzysxm varchar2(20); Vybzxlb IC_YBBRLB.YBZXLB%type; Vybbrlb BM_BRXXB0.YBBRLB%type; Vfbbh00 BM_BRXXB0.FBBH00%type; Vbrblh0 BM_BRXXB0.BRBLH0%type; Vyxcfgh XT_XTCS00.VALUE0%type; --允许医生有效期内给病人重复挂号 Vxzzyjz XT_XTCS00.VALUE0%type; --住院病人是否限制门诊就诊,Y限制 N不限制 默认为Y Vghdjxz XT_XTCS00.VALUE0%type; --医生挂号等级限制 Vxzhzxh XT_XTCS00.VALUE0%type; --护士挂号时,是否指定候诊序号 Vghyxts XT_XTCS00.VALUE0%type; --挂号有效天数 Vsfxmkqyy XT_XTCS00.VALUE0%type; --是否厦门口腔医院模式 Vybghfs varchar2(10); --医保病人挂号室挂号费用收取方式0都收1只收挂号费2都不收 Vghzkbh SF_YSGHHB.GHZKBH%type; --专科名称编号 Vhzqsrq SF_HZBR00.HZQSRQ%type; --候诊开始日期 Vhzqssj SF_HZBR00.HZQSSJ%type; Vhzjzrq SF_HZBR00.HZJZRQ%type; --候诊结束日期 Vhzjzsj SF_HZBR00.HZJZSJ%type; Vghhzck SF_YSGHHB.GHHZCK%type; --挂号候诊窗口 Vzsxx00 SF_BRXXB0.ZSXX00%type; --诊室信息 Vyghh00 SF_BRXXB0.GHH000%type; --病人的预挂号的挂号号 Vhzsjd0 SF_BRXXB0.HZSJD0%type; --候诊时间段 Vghje00 SF_BRXXB0.GHJE00%type; --挂号金额 Vhzlbid SF_HZBR00.ID0000%type; -- Vdlxh00 SF_HZBR00.DLXH00%type; --队列序号 Vhzlb00 SF_HZBR00.HZLB00%type; --候诊类别 Vhzxh00 SF_HZBR00.HZXH00%type; --候诊序号 Vhzxhmc SF_HZBR00.HZXHMC%type; --候诊序号名称 Vyjdjh0 YJ_YW0000.YJDJH0%type; Vdjh000 SF_FYMX00.DJH000%type; Vzlxmid BM_ZLZD00.ZLXMID%type; Vxkh000 BM_YGBM00.XKH000%type; Vghhbid SF_YSGHHB.GHHBID%type; --挂号号表id Vpjzzsj SF_YSGHHB.PJZZSJ%type; --挂号号表平均诊治时间 Vynblmx SF_YSGHHB.YNBLMX%type; --院内保留明细号 Vsfkzxmyy XT_XTCS00.VALUE0%type; --是否开展厦门统一的预约模式 插入数据模式使用数据链路 Vdlxhscgz XT_XTCS00.VALUE0%type; --队列序号生成规则 Vxcqhgz XT_XTCS00.VALUE0%type; --现场取号规则 Vzsghzj XT_XTCS00.VALUE0%type; --正式挂号是否自动进行诊结:1是 0否,默认0 Vhzsjdxrgz number(5) ; Vczrq00 char(8); Vczsj00 char(8); Vnl0000 number; --年龄 Vcounter number; --计数器变量 Vcounter1 number; --计数器变量 Vcounter2 number; --计数器变量 Vsql000 varchar2(1000); Ecustom exception; ls_ghje00 sf_brxxb0.GHJE00%type; --挂号总金额 ls_ghfzje sf_brxxb0.ghfzje%type; --挂号费总金额 ls_zcfje0 sf_brxxb0.ZCFJE0%type; --诊查费总金额 ls_je0000 yj_yw0000.ZJE000%type; --单个项目的金额 Vtzbz00 SF_YSGHHB.TZBZ00%type; Vlnsfyx XT_XTCS00.VALUE0%type; --老年是否有效就诊 V_value0 XT_XTCS00.VALUE0%type; --预挂号是否直接用排班时候的挂号类别 Vekqhxz XT_XTCS00.VALUE0%type; --儿科取号是否限制年龄 Vqhxzye XT_XTCS00.VALUE0%type; --取号是否限制部分患者账户可用额 Vbrkyje SF_BRZHXX.ZYE000%type; --病人可用余额 Vydlsf0 XT_XTCS00.VALUE0%type; --优待项目是否0金额收费(系统参数) Vsfydxm char(1); --项目是否优待项目 Vyjzhje number; ----医技折后金额=0不生效,=-99999999表示直接单价改为0 Vbrdh00 BM_BRXXB0.BRDH00%type; Vbrzjbh BM_BRXXB0.BRZJBH%type; type T_CUR_GHXMDY is ref cursor; CUR_GHXMDY T_CUR_GHXMDY; Vxxxlog varchar2(2000); begin Pzxcgbz := 0; Vczrq00 := to_char(sysdate,'yyyymmdd'); Vczsj00 := to_char(sysdate,'hh24:mi:ss'); Vxxxlog := substr('PBRID00:'||nvl(to_char(PBRID00), 'null')||','||'PGHLB00:'||nvl(to_char(PGHLB00), 'null')||','||'PGHKS00:'||nvl(to_char(PGHKS00), 'null')||','||'PJZYS00:'||nvl(to_char(PJZYS00), 'null')||','||'PGHHBID:'||nvl(to_char(PGHHBID), 'null')||','||'PSFYD00:'||nvl(to_char(PSFYD00), 'null')||','||'PHZLB00:'||nvl(to_char(PHZLB00), 'null')||','||'PHZXH00:'||nvl(to_char(PHZXH00), 'null')||','||'PSFZZ00:'||nvl(to_char(PSFZZ00), 'null')||','||'PGHH000:'||nvl(to_char(PGHH000), 'null')||','||'PCZY000:'||nvl(to_char(PCZY000), 'null')||','||'PCZYKS0:'||nvl(to_char(PCZYKS0), 'null')||','||'PCOMMIT:'||nvl(to_char(PCOMMIT), 'null')||','||'PGHFJE0:'||nvl(to_char(PGHFJE0), 'null')||','||'PZCFJE0:'||nvl(to_char(PZCFJE0), 'null')||','||'PCWTS00:'||nvl(to_char(PCWTS00), 'null')||','||'PSFLNYX:'||nvl(to_char(PSFLNYX), 'null')||','||'PBXLB00:'||nvl(to_char(PBXLB00), 'null')||','||'PBZ0000:'||nvl(to_char(PBZ0000), 'null')||','||'PSFXEJS:'||nvl(to_char(PSFXEJS), 'null')||','||'PSFCZ00:'||nvl(to_char(PSFCZ00), 'null'),1,2000); Pxxxx00 := ''; SP_TransLog(sysdate,'SP_SF_BRXXB0_BRGH00',Pczy000,Pczyks0,Vxxxlog); select nvl(trim(max(value0)),'Y') into Vyxcfgh from XT_XTCS00 where name00='YS_YXCFGH'; select nvl(max(trim(VALUE0)),'Y') into Vxzzyjz from XT_XTCS00 where NAME00='YS_ZYBRSFXZMZJZ'; select nvl(trim(max(value0)),'N') into Vghdjxz from XT_XTCS00 where name00='XT_GHDJXZ'; select nvl(trim(max(value0)),'N') into Vxzhzxh from XT_XTCS00 where name00='YS_HSGHXZHZXH'; select nvl(trim(max(value0)),1) into Vghyxts from XT_XTCS00 where name00='GHYXTS'; select nvl(trim(max(value0)),'0') into Vybghfs from XT_XTCS00 where name00='MZYS_YBBRGHFYSQFS'; select nvl(trim(max(value0)),'N') into Vsfxmkqyy from XT_XTCS00 where name00='YS_SFXMKQYY'; select nvl(trim(max(value0)),'0') into Vdlxhscgz from XT_XTCS00 where name00='MZHS_YYBRDCQRSHZDLXHSCGZ'; select nvl(trim(max(value0)),'0') into Vxcqhgz from XT_XTCS00 where name00='MZHS_XCQHGZ'; select nvl(trim(max(value0)),'Y') into Vlnsfyx from XT_XTCS00 where name00='MZHS_SFLNYX'; select nvl(trim(max(value0)),'N') into Vekqhxz from XT_XTCS00 where name00='MZHS_EKQHXZNL'; select nvl(trim(max(value0)),'N') into Vqhxzye from XT_XTCS00 where name00='MZHS_QHSFXZZHKYE'; select nvl(trim(max(value0)),'0') into Vzsghzj from XT_XTCS00 where name00='YS_ZSGHSFZJ'; begin select nvl(trim(VALUE0),'N') into Vsfkzxmyy from XT_XTCS00 where NAME00='YY_XMSYYYYQZJ'; exception when others then Vsfkzxmyy:='N'; end; begin select to_number(value0) into Vhzsjdxrgz from XT_XTCS00 where name00='MZHS_HZSJDXRGZ'; exception when others then Vhzsjdxrgz :=0; end; begin select nvl(max(trim(value0)),'N') into V_value0 from XT_XTCS00 where name00='MZHS_YGHZJYPBGHLB'; exception when others then V_value0:='N'; end; select A.BRXM00,B.YBZXLB,A.YBBRLB,A.FBBH00,A.BRBLH0,SF_YS_CSRQTONL(a.BRCSRQ) into Vbrxm00,Vybzxlb,Vybbrlb,Vfbbh00,Vbrblh0,Vnl0000 from BM_BRXXB0 A,IC_YBBRLB B where A.BRID00=Pbrid00 and B.YBLB00=A.YBLB00 and B.FBBH00=a.FBBH00; if Vfbbh00<>3 then Vybghfs:='0'; end if; select count(*) into Vcounter from SF_BRXXB0 where BRBLH0 = Vbrblh0 and BRID00<>Pbrid00; if Vcounter > 0 then Ptsxx00 :='该病历号已被别的病人所使用!'; raise Ecustom; end if; /*if Pghlb00=-99999 then--杜绝乱自助取号 select count(*) into Vcounter from sf_brxxb0 where GHRQ00=Vczrq00 and BRID00=Pbrid00 and ((JZYS00=Pjzys00 and JZYS00>0) or (JZYS00=0 and GHKS00=Pghks00 and Pjzys00=0)) and THRQ00 is null and GHLB00=-99999; if Vcounter>0 then Ptsxx00 :='对不起,你已经在该医生取过排队号!'; raise Ecustom; end if; end if;*/ if Vyxcfgh='N' then--预交金挂号,要判定病人是否被重复挂号 select count(*) into Vcounter from VW_YS_YXGH00 where brid00=Pbrid00 and GHKS00=Pghks00 and JZYS00=Pjzys00 and ghlb00<>-99999; if Vcounter > 0 then Ptsxx00 :='该病人已经在该医生挂过号,不允许重复挂号!'; raise Ecustom; end if; end if; if Vxzzyjz='Y' then --判断病人能否挂号,若是住院病人就不能挂号 select count(*) into Vcounter from ZY_BRXXB0 where BRID00 = Pbrid00 and (CYRQ00 is null or CYRQ00='20991231'); --未出院的病人 if Vcounter > 0 then Ptsxx00 :='该病人正在住院,不能挂号,病人挂号登记失败!'; raise Ecustom; end if; end if; if Vghdjxz='Y' then--进行医生挂号等级限制 select count(*) into Vcounter from BM_GHLBB0 where LBBH00 = Pghlb00 and GHDJ00>(select GHDJ00 from BM_GHLBB0 where lbbh00=(select MRGHLB from BM_YGBM00 where YGBH00=Pjzys00 and Pczy000=Pjzys00)); if Vcounter>0 then Ptsxx00 :='不能挂级别高的号!*'; raise Ecustom; end if; end if; -- 不允许已预约未确认病人同一个医生的现场号 by MZHS9-20200826-001 select count(1) into Vcounter from sf_yybrb0 where yyRQ00=to_char(sysdate,'YYYYMMDD') and brid00=0 and yyzt00<>'2' and GHHBID=Vghhbid and ((Vbrzjbh=SFZH00 and brxm00=Vbrxm00) or ( brxm00=Vbrxm00 and brdh00=Vbrdh00) ) and decode(sign(to_number(substr(yyjssj,1,2))-12),-1,'上午','下午')= decode(sign(to_number(to_char(sysdate,'HH24'))-12),-1,'上午','下午'); if Vcounter>=1 then Ptsxx00 :='-您今天有当前医生的预约号,请到自助机预约取号界面取号。'; raise Ecustom; end if; select count(*) into Vcounter from XT_XTCS00 where NAME00='SF_XZMZJZDFB' and instrb(','||trim(VALUE0)||',',','||to_char(Vfbbh00)||',')>0; if Vcounter>0 then Ptsxx00 :='该费别病人不允许在门诊就诊,请先到收费处处理!'; raise Ecustom; end if; -- select count(*) into Vcounter from BM_GHXMDY where LBBH00 = Pghlb00 and SYBZ00 = '1'; -- if Vcounter=0 then -- Ptsxx00 :='该挂号类别没有维护项目,请联系管理员!'; -- raise Ecustom; -- end if; Vsfyd00 := Psfyd00; if Vsfyd00<>'Y' then --两费病人自动优待,免除挂号费 if SF_YF_JudgeSFLNYD(Pbrid00) = 1 then update BM_BRXXB0 set SFYD00='1' where BRID00=Pbrid00; Vsfyd00 :='Y'; end if; end if; begin select ZWXM00 into Vczyxm0 from BM_YGBM00 where YGBH00 = Pczy000; exception when others then Vczyxm0:='未定义'; end; begin select ZWXM00 into Vjzysxm from BM_YGBM00 where YGBH00 = Pjzys00; exception when others then Vjzysxm:='未定义'; end; Vghhbid := Pghhbid; Vhzlb00 := Phzlb00; Vhzxh00 := Phzxh00; if Vghhbid > 0 then begin select GHZKBH,GHMZSJ,GHQSSJ,GHMZSJ,GHJSSJ,GHHZCK,nvl(CKXXDZ,CKMC00),nvl(a.PJZZSJ,0),YNBLMX,a.TZBZ00 into Vghzkbh,Vhzqsrq,Vhzqssj,Vhzjzrq,Vhzjzsj,Vghhzck,Vzsxx00,Vpjzzsj,Vynblmx,Vtzbz00 from SF_YSGHHB a,BM_CKBM00 b where a.GHHZCK = b.CKBH00(+) and GHHBID = Vghhbid; exception when no_data_found then Ptsxx00 :='数据没有找到,请核对您所输入的医生挂号号表是否正确!'; raise Ecustom; end; SP_SF_XZGSKH(Vghhbid,0,0,'N',Pzxcgbz,Ptsxx00,Pxxxx00); else Vhzqsrq :=Vczrq00; Vhzqssj :=Vczsj00; Vhzjzrq :=Vczrq00; Vhzjzsj :=Vczsj00; Vghhzck :=0; end if; if (Vynblmx is not null) and (instr(','||Vynblmx||',',','||to_char(Vhzxh00)||',')>0) and Vhzlb00<>2 then Vhzlb00 := 3; end if; if Pghh000 is null then select SQ_SF_BRXXB0_GHID00.nextval into Pghh000 from dual; end if; select SQ_SF_BRJFB0_DJH000.nextval into Vdjh000 from dual; --SF_HZBR00的队列序号处理开始 if Vxzhzxh='Y' and Pghlb00=-99999 then --预挂号 if Vqhxzye<>'N' and instrb(','||substrb(Vqhxzye,1,instrb(Vqhxzye,'|')-1)||',',','||Vybzxlb||',')>0 then Vbrkyje := SF_SF_GETKYJE(Pbrid00); if Vbrkyje'N' and instrb(','||substrb(Vekqhxz,1,instrb(Vekqhxz,'|')-1)||',',','||Pghks00||',')>0 then if Vnl0000>to_number(substrb(Vekqhxz,instrb(Vekqhxz,'|')+1,3)) then Ptsxx00 :='年龄大于'||substrb(Vekqhxz,instrb(Vekqhxz,'|')+1,3)||'岁不能取儿科号'; raise Ecustom; end if; end if; --已经停诊的不允许取现场号或预约号 if Vtzbz00='1' then Ptsxx00 :='该医生已停诊,不能取号!'; raise Ecustom; end if; --if Vxcqhgz = '0' then select nvl(max(HZXH00),0) into Vcounter from SF_HZBR00 where BRID00=Pbrid00 and YSPBID=Vghhbid and GHLB00=-99999 and HZZT00<>'3'; if Vcounter>0 then Ptsxx00 :='患者已经排'||to_char(Vcounter)||'号,不能重复取号!'; raise Ecustom; end if; --2016.02.26 if Vxcqhgz = '-1' or Vxcqhgz<>'0' and instrb(','||Vxcqhgz||',',','||Pghks00||',')<=0 then select nvl(max(GHYS00),0) into Vcounter2 from SF_HZBR00 where BRID00=Pbrid00 and GHLB00=-99999 and HZQSRQ=Vhzqsrq and HZQSSJ=Vhzqssj and GHKS00=Pghks00 and HZZT00<>'3'; if Vcounter2>0 then select max(zwxm00) into Ptsxx00 from bm_ygbm00 where ygbh00=Vcounter2; Ptsxx00 :='患者已经在本科室医生:'||Ptsxx00||' 取过号了,不能重复取号!'; raise Ecustom; end if; end if; --Update YS_HBHZXH set BRID00 = Pbrid00, BRXM00= Vbrxm00,GHH000=Pghh000 where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and nvl(BRID00,0)=0; zhangwz 20140225 --Update YS_HBHZXH set BRID00 = Pbrid00, BRXM00= Vbrxm00,GHH000=Pghh000 where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and --((nvl(BRID00,0)=0) or (BRID00=Pbrid00 and exists (select 1 from SF_YYBRB0 where YYID00=YS_HBHZXH.YYID00 and YYZT00='0'))); --2017.02.03 qks 解决预约号被门诊护士工作站现场取走问题 Update YS_HBHZXH set BRID00 = Pbrid00, BRXM00= Vbrxm00,GHH000=Pghh000 where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and (nvl(BRID00,0)=0 and nvl(BRXM00,' ')=' ' or ((BRID00=Pbrid00 or nvl(BRXM00,' ')<>' ') and exists (select 1 from SF_YYBRB0 where YYID00=YS_HBHZXH.YYID00 and BRXM00=Vbrxm00 and YYZT00 in ('0','1')))); if sql%notfound then Ptsxx00 :=to_char(Vhzxh00)||'已经被占用,请重试'; raise Ecustom; end if; if Vpjzzsj>0 then begin select to_char(to_date(Vhzqsrq||Vhzqssj,'YYYYMMDDHH24:MI:SS')+Vpjzzsj*(Vhzxh00-1)/1440,'YYYYMMDDHH24:MI:SS') into Vhzsjd0 from dual; exception when others then Vhzsjd0:=null; end; if Vhzsjd0>to_char(to_date(Vhzjzrq||Vhzjzsj,'YYYYMMDDHH24:MI:SS')-(Vhzsjdxrgz/(24*60)),'YYYYMMDDHH24:MI:SS') then Vhzsjd0:=to_char(to_date(Vhzjzrq||Vhzjzsj,'YYYYMMDDHH24:MI:SS')-(Vhzsjdxrgz/(24*60)),'YYYYMMDDHH24:MI:SS'); end if; else Vhzsjd0 := null; end if; Vdlxh00:=nvl(Vhzxh00,0)*50; if Vdlxhscgz='1' then begin select count(*) into Vcounter1 from YS_HBHZXH where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and YYID00 is not null and HZQSSJ is not null and HZQSSJ0 then --预约到场确认时间大于预约就诊时间 select nvl(max(DLXH00),0)+1 into Vdlxh00 from SF_HZBR00 where YSPBID = Vghhbid; end if; end if; --八十岁优先 --if Vnl0000>=80 then --2017.12.27 增加条件and DLXH00>=0 if (Vnl0000>=79) and (Psflnyx = 'Y') and (Vlnsfyx='Y') then Vhzlb00:=2; select nvl(max(DLXH00),0)+1 into Vdlxh00 from SF_HZBR00 where YSPBID = Vghhbid and DLXH00<50 and DLXH00>=0; end if; if Vsfxmkqyy='Y' then begin select count(*) into Vcounter1 from bm_brxxb0 where brid00=Pbrid00 and brztqk in ('一级保健','二级保健','三级保健','A卡'); exception when others then Vcounter1 :=0; end; if Vcounter1>0 then --保健病人优先 Vhzlb00:=2; end if; end if; if Vhzlb00=1 then--普通病人 Vhzxhmc:=Lpad(to_char(Vhzxh00),4,'0'); elsif Vhzlb00=3 then Vhzxhmc:='Y'||Lpad(to_char(Vhzxh00),3,'0'); else --优待病人 Vhzxhmc:='L'||Lpad(to_char(Vhzxh00),3,'0'); --2017.12.27 增加条件and DLXH00>=0 select nvl(max(DLXH00),0)+1 into Vdlxh00 from SF_HZBR00 where YSPBID = Vghhbid and DLXH00<50 and DLXH00>=0; end if; select SQ_SF_HZBR00_ID0000.nextval into Vhzlbid from dual; Insert into SF_HZBR00(ID0000,BRID00,GHH000,GHKS00,JZKS00,GHYS00,GHLB00,HZLB00,HZXH00, DJRQ00,DJSJ00,HZQSRQ,HZQSSJ,HZJZRQ,HZJZSJ,HZZT00,CZY000,YSPBID, JZZS00,HZSJD0,JZKSMC,GHYSXM,HZLBMC,HZXHMC,DLXH00,BZ0000,SFJZLB) select Vhzlbid,Pbrid00,Pghh000,Pghks00,Pghks00,Pjzys00,Pghlb00,Vhzlb00, Vhzxh00,Vczrq00,Vczsj00,Vhzqsrq,Vhzqssj,Vhzjzrq,Vhzjzsj,'0',Pczy000,Vghhbid, Vghhzck,substr(Vhzsjd0,9,5),b.BMMC00,nvl((select a.ZWXM00 from BM_YGBM00 a where a.YGBH00=Pjzys00 and rownum=1),'未定义'), c.HZLBMC,Vhzxhmc,Vdlxh00,Pbz0000,Psfjzlb from BM_BMBM00 b,BM_HZLB00 c --BM_YGBM00 a, where b.BMBH00=Pghks00 and c.HZLB00=Vhzlb00; --a.YGBH00=Pjzys00 and if Vsfkzxmyy='Y' then select count(*) into Vcounter from YS_HBHZXH where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and YYID00 is null; if Vcounter>0 then insert into SF_YYZJB0(ID0000,GHHBID,YYID00,HZID00,CZLX00,CZY000,CZYKS0,CZRQ00,CZSJ00) select SQ_SF_YYZJB0_ID0000.nextval,Vghhbid,null,Vhzlbid,'0',Pczy000,Pczyks0,to_char(sysdate,'YYYYMMDD'),to_char(sysdate,'HH24:MI:SS') from dual; end if; end if; elsif Vxzhzxh='Y' and Pghlb00<>-99999 then Vdlxh00 := -100; --检查有没有预挂号,如果有,修改预挂号 /* select max(a.ID0000) into Vhzlbid from SF_HZBR00 a,SF_YSGHHB b where a.JZKS00=Pghks00 and ((a.GHYS00=Pjzys00 and b.PBLX00='0') or (a.GHYS00=0 and b.PBLX00='1')) and a.BRID00=Pbrid00 and a.DLXH00>0 and a.GHLB00=-99999 and a.YSPBID=b.GHHBID; */ --2016.03.09 select max(a.ID0000) into Vhzlbid from SF_HZBR00 a,SF_YSGHHB b where a.HZQSRQ=Vczrq00 and ((a.GHYS00=Pjzys00 and b.PBLX00='0') or (a.GHYS00=0 and b.PBLX00='1')) and a.BRID00=Pbrid00 and a.DLXH00>0 and a.GHLB00=-99999 and a.YSPBID=b.GHHBID; if Vhzlbid is null then--没有预挂号 select max(GHHBID) into Vghhbid from SF_YSGHHB where GHMZSJ=Vczrq00 and GHKSBH=Pghks00 and TZBZ00='0' and Vczsj00 between GHQSSJ and GHJSSJ and GHYSBH=Pjzys00 ; if Vghhbid>0 then --有号表,占用号, 无排班,不管 --有可能不允许直接挂号,有可能不占用号,有可能占用号 --占用号的处理 select GHZKBH,GHMZSJ,GHQSSJ,GHMZSJ,GHJSSJ,GHHZCK,nvl(CKXXDZ,CKMC00),YNBLMX into Vghzkbh,Vhzqsrq,Vhzqssj,Vhzjzrq,Vhzjzsj,Vghhzck,Vzsxx00,Vynblmx from SF_YSGHHB a,BM_CKBM00 b where a.GHHZCK = b.CKBH00(+) and GHHBID = Vghhbid; if nvl(Phzxh00,0)=0 then --取未用号 select min(HZXH00) into Vhzxh00 from YS_HBHZXH where GHHBID=Vghhbid and YYBZ00='1' and BRID00 is null and instrb(','||Vynblmx||',',','||to_char(HZXH00)||',')=0; end if; -- if Vhzxh00>0 then select SQ_SF_HZBR00_ID0000.nextval into Vhzlbid from dual; Vdlxh00:=nvl(Vhzxh00,0)*50; if Vhzlb00=1 then--普通病人 Vhzxhmc:=Lpad(to_char(Vhzxh00),4,'0'); elsif Vhzlb00=3 then Vhzxhmc:='Y'||Lpad(to_char(Vhzxh00),3,'0'); else --优待病人 Vhzxhmc:='L'||Lpad(to_char(Vhzxh00),3,'0'); end if; select SQ_SF_HZBR00_ID0000.nextval into Vhzlbid from dual; Insert into SF_HZBR00(ID0000,BRID00,GHH000,GHKS00,JZKS00,GHYS00,GHLB00,HZLB00,HZXH00, DJRQ00,DJSJ00,HZQSRQ,HZQSSJ,HZJZRQ,HZJZSJ,HZZT00,CZY000,YSPBID, JZZS00,HZSJD0,JZKSMC,GHYSXM,HZLBMC,HZXHMC,DLXH00,SFJZLB) select Vhzlbid,Pbrid00,Pghh000,Pghks00,Pghks00,Pjzys00,Pghlb00,Vhzlb00, Vhzxh00,Vczrq00,Vczsj00,Vhzqsrq,Vhzqssj,Vhzjzrq,Vhzjzsj,'0',Pczy000,Vghhbid, Vghhzck,substr(Vhzsjd0,9,5),b.BMMC00,a.ZWXM00,c.HZLBMC,Vhzxhmc,Vdlxh00,Psfjzlb from BM_YGBM00 a,BM_BMBM00 b,BM_HZLB00 c where a.YGBH00=Pjzys00 and b.BMBH00=Pghks00 and c.HZLB00=Vhzlb00; if V_value0<>'Y' then Update YS_HBHZXH set BRID00 = Pbrid00, BRXM00= Vbrxm00,GHH000=Pghh000 where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and BRID00 is null; else Update YS_HBHZXH set BRID00 = Pbrid00, BRXM00= Vbrxm00,GHH000=Pghh000 where GHHBID=Vghhbid AND HZXH00=Vhzxh00 and ((nvl(BRID00,0)=0) or (BRID00=Pbrid00 and exists (select 1 from SF_YYBRB0 where YYID00=YS_HBHZXH.YYID00 and YYZT00='0'))); end if; if sql%notfound then Ptsxx00 :=to_char(Vhzxh00)||'已经被占用,请重试'; raise Ecustom; end if; end if; else --无号表 Vcounter:=Vcounter; end if; end if; --2017.12.27 if Vzsghzj='1' and Vhzlbid is not null then--有预挂号 --2018.11.14 select count(1) into Vcounter from SF_HZBR00 where ID0000=Vhzlbid; if Vcounter>0 then select YSPBID,GHH000,HZXH00,HZLB00 into Vghhbid,Vyghh00,Vhzxh00,Vhzlb00 from SF_HZBR00 where ID0000=Vhzlbid; --修改SF_HZBR00.GHH000,GHLB00,YS_HBHZXH.GHID00,SF_YYBRB0.GHID00,删除SF_BRXXB0 update SF_HZBR00 set GHH000=Pghh000,GHLB00=Pghlb00,HZZT00='3',GHYS00=decode(GHYS00,0,Pjzys00,GHYS00),GHYSXM=decode(GHYS00,0,Vjzysxm,GHYSXM), JZRQ00=Vczrq00,JZSJ00=Vczsj00 where ID0000 = Vhzlbid; update YS_HBHZXH set GHH000=Pghh000 where GHHBID=Vghhbid and HZXH00=Vhzxh00; update SF_YYBRB0 set GHID00=Pghh000 where YYRQ00=Vczrq00 and GHHBID=Vghhbid and GHID00=Vyghh00; delete SF_BRXXB0 where GHH000=Vyghh00; end if; end if; --2014.02.24 /* if Vghhbid>0 then select count(*) into Vcounter from BM_GHLBB0 where LBBH00 = Pghlb00 and lbmc00 like '%专家%'; if Vcounter>0 then select count(1) into Vcounter from SF_YYBRB0 where YYRQ00=Vczrq00 and GHHBID=Vghhbid and BRID00=Pbrid00 and VIP000='Y'; if Vcounter>0 then Ptsxx00 :='该病人为全球通VIP客户,在本院享有名医苑特诊转优的优惠,不允许挂专家号,请选择主任号!'; raise Ecustom; end if; end if; if Vhzlbid is null then Update SF_YYBRB0 set GHID00=Pghh000 where YYRQ00=Vczrq00 and GHHBID=Vghhbid and BRID00=Pbrid00 and VIP000='Y'; end if; end if; */ else--Vxzhzxh='N'排班时候不指定候诊序号,广州模式 begin Vhzsjd0 :=trim(SF_YS_HZSJ00(Vhzlbid, null)); --根据函数得到相关的时间段 exception when others then Ptsxx00 :='获得候诊时间出错误,请稍候再试!'; raise Ecustom; end; if Vhzsjd0 is not null then Vhzxh00 := nvl(substr(Vhzsjd0,35,5),'0'); Vdlxh00 := -100; if (Pghlb00<>-99999) then select to_char(nvl(max(HZXH00),to_number(Vhzxh00))), nvl(max(HZLB00),Vhzlb00), nvl(max(DLXH00),-100) into Vhzxh00, Vhzlb00, Vdlxh00 from VW_YS_HZBR00 where JZKS00=Pghks00 and JZYS00=Pjzys00 and BRID00=Pbrid00 and DLXH00>0 and GHLB00=-99999 and YSPBID=Vghhbid; end if; --zhr 2008.01.03 预约病人进行提前挂号,如果预约时间之前的候诊段有余号,会被自动转为普通病人。 select nvl(max(trim(HZLB00)),Vhzlb00) into Vhzlb00 from SF_HZBR00 where ID0000=Vhzlbid and HZLB00<>Vhzlb00; update SF_HZBR00 set HZQSRQ = nvl(substr(Vhzsjd0,1,8),Vczrq00), --候诊起始日期 HZQSSJ = nvl(substr(Vhzsjd0,9,8),Vczsj00), --候诊起始时间 HZJZRQ = nvl(substr(Vhzsjd0,18,8),Vczrq00), --候诊结束日期 HZJZSJ = nvl(substr(Vhzsjd0,26,8),Vczsj00), --候诊结束时间 HZXH00 = Vhzxh00 --候诊序号 where ID0000 = Vhzlbid; if (Vdlxh00<>-100) and (Vhzlb00=2) then update SF_HZBR00 set DLXH00=Vdlxh00 where ID0000 = Vhzlbid; end if; end if; end if; --SF_HZBR00的队列序号处理结束 if (Vghhbid > 0) then if (Pghlb00<>-99999) then Update SF_YSGHHB SET GHYGHS=nvl(GHYGHS,0)+1 where GHHBID = Vghhbid; end if; if Vhzlb00='3' then Update SF_YSGHHB SET GHYYHS=nvl(GHYYHS,0)+1 where GHHBID = Vghhbid; end if; end if; if Vghhbid is null then--没有预挂号 select max(GHHBID) into Vghhbid from SF_YSGHHB where GHMZSJ=Vczrq00 and GHKSBH=Pghks00 and TZBZ00='0' and Vczsj00 between GHQSSJ and GHJSSJ and GHYSBH=Pjzys00 ; end if; --VIP if Vxzhzxh='Y' and Pghlb00<>-99999 and Vghhbid>0 then select count(*) into Vcounter from BM_GHLBB0 where LBBH00 = Pghlb00 and lbmc00 like '%专家%'; if Vcounter>0 then select count(1) into Vcounter from SF_YYBRB0 where YYRQ00=Vczrq00 and GHHBID=Vghhbid and BRID00=Pbrid00 and VIP000='Y'; if Vcounter>0 then Ptsxx00 :='该病人为全球通VIP客户,在本院享有名医苑特诊转优的优惠,不允许挂专家号,请选择主任号!'; raise Ecustom; end if; end if; --if Vhzlbid is null then update SF_YYBRB0 set GHID00=Pghh000 where YYRQ00=Vczrq00 and GHHBID=Vghhbid and BRID00=Pbrid00 and VIP000='Y' and GHID00 is null; --end if; end if; insert into SF_BRXXB0(GHID00,BRBLH0,GHH000,YBGHH0,GHLB00,BRID00,SFCZ00,XM0000,XB0000,CSRQ00, FBBH00,YBZXLB,YBBRLB,LBBH00,GFZH00,GHRQ00,GHSJ00,GHY000,GHYXM0,GHKS00, JZRQ00,JZSJ00,JZKS00,JZYS00,JZYSXM,SFYY00,THBZ00,PJH000, GHYXTS,SFNLYD,HZLB00,HZSJD0,GHJE00,ZCFJE0,CZRQ00,CZSJ00,GHZKBH, GHSJD0,GHHBID,ZSXX00,HBQX00,GRSFEN,SFZZ00,YBLB00,BXLB00) select Pghh000,BRBLH0,Pghh000,'0',Pghlb00,BRID00,PSFCZ00,BRXM00,BRXB00,BRCSRQ, Vfbbh00,Vybzxlb,Vybbrlb,1,BRGFZH,nvl(trim(substr(Vhzsjd0,1,8)),Vczrq00),Vczsj00,Pczy000,Vczyxm0,Pghks00, nvl(trim(substr(Vhzsjd0,1,8)),Vczrq00),Vczsj00,Pghks00,Pjzys00,Vjzysxm,'N','1',0, Vghyxts,Vsfyd00,Vhzlb00,Vhzsjd0,nvl(Pghfje0,0),nvl(Pzcfje0,0),Vczrq00,Vczsj00,Vghzkbh, null,Vghhbid,Vzsxx00,'0',GRSFEN,Psfzz00,YBLB00,Pbxlb00 from BM_BRXXB0 where BRID00=Pbrid00; --重要来人短信通知 if ((Vybzxlb='L' and Vfbbh00=10) or (Vybzxlb='B' and Vfbbh00=8)) then SP_YJ_DXTZ00(Pbrid00,'来人提醒','挂号',Pczy000,Pczyks0,'N',Pzxcgbz,Ptsxx00,Pxxxx00); end if; --警惕患者短信通知 select instrb(','||nvl(max(VALUE0),',')||',',','||to_char(Pbrid00)||',') into Vcounter from XT_XTCS00 where NAME00='MZ_JTHZ_BRID'; if Vcounter>0 then SP_YJ_DXTZ00(Pbrid00,'警惕患者提醒','挂号',Pczy000,Pczyks0,'N',Pzxcgbz,Ptsxx00,Pxxxx00); end if; Vsql000 := 'select a.ZLXMID,decode(b.LBBH00,20,''3'',''4'') FJDJBZ,a.YDJM00 from BM_GHXMDY a,BM_ZLZD00 b where a.ZLXMID=b.ZLXMID and a.LBBH00 = '||to_char(Pghlb00)||' and a.SYBZ00 = ''1'''; select count(*) into Vcounter from YS_GHJMSZ where KS0000=Pghks00 and YS0000=Pjzys00 and exists(select 1 from BM_TYZD00 where ZDMC00='免挂号费医保中心' and BH0000=Vybzxlb); --优待病人0金额收费 select nvl(trim(max(value0)),'N') into Vydlsf0 from XT_XTCS00 where name00='YS_YDBRLJESF'; if Vydlsf0 <> 'Y' then if Vcounter > 0 or Vsfyd00='Y' then Vsql000:=Vsql000||' and b.LBBH00<>20'; end if; end if; --处理小儿加收 if Psfxejs = 'Y' then select trunc(sysdate)-trunc(to_date(brcsrq,'yyyyMMdd')) into Vcounter1 from bm_brxxb0 where brid00=Pbrid00; if Vcounter1 <= 2190 then --替换 Vsql000:=Vsql000||' and nvl(a.XECZBZ,0)<>''1'' union all select a.XEJSXM,decode(b.LBBH00,20,''3'',''4'') FJDJBZ,a.YDJM00 from BM_GHXMDY a,BM_ZLZD00 b where a.XEJSXM=b.ZLXMID and a.LBBH00 = '||to_char(Pghlb00)||' and a.SYBZ00 = ''1'' and nvl(a.XECZBZ,0)=''1'' '; --加收 Vsql000:=Vsql000||' union all select a.XEJSXM,decode(b.LBBH00,20,''3'',''4'') FJDJBZ,a.YDJM00 from BM_GHXMDY a,BM_ZLZD00 b where a.XEJSXM=b.ZLXMID and a.LBBH00 = '||to_char(Pghlb00)||' and a.SYBZ00 = ''1'' and nvl(a.XECZBZ,0)<>''1'' '; end if; end if; ls_ghje00 := 0; ls_ghfzje := 0; ls_zcfje0 := 0; if Vsfxmkqyy='Y' then --加金额为了能收费成功,因为能否挂号成功以及挂号需要的自费金额多少靠口腔医院的HIS进行判断,挂号成功会同步余额回来 update SF_BRZHXX set XJYE00=XJYE00+100,ZYE000=ZYE000+100,YKZYE0=YKZYE0+100 where BRID00=Pbrid00 and JFLBID=1; end if; open CUR_GHXMDY for Vsql000; loop fetch CUR_GHXMDY into Vzlxmid,Vfjdjbz,Vsfydxm; exit when CUR_GHXMDY%notfound; Vyjdjh0 := null; if Vsfydxm = 'Y' and Vsfyd00='Y' and Vydlsf0 = 'Y' then Vyjzhje := -99999999; else Vyjzhje := 0; end if; SP_YJ_YJSQWH( 2, --操作内容 1修改 2增加 3删除 Vyjdjh0, --操作的医技单据号 Pghh000, --挂号id '0', --门诊住院标志 Vzlxmid, --诊疗项目id null, --子项目id串,如果没有传入参数,表示使用所有明细项 null, --诊断id null, --诊断名称 null, --标本ID null, --特殊病种编号 'N', --医技录入标志 'N', --急诊标志 Pczy000, --开单医生 Pczyks0, --开单科室编号 null, --开单病区 Pczyks0, --医技科室编号 1, --数量 null, --备注 Vfjdjbz, --附加单据标志 Pczy000, --操作员 Pczyks0, --操作员科室 'N', --是否提交 Pzxcgbz, --执行成功标志 1成功 0失败 Ptsxx00, --执行结果提示信息,成功的情况下也可能有警告信息 Pxxxx00, --执行结果详细信息,成功的情况下也可能有警告信息,一般用来显示参数等指标 null, null, null, 1, null, null, null, null, null, null, null, null, 0, 1, Vyjzhje ); if Pzxcgbz = 0 then Ptsxx00 := '申请出错'; raise Ecustom; end if; select zje000 into ls_je0000 from yj_yw0000 where yjdjh0 = Vyjdjh0; ls_ghfzje:= ls_ghfzje + ls_je0000; if Vfjdjbz = '3' then ls_ghje00 := ls_ghje00 + ls_je0000; else ls_zcfje0 := ls_zcfje0 + ls_je0000; end if; if (Vybghfs='0') or (Vybghfs='1' and Vfjdjbz='3') then select XKH000 into Vxkh000 from BM_YGBM00 where YGBH00=Pczy000; SP_YJ_YWZX00( Vyjdjh0, Vzlxmid, 1, 2, Vxkh000, Pczyks0, 'N', 0 ); end if; end loop; close CUR_GHXMDY; --select nvl(sum(HJJE00),0) into Vghje00 from SF_FYMX00 where DJH000=Vdjh000; update SF_BRXXB0 set GHJE00 = ls_ghje00,ZCFJE0 = ls_zcfje0, GHFZJE = ls_ghfzje where GHH000 = Pghh000; --变更预约费信息 select nvl(max(value0),'0') into Vzlxmid from XT_XTCS00 where name00='MZSF_YYFWZLXMID'; if (Pghlb00>0) and (Vzlxmid>0) then update SF_BRFY00 set MZH000=Pghh000,MZID00=to_number(Pghh000) where BRID00=Pbrid00 and MZH000='-1'; update SF_FYMX00 set MZH000=Pghh000 where BRID00=Pbrid00 and MZH000='-1' and SFLB00='1'; update YJ_YW0000 set ZYHGHH=Pghh000,ZYGHID=to_number(Pghh000) where BRID00=Pbrid00 and ZLXMID=Vzlxmid and MZZYBZ='0' and ZYHGHH='-1'; end if; Pzxcgbz:=1; if pcommit='Y' then commit; end if; exception when no_data_found then raise_application_error(-20001,substrb('没有找到数据!*'||sqlerrm,1,240)); when Ecustom then if Pcwts00 = '0' then raise_application_error(-20010,substrb(Ptsxx00||'!*',1,240)); else return; end if; when others then raise_application_error(-20002,substrb(nvl(sqlerrm, '原因不明出错')||'!*',1,240)); end; /