(5) If the defendant is committed or transferred to a public or private treatment facility approved by the county mental health director, the court may, upon receiving the written recommendation of the county mental health director, transfer the defendant to another public or private treatment facility approved by the county mental health director. In the event of dismissal of the criminal charges before the defendant recovers competence, the person shall be subject to the applicable provisions of Part 1 (commencing with Section 5000) of Division 5 of the Welfare and Institutions Code. Where either the defendant or the prosecutor chooses to contest the order of transfer, a petition may be filed in the court for a hearing, which shall be held if the court determines that sufficient grounds exist. At the hearing, the prosecuting attorney or the defendant may present evidence bearing on the order of transfer. The court shall use the same standards as are used in conducting probation revocation hearings pursuant to Section 1203.2.
Prior to making an order for transfer under this section, the court shall notify the defendant, the attorney of record for the defendant, the prosecuting attorney, and the county mental health director or his or her designee.