That’s probably dependent by state. For example, some states don’t allow for doctors’ offices to dispense medications, others have restrictions on controlled substance prescriptions.
Most however, put the responsibility more on the pharmacy than the prescribing doctor to police that. In other words, a doctor can prescribe what he wants, but the pharmacy is who has to make sure they don’t give out too much at once, or whatever. It almost certainly requires a call back to the prescribing provider saying “Hey Dr. X, you know that this patient has already been prescribed so much Tramadol- he can’t have more until 10 days are up” (or whatever), and then the Dr. will adjust his prescription/treatment plan accordingly.