^^ This.
Also, i believe it illegal discrimination, to not hire someone merely on the grounds they have a script for what the test positive for, that's a controlled substance. ADA legislation prohibits that so long as you disclose it beforehand, the drug is legal, you have a prescription, and the usage doesn't affect the performance of your job.
Which is really the only test an employee should be held to, if the are a crappy employee because they are abusing drugs, and won't stop, fire them because they are a crappy employee. This a very big issue associated with prohibition of drugs imho.
If i was an employer, i really wouldn't care what you did in your private life and your own body, so long as you do your job well, and it doesn't affect your performance at work. If you are on a medication/or medical cannabis, if it doesn't affect the performance of your job, it should not be an issue, and the only person who has a problem with that is the feds.
The gestalt of that is a quote i remember from somewhere, "judge a man by the quality of his work, not the contents of his piss".
In certain industries though, i can see where testing is necessary for high risk jobs, but only if there an accident where there's reasonable suspicion to believe they were intoxicated with X illegal/legal drugs when an accident occurred that caused considerable damage, death, injury, or considerable monetary loss on the behalf of the employer.
That would be hard though, as you would have to get a test quickly and then determine the level of intoxication the employee was at when the accident happened, to know if it was because they were abusing legal drugs they have a script for, illegal drugs (imho there should only be one category, drugs, but that's another topic) or if they were taking the medication as prescribed.
IE quantitative concentrations of the drug, that show the concentrations of the drug used prescribed was much lower than what they were at at the time of the incident. But that opens a whole nother can of worms regarding diverse biochemistry in the metabolism of drugs across the population.
Though a good employer should be able to weed out individuals that abuse drugs, and won't stop doing so, or there was a serious incident while they were intoxicated. Simply because they did not do what was required to hold that job, and would have been fired even if drugs weren't involved.
Then, if you are still qualified for your job, and can perform your abilities to the extent required beforehand, it should not be legal to discharge someone for that. You had a medical problem, and you medically got treatment.
But like i said, technically they would be discriminating against your for medical reasons to deny employment only on the grounds of you taking legally prescribed drugs, as instructed by a MD.
Source-
ADA act legislation text