it is legal for the pharmacy to keep your script. While in your situation, I don't feel it was appropriate and a simple phone call could have cleared up any questions or confusion, the pharmacy is under no obligationt to fill yoru script early, even if you offer to pay cash for it. Pharmacies are under a lot of scrutiny, and unfortunately, the "tactic" of "paying cash instead" is one that many drug seekers use in order to avoid the system, therefore, many pharmacies adopt a no cash policy if you have insurance that normally would cover the medication. And with a request for an early refill (even though your situation was completely legitimate), keeing the script is a way the pharmacy can make sure it's not simply taken to a different pharmacy to be filled.
My suggestion would be to either go back to the pharmacy and request the pharmacist call your doctor while you're there and have the doctor verify that he had, in fact, told you to take more of your pain meds than previously prescribed and that was the reason you were running out early - and that he/she approves an early fill on the script. The other option would be to have your doctor call the pharmacist and do the same thing. The pharmacist may even request that your doctor fax something over to him stating the same thing (that way if they are ever "audited" or checked, they have proof that the doctor has aprpvoed the fill).
Once the pharmacist and doctor have talked to one another, the pharmacist may possibly fill the script for you, however, it's not guaranteed.
I had pretty much teh same situation one time when my pain was out of control and my doctor had told me to take two pills at a time instead of one, so therefore, like you, it made it so that my script did not last as long as it normally would have. When I went in for a refill, I explained the situation to the pharmacist and he simply told me to have my doctor call him and let him know that he a) was, in fact, aware that I had been taking more of my meds than the original script called for - under his direction and b) that he was authorizing an early fill on the script. My doctor did that, and I was able to get my refill - insurance still would not pay because the timing was not right for them to do so, but at that point, the pharmacist was comfortable with me paying as a cash customer.
Did you explain the situation with the accident before the pharmacist attempted to fill your script through the insurance or had he already tried to put it through insurance when you explained it to him? That may make a difference also. In my case, I explained right up fromt even before requesting the refill, so they didn't even make an attempt with the insurance company. It makes it a little more difficutl for the pharmacy if they HAD attempted to put it through the insurance and it was denied becasue then if they fill it, it can send up red flags to the DEA, thinking they filled it when they knew it had been denied by insurance. However, if your doctor and pharmacist speak to one another (and like I said, maybe your doctor can fax something in writing to thepharmacist), you may be able to get it filled.
Even if the pharmcist does not agree to fill yoru script even after speaking with your doctor, by having them speak, your doctor may be more willing to re-write the script for you becuase of the problem with the pharmacy.
Best of luck.
Oh, man. You're in a tough situation. I'm surprised that they kept your prescription. I would say that it seems that you really have no choice but to call your doctor and ask for another script.