(a) No person who is on outpatient status pursuant to this title or Section 2972 shall leave this state without first obtaining prior written approval to do so from the committing court. The prior written approval of the court for the person to leave this state shall specify when the person may leave, when the person is required to return, and may specify other conditions or limitations at the discretion of the court. The written approval for the person to leave this state may be in a form and format chosen by the committing court. In no event shall the court give written approval for the person to leave this state without providing notice to the prosecutor, the defense counsel, and the community program director. The court may conduct a hearing on the question of whether the person should be allowed to leave this state and what conditions or limitations, if any, should be imposed.