Taking the medication exactly as prescribed is not a complete defense, but it matters for negotiations and at trial. If you took a therapeutic dose and were not actually impaired, the case may resolve favorably. Lab issues, polypharmacy, and time-of-use defenses also apply when the prescription was followed correctly.
