A. At any time after a defendant’s commitment, if either the superintendent of the mental institution or the administrator of outreach forensic services reports to the committing court that the defendant presently has the mental capacity to proceed, the defendant, if hospitalized, shall be discharged from the mental institution and released to the custody of the sheriff of the parish from which the defendant was committed, and the court shall hold a contradictory hearing within thirty days on that issue. No defendant shall be released prior to the holding of the contradictory hearing on his release unless the office of the district attorney in charge of the prosecution of the defendant receives seven days notice of the pending release of the defendant.B. Prior to such a hearing, the court shall appoint counsel to represent the defendant, if the defendant does not have counsel, and may order a mental examination by a sanity commission appointed in conformity with Article 644. The report of the superintendent of the mental institution or the administrator of outreach services may be stipulated to and submitted by the state and the defense in lieu of a mental examination by a sanity commission. If the committing court does not hold a hearing within thirty days, the sheriff of the parish from which the defendant was committed shall appear at the institution within seven days thereafter and shall receive and hold the defendant in custody pending further orders of the committing court. If the sheriff fails to appear with a court order and accept custody of the defendant, the superintendent of the state mental institution or the director of the mental health unit shall notify the judicial administrator and the attorney general of such fact. Thereafter the Criminal Court Fund of the parish from which the defendant was committed shall pay to the general fund of the state the sum of one hundred dollars a day until the sheriff appears and accepts custody of the defendant for the court.C. The district attorney or the defense may apply to the court to have the proceedings resumed, on the ground that the defendant presently has the mental capacity to proceed. Upon receipt of such application the court shall hold a contradictory hearing to determine if there is reasonable ground to believe that the defendant presently has the mental capacity to proceed. The court may direct the superintendent of the mental institution where the defendant is committed or the administrator of outreach forensic services, if treatment is initiated in jail, to make a report and recommendation prior to such hearing as to whether the defendant presently has capacity to proceed, or may order an independent mental examination by a sanity commission appointed in conformity with Article 644.D. Reports as to present mental capacity to proceed shall be filed in conformity with Article 645, and the court’s determination of present mental capacity to proceed shall be made in conformity with the appropriate provisions of Articles 646 and 647.E. If the court determines that the defendant has the mental capacity to proceed, the proceedings shall be promptly resumed.