Section 6. (a) No person shall be retained at a facility or at the Bridgewater state hospital except under the provisions of paragraph (a) of section ten, the provisions of paragraphs (a), (b), and (c) of section twelve, section thirteen, paragraph (e) of section sixteen and section thirty-five or except under a court order or except during the pendency of a petition for commitment or to the pendency of a request under section fourteen. A court order of commitment to a facility or to the Bridgewater state hospital shall be valid for the period stipulated in this chapter or, if no such period is so stipulated, for one year. A petition for the commitment of a person may not be issued except as authorized under the provisions of this chapter.
(b) Following the filing of a petition for a commitment to a facility or to the Bridgewater state hospital, a hearing shall be held unless waived in writing by the person after consultation with his counsel. In the event the hearing is waived, the person may request a hearing for good cause shown at any time during the period of commitment.