My answer is going to be purely "theoretical" and is NOT advice, because I don't know the situation.
Yes, some kinds of mental anguish are purely medical in origin - though there is every reason to expect that demons will happily take advantage of any weakness they find in us and delight in antagonizing us further. Medical intervention may or may not help, as it is an inexact science and sometimes (often) a matter of finding the correct treatment (or combination of treatment) which may help in varying degrees. Spiritual aid may still benefit, regardless of the degree of success from medical treatments.
Demons can also be a sole cause. It has happened to me more than once, but I recall a particularly low period in my life (brought on largely by my own spiritual ignorance and involving prelest too) ... where I felt literally eaten up by my thoughts every moment of every day for months. It was to the point of pretty much being unbearable. And then a thought came to me - thank God! Perhaps God was rescuing me (well, no "perhaps" about it!) ... but perhaps I needed or certainly I had deserved that suffering. Maybe it had done its work. Or maybe I was too mired to benefit and God had mercy. At any rate ... it suddenly fell into my mind that everything I was suffering was NOT my own thoughts, not true, but constant demonic suggestion. And I had been falling for it. I felt a flash of anger at the demons. But in that instant, I was also freed. My mind cleared and my life utterly changed. I still made lots more mistakes and took years to dig myself fully out (or there I go again, it took years before I let God dig me out? Even at that I was forced, and suffered much.) But I know from my experience (this and others) that demons can make our lives a living hell in more ways and with more tactics than this. But yes ... the mind burns, is "scalded".
And another thing. Torment can actually come from God, with His reasons. I am reminded of St. Silouan, who explains it as "keeping one's mind in hell but despairing not" ... so for some there can be a benefit and God Himself will allow it.
It reminds me of when people ask about suggestions, or thoughts, or visions ... like so many things, the source can be ourselves, or demons, or God (whether from Himself on the Holy Angels, etc.). Or some combination, especially if demons are involved, since they love to cause confusion. God can sometimes be VERY clear and leave no doubt, but then again it's maybe possible to be confused by other sources even when God is involved.
So it can be very difficult to discern. I have made grave mistakes in my life on that point. Looking back even, I am unwilling to try to untangle source(s). It doesn't matter anymore anyway. It's in my past. But in someone else's present ... well, I would seek out my priest's advice, or perhaps go to a monastery if someone there might help.
Prayers for you.