Ok here's what I think
It is legal, because the pharmacist isnt a doctor, who has a patient-doctoer confidentiality agreement with you. It is, however, unethical not to mention unproffessional.
You might have been buying them for a friend, or anything! how rude! I'd have been angry and I would certainly NEVER go to that chemist again
I assume that your mother knew the chemist involved