(a) If the director shall determine that a resident admitted upon an application supported by medical certification, for whom there is no court order authorizing retention for a specified period, is in need of retention and if such resident does not agree to remain in such school as a voluntary resident, the director shall apply to the supreme court or the county court in the county where the school is located for an order authorizing continued retention. Such application shall be made no later than sixty days from the date of involuntary admission on application supported by medical certification or thirty days from the date of an order denying an application for resident's release pursuant to section 15.31, whichever is later; and the school is authorized to retain the resident for such further period during which the school is authorized to make such application or during which the application may be pending. The director shall cause written notice of such application to be given the resident and a copy thereof shall be given personally or by mail to the persons required by this article to be served with notice of such resident's initial admission and to the mental hygiene legal service. Such notice shall state that a hearing may be requested and that failure to make such a request within five days, excluding Sunday and holidays, from the date that the notice was given to the resident will permit the entry without a hearing of an order authorizing retention.
(b) If no request is made for a hearing on behalf of the resident within five days, excluding Sunday and holidays, from the date such notice of such application was given such resident, and if the mental hygiene legal service has not requested a hearing, the court receiving the application may, if satisfied that the resident requires continued retention for care and treatment or transfer and continued retention, immediately issue an order authorizing continued retention of such resident in such school for a period not to exceed one year from the date of the order.
(c) Upon the demand of the resident or of anyone on his behalf or upon request of the mental hygiene legal service, the court shall, or may on its own motion, fix a date for the hearing of the application, in like manner as is provided for hearings in section 15.31. The provisions of such section shall apply to the procedure for obtaining and holding a hearing and to the granting or refusal to grant an order of retention by the court, except that the resident shall not have the right to designate initially the county in which the hearing shall be held.
(d) If the director of a school, in which a resident is retained pursuant to the foregoing subdivisions of this section, shall determine that the condition of such resident requires his further retention in a school, he shall, if such resident does not agree to remain in such school as a voluntary resident, apply during the period of retention authorized by the last order of the court to the supreme court or the county court in the county where the school is located for an order authorizing further continued retention of such resident. The procedures for obtaining any order pursuant to this subdivision shall be in accordance with the provisions of the foregoing subdivisions of this section; provided that the resident or anyone on his behalf or the mental hygiene legal service may request that the resident be brought personally before the court, in which case the court shall not grant an order for periods of one year or longer unless such resident shall have appeared personally before the court. Orders obtained under this subdivision shall authorize further continued retention of the resident for periods not to exceed two years each from the date of the order.