I'm intentionally not reading the non-edited version of this question, because if it is more personal in nature @WaxEagle is right, you should ask a priest (one you know is a really straightforward confessor) for advice.
It's not the medication that is treated as grave matter by the Catholic Church, it's contracepting itself.
Contrary to popular belief, the Church does not oppose artificial birth control because it’s artificial. She opposes it because it’s contraceptive. Contraception is the choice by any means to impede the procreative potential of a given act of intercourse. In other words, the contracepting couple chooses to engage in intercourse, and, foreseeing that their act may result in a new life, they intentionally and willfully suppress their fertility - Christopher West, The Good News about Sex and Marriage
And as far as being prescribed contraceptives by a hospital, you'll know when you get them at a Catholic Hospital (if your doctor says you need them):
Any cooperation institutionally approved or tolerated in actions which are in themselves, that is, by their nature and condition, directed to a contraceptive end . . . is absolutely forbidden. -#44 Ethical Religious Directives
I'm not a doctor, I'm not a theologian either (but I play one on the Internets), but I've been told by my wife who is still not a doctor, but is a woman, that prescribing contraceptives to young women to treat other disorders is mostly a rouse to get them on contraceptives in the first place.
Furthermore, the harm that contraceptives cause the body may outweigh the benefits.
The medical community clearly understands that there are serious medical side effects from the specific use of the injectable or non-injectable hormones. While some claim that the good outweighs the bad, too many healthcare professionals continue to prescribe and/or assist with birth control and abortion with little concern for the consequences. couple to couple league
Most birth control drugs use a combination of two female hormones, estrogen and progestin, to stop ovulation and thicken cervical mucus, which helps block sperm. For decades many women have reported bloating and mood swings as side effects. Huffington post 12/6/11
So, as a rule, yes, it's the contraception action which is at issue here, not the contraception itself. But if you dig a little deeper and you want to be ever faithful to the teachings of the Church, it's a bridge that is better left uncrossed.
Natural Family Planning Resources
Teachings of the Catholic Church regarding Contraception