This is how Australia does it.
The PBS - Pharmaceutical Benefits Scheme - provides heavily subsidised prescription meds to any with a script from a Doctor (and super cheap for certain categories like Age Pensioners, disabled etc).
The catch is, pharmaceutical companies have to try and get their drugs on the PBS, and to do that they have to offer up evidence that their drug is better than those currently on the PBS, and quantify the extra benefit. For some drugs (like psychiatric meds), just show ANY benefit over placebo is a huge hurdle. Then quantifying the benefit to tax payers to justify what gets paid per pill.
Sometimes it limits the quick adoption of new drugs (although there are other paths for experimental treatments), but the main thing it provides is a science based monopoly buyer. The drug companies don't get to artificially court demand, and extract super high margins without showing they're worth it.
Oh, and it is illegal to advertise prescription meds in Australia. None of these ads full of older gents "Talk to your Doctor today about Cialis."
The system is very effective.