Well, it seems that you are on the right track in many ways… As I said, if the problem is medical, then you need to seek medical advice - and I know someone on a different thread pointed out that some of us are often very quick to explain problems merely from a spiritual perspective, when a problem may actually be physiological or psychological. So do seek help from the right people.
That said, I know that impurity can be combatted very forcefully by having a strong and active prayer life. It is never wrong to call on the Lord for help, and it will be beneficial to you to pray when you feel tempted - and also in thanksgiving for the times when you overcome temptation. Many people recommend praying the Rosary to help fight impurity; I myself find that I am greatly strengthened by the Holy Mass and by spending time (daily when possible) with the Lord in the Blessed Sacrament - it is a great comfort to be able to come before the Lord in all one’s weakness and lay one’s difficulties before Him.
Something else that will be of great spiritual benefit to you, if you are not already doing it, is frequent Confession. Many people recommend monthly confession - like me, you may sometimes feel the need to go to confession more frequently; indeed, sometimes you can feel like a broken record listing the same sins time after time. What you need to accept is that we all fall sometimes in different ways, but you have one of the central requirements for making a good confession - a sincere purpose of amendment & a desire to turn from your sinful ways. Let your confession be plain and entire - this will be a great help for the priest in giving useful and relevant advice to you.
So, don’t lose heart - you certainly can get through your difficulties… you are, after all a Saint Wannabe