How do you define failing health? If you could, then it may be possible to frame rules. But I suspect that this is too difficult to do.
Besides, life and death are not easily predicted. In 1991, Narasimha Rao told Rajiv Gandhi that his health was failing and so, he would retire and move to Andhra. As it turned out, an assassin took Rajiv's life while Narasimha Rao survived to become a full-time Prime Minister.