--医嘱管理直接开的医嘱
SELECT *FROM (  SELECT A.*,(select decode(count(1),0,null,'4+7') from BM_YDTSSX where YPNM00=A.YPNM00 and SXBH00='02') YPSX00,
(select decode(C.YBZXLB,'0','0',decode(C.ZFBL00,1,'$0000FF',(decode(c.bz0000,'','','16711935')))) from VW_BM_YBSFDY_ZYDZBL C where
c.SFYP00='Y' and c.YBZXLB <> '0' and c.YXBZ00='1' and c.sfxmid=a.YPNM00 and c.ybzxlb='0' and c.YBBRLB='0' and rownum=1) COLOUR 
FROM VW_ZS_YPSRF0 A WHERE ( ((YFBMBH = 163 and LBBH00 = '0') OR (YFBMBH = 166 and LBBH00 = '1')) ) AND  
(YPBM00 like 'wssb6%'  OR PYSM00 like 'wssb6%'  OR bmpysm like 'wssb6%' )  AND  YLBH00 like'%' AND (LBBH00='0' OR  LBBH00= '1' OR LBBH00='3') 
 and a.YPNM00 not in (select YPNM00 from VW_YS_TSXZYP)  ORDER BY a.PYSM00,a.YPMC00 asc,a.ykkcsl desc) WHERE ROWNUM<=100;


--修改时开的医嘱
SELECT *FROM (  SELECT A.*,(select decode(count(1),0,null,'4+7') from BM_YDTSSX where YPNM00=A.YPNM00 and SXBH00='02') YPSX00,
(select decode(C.YBZXLB,'0','0',decode(C.ZFBL00,1,'$0000FF',(decode(c.bz0000,'','','16711935')))) from VW_BM_YBSFDY_ZYDZBL C where 
c.SFYP00='Y' and c.YBZXLB <> '0' and c.YXBZ00='1' and c.sfxmid=a.YPNM00 and c.ybzxlb='0' and c.YBBRLB='0' and rownum=1) COLOUR   
FROM VW_ZS_YPSRF0 A WHERE (1=1) AND  (YPBM00 like 'wssb6%'  OR PYSM00 like 'wssb6%'  OR bmpysm like 'wssb6%' )  AND  YLBH00 like'%' 
AND (LBBH00='0' OR  LBBH00= '1' OR LBBH00='3')  and a.YPNM00 not in 
(select YPNM00 from VW_YS_TSXZYP)  ORDER BY a.PYSM00,a.YPMC00 asc,a.ykkcsl desc) WHERE ROWNUM<=100;