Microscopic calculation of medium corrections to pion-nuclear elastic scattering