Skip to content
Snippets Groups Projects

Update patient_mgb_patients.sql for max(EligibilityDTS) precision

Merged Boukus, Ellyn R requested to merge eb_PatientMGBPatients_UpdateMaxElig into main
1 file
+ 5
1
Compare changes
  • Side-by-side
  • Inline
@@ -100,13 +100,17 @@ with pcmh_practice as (
inner join (
select
pd.PlanCD,
pd.ProductTypeCD,
pd.InsuranceTypeCD,
max(edd.EligibilityDTS) as EligibilityDTS
from Payer.HealthPlanDM.MemberMonthDetailFact mmdf
inner join Payer.HealthPlanDM.EligibilityDateDimension edd on mmdf.EligibilityDateID = edd.EligibilityDateID
inner join Payer.HealthPlanDM.ProductDimension pd on mmdf.ProductID = pd.ProductID
group by pd.PlanCD
group by pd.PlanCD, pd.ProductTypeCD, pd.InsuranceTypeCD
) mce on edd.EligibilityDTS = mce.EligibilityDTS
and pd.PlanCD = mce.PlanCD
and pd.ProductTypeCD = mce.ProductTypeCD
and pd.InsuranceTypeCD = mce.InsuranceTypeCD
left join Payer.Reference.ReportGroup rg on mmdf.PCPReportGroupID = rg.ReportGroupID
left join Epic.Patient.Patient_Enterprise ptn on mdd.EDWPatientID = ptn.EDWPatientID
left join Integration.MasterReference.Patient mrp on mdd.EDWPatientID = mrp.EDWPatientID
Loading