How should the judiciary balance ethical, legal, and emotional aspects in cases involving withdrawal of life-sustaining treatment?

The Supreme Court is considering a plea to withdraw life-sustaining treatment for Harish Rana. I want to understand how courts can approach such sensitive issues that involve medical ethics, individual rights, and family concerns.