(1) This section applies if a person taken to be in the custody of the director-general is required to appear before a court.
(2) The corrections director-general or the CYP director-general must tell the director-general about the requirement as soon as practicable after becoming aware of it.
(3) When the person is transferred from a secure mental health facility for the purpose of attending court, the person is taken to be in the custody of—
(a) if the person is a detainee—the corrections director-general; and
(b) if the person is a young detainee—the CYP director-general.
(4) When the person is returned to the secure mental health facility, the person is taken to be in the custody of the director-general.
(5) In this section:
"court" includes the integrity commission.