Four things, in this order. First, the pharmacist or technician enters the prescription into the system and checks it against the prescriber's instructions. Second, the pharmacy runs it through your insurance plan, which returns the price your plan has negotiated with that pharmacy. Third, the pharmacist performs a drug utilization review — a screen for interactions, allergies, duplicate therapy, and dose accuracy against everything else you are taking. Fourth, if everything checks out, the prescription is filled and dispensed.
Most patients only see the fourth step, and often only the price at the end. But the second and third steps are where most of the value actually lives. The price is a number; the drug utilization review is a clinician catching something before it harms you.