A closed-loop drug delivery system uses patient response and rule based decision making methods to achieve operator specified responses for diagnostic purposes. In the preferred embodiment, cardiac diagnosis is performed by pharmacologically stressing the heart by administration of an exercise simulating agent drug. In the preferred method, a protocol is defined, which preferably includes a target for a physiologic variable, such as heart rate, and a plan to achieve that target value. Preferably, the plan includes a specification of the desired rate of increase in that variable, such as the rate of increase in the heart rate per minute. The plan comprises the desired changes in the physiologic variable as a function of time. While any desired function may be used, the more common modes include RAMP, HOLD, LEVEL and TARGET mode. In one aspect of this invention, the protocol may be varied by the operator after drug administration has begun. Further, in one embodiment, the protocol includes a definition of an acceptable zone of deviation from the plan, such that if the patient physiologic variable deviates from the permissible zone, alternate control rules are implemented. Preferably, saturation detection and avoidance is implemented.