The Gemara on Amud Aleph describes an individual who is sometimes sane and sometimes insane. When he is in his sane phase, he has the halakhic status of a regular person, when he is out of his mind, he has the status of a shoteh, that is a person exempt from mitzvos. This works both ways. If he is not in a sane status he is exempt from mitzvos but also doesn’t fulfill them. So if he ate matzah seder night in an insane state and then calmed down he would have to eat all over again to fulfill the mitzvah.
While we cannot be sure, the condition described by this Gemara sounds like a manic episode. It also sounds similar to what Shaul Hamelech experienced as described in I:Shmuel:16. However, we have to be carefulabout inserting our ideas about mental illness into other cultures.
There is a concept in psychology known as the symptom pool. Imagine psychological and somatic symptoms at a smorgasbord buffet where each person chooses the collection of symptoms that best express their pains and conflicts within their culture. For example a young woman who lived in an area where most people were undernourished and starving would be unlikely to exhibit Anorexia. It’s simply not a place where she could even express her unconscious desire for control over herself by not eating. It would have to come out in a different way. Maybe she would develop a mysterious fainting ailment, who knows? What we do know is that different cultures express mental illness through variations of symptoms. Because the symptoms are expressions of symbolic ideas they will change based on the environment. In the back of the DSM IV there is an extensive list of culture bound conditions and symptoms. So, while the underlying psychic forces that are expressed through mania probably do not change much even over thousands of years, the symptom expression might be very different.
Regardless, there are some important ideas to discuss regarding bipolar disorder and halakha. It’s simply common sense that a person who is in a full blown manic state is no longer in their right mind and is even in a state of pikuach nefesh. This is because their judgement is so distorted that they can put themselves in mortal danger even without any suicidal intent. They could feel invincible and cross the street without looking, or pick a fight with a police officer etc. Thus, any kind of action taken to protect this person on shabbos or Yom Tov is permitted.
What is difficult to define is how dangerous it is when the person is hypomanic or in a severe depressed state. It certainly hits the criteria of choleh she’eyn bo sakkana (serious illness but not life threatening) because of the distress level and global impairment, and thus any rabbinically prohibited activity should be permitted that can ease the condition, including use of phones and electrical appliances. (Appliances that cause fire or glowing hot coils might be biblically forbidden on shabbos as that is considered fire.) Arukh HaShulkan in the laws of Divorce (EH 121:13) speaks of various stages of depression and to what degree that is considered a loss of sanity. He says, ultimately it is up to the dayyan to ascertain his general disposition. He does quote a Rashi from Chaggigah 3b that indicates that severe depression alone without other loss of mental faculties is not at the level of loss of sanity. It’s important to keep in mind though, the Arukh HaShulkhan was referring to laws of Divorce where he wants to look for leniencies so that the woman not remain an agunah. While regarding laws of saving a life, any reasonable doubt requires one to violate shabbos, so he might be more likely to consider deep depression as life threatening. It is also important to note that poskim hold there is a subjective element to pikuach nefesh, that is it can be evaluated based on the person’s own subjective fears and concerns (See for example Iggros Moshe OH:I:127.) Another important factor to consider is that if there is a fear that by neglecting treating the condition it could deteriorate into a state of danger, then it is still permitted to violate shabbos. Thus a hypomanic person or a person who is in a depressed state of the bipolar cycle might be still considered in a state of mortal danger, even if at the moment, the symptoms are not yet severe, so long as the intervention is believed to be helpful in staving off further deterioration.
Another interesting angle is that preventing a person from losing sanity or restoring sanity fulfills another dictum that allows for violating the shabbos, that is that in order to preserve future Shabbos observance one may violate Shabbos (Yoma 85b). This principle is so powerful, that Shulkhan Arukh (OH 306:14, MB 57) allows one to violate shabbos in order to save someone from kidnapping that would lead to apostasy, even if determined to be not at all physically life threatening. Using this logic, one should be allowed to make efforts to preserve sanity even to the point of violating the Shabbos, when there is a significant danger that otherwise the person will lose sanity for an extended period and lose the ability to keep shabbos in the future.
One final point: We see from our Gemara that someone in certain distorted psychological states is exempt from mitzvos. Full blown mania likely fits that category and has implications for easing the guilt of the person in recovery. Persons in manic states can become promiscuous and commit numerous moral violations. Knowing that they likely were not in a state of being obligated in mitzvos could offer an appropriate easing of their conscience. On the other hand, interpersonally they may have caused pain and betrayal to loved ones, loss of trust, fidelity and money. Though they technically may be exempt from moral responsibility, the need to heal the relationship and somehow making amends is still necessary.