I've been thinking about something along these lines for a while. A few months ago the science fiction writer William Hertling wrote an interesting blog post that, among other things, predicts we will have implantable computers by 2030.
http://www.feld.com/wp/archives/2012/06/how-to-predict-the-f...
It strikes me that this will enable a whole range of behavior optimization based on the computer having access to info provided by your body chemistry.