A device and a method for treating a medical condition include a reversible memberdisposed in a patient's gastro-intestinal tract, and a dispensing membercoupled to the reversible member that delivers a drug and/or a noxious when a predeterminedsubstance is detected. In a different embodiment, the device and method of thepresent invention include a polymer infused with a drug and disposed into a preformedshell inside the gastric space, where it expands and hardens, releasing the drugover time. Both the casing and the polymer may be biocompatible. The present inventionenables the slow-release of anti-addictive agents without patient tamperingand with the appropriate dosage. Ancillary systems such as sensors, actuators,refill and recharge ports, and communication and data processing units may alsobe included.