Section 24Q. A mandatory condition of any sentence imposed for: (1) a conviction or an assignment to an alcohol or controlled substance education, treatment or rehabilitation program if evidence in the prosecution of a violation of this chapter or chapter 90B was that a person's blood alcohol percentage, by weight, was not less.20 or (2) an assignment to an alcohol or controlled substance education, treatment or rehabilitation program or a conviction for violating paragraph (a) of subdivision (1) of section 24, subsection (a) of section 24G, operating a motor vehicle with a percentage by weight of blood alcohol of eight one-hundredths or greater, or while under the influence of intoxicating liquor in violation of subsection (b) of said section 24G, section 24L, subsection (a) of section 8 of chapter 90B, section 8A or 8B of chapter 90B, or section 131/2 of chapter 265 or, in the case of any other jurisdiction, for any like offense, if the person being sentenced has previously been so assigned or convicted of a like offense, shall be that such person complete an alcohol or drug assessment conducted by the department of public health or other court-approved program. The assessment shall include, but not be limited to, an assessment of the level of the offender's addiction to alcohol or drugs, and the department's recommended course of treatment. Such assessment and recommended course of treatment shall be reported to the offender's probation or parole officer. No person shall be excluded from an assessment for inability to pay if the offender files an affidavit of indigency or inability to pay with the court and an investigation by the probation or parole officer confirms such indigency or establishes that such payment would cause a grave and serious hardship to the offender or his family, and the court enters written findings relative thereto. The commissioner of public health may make such rules and regulations as are necessary or proper to carry out this section.