All reports of examinations made to a court pursuant to sections one to eighteen, inclusive, section forty-seven and forty-eight shall be private except in the discretion of the court. All petitions for commitment, notices, orders of commitment and other commitment papers used in proceedings under sections one to eighteen and section thirty-five shall be private except in the discretion of the court. Each court shall keep a private docket of the cases of persons coming before it believed to be mentally ill, including proceedings under section thirty-five; provided that nothing in this section shall prevent public inspection of any complaints or indictments in a criminal case, or prevent any notation in the ordinary docket of criminal cases concerning commitment proceedings under sections one to eighteen against a defendant in a criminal case. Notwithstanding the provisions of this paragraph, any person who is the subject of an examination or a commitment proceeding, or his counsel, may inspect all reports and papers filed with the court in a pending proceeding, and the prosecutor in a criminal case may inspect all reports and papers concerning commitment proceedings that are filed with the court in a pending case.
Notwithstanding this section, a court may, pursuant to section 35 and section 36C, transmit information contained in court records to the department of criminal justice information services to provide:
Mass. Gen. Laws ch. 123, § 36A