Interesting problem. I would have suggested to secure the bottles instead. Make a bottle that spits out a pill at an interval after authenticating the user (with one unauthenticated emergency pill per bottle) and tamper proof it by having a layer of air-pressure gap and conductive epoxy where if the pressure drops or voltage differential changes a solution rendering the pills useless is released(dilluted HCL?), that way you need to pierce it under a bottle specific air pressure an figure out the bottle specific votage for the epoxy. Sensors and all included I speculate under $30 shipped is doable for very high risk and addictive pills that cost a lot anyways.