Q. If he (a patient that has lost most of his memory) regains some memory only from time to time and only then is rational, is he liable on mitzvos when he is well?

A. See prior answer where Horav Shlomo Miller Shlit”a indicated that one who suffers of memory loss, even severe by itself does not qualify as a shoiteh, unless he becomes detached from reality and is incapacitated. Shulchan Aruch (E. H. 121: 3) rules that one who is sometimes healthy mentally and sometimes not, during his periods of sanity he is considered in Halacha capable for everything. Poskim maintain that the above is correct even when at his healthy intervals he still shows some signs of illness. (Beis Yosef E.H. 121 quoting Responsa Rashbo et. al.)

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