If you are not experiencing constant or frequently-recurring pain, then it might be helpful to think about activities that appear to trigger your pain, such as walking or riding in a car, for example. If there is a link between the pain and something you do, then you can arrange to take the medication in sufficient time to have sufficient relief in place when you undertake the activity. Breakthrough pain can occur for no obvious reason, or as the result of some activity that seems to trigger it, such as walking, coughing, etc. Regardless of the reason, it's likely that you'll need an additional medication to use during these times. Sometimes I've had difficulty in finding a pharmacy willing to fill my pain medication prescription.
Some pharmacies are reluctant to stock opioid medications, because of a variety of concerns.
Speak with your health care provider or your hospital social worker or pharmacist to learn the names of pharmacies that stock the medication you need and arrange to have your prescriptions filled there. I don't have health insurance that covers my prescription medications for pain, and I can't afford to pay for them. Many pharmaceutical companies have programs to provide prescription medications to patients who cannot afford to pain for them. Most programs require your physician to make the contact regarding the medication. I take pain medications around the clock, and sometimes this means I have to wake myself up several times during the night to take a pill.