lis8.0/sql/lis8.0/web_fs_printReport.sql
2025-11-14 18:16:33 +08:00

71 lines
3.1 KiB
Transact-SQL

CREATE VIEW [dbo].[web_fs_printReport]
AS
select isnull((select bz from com_dict where zdlb='HOS' AND zddh=a.yljg),a.yljg) yljg,a.jyrq,
--a.yq,
z.yqmc as yq,
a.ybh ,a.brxm,
--a.brdh,
e.bz1 brdh,
a.ch,
--a.jymd
e.jymd as jymd
,a.zd,isnull(e.sqsj,a.sqsj) as sqsj,isnull(e.cysj,a.cyrq) as cyrq,isnull(e.jssj,a.sqsj) as lastdt,a.confirmdt,a.confirmer,a.sqh,
(CONVERT(varchar(12), a.jyrq, 112)+'_'+rtrim(a.yq)+'_'+a.ybh) as bgdh,y.xmdh,y.csjg,y.refs,y.dw,y.result_flag,z.yqmc,z.yqdl,
(select c.xmmc from xm_info c where c.yq=a.yq and c.xmdh=y.xmdh) as xmmc,
(CONVERT(varchar(10),a.nl)+(select b.zdmc from com_dict b where zdlb='AU' and a.nldw=b.zddh)) as nl,
(select b.zdmc from com_dict b where zdlb='DP' and a.ksdh=b.zddh) as ksname,
(select b.zdmc from com_dict b where zdlb='PT' and a.brly=b.zddh) as brlyname,
(CASE WHEN a.brxb = '1' THEN 'ÄÐ' WHEN a.brxb = '2' THEN 'Å®' ELSE 'ÆäËû' END) as brxbname,
isnull((select b.zdmc from com_dict b where zdlb='BT' and a.yblx=b.zddh),a.yblx) as yblxname,
isnull((select b.zdmc from com_dict b where zdlb='SRD' and a.sjys=b.zddh),a.sjys) as sjysname,
b.dyxh,
(case y.result_flag when 'Q' then '+' when 'L' THEN '¡ý' WHEN 'H' then '¡ü' else '' end) flag,
a.yhdh AS lastuser,
(select dzqm from com_usr c where a.confirmer=c.yhdh) confirmerpic,
(select dzqm from com_usr c where a.yhdh=c.yhdh) as lastpic,a.bz AS bz
from lab_pat a left join lab_reqmain e on a.sqh=e.sqh,lab_result y,lab_instr z ,xm_info b
where y.yq=b.yq and y.xmdh=b.xmdh and a.jyrq=y.jyrq
and a.yq=y.yq and y.ybh=a.ybh and a.brxm is not null and a.yq=z.yq
and a.brly='3'
and a.jyrq >getdate()-360
union all
select isnull((select bz from com_dict where zdlb='HOS' AND zddh=a.yljg),a.yljg) yljg,a.jyrq,
--a.yq,
z.yqmc as yq,
a.ybh ,a.brxm,
--a.brdh,
a.brdh brdh,
a.ch,
--a.jymd
e.jymd as jymd
,a.zd,isnull(e.sqsj,a.sqsj) as sqsj,isnull(e.cysj,a.cyrq) as cyrq,isnull(e.jssj,a.sqsj) as lastdt,a.confirmdt,a.confirmer,a.sqh,
(CONVERT(varchar(12), a.jyrq, 112)+'_'+rtrim(a.yq)+'_'+a.ybh) as bgdh,y.xmdh,y.csjg,y.refs,y.dw,y.result_flag,z.yqmc,z.yqdl,
(select c.xmmc from xm_info c where c.yq=a.yq and c.xmdh=y.xmdh) as xmmc,
(CONVERT(varchar(10),a.nl)+(select b.zdmc from com_dict b where zdlb='AU' and a.nldw=b.zddh)) as nl,
(select b.zdmc from com_dict b where zdlb='DP' and a.ksdh=b.zddh) as ksname,
(select b.zdmc from com_dict b where zdlb='PT' and a.brly=b.zddh) as brlyname,
(CASE WHEN a.brxb = '1' THEN 'ÄÐ' WHEN a.brxb = '2' THEN 'Å®' ELSE 'ÆäËû' END) as brxbname,
isnull((select b.zdmc from com_dict b where zdlb='BT' and a.yblx=b.zddh),a.yblx) as yblxname,
isnull((select b.zdmc from com_dict b where zdlb='SRD' and a.sjys=b.zddh),a.sjys) as sjysname,
b.dyxh,
(case y.result_flag when 'Q' then '+' when 'L' THEN '¡ý' WHEN 'H' then '¡ü' else '' end) flag,
a.yhdh AS lastuser,
(select dzqm from com_usr c where a.confirmer=c.yhdh) confirmerpic,
(select dzqm from com_usr c where a.yhdh=c.yhdh) as lastpic,a.bz AS bz
from lab_pat a left join lab_reqmain e on a.sqh=e.sqh,lab_result y,lab_instr z ,xm_info b
where y.yq=b.yq and y.xmdh=b.xmdh and a.jyrq=y.jyrq
and a.yq=y.yq and y.ybh=a.ybh and a.brxm is not null and a.yq=z.yq
and a.brly='1'
and a.jyrq >getdate()-360
GO