A historic former St Andrews mansion, which was once a hospital, has been put on the market.