Buying in large well-established stores is a good strategy.
As to Ambien, etc. be aware that, though the government interferes minimally in the sale / dispensing of various drugs one would require a prescription for in "el norte," the government is significantly more zealous about controlled drugs like benzodiazepines, soporifics, sedative-hypnotics and their ilk.
And you might not be able to find the latest or most effective drugs for other problems (e.g. Malarone as a malaria preventive.)
DO check expiration dates ("fecha de caducidad",) how the medications have been kept (how warm is the temperature at mid-day?) even in larger stores.