(4)A person who is a patient in any establishment maintained wholly or mainly for the reception and treatment of persons suffering from mental illness or mental defectiveness , or who is detained in prison or other legal custody at any place shall not, by reason thereof, be deemed to be ordinarily resident therein.