Hi
I am suspecting issue with below WHERE condition. So first check below where condition syntax is working or not ..then you can use in the derive table.
where EMR_REPORTING.dbo.vMH_MEASURE_PRACTICE.RPT_YEAR_MONTH = convert(varchar(6), dateadd(MM,-3, convert(datetime, substring(cast(@rpt_year_month as varchar), 5,2) + '/' + '30'
+ '/'+ substring(cast(@rpt_year_month as varchar), 1,4))), 112)) b