First , they must determine if he can aid in his own defense at the time of trial -- if he is competent to stand trial.   What happened at the time of the offense is a WHOLE other matter under the law.   If he is able to be "restored" to be able to stand trial, then they will deal with the issue of his mental state at the time of the incident.   That is the law.   If he has a severe mental disease or defect, he MIGHT, in OREGON be able to be deemed Guilty Except for Insanity (GEI) which will get him treatment (as you suggest).   Please see:  http://www.oregon.gov/prb/Pages/GEI-Adults.aspx      

He would then be subject to the Psychiatric Security Review Board (PSRB) until they see fit to release him (if ever).   
None of this can take place until he can help in his own defense (if that ever happens) and if he cannot ever do that, he will go directly to the PSRB.  This is what happened with Cheryl Kidd, the person who killed Officer Chris Kilcullen. 
Hope this helps.