create or replace view vw_bq13_ypyzzxd_qxcf as
select
YZID00,YZMXID,ZYID00,CLBZ00,BQH000,KSH000,YFID00,YPYFMC,YZZT00,BZ0000,CH0000,ZYH000,XM0000,MCSL00,JLDW00,
PCMC00,ZXDDY0,YFLBID,LYL000,ZYFYDW,YPLBBH,YPNM00,LRRQ00,LRSJ00,QYRQ00,QYSJ00,TZRQ00,TZSJ00,
YPMC00,YPGG00,MCSLDW,SRCS00,YZNR00,YZNR04,YZNR01,MIN(ZXRQ01) AS ZXRQ01,
substr(MIN(ZXRQ01),1,4)||substr(MIN(ZXRQ01),6,2)||substr(MIN(ZXRQ01),9,2) AS ZXRQ00,
decode(YZCLLB,'正常','','自备药','[备]','门诊带药','[门]','嘱咐','[嘱]') YZCLLB
--'[嘱]' YZCLLB
, YZFW00,
 decode(CLBZ00,'0','长','1','临') CLBZ02,
DECODE(PCMC00,'s.t.','(急)','') AS PCMC02,PSPC00,
XB0000,NL0000,decode(YYZF00,'','','【嘱】') YYZF00,YZCLLB YZCLLB2,TQBZ00,GWBZ00,LRRXM0
 from VW_BQ13_YPYZZXDNEW_CF
 group by(
 YZID00,YZMXID,ZYID00,CLBZ00,BQH000,KSH000,YFID00,YPYFMC,YZZT00,BZ0000,CH0000,ZYH000,XM0000,MCSL00,JLDW00,
 PCMC00,ZXDDY0,YFLBID,LYL000,ZYFYDW,YPLBBH,YPNM00,LRRQ00,LRSJ00,QYRQ00,QYSJ00,TZRQ00,TZSJ00,
YPMC00,YPGG00,MCSLDW,SRCS00,YZCLLB,YZNR00,YZNR04,YZNR01,ZXRQ01,yzfw00,PSPC00,XB0000,NL0000,YYZF00,TQBZ00,GWBZ00,LRRXM0
 )
 having 1=1 ORDER BY CH0000,CLBZ00,ZXRQ01,YZID00,YZMXID
;
