Exact analytic relation between quantum defects and scattering phases with applications to Green’s functions in quantum defect theory