Patients aged 30-60 years with a body-mass index of 35 kg/m ( 2 ) or more and a history of type 2 diabetes lasting at least 5 years were randomly assigned ( 1:1:1 ) , via a computer-generated randomisation procedure , to receive either medical treatment or surgery by Roux-en-Y gastric bypass or biliopancreatic diversion .