Your question touches on sensitive medical issues that more information would be needed to assess, and a public forum really isn't appropriate for that discussion. Depending on the nature of your medication and what condition requires it, you may have protections under the ADA. I say may because the ADA does not cover all medical conditions. However, even if your situation is because of your medication, proving that may be difficult. Your question is complex and would be better served in a detailed consultation. Use the Find a Lawyer function to locate a discrimination attorney in your area.
I agree with Janine's response to you and would add this additional comment. A prescription may be legal but still interfere with your ability to perform the essential functions of your job in which case your employer may not be discriminating. Only a full investigation of your facts as Janine has indicated would answer that question.
As an aside, some states permit legal prescriptions for marijuana; however its use is still not legal under federal law. Depending on the state law your employer may still be able to terminate you if you test positive for medical marijuana regardless of having a legal prescription for it. That is the opinion issued by the California Supreme Court. If you are in a federally regulated job that requires random testing, i.e., Department of Transportation, you could be terminated for marijuana use as well even if you have a legal prescription. You didn't say what the prescription was for and you shouldn't in a public forum. Speak with an employment attorney in your state to get the best advice.