Thyroid function could be key to surviving a hospital stay research reveals