They are different things entirely.
Clinical insanity is a medical term. Someone can be totally insane but still know the difference between right and wrong.
Legal insanity is decided under what is called the "M'Naughton rule" (After Daniel M'Naughton, who was found not guilty of murder on the grounds of insanity in England in 1849) The Law Lords (English equivalent to the Supreme Court) established a set of rule to determine when someone was not guilty of a crime by reason of insanity. These rules were adopted in most 'common law' countries, including most American states.
The Rules, stated shortly are:
(1) Persons acting under the influence of an insane delusion are punishable if they knew at the time of committing the crime that they were acting contrary to law.
(2) Every man is presumed sane and to have sufficient reason to be held responsible for his crimes.
(3) To establish a defense on the ground of insanity it must be clearly proved that, at the time of committing the act, the accused was laboring under such a defect of reason, from disease of the mind, as not to know the nature and quality of the act he was doing or, if he did know it, that he did not know he was doing what was wrong. If the accused was conscious that the act was one that he ought not to do, and if the act was at the same time contrary to the law of the land, he is punishable.
In the USA, the Supreme court has held that there is NO Constitutional right to an insanity defense. It is Constitutional for a State to decide to not allow such a defense. This question was finally settled in "Clark v. Arizona".
In 1999, 16 year old Eric Clark was discharged from a mental hospital when his parents medical insurance ran out. Clark suffered from delusional paranoid schizoprhrenia. After being released he became convinced that Flagstaff was infested by space aliens who were preparing to take over the earth. He visited the police station many times begging them to arrest various people (Including, at one point, his parents) as alien spies. Shortly after his 17th birthday he became convinced that the invasion was about to begin, and was driving around the streets yelling for everyone to get out of town as the aliens were coming.
A police officer approached his truck, and Clark shot him. He then drove to the police station and told them he'd just shot an alien soldier, and they should call out the national guard.
Under Arizona law there is no "Not guilty by reason of insanity" defense, so Clark was convicted of murder. His guardians appealed all the way to the Supreme Court, arguing that it was "cruel and unusual punishment" to convict a minor for a crime that even the prosecution agreed that he did not know he was comitting.
The Supreme court upheld his conviction, ruling that there is no absolute right to an insanity defense.