create or replace view vw_yf_yfdydjbq as select distinct ' ' BZJHM0, c.CKDH00 ID0000, c.BRXM00, c.CH0000, c.YZID00 CFLSH0, decode(DJSFQS,'1','全送', '') QSMC00, (select BMMC00 from BM_BMBM00 where BMBH00 = c.BQBMBH) BQMC00, (select BMMC00 from BM_BMBM00 where BMBH00 = c.DQKS00) KSMC00, (select BMMC00 from BM_BMBM00 where BMBH00 = c.ssKS00) KSMC01, --新增所属科室字段 by cly 20250729 药品标签打印显示病人所在科室 case when c.YPYFMC like '%内服%' then '内服' when c.YPYFMC like '%冲服%' then '冲服' when c.YPYFMC like '%口服%' then '口服' when c.YPYFMC like '%薰洗%' then '外用' else replace(c.YPYFMC,' ','') end YPYFJC, --药品用法简称 case when e.DJSFQS='1' then '' else substr(b.ZXRQ00,1,4)||'-'||substr(b.ZXRQ00,5,2)||'-'||substr(b.ZXRQ00,7,2) end YYRQQS, --服药日期全送 case when c.YFSMMC like '%浓煎%' then '浓煎' else c.YFSMMC end YPYFSM, --药品用法简称 '1'||decode(mod(length(c.YZID00),2),0,'0','')||c.YZID00 TXM000, (select distinct nvl(max(DYCS00), 0) from YF_YPCKD0 where CKDH00 = c.CKDH00) DYCS00, c.BQBMBH BQBH00, c.YZXZ00, '1&'||b.ID0000 TXM100, '1&'||c.YZID00||'&'||b.ZXRQ00||'&'||nvl(b.ZXSJ00, '00:00:00')||'&0&0' TXM200,--1&医嘱ID&启用日期&启用时间&0&0 c.zyh000 , e.PCMC00, c.Zyts00, c.ZYDJS0, c.ZYDJS0*2 as ZYDJS1 --by cly 20250624 林珍红要求代煎单包数按照乘2取值 ,case when c.fysj00<'15:00:00' then TO_CHAR(TRUNC(SYSDATE) , 'YYYYMMDD') else TO_CHAR(TRUNC(SYSDATE) + 1, 'YYYYMMDD') end YYRQQS1, --by cly 20250624 林珍红要求 代煎单煎药日期取值,当发药日期大于15:00:00,体现第二天日期 c.fysj00 from YF_YZYPSQ c,BQ_YZCFMX b, BQ_YPYZ00 e where c.YZID00 = b.YZID00 and c.YZID00 = e.YZID00 and C.CXBZ00= 'Z' and c.YPDLBH = '2' and c.ZYDJS0 > 0 and b.TQBZ00 = '1';