create or replace function SF_YF_CFLSH_GETBRXM -- modification history -- Person Date Comments -- xuzw 2016.02.24 create -- wusq 2016.09.21 返回值增加显示BRXM00或BMMC00,并增加参数PYPCKPC by YF9-20160914-001 -- luowf 2020.05.21 增加入参PSFXXYS,PSFXXYS=1时返回值带上开单医生 YF9-20200519-001 -- luowf 2021.10.21 入参留着暂不删除,还原查询语句不带上开单医生 YF9-20211021-002 --chenzh 2022.03.02 nhxzyy要求返回值增加显示XB0000,csrq00 ( PDJH000 in varchar2, --门诊:YF_MZCF00.cflsh0 住院;yf_yzypsq.ckdh00 PRCLXBH in varchar2, --入出库类型 PYPNM00 in number, PYPCKPC in number default 0, --药品出库批次 PSFXXYS in number default 0 --是否显示医生 --因为出库明细账查询也调用这个函数 ) return varchar2 --1发药状态 0非发药状态 is Pbrxm00 varchar2(100); begin if PRCLXBH = '09' then select trim(nvl(BRXM00,'')||' '||nvl(a.xb0000,'')||' '||nvl(sf_xt_csrqtonl(a.csrq00),'')||' '||(select nvl(BMMC00,'') from BM_BMBM00 where BMBH00=A.SSKS00)) into Pbrxm00 from YF_MZCF00 A,YF_MZCFMX B where a.CFLSH0 = b.CFLSH0 and a.CFLSH0 = PDJH000 and rownum=1 and YPNM00=PYPNM00; ELSIF PRCLXBH = '10' then if PYPCKPC=0 then select trim(nvl(A.BRXM00,'')||' '||nvl(C.xb0000,'')||' '||nvl(sf_xt_csrqtonl(C.csrq00),'')||' '||nvl(B.BMMC00,'')) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B,ZY_BRXXB0 C where A.DQKS00 = B.BMBH00 AND A.ZYID00=C.ZYID00 AND (nvl(PYPCKPC,0)=0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; else select trim(nvl(A.BRXM00,'')||' '||nvl(C.xb0000,'')||' '||nvl(sf_xt_csrqtonl(C.csrq00),'')||' '||nvl(B.BMMC00,'')) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B,ZY_BRXXB0 C where A.DQKS00 = B.BMBH00 and A.ZYID00=C.ZYID00 AND (A.YPQLPC = PYPCKPC and PYPCKPC>0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; end if; end if; --if PSFXXYS = 0 then --if PRCLXBH = '09' then --select trim(nvl(BRXM00,'')||' '||(select nvl(BMMC00,'') from BM_BMBM00 where BMBH00=A.SSKS00)) into Pbrxm00 from YF_MZCF00 A,YF_MZCFMX B where A.CFLSH0 = B.CFLSH0 and A.CFLSH0 = PDJH000 and rownum=1 and YPNM00=PYPNM00; --elsif PRCLXBH = '10' then --if PYPCKPC=0 then --select trim(nvl(A.BRXM00,'')||' '||nvl(B.BMMC00,'')) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B where A.DQKS00 = B.BMBH00 and (nvl(PYPCKPC,0)=0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; --else --select trim(nvl(A.BRXM00,'')||' '||nvl(B.BMMC00,'')) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B where A.DQKS00 = B.BMBH00 and (A.YPQLPC = PYPCKPC and PYPCKPC>0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; --end if; --end if; --elsif PSFXXYS = 1 then --if PRCLXBH = '09' then --select trim(nvl(BRXM00,'')||' '||(select nvl(BMMC00,'') from BM_BMBM00 where BMBH00=A.SSKS00))||' '||A.YSXM00 into Pbrxm00 from YF_MZCF00 A,YF_MZCFMX B where A.CFLSH0 = B.CFLSH0 and A.CFLSH0 = PDJH000 and rownum=1 and YPNM00=PYPNM00; --elsif PRCLXBH = '10' then --if PYPCKPC=0 then --select trim(nvl(A.BRXM00,'')||' '||nvl(B.BMMC00,''))||' '||(select nvl(ZWXM00,'') from BM_YGBM00 where YGBH00=A.YSGZH0) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B where A.DQKS00 = B.BMBH00 and (nvl(PYPCKPC,0)=0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; --else --select trim(nvl(A.BRXM00,'')||' '||nvl(B.BMMC00,''))||' '||(select nvl(ZWXM00,'') from BM_YGBM00 where YGBH00=A.YSGZH0) into Pbrxm00 from YF_YZYPSQ A,BM_BMBM00 B where A.DQKS00 = B.BMBH00 and (A.YPQLPC = PYPCKPC and PYPCKPC>0 and A.CKDH00=PDJH000) and rownum=1 and YPNM00=PYPNM00; --end if; --end if; --end if; return Pbrxm00; end;