Dr. Warren Silberman, chief of airmen certification for the FAA's Aerospace Medical Certification office in Oke City, says you can fly after 24 hours.
Refer to page 8 in the following Medical Bulletin:
Search Results
This is not to say the drug will not appear on a drug screen. But if you have the prescription and waited the 24 hours, seems you'd be okay, depending on the underlying cause of the pain.
If you want totally clean urine, 24 hours is probably not enough.