This had nothing, nothing, to do with your medication. This had everything, everything, to do with you being a good little boy/girl.
I think the problem with these situations is pretty much the same every time: The passenger is trying to manage the rational and obvious problem (in your case, you are working the problem of getting your prescriptions on the plane with you) and the screener is trying to manage a more subtle problem (working the problem of his or her own ego.) We're never on the same page.