Agree with others - it will get expensive by the time you replace all of the components to make the conversion. In addition to the obvious bars and the shifters/brakes/stem already mentioned, don't forget about ergo grips and possibly bar ends, and you might need to replace all of the cabling and hydraulic lines too, depending on compatibility with the new levers and how much slack there is in the existing ones. It gets a lot more involved than it seems up front. You would probably be better off looking for a bike with similar geometry and component level that already has the flat bars.
Cheers
TRJB