CREATE OR REPLACE PROCEDURE SP_YJ_DXTZ00 ( Pbrid00 in number , --BRID Pdxlbmc in varchar2, --短信类型名称 Pczlbmc in varchar2, --操作类别名称 Pczy000 in number , --操作员 Pczyks0 in number , --操作员科室 Pcommit in varchar2 default 'N', --是否提交 Pzxcgbz out number, --执行成功标志 1成功 0失败 Ptsxx00 out varchar2, --执行结果提示信息,成功的情况下也可能有警告信息 Pxxxx00 out varchar2, --执行结果详细信息,成功的情况下也可能有警告信息,一般用来显示参数等指标 Pdjh000 in number default 0 --单据号 ) as -- MODIFICATION HISTORY -- Person Date Comments -- zhr 2013.05.10 Create -- qks 2013.11.11 增加Pdxlbmc='手术排台提醒';增加入参Pdjh000 -- qks 2014.04.22 字段YJ_DXTZ00.DXNR00长度扩展到2000个字节 -- qks 2016.09.07 增加全院药占比、门诊药占比、住院药占比:药占比=西成药(剔除本院制剂)/总收入(剔除中草药以及本院制剂) -- qks 2017.03.08 短信内容最后面增加[信息中心],新增参数YJ_DXTZGDNR维护; for YJ9-20170308-001 -- qks 2017.04.17 使用参数ZY_SFQYXFFDBZJK控制:短信内容是否增加“单病种日报”; for YJ9-20170418-002 -- qks 2017.08.30 全院HIS周报、HIS月报短信内容修改:如果有体检收入数据,需要在“全院总收入***.**”后增加“(其中体检收入***.**)”,在“全院药占比”后增加“(含体检)”; for YJ9-20170830-001 -- qks 2019.01.05 省人民要求全院HIS日报、HIS周报、HIS月报死亡短信通知增加:死亡3人(内科1例,外科2例) for YJ9-20190105-003 -- gzj 2019.01.12 增加Pdxlbmc='项目退费成功提醒' for YJ9-20181228-002 -- qks 2019.01.14 改为自定义归档; for YJ9-20190114-001 -- qiulf 2021.08.02 增加核酸检测后入院通知 by YJ9-20210730-001 Vcount0 number; --计数器变量 Vcount1 number; --计数器变量 Vdqksmc varchar2(100); Vksmc00 varchar2(100); Vparams varchar2(200); --参数变量 Vybjgjc IC_YBBRLB.YBJGJC%TYPE; Vbrxm00 BM_BRXXB0.BRXM00%TYPE; VYSLXDH WZ_GZBHMX.YSLXDH%TYPE; VZLXMJC BQ_YJYZ00.ZLXMJC%TYPE; VTJSR00 ZH_ZTJZB0.TJJG00%TYPE; --体检收入 Ecustom exception; --错误变量 Vczrq00 CHAR(8); Vczsj00 CHAR(8); Vrq0000 varchar2(8); Vrq0001 varchar2(8); Vtmpstr varchar2(500); --varchar2(300) Vdxnr00 varchar2(2000); --varchar2(600) VTJSR01 varchar2(50); --体检收入说明1 VTJSR02 varchar2(50); --体检收入说明2 VSWSM00 varchar2(500); --死亡科室人数明细说明; lv_GDNR00 xt_xtcs00.value0%type; VYJYW00 YJ_YW0000%rowtype; begin Pzxcgbz:=0; Vczrq00 := to_char(sysdate,'YYYYMMDD'); Vczsj00 := to_char(sysdate,'HH24:MI:SS'); Vparams :=nvl(to_char(Pbrid00),'null')||','||nvl(to_char(Pdxlbmc),'null')||','||nvl(to_char(Pczlbmc),'null')||','|| nvl(to_char(Pczy000),'null')||','||nvl(to_char(Pczyks0),'null')||','''||Pcommit||''',Pzxcgbz,pzxjg00,Pxxxx00)'; SP_TransLog(sysdate,'SP_YJ_DXTZ00',Pczy000,null,Vparams); select nvl(max(trim(VALUE0)),'') into lv_GDNR00 from xt_xtcs00 where name00='YJ_DXTZGDNR'; if Pdxlbmc ='核酸检测后入院通知' then insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,BRID00,CZRQ00,CZSJ00,DH0000,JSR000) select SQ_YJ_DXTZ00_DXID00.nextval,Pdxlbmc,a.BRXM00||'您好!您的核酸检测报告已出,可关注福建省人民医院微信公众号查阅,如需纸质报告,请前往核酸检测站或1号楼二层检验科自助打印。', Vczrq00,VYJYW00.BRID00,to_char(sysdate,'yyyymmdd'),to_char(sysdate,'hh24:mi:ss'), nvl(a.BRLXDH,a.BRDH00),BRXM00 from BM_BRXXB0 a where a.BRID00=Pbrid00; elsif Pdxlbmc='来人提醒' then select count(*) into Vcount0 from YJ_DXTZ00 where CZRQ00=to_char(sysdate,'yyyymmdd') and BRID00=Pbrid00 and to_char(to_date(CZSJ00,'hh24:mi:ss'),'AM')=to_char(sysdate,'AM') and DXNRFL=Pdxlbmc ; if Vcount0=0 then select YBJGJC,a.BRXM00 into Vybjgjc,Vbrxm00 from BM_BRXXB0 a,IC_YBBRLB b where a.BRID00=Pbrid00 and a.FBBH00=b.FBBH00 and a.YBLB00=b.YBLB00; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,Pdxlbmc,'提示:'||Vybjgjc||Vbrxm00||'同志于'|| to_number(substrb(Vczrq00,5,2))||'月'||to_number(substrb(Vczrq00,7,2))||'日'||substrb(Vczsj00,1,5)|| '来我院'||c.BMMC00||a.ZWXM00||'处'||Pczlbmc||',请予以关注。', Vczrq00,Vczrq00,Vczsj00,d.MC0000,d.BZ0000,Pbrid00 from BM_YGBM00 a,BM_BMBM00 c,BM_TYZD00 d where a.YGBH00=Pczy000 and c.BMBH00=Pczyks0 and d.ZDMC00='来人提醒电话' and d.YXBZ00='1'; end if; elsif Pdxlbmc='手术排台提醒' then select count(*) into Vcount0 from YJ_DXTZ00 where CZRQ00=to_char(sysdate,'yyyymmdd') and BRID00=Pbrid00 and to_char(to_date(CZSJ00,'hh24:mi:ss'),'AM')=to_char(sysdate,'AM') and DXNRFL=Pdxlbmc ; if Vcount0=0 then select max(YSLXDH) into VYSLXDH from WZ_GZBHMX where SSDH00=Pdjh000; --select max(a.ZLXMJC) into VZLXMJC from BQ_YJYZ00 a,SS_YW0000 b where a.YZMXID=b.YZMXID and b.SSDH00=Pdjh000; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,Pdxlbmc,'提示:'||c.BMMC00||' '||(select max(RYCWH0) from zy_brxxb0 where zyid00=b.ZYGHID)||'床'||b.XM0000|| ','||(select max(SSXMJC) from ss_ywmx00 where SSDH00=b.SSDH00)||' 已安排'||substrb(YYSSRQ,5,2)||'月'||substrb(YYSSRQ,7,2)||'日'||'手术,医生:'||a.ZWXM00||',电话'||VYSLXDH||',请予以关注。', Vczrq00,Vczrq00,Vczsj00,d.MC0000,d.BZ0000,Pbrid00 from SS_YW0000 b,BM_YGBM00 a,BM_BMBM00 c,BM_TYZD00 d where b.SSDH00=Pdjh000 and a.YGBH00=b.SQYS00 and c.BMBH00=b.SQKS00 and d.ZDMC00='手术排台通知电话' and d.YXBZ00='1'; end if; elsif Pdxlbmc='警惕患者提醒' then select count(*) into Vcount0 from YJ_DXTZ00 where CZRQ00=to_char(sysdate,'yyyymmdd') and BRID00=Pbrid00 and to_char(to_date(CZSJ00,'hh24:mi:ss'),'AM')=to_char(sysdate,'AM') and DXNRFL=Pdxlbmc ; if Vcount0=0 then select YBJGJC,a.BRXM00 into Vybjgjc,Vbrxm00 from BM_BRXXB0 a,IC_YBBRLB b where a.BRID00=Pbrid00 and a.FBBH00=b.FBBH00 and a.YBLB00=b.YBLB00; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,Pdxlbmc,'提示:'||Vbrxm00||'同志于'|| to_number(substrb(Vczrq00,5,2))||'月'||to_number(substrb(Vczrq00,7,2))||'日'||substrb(Vczsj00,1,5)|| '来我院'||c.BMMC00||a.ZWXM00||'处'||Pczlbmc||',请予以关注。', Vczrq00,Vczrq00,Vczsj00,d.MC0000,d.BZ0000,Pbrid00 from BM_YGBM00 a,BM_BMBM00 c,BM_TYZD00 d where a.YGBH00=Pczy000 and c.BMBH00=Pczyks0 and d.ZDMC00='警惕通知电话' and d.YXBZ00='1'; end if; elsif Pdxlbmc='HIS日报' then Vrq0000:=to_char(Pbrid00); if Vrq0000>=to_char(sysdate,'yyyymmdd') then return; end if; Vdxnr00:='<'||to_char(to_number(substrb(Vrq0000,5,2)))||'月'||to_char(to_number(substrb(Vrq0000,7,2)))||'日院况简报>'; --门诊: --2016.09.07 select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0034' and TJJG00<>0; if Vcount0>0 then --全院总收入 select Vdxnr00||'全院总收入'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0034' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0090' and TJJG00<>0; if Vcount0>0 then --全院药占比 select Vdxnr00||'全院药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0090' and TJJG00<>0; end if; Vdxnr00 := Vdxnr00||'门诊:'; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0001' and TJJG00<>0; if Vcount0>0 then --门急诊人数 select Vdxnr00||'挂号数'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0001' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0016' and TJJG00<>0; if Vcount0>0 then --门诊总收入 select Vdxnr00||'收入'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0016' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0056' and TJJG00<>0; if Vcount0>0 then --门诊次均费用 select Vdxnr00||'次均费用'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0056' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0058' and TJJG00<>0; if Vcount0>0 then --门诊药品比例 --药品比例->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0058' and TJJG00<>0; end if; Vdxnr00:=Vdxnr00||'住院:'; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0033' and TJJG00<>0; if Vcount0>0 then --在院人数 select Vdxnr00||'在院'||to_char(TJJG00)||'人;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0033' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0018' and TJJG00<>0; if Vcount0>0 then --住院总收入 select Vdxnr00||'收入'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0018' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0078' and TJJG00<>0; if Vcount0>0 then --住院药品比例 --药品比例->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0078' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0080' and TJJG00<>0; if Vcount0>0 then --住院材料比例 select Vdxnr00||'材料比例'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0080' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0041' and TJJG00<>0; if Vcount0>0 then --住院手术例数 select Vdxnr00||'手术'||to_char(TJJG00)||'例;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0041' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0076' and TJJG00<>0; if Vcount0>0 then --住院病危 select Vdxnr00||'病危'||to_char(TJJG00)||'人;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0076' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0077' and TJJG00<>0; if Vcount0>0 then --住院死亡 --2018.12.29 VSWSM00 := ''; for DBZXR in (select b.BMMC00,count(1) SWSL00 from ZY_BRXXB0 a,BM_BMBM00 b where a.SJCYRQ=Vrq0000 and a.DQKS00=b.BMBH00 and a.RCYFH0 like '%死亡%' and a.BRZT00 not in ('9','1') group by b.BMMC00 ) loop VSWSM00 := VSWSM00||DBZXR.BMMC00||to_char(DBZXR.SWSL00)||'例,'; end loop; if VSWSM00 is not null then VSWSM00 := '('||substrb(VSWSM00,1,instrb(VSWSM00,',',-1,1)-1)||')'; end if; select Vdxnr00||'死亡'||to_char(TJJG00)||'人'||VSWSM00||';'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0077' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0007' and TJJG00<>0; if Vcount0>0 then --入院人数 select Vdxnr00||'入院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0007' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0008' and TJJG00<>0; if Vcount0>0 then --出院人数 select Vdxnr00||'出院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0008' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0028' and TJJG00<>0; if Vcount0>0 then --住院患者人均费用 select Vdxnr00||'出院人均费用'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0028' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0042' and TJJG00<>0; if Vcount0>0 then --出院平均住院日 select Vdxnr00||'出院平均住院'||to_char(TJJG00)||'天;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB00 where TJRQ00=Vrq0000 and TJBH00='0042' and TJJG00<>0; end if; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,'HIS日报',Vdxnr00||lv_GDNR00,Vrq0000,to_char(to_date(Vrq0000,'YYYYMMDD')+1,'YYYYMMDD'),'08:00:00',d.MC0000,d.BZ0000,0 from BM_TYZD00 d where d.ZDMC00='HIS日报号码' and YXBZ00='1' and not exists (select 1 from YJ_DXTZ00 where d.MC0000=DH0000 and DXNRFL='HIS日报' and YWRQ00=Vrq0000); --【省人民医院】<4月16日 单病种运行情况日报>在科5例,出院1例,新入6例。新入明细:外五科1例;耳鼻喉科1例;妇科2例;骨伤一科1例;骨伤二科1例【信息中心】 --2017.04.17 select count(1) into Vcount0 from xt_xtcs00 where name00='ZY_SFQYXFFDBZJK' and value0='Y'; if Vcount0>0 then select count(1) into Vcount0 from ZY_ZYBRMX where zyrq00=Vrq0000 and flag00='0'; if Vcount0>0 then Vdxnr00:='<'||to_char(to_number(substrb(Vrq0000,5,2)))||'月'||to_char(to_number(substrb(Vrq0000,7,2)))||'日 单病种运行情况日报>'; --在院病人 select count(distinct a.ZYID00) into Vcount0 from ZY_ZYBRMX a,zy_dbzczb b where a.zyrq00=Vrq0000 and a.flag00='0' and a.zyid00=b.zyid00 and nvl(b.TCRQ00,'20991231')>Vrq0000; Vdxnr00 := Vdxnr00||'在科'||to_char(Vcount0)||'例,'; --出院病人 select count(distinct a.zyid00) into Vcount0 from ZY_ZYBRMX a,zy_brxxb0 b where a.zyrq00=Vrq0000 and a.flag00='2' and a.zyid00=b.zyid00 and b.FFBZBM is not null; Vdxnr00 := Vdxnr00||'出院'||to_char(Vcount0)||'例,'; --中途退出 select count(distinct a.zyid00) into Vcount0 from zy_dbzczb a,zy_brxxb0 b where a.zyid00=b.zyid00 and a.TCRQ00=Vrq0000 and a.JRRQ000 then Vdxnr00 := Vdxnr00||'退出'||to_char(Vcount0)||'例,'; end if; --新入病人 select count(distinct a.zyid00) into Vcount0 from zy_dbzczb a,zy_brxxb0 b where a.zyid00=b.zyid00 and a.JRRQ00=Vrq0000 and nvl(a.TCRQ00,'20991231')>Vrq0000; Vdxnr00 := Vdxnr00||'新入'||to_char(Vcount0)||'例。'; if Vcount0>0 then Vdxnr00 := Vdxnr00||'新入明细:'; for DBZXR in (select bb.BMMC00,count(1) XRSL00 from ( select distinct b.zyid00,nvl(c.DYMZKS,b.DQKS00) KSH000 From zy_dbzczb a,zy_brxxb0 b,bm_bmbm00 c where a.zyid00=b.zyid00 and a.JRRQ00=Vrq0000 and nvl(a.TCRQ00,'20991231')>Vrq0000 and b.dqks00=c.BMBH00 )aa,bm_bmbm00 bb where aa.KSH000=bb.BMBH00 group by bb.BMMC00 ) loop Vdxnr00 := Vdxnr00||DBZXR.BMMC00||to_char(DBZXR.XRSL00)||'例;'; end loop; if substrb(Vdxnr00,-1,1)=';' then Vdxnr00 := substrb(Vdxnr00,1,lengthb(Vdxnr00)-1); end if; end if; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,'单病种日报',Vdxnr00||lv_GDNR00,Vrq0000,to_char(to_date(Vrq0000,'YYYYMMDD')+1,'YYYYMMDD'),'08:00:00',d.MC0000,d.BZ0000,0 from BM_TYZD00 d where d.ZDMC00='HIS日报号码' and YXBZ00='1' and not exists (select 1 from YJ_DXTZ00 where d.MC0000=DH0000 and DXNRFL='单病种日报' and YWRQ00=Vrq0000); end if; end if; elsif Pdxlbmc='HIS周报' then Vrq0000:=to_char(Pbrid00); Vrq0001:=to_char(to_date(to_char(Pbrid00),'yyyymmdd')+6,'yyyymmdd'); if Vrq0000>=to_char(sysdate,'yyyymmdd') then return; end if; Vdxnr00:='<'||to_char(to_number(substrb(Vrq0000,5,2)))||'.'||to_char(to_number(substrb(Vrq0000,7,2))); Vdxnr00:=Vdxnr00||'-'||to_char(to_number(substrb(Vrq0001,5,2)))||'.'||to_char(to_number(substrb(Vrq0001,7,2)))||'院况周报>'; --门诊: --2016.09.07 select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0034' and TJJG00<>0; if Vcount0>0 then --全院总收入 select nvl(max(TJJG00),0) into VTJSR00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='2001' and TJJG00<>0; if VTJSR00>0 then VTJSR01:='(其中体检收入'||to_char(VTJSR00)||')'; VTJSR02:='(含体检)'; else VTJSR01:=''; VTJSR02:=''; end if; select Vdxnr00||'全院总收入'||to_char(TJJG00)||VTJSR01||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0034' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1004' and TJJG00<>0; if Vcount0>0 then --全院药占比 select Vdxnr00||'全院药占比'||VTJSR02||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1004' and TJJG00<>0; end if; Vdxnr00 := Vdxnr00||'门诊:'; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0001' and TJJG00<>0; if Vcount0>0 then --门急诊人数 select Vdxnr00||'挂号数'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0001' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0016' and TJJG00<>0; if Vcount0>0 then --门诊总收入 select Vdxnr00||'收入'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0016' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0056' and TJJG00<>0; if Vcount0>0 then --门诊次均费用 select Vdxnr00||'次均费用'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0056' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0058' and TJJG00<>0; if Vcount0>0 then --门诊药品比例 --药品比例-->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0058' and TJJG00<>0; end if; Vdxnr00:=Vdxnr00||'住院:'; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0033' and TJJG00<>0; if Vcount0>0 then --在院人数 select Vdxnr00||'在院'||to_char(TJJG00)||'人;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0033' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0018' and TJJG00<>0; if Vcount0>0 then --住院总收入 select Vdxnr00||'收入'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0018' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0078' and TJJG00<>0; if Vcount0>0 then --住院药品比例 --药品比例-->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0078' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0080' and TJJG00<>0; if Vcount0>0 then --住院材料比例 select Vdxnr00||'材料比例'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0080' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0041' and TJJG00<>0; if Vcount0>0 then --住院手术例数 select Vdxnr00||'手术'||to_char(TJJG00)||'例;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0041' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0076' and TJJG00<>0; if Vcount0>0 then --住院病危 select Vdxnr00||'病危'||to_char(TJJG00)||'人;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0076' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0077' and TJJG00<>0; if Vcount0>0 then --住院死亡 --2019.01.05 VSWSM00 := ''; for DBZXR in (select b.BMMC00,count(1) SWSL00 from ZY_BRXXB0 a,BM_BMBM00 b where a.SJCYRQ>=Vrq0000 and a.SJCYRQ<=Vrq0001 and a.DQKS00=b.BMBH00 and a.RCYFH0 like '%死亡%' and a.BRZT00 not in ('9','1') group by b.BMMC00 ) loop VSWSM00 := VSWSM00||DBZXR.BMMC00||to_char(DBZXR.SWSL00)||'例,'; end loop; if VSWSM00 is not null then VSWSM00 := '('||substrb(VSWSM00,1,instrb(VSWSM00,',',-1,1)-1)||')'; end if; select Vdxnr00||'死亡'||to_char(TJJG00)||'人'||VSWSM00||';'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0077' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0007' and TJJG00<>0; if Vcount0>0 then --入院人数 select Vdxnr00||'入院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0007' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0008' and TJJG00<>0; if Vcount0>0 then --出院人数 select Vdxnr00||'出院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0008' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0028' and TJJG00<>0; if Vcount0>0 then --住院患者人均费用 select Vdxnr00||'出院人均费用'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0028' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0042' and TJJG00<>0; if Vcount0>0 then --出院平均住院日 select Vdxnr00||'出院平均住院'||to_char(TJJG00)||'天;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='0042' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1014' and TJJG00<>0; if Vcount0>0 then --在院日均费用 select Vdxnr00||'在院日均费用'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1014' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1019' and TJJG00<>0; if Vcount0>0 then --病床使用率 select Vdxnr00||'病床使用率'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_ZTJZB0 where TJKSRQ=Vrq0000 and TJBH00='1019' and TJJG00<>0; end if; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,'HIS周报',Vdxnr00||lv_GDNR00,Vrq0000,to_char(to_date(Vrq0001,'YYYYMMDD')+1,'YYYYMMDD'),'08:00:00',d.MC0000,d.BZ0000,0 from BM_TYZD00 d where d.ZDMC00='HIS日报号码' and YXBZ00='1' and not exists (select 1 from YJ_DXTZ00 where d.MC0000=DH0000 and DXNRFL='HIS周报' and YWRQ00=Vrq0000); elsif Pdxlbmc='HIS月报' then Vrq0000:=substrb(to_char(Pbrid00),1,6); if Vrq0000>=to_char(sysdate,'yyyymmdd') then return; end if; Vdxnr00:='<'||to_char(to_number(substrb(Vrq0000,5,2)))||'月院况月报>'; --门诊: --2016.09.07 select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0034' and TJJG00<>0; if Vcount0>0 then --全院总收入 select nvl(max(TJJG00),0) into VTJSR00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='2001' and TJJG00<>0; if VTJSR00>0 then VTJSR01:='(其中体检收入'||to_char(VTJSR00)||')'; VTJSR02:='(含体检)'; else VTJSR01:=''; VTJSR02:=''; end if; select Vdxnr00||'全院总收入'||to_char(TJJG00)||VTJSR01||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0034' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1004' and TJJG00<>0; if Vcount0>0 then --全院药占比 select Vdxnr00||'全院药占比'||VTJSR02||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1004' and TJJG00<>0; end if; Vdxnr00 := Vdxnr00||'门诊:'; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0001' and TJJG00<>0; if Vcount0>0 then --门急诊人数 select Vdxnr00||'挂号数'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0001' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0016' and TJJG00<>0; if Vcount0>0 then --门诊总收入 select Vdxnr00||'收入'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0016' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0056' and TJJG00<>0; if Vcount0>0 then --门诊次均费用 select Vdxnr00||'次均费用'||to_char(TJJG00)||','||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0056' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0058' and TJJG00<>0; if Vcount0>0 then --门诊药品比例 --药品比例-->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0058' and TJJG00<>0; end if; Vdxnr00:=Vdxnr00||'住院:'; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0033' and TJJG00<>0; if Vcount0>0 then --在院人数 select Vdxnr00||'在院'||to_char(TJJG00)||'人;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0033' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0018' and TJJG00<>0; if Vcount0>0 then --住院总收入 select Vdxnr00||'收入'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0018' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0078' and TJJG00<>0; if Vcount0>0 then --住院药品比例 --药品比例-->药占比 select Vdxnr00||'药占比'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0078' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0080' and TJJG00<>0; if Vcount0>0 then --住院材料比例 select Vdxnr00||'材料比例'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0080' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0041' and TJJG00<>0; if Vcount0>0 then --住院手术例数 select Vdxnr00||'手术'||to_char(TJJG00)||'例;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0041' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0076' and TJJG00<>0; if Vcount0>0 then --住院病危 select Vdxnr00||'病危'||to_char(TJJG00)||'人;'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0076' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0077' and TJJG00<>0; if Vcount0>0 then --住院死亡 --2019.01.05 VSWSM00 := ''; for DBZXR in (select b.BMMC00,count(1) SWSL00 from ZY_BRXXB0 a,BM_BMBM00 b where a.SJCYRQ like Vrq0000||'%' and a.DQKS00=b.BMBH00 and a.RCYFH0 like '%死亡%' and a.BRZT00 not in ('9','1') group by b.BMMC00 ) loop VSWSM00 := VSWSM00||DBZXR.BMMC00||to_char(DBZXR.SWSL00)||'例,'; end loop; if VSWSM00 is not null then VSWSM00 := '('||substrb(VSWSM00,1,instrb(VSWSM00,',',-1,1)-1)||')'; end if; select Vdxnr00||'死亡'||to_char(TJJG00)||'人'||VSWSM00||';'||decode(LSXGBZ,1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0077' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0007' and TJJG00<>0; if Vcount0>0 then --入院人数 select Vdxnr00||'入院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0007' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0008' and TJJG00<>0; if Vcount0>0 then --出院人数 select Vdxnr00||'出院'||to_char(TJJG00)||'人;' into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0008' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0028' and TJJG00<>0; if Vcount0>0 then --住院患者人均费用 select Vdxnr00||'出院人均费用'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||',降'||to_char(LSXGBL,'FM9999990.999')||'%),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||',增'||to_char(LSXGBL,'FM9999990.999')||'%),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0028' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0042' and TJJG00<>0; if Vcount0>0 then --出院平均住院日 select Vdxnr00||'出院平均住院'||to_char(TJJG00)||'天;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='0042' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1014' and TJJG00<>0; if Vcount0>0 then --在院日均费用 select Vdxnr00||'在院日均费用'||to_char(TJJG00)||';'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1014' and TJJG00<>0; end if; select count(*) into Vcount0 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1019' and TJJG00<>0; if Vcount0>0 then --病床使用率 select Vdxnr00||'病床使用率'||to_char(TJJG00)||'%;'||decode(LSXGBZ,2,'创新低('||LSXGRQ||':'||to_char(LSXGZ0)||'),', 1,'创新高('||LSXGRQ||':'||to_char(LSXGZ0)||'),','') into Vdxnr00 from ZH_TJZB01 where TJYF00=Vrq0000 and FLAG00='0' and TJBH00='1019' and TJJG00<>0; end if; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,'HIS月报',Vdxnr00||lv_GDNR00,Vrq0000,to_char(add_months(to_date(Vrq0000||'01','YYYYMMDD'),1),'YYYYMMDD'),'08:00:00',d.MC0000,d.BZ0000,0 from BM_TYZD00 d where d.ZDMC00='HIS日报号码' and YXBZ00='1' and not exists (select 1 from YJ_DXTZ00 where d.MC0000=DH0000 and DXNRFL='HIS月报' and YWRQ00=Vrq0000); elsif Pdxlbmc='危重简报' then Vrq0000:=to_char(Pbrid00); declare cursor BWBR is select YZMXID,BMMC00,c.RYCWH0,c.XM0000,c.XB0000,c.CSRQ00, substrb(QYRQ00,5,2)||'.'||substrb(QYRQ00,7,2)||' '||substrb(QYSJ00,1,5) QYRQSJ, KSH000,decode(TZRQ00,null,null,substrb(TZRQ00,5,2)||'.'||substrb(TZRQ00,7,2)||' '||substrb(TZSJ00,1,5))TZRQSJ, SXYSXM,decode(yzzt00,'1','核对','2','执行','3','停止')YZZT00,c.RYZDMC from BQ_YJYZ00 a,BM_BMBM00 b,ZY_BRXXB0 c where YZZT00 in ('2','3') and a.KSH000=b.BMBH00 and c.ZYID00=a.ZYID00 and (ZLXMJC like '%病危%' ) and Vrq0000>=QYRQ00 and Vrq0000=QYRQ00 and Vrq0000Vdqksmc then Vdxnr00:=Vdxnr00||Vksmc00||to_char(Vcount0)||'人;'||Vtmpstr; Vksmc00:=Vdqksmc; Vcount0:=0; Vtmpstr:=''; end if; Vtmpstr:=Vtmpstr||'姓名:'||br.XM0000||',诊断:'||br.RYZDMC||',医生:'||br.SXYSXM||';'; Vcount0:=Vcount0+1; Vcount1:=Vcount1+1; end loop; if Vksmc00<>' ' then Vdxnr00:='病危'||to_char(Vcount1)||'人:'||Vdxnr00||Vdqksmc||to_char(Vcount0)||'人;'||Vtmpstr; Vdxnr00:=substrb(Vdxnr00,1,Lengthb(Vdxnr00)-1); end if; Vcount0:=0; Vtmpstr:=''; for br in BZBR loop Vtmpstr:=Vtmpstr||replace(br.BMMC00,'(病区)','')||to_char(br.RS0000)||'人,'; Vcount0:=Vcount0+br.RS0000; end loop; if Vcount0>0 or Vcount1>0 then Vdxnr00:=substrb('<'||to_char(to_number(substrb(Vrq0000,5,2)))||'月'||to_char(to_number(substrb(Vrq0000,7,2)))||'日危重简报>'|| '危重共'||to_char(Vcount0+Vcount1)||'人。'||Vdxnr00,1,2000); if Vcount1>0 then Vdxnr00:=substrb(Vdxnr00||'。病重'||to_char(Vcount0)||'人:'||substrb(Vtmpstr,1,Lengthb(Vtmpstr)-1)||'。',1,2000); end if; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,CZRQ00,CZSJ00,DH0000,JSR000,BRID00) select SQ_YJ_DXTZ00_DXID00.nextval,'危重简报',Vdxnr00||lv_GDNR00,Vrq0000,to_char(sysdate,'yyyymmdd'),to_char(sysdate,'hh24:mi:ss'),d.MC0000,d.BZ0000,0 from BM_TYZD00 d where d.ZDMC00='危重简报号码' and YXBZ00='1' and not exists (select 1 from YJ_DXTZ00 where d.MC0000=DH0000 and DXNRFL='危重简报' and YWRQ00=Vrq0000); end if; end; elsif Pdxlbmc='项目退费成功提醒' then select * into VYJYW00 from YJ_YW0000 where BRID00=Pbrid00 and YJDJH0=Pdjh000; Vdxnr00:=VYJYW00.BRXM00||',您好!您在'||substr(VYJYW00.KDRQ00,1,4)||'年'||substr(VYJYW00.KDRQ00,5,2)||'月'||substr(VYJYW00.KDRQ00,7,2)||'日 开单的'||VYJYW00.ZLXMJC ||'项目(金额'||abs(VYJYW00.ZJE000)||'元),已于'||substr(VYJYW00.ZXRQ00,5,2)||'月'||substr(VYJYW00.ZXRQ00,7,2)||'日退费成功,如已预约,预约号同步作废。'; insert into YJ_DXTZ00(DXID00,DXNRFL,DXNR00,YWRQ00,BRID00,CZRQ00,CZSJ00,DH0000,JSR000) select SQ_YJ_DXTZ00_DXID00.nextval,'项目退费成功提醒',Vdxnr00,Vczrq00,VYJYW00.BRID00,to_char(sysdate,'yyyymmdd'),to_char(sysdate,'hh24:mi:ss'), nvl(a.BRLXDH,a.BRDH00),VYJYW00.BRXM00 from BM_BRXXB0 a where a.BRID00=VYJYW00.BRID00; --and not exists(select 1 from YJ_DXTZ00 where DH0000= and DXNRFL='项目退费成功提醒' and YWRQ00=Vczrq00); end if; Pzxcgbz:=1; if pcommit='Y' then commit; end if; exception when no_data_found then raise_application_error(-20001,substrb('没有找到数据!*'||sqlerrm||','||Vparams,1,240)); when Ecustom then raise_application_error(-20010,substrb(Ptsxx00||'!*'||Pxxxx00,1,240)); when others then raise_application_error(-20002,substrb(nvl(sqlerrm, '原因不明出错')||'!*'||Vparams,1,240)); end;