This is a very loaded question, and one that is hard to analyze so quickly, but I'll give you a 10,000 foot view. Unfortunately, jails are notorious for failing to provide medication --- and oftentimes, the fail to provide validly prescribed medications that have an impact on the physical and mental stability of an inmate. That can have an impact on a defendant's ability to comprehend the actions they are taking, but it can be a difficult thing to prove. That's because a judge, typically, painstakingly asks questions during part of a plea hearing that address questions of understanding, duress, coercion, etc. Your defense attorney and you sign off on any plea, and in so doing, often acknowledge that you were of sound mind when you signed it. Can a plea be reversed on this issue,? Yes. It is difficult? Yes. It requires hearings before the judge, perhaps medical testimony, and/or post-conviction relief proceedings. Then, a lot is going to hinge on the seriousness of your illness and how not taking medicine can impact your ability to knowingly and voluntarily enter into a plea --- but you still appear to be lucid enough to a judge to have accepted it in the first place. The bottom line, hire a lawyer to look into it if you truly believe it was in error.
All of the information that you provided here is interesting and enough to at least talk about the issue of involutaily entering into a plea of guilty HOWEVER to OVERCOME the plea and reder it void or to be allowed to withdraw it, even after days or weeks, let alone years in this case is very, very unlikely and a normal person with normal resources would find it long and very expensive to even try it. The first thing you would have to do is get a copy of the proceeding where you entered your plea of guilty to see exactly what was said, what questions the Judge asked of you and your answers. What you said and how you said them are very important in a case like this. Good Luck to you.
If you have exhausted your state and federal remedies, and you believe you have discovered additional newly discovered evidence that could support your position, then it seems you're asking several questions. 1. Have you exhausted your remedies? You have a right to post conviction relief and that is where most pleas are challenged. If your counsel missed this and did not investigate properly, then you have a "successor PCR" when you argue you were not properly represented at the post conviction stage. If you pursued any of this pro se, then you waive ineffective assistance of counsel. You need to consult a post conviction lawyer, or the clinical division of a local law school.