Why is it safe for patients to drink barium sulfate even though barium ions are toxic?

Not absorbed. Barium is a heavy metal which is not absorbable. It therefore passes through your system unaltered. It is generally taken as a salt (barium sulfate), .
Barium is safe. Barium sulfate is the inert form that lets your digestive system be seen on x-ray, but is not absorbed in your system. It passes through.