Insanity is a legal concept, not a medical diagnosis. It is determined by a court in a criminal proceeding, not doctors deciding whether to release someone who has been involuntarily detained for a mental health evaluation.

All insane people are mentally ill but not mentally ill people are insane.