The first thing I would suggest is a second opinion. Sometimes endometriosis causes this type of pain. Before treating you psychologically, I’d want to be sure that the problem isn’t physical.
If you are medically okay, I’d want to know what happened a year ago that changed things for you. That might lead us to determine what could be making you so anxious that sex has become painful.
Unfortunately, once someone has experienced painful intercourse, it is only natural for the body to brace against the possibility of more pain when the couple tries again to have sex. The anxiety then creates more pain. This can become a vicious circle.
I’m sorry your doctor advised against sex. In my opinion, he or she should have advised treatment. You should have had medical treatment if the problem is physical. You and your partner should have been referred for couples counseling to learn how to break the cycle of anxiety if that is the problem.
I’m sorry both you and your partner have been deprived of the closeness and intimacy that comes with a satisfying sex life. You both deserve that. And your baby deserves to have happy parents!
I wish you well.