As a judicial term, the concept of a ‘sane person’ refers to an individual who is adequate regarding the mental abilities that serve to differentiate between good and evil, gain and loss.
When one’s ability to reason and differentiate is impeded, he or she is dismissed from religious responsibilities. The crucial point here is whether, at the time discretion is exercised, the individual has the ability to differentiate between good and evil. This is because while some mental illnesses permanently impair the ability to differentiate, others’ impairment of this ability is not permanent. The sufferer is responsible for his or her actions and exercises of discretion during the time he or she is sane. For example, epilepsy sufferers are sane in-between two epileptic seizures. Likewise, sleepwalkers have the ability to differentiate at other times.
SOURCE: Religious and Comprehensive Encyclopedia of Islam (Diyanet ve Samil Islam Ansiklopedisi), the entries entitled ‘reason’ (‘Akil’) and ‘mental illness’ (‘Akil Hastaligi’) by Hamdi Döndüren.