@ElizaBennett - You make a nice point, which is basically that it's important to consider not only the effects of the medicine on your unborn baby, but also the effect of your condition!
For instance, I had a bad cough in late pregnancy, around thirty weeks. My doctor was concerned that this could cause preterm labor or premature rupture of membranes. So he put me on a codeine cough syrup. He said that while taking narcotics during pregnancy is certainly not ideal, it was a heck of a lot better than being born at thirty weeks. And because I was far from my due date, there was certainly plenty of time for the drugs to clear baby's system before delivery--that's really important with narcotics, because otherwise baby goes into withdrawal.