Section 39L. (a) Before or after arraignment in any juvenile delinquency or criminal proceeding against a sexually exploited child alleging that such juvenile or such defendant violated the prohibition against common night walking or common streetwalking under section 53 of chapter 272 or the provisions of subsection (a) of section 53A of said chapter 272, there shall be a presumption that a care and protection petition on behalf of such child, or a child in need of services petition under section 39E, shall be filed. Any person, including the juvenile, may file a care and protection petition on behalf of such child, including a petition for emergency commitment under section 24, or a parent or a police officer may file a child in need of services petition under section 39E.
(b) The court may appoint a guardian ad litem and shall hold a hearing on such petition. The court may allow a reasonable delay in the proceedings, including any arraignment, to consider the petition. The necessary findings of fact to support the court's decision shall be reduced to writing and made part of the court record.
(c) Upon a motion by a party to the juvenile delinquency or criminal proceeding or by a guardian ad litem, unless the district attorney or the attorney general objects, and upon a finding that a child alleged to be a juvenile delinquent by reason of violating section 53 of chapter 272 or subsection (a) of section 53A of said chapter 272 is a child in need of care and protection or a child in need of services, the court shall, if arraignment has not yet occurred, indefinitely stay arraignment and place the proceeding on file. If the court finds that the child has failed to substantially comply with the requirements of services or that the child's welfare or safety so requires, the court may remove the proceeding from file, arraign the child and restore the delinquency or criminal complaint to the docket for trial or further proceedings in accordance with the regular course of such proceedings. If arraignment has already occurred, unless the district attorney or the attorney general objects, the court shall place the child on pretrial probation under section 87 of chapter 276. If appropriate, the conditions of such probation shall include, but not be limited to, requiring the child to substantially comply with all lawful orders of the court, including orders relating to any care and protection or child in need of services proceeding, and the child shall also comply with the guidance and services of the department or any designated non-governmental service provider. If the child fails to substantially comply with the conditions of probation or if the child's welfare or safety so requires, the court may in its discretion restore the delinquency or criminal complaint to the docket for trial or further proceedings in accordance with the regular course of such proceedings.