The former X Factor judge opened up about her battle with the health problem that went undiagnosed for years