There's a great post up on Pete Earley's blog entitled "What's Really Insane? Our System" that outlines the conundrum of our mental health system from beginning to end. He starts out by discussing the Jared Loughner case and the difference between hospitalization for treatment versus hospitalization for restoration of competence. Among forensic psychiatrists we call this "clinical competence" (reduction of symptoms, restoration of function) versus "legal competence" (the mental capacity to participate in a legal proceeding). While he says these are two separate and distinct issues, in fact there is a correlation between mental capacity and symptomatology. I'm running late this morning and don't have time to post citations, but off the top of my head I remember reading some articles that correlate BPRS (a symptom scale) scores with evaluators' assessments of legal competency. In other words, treating someone's symptoms will improve and restore competency. That alone isn't always enough though, which is why forensic inpatients are also often involved in competency restoration groups to target that specific issue.
Earley does a nice job of outlining the problem of involuntary medication in some criminal defendants; in Maryland it's a particular problem due to a Court of Appeals decision that the person has to be dangerous in the hospital before they can be treated. Thus, someone could end up institutionalized for a very long time awaiting trial.
That's an incomplete summary of a very good post. Surf over to his site and read the full piece.