If a health care provider is negligent, you may be able to hold that provider responsible for their negligence and for the damages that are suffered. However, that means that there actually has to be damages. In your case, since you were lucky and you didn't actually take the drugs or suffer any harm, your damages would either be very small or non-existent. This means it is generally not going to be worth it to sue.
Medical malpractice is a special body of tort law designed to provide compensation to those who are hurt by their doctors or healthcare providers. There are two things you need to prove in a malpractice case: that negligence (a breach of the standard of care) occurred, and that the negligence was a direct cause of some kind of harm.
The reason that both of these elements are required is because:
Thus, while you may be able to sue, you'd probably be awarded only nominal damages, which is a very, very small award (usually around $1 or $2) which indicates that you did have a legal cause of action but that you didn't suffer because of it. This generally means it is not worth it to sue.
If you are concerned about the pharmacy's carelessness, you should consider speaking with a lawyer. Your attorney can help you to determine if a lawsuit is worth it, or may be able to help you notify a state licensing board in your state about what went on so the proper steps can be taken to make sure the pharmacist is more careful in the future.