It should be legal. Caveat Emptor applies always. to everything. I'd rather have choices available in a marketplace rather than a nanny state stifling innovation through its own incompetence.
With computerized registers and loyalty programs, it is way too easy to profile. I am not too worried about looking like I chug too much aspirin; it's the further out assumptions or speculations that models (like I myself once designed or otherwise) might make that I worry about, that would not require proof, and would not be documented somewhere. I mean there is also stuff "like" congestion pricing to worry about, and maybe that would work better to make people think about liberties and tech. Dunno.
in the specific case of this article, "innovation" and "choice" are exactly the problem here. we know what works well - they're well-studied generic compounds. there's no social reason whatsoever that "dayquil" or "tylenol" or "sudafed" should exist when generics are readily available and clearly labeled.