1. When a superior court, following a hearing conducted pursuant to subdivision three or four of section 730.30 of this article, is satisfied that the defendant is not an incapacitated person, the criminal action against him or her must proceed. If it is satisfied that the defendant is an incapacitated person, or if no motion for such a hearing is made, it must adjudicate him or her an incapacitated person, and must issue a final order of observation or an order of commitment. When the indictment does not charge a felony or when the defendant has been convicted of an offense other than a felony, such court (a) must issue a final order of observation committing the defendant to the custody of the commissioner for care and treatment in an appropriate institution for a period not to exceed ninety days from the date of such order, provided, however, that the commissioner may designate an appropriate hospital for placement of a defendant for whom a final order of observation has been issued, where such hospital is licensed by the office of mental health and has agreed to accept, upon referral by the commissioner, defendants subject to final orders of observation issued under this subdivision, and (b) must dismiss the indictment filed in such court against the defendant, and such dismissal constitutes a bar to any further prosecution of the charge or charges contained in such indictment. Upon the issuance of a final order of observation, the district attorney shall immediately transmit to the commissioner, in a manner intended to protect the confidentiality of the information, a list of names and contact information of persons who may reasonably be expected to be the victim of any assault or any violent felony offense, as defined in the penal law, or any offense listed in section 530.11 of this chapter which would be carried out by the committed person; provided that the person who reasonably may be expected to be a victim does not need to be a member of the same family or household as the committed person. When the indictment charges a felony or when the defendant has been convicted of a felony, it must issue an order of commitment committing the defendant to the custody of the commissioner for care and treatment in an appropriate institution or, upon the consent of the district attorney, committing him or her to the custody of the commissioner for care and treatment on an out-patient basis, for a period not to exceed one year from the date of such order. Upon the issuance of an order of commitment, the court must exonerate the defendant's bail if he or she was previously at liberty on bail; provided, however, that exoneration of bail is not required when a defendant is committed to the custody of the commissioner for care and treatment on an out-patient basis. When the defendant is in the custody of the commissioner pursuant to a final order of observation, the commissioner or his or her designee, which may include the director of an appropriate institution, immediately upon the discharge of the defendant, must certify to such court that he or she has complied with the notice provisions set forth in paragraph (a) of subdivision six of section 730.60 of this article.
2. When a defendant is in the custody of the commissioner immediately prior to the expiration of the period prescribed in a temporary order of commitment and the superintendent of the institution wherein the defendant is confined is of the opinion that the defendant continues to be an incapacitated person, such superintendent must apply to the court that issued such order for an order of retention. Such application must be made within sixty days prior to the expiration of such period on forms that have been jointly adopted by the judicial conference and the commissioner. The superintendent must give written notice of the application to the defendant and to the mental hygiene legal service. Upon receipt of such application, the court may, on its own motion, conduct a hearing to determine the issue of capacity, and it must conduct such hearing if a demand therefor is made by the defendant or the mental hygiene legal service within ten days from the date that notice of the application was given them. If, at the conclusion of a hearing conducted pursuant to this subdivision, the court is satisfied that the defendant is no longer an incapacitated person, the criminal action against him must proceed. If it is satisfied that the defendant continues to be an incapacitated person, or if no demand for a hearing is made, the court must adjudicate him an incapacitated person and must issue an order of retention which shall authorize continued custody of the defendant by the commissioner for a period not to exceed one year.
3. When a defendant is in the custody of the commissioner immediately prior to the expiration of the period prescribed in the first order of retention, the procedure set forth in subdivision two shall govern the application for and the issuance of any subsequent order of retention, except that any subsequent orders of retention must be for periods not to exceed two years each; provided, however, that the aggregate of the periods prescribed in the temporary order of commitment, the first order of retention and all subsequent orders of retention must not exceed two-thirds of the authorized maximum term of imprisonment for the highest class felony charged in the indictment or for the highest class felony of which he was convicted.
4. When a defendant is in the custody of the commissioner at the expiration of the authorized period prescribed in the last order of retention, the criminal action pending against him in the superior court that issued such order shall terminate for all purposes, and the commissioner must promptly certify to such court and to the appropriate district attorney that the defendant was in his custody on such expiration date. Upon receipt of such certification, the court must dismiss the indictment, and such dismissal constitutes a bar to any further prosecution of the charge or charges contained in such indictment.
5. When, on the effective date of this subdivision, any defendant remains in the custody of the commissioner pursuant to an order issued under former code of criminal procedure section six hundred sixty-two-b, the superintendent or director of the institution where such defendant is confined shall, if he believes that the defendant continues to be an incapacitated person, apply forthwith to a court of record in the county where the institution is located for an order of retention. The procedures for obtaining any order pursuant to this subdivision shall be in accordance with the provisions of subdivisions two, three and four of this section, except that the period of retention pursuant to the first order obtained under this subdivision shall be for not more than one year and any subsequent orders of retention must be for periods not to exceed two years each; provided, however, that the aggregate of the time spent in the custody of the commissioner pursuant to any order issued in accordance with the provisions of former code of criminal procedure section six hundred sixty-two-b and the periods prescribed by the first order obtained under this subdivision and all subsequent orders of retention must not exceed two-thirds of the authorized maximum term of imprisonment for the highest class felony charged in the indictment or the highest class felony of which he was convicted.