create or replace function SF_ZS_YZMCZT ( PZYID00 in number, PYZID00 in number, PCLBZ00 in number, --长临标志 PYZLB00 in number --医嘱类型 0药品1非药 ) return varchar2 is VRQ0000 char(8); VZXZT00 varchar2(100); VCOUNT0 number; VCLBZ00 char(1); LV_XTCS_VALUE XT_XTCS00.VALUE0%type;--系统参数值 -- MODIFICATION HISTORY -- Person Date Comments -- xuxm 2022.09.08 ZYDZBL-20220902-003 已退费和已退药的临时医嘱要显示(取消) begin VRQ0000:=to_char(sysdate,'yyyymmdd'); if PYZLB00=0 then --已退费和已退药的临时医嘱要显示(取消) if (PCLBZ00='1') then --临嘱判断 begin select trim(VALUE0) into LV_XTCS_VALUE from Xt_Xtcs00 where NAME00='ZS_SFXSTYBZ'; exception when others then Lv_Xtcs_Value:='N'; end; if (LV_XTCS_VALUE!='N') then --有开参数的才需要判断 select count(*) into Vcount0 from YF_YZYPSQ where ZYID00=Pzyid00 and YZID00=PYZID00 and CLBZ00='1' and YPZSL0>0; if Vcount0=0 then Vzxzt00:='未申请'; else --2020.04.23 药品退药后还可提取的情况下存在一条药品医嘱对应多笔YF_YZYPSQ,取最后一笔的结果显示 select ZXZT00 into VZXZT00 from (select decode(QLZT00,'0','未扣费','1','已扣费','2','已摆药','3','作废','4','已领药','5','已退药','6','已退费','其他')||decode(sign(BCCXSL+ZCXSL0),1,'(退)','') ZXZT00 from YF_YZYPSQ where ZYID00=PZYID00 and YZID00=Pyzid00 and CLBZ00='1' and YPZSL0>0 order by YPQLPC desc) where rownum=1; end if; if(LV_XTCS_VALUE='Y' and instr(VZXZT00,'退')>0) then --参数为Y 显示退费,退药标志 Vzxzt00:=VZXZT00; elsif (LV_XTCS_VALUE='X' and instr(VZXZT00,'退')>0) then --参数为X 显示取消标准 VZXZT00:='(取消)'; elsif (LV_XTCS_VALUE='X') then select count(*) into VCOUNT0 from YF_ZYCFMX where YZID00 = PYZID00 and CXBZ00 in ('+','-'); if(VCOUNT0 >0) then VZXZT00:='(取消)'; else VZXZT00:=''; end if; else VZXZT00:=''; end if ; end if; end if; end if; return Vzxzt00; end;