1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
|
ALTER PROCEDURE [dbo].[Report_RPT037_grpKey_Indicator_Performance]
@QcatName nvarchar(50),@QReportType nvarchar(50),@StartDate Datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @NumberOfQuestion int,@ChartType char
select @NumberOfQuestion=count(*) from RegionalReportQI
where ReportType=@QReportType and QuestionCategory=@QcatName
select @ChartType=ChartType from RegionalReportQI
where ReportType=@QReportType and QuestionCategory=@QcatName
-- Insert statements for procedure here
--Get Beddays , Sum of answer for each facility
declare @FacilityValues table
(
QuestionCategory varchar(50),
CareLevel varchar(100),
Region varchar(100),
MemberName varchar(100),
SumAnswer int,
BedDays int,
Beddays000 float,
CountOfAnswer int,
MonthReported float,
UCAMeans float,
Expected int,
ExpectedReal float,
Lower2s float,
Lower3s float,
Upper2s float,
Upper3s float,
Flag varchar(20),
ReportStandard int, --int of Month Reported
fDementia nvarchar(50),
avgBeds int, --avg beds for member
avgAnswer int --avg answer for member work with avgbeds to get the new expected value
);
insert into @FacilityValues (QuestionCategory,CareLevel,Region,MemberName,SumAnswer,BedDays,
CountOfAnswer,MonthReported,fDementia,avgBeds,avgAnswer)
select @QcatName,min([membertype]) as CareLevel,BGName,[Member Name] as MemberName,sum(answer) SumAnswer ,
sum((datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year([monthdate]) as varchar)+'-'+cast(month([monthdate]) as varchar)+'-01' as datetime)))))*beds) AS BedDays,
count(*) As CountofAnswer , cast(count(*) as Decimal)/ @NumberOfQuestion AS [MonthReported],
min(fDementia),
avg(beds),avg(answer)
from #temprpt037Monthqi
where EQBID in (select qid from regionalreportqi where ReportType =@QReportType and QuestionCategory=@QcatName)
and monthdate>=@StartDate
group by BGName,[member name] --Line 69
order by BGName,[member name]
--Get the Benchmark Value value sum(expected value for each question category
if @ChartType='U'
update TA set TA.UCAMeans=
(
select sum(ExpectURate) from #temprpt037BenchMeanQI TB where TB.fmembertype=TA.CareLevel
and TB.fDementia =TA.fDementia and --Line 77
TB.QBID in (select qid from regionalreportqi where ReportType=@QReportType and QuestionCategory=@QcatName)
)
From @FacilityValues AS TA
|