Whenever any court in this State grants probation to any person that the court has reason to believe is or has been an addict or unlawful possessor of controlled substances, the court shall require, as a condition of probation, that the probationer submit to periodic tests by the Department of Corrections to determine by means of appropriate chemical detection tests whether the probationer is using controlled substances. The court may require as a condition of probation that the probationer enter an approved treatment program, if the court determines that the probationer is addicted to a controlled substance. Whenever the Prisoner Review Board grants parole or the Department of Juvenile Justice grants aftercare release to a person believed to have been an unlawful possessor or addict of controlled substances, the Board or Department shall require as a condition of parole or aftercare release that the parolee or aftercare releasee submit to appropriate periodic chemical tests by the Department of Corrections or the Department of Juvenile Justice to determine whether the parolee or aftercare releasee is using controlled substances.
720 ILCS 570/509