Fully relativistic ab initio treatment of spin-flip scattering caused by impurities