Hospitals said they lost money on Medicare patients. Some made millions, a state report has found