A. A person shall not be tried, convicted, sentenced or punished for an offense if the court determines that the person is incompetent to stand trial.
B. The prosecutor or defense attorney may file any pretrial motion at any time while the defendant is incompetent to stand trial. The court shall hear and decide any issue presented by the motion if the defendant's presence is not essential for a fair hearing as determined by the court.