forked from mtikoian/sql-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnthem Risk Adjustment.sql
More file actions
52 lines (46 loc) · 1.64 KB
/
Copy pathAnthem Risk Adjustment.sql
File metadata and controls
52 lines (46 loc) · 1.64 KB
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
drop table #temp
select
distinct
ac.RequestID
,ac.MemberName
,ac.DOB
,ac.AllProviders
,ac.Project
,ac.Region
,ac.ProjectDOS
,ac.TotalRequests
--,ac.RequestsW/DoS
,ac.[Due Date]
--,cast(tdl.orig_service_date as date) as 'Service Date'
,arpb_tx.service_date as 'Service Date'
into #temp
from claritychputil.rpt.anthem_toledo ac
inner join clarity.dbo.patient pat on pat.pat_last_name = ac.[Last Name] and pat.pat_first_name = ac.[First Name] and pat.birth_date = ac.[DOB]
left join clarity.dbo.arpb_transactions arpb_tx on arpb_tx.patient_id = pat.pat_id
left join clarity.dbo.clarity_epm epm on epm.payor_id = arpb_tx.original_epm_id
--left join clarity.dbo.clarity_loc loc on loc.loc_id = arpb_tx.loc_id
left join clarity.dbo.zc_loc_rpt_grp_10 sa on sa.rpt_grp_ten = loc.rpt_grp_ten
where arpb_tx.tx_type_c = 1 -- charges
and arpb_tx.service_date >= '2016-01-01 00:00:00'
and sa.rpt_grp_ten = 18
--and original_epm_id in (1005, 3010) -- ANTHEM MEDICARE, ANTHEM
--and ac.requestid = 'A643-161224'
and arpb_tx.void_date is null
;
select distinct
FQ.RequestID
,fq.MemberName
,convert(varchar(10),fq.dob,101) as 'DOB'
,fq.AllProviders
,fq.Project
,fq.Region
,fq.ProjectDOS
,convert(varchar(10), fq.[Due Date],101) as 'Due Date'
,Stuff((SELECT distinct concat(',', convert(varchar(10), sq.[service date], 101), ' ')
FROM #temp as SQ
where Sq.RequestID = fq.RequestID
FOR XML PATH('')), 1, 1, '')
as 'Service Date(s)'
from
#temp as FQ
order by membername