OiD is right, The number 1 treatment for insomnia is physical activity. Whatever you can, on a regular basis. Try swimming, it is low impact for your knees and back. The second is called "learned insomnia," which is where people do things in the bedroom other than sleep and sex. ex: laying in bed watching TV, you train youself to stay awake and watch the movie, and not sleep. So, no computer, books, tv, in the bedroom. You should try to make a regular sleep cycle. Go to sleep at 10pm, get up at 6 am. If you don't fall asleep in 10 minutes, get up and go to the livingroom and read or something. Try again in an hour.
For pain, if the problem is swelling, vicodin won't help, because tylenol has no antiinflammatory properties. You need to "get ahead" of the swelling by taking some sort of NSAID on a regular basis, like IBUprofen. BUT! NSAIDs can make other problems worse, like ulcers, so you should probably go to the doctor and discuss other options. AND, narcotics (almost all) will cause respiratory suppression, which will make your sleep apnea worse.
Your doctor isn't a mind reader. If you don't go see him and tell him you are having a problem, he won't change your prescription.