Q. A patient who is so depressed that becomes irrational, is he a halachic shote at that time?

A. In the expressions of our sages one suffering from depression is named a Baal Moro Shechoro or suffering from Melankolio. Divrei Malkiel (7: 36 ) maintains that he is the classic case mentioned in Talmud (Chagiga 3b) as “the one who sleeps over in a cemetery,” or “walks around at wee hours of the night alone.” However, other Poskim disagree. (Aruch Hashulchan E.H. 121: 13., Piskey Teshuva ibid. ) Some maintain that although there may be an indication of the beginning of the process of becoming a shoiteh, he is still sane. (Responsa Chasam Sofer E. H. 2: 2)
Horav Shlomo Miller’s Shlit”a opinion is that all cases differ and a correct ruling depends on many different factors. He advises to consult a competent Rabbi when necessary.

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a