Mental illness of such a severe nature that a person cannot distinguish fantasy from reality, cannot conduct her/his affairs due to psychosis, or is subject to uncontrollable impulsive behavior. insanity is distinguished from low intelligence or mental deficiency due to age or injury. if a complaint is made to law enforcement, to the district attorney or to medical personnel that a person is evidencing psychotic behavior, he/she may be confined to a medical facility long enough (typically 72 hours) to be examined by psychiatrists who submit written reports to the local superior/county/district court. a hearing is then held before a judge, with the person in question entitled to legal representation, to determine if she/he should be placed in an institution or special facility. the person ordered institutionalized at the hearing may request a trial to determine sanity. particularly since the original hearings are often routine with the psychiatric findings accepted by the judge. in criminal cases, a plea of “not guilty by reason of insanity” will require a trial on the issue of the defendant’s insanity (or sanity) at the time the crime was committed. in these cases the defendant usually claims “temporary insanity” (crazy then, but okay now). the traditional test of insanity in criminal cases is whether the accused knew “the difference between right and wrong,” following the “m’naughten rule” from 19th century england. most states require more sophisticated tests based on psychiatric and/or psychological testimony evaluated by a jury of laypersons or a judge without psychiatric training. a claim by a criminal defendant of his/her insanity at the time of trial requires a separate hearing to determine if a defendant is sufficiently sane to understand the nature of a trial and participate in his/her own defense. if found to be insane, the defendant will be ordered to a mental facility, and the trial will be held only if sanity returns. sex offenders may be found to be sane for all purposes except the compulsive dangerous and/or antisocial behavior. they are usually sentenced to special facilities for sex offenders, supposedly with counseling available. however, there are often maximum terms related to the type of crime, so that parole and release may occur with no proof of cure of the compulsive desire to commit sex crimes.