No person may knowingly ingest a controlled drug or substance or have a controlled drug or substance in an altered state in the body unless the substance was obtained directly or pursuant to a valid prescription or order from a practitioner, acting in the course of the practitioner's professional practice, or except as otherwise authorized by chapter 34-20B. The following penalties apply to a violation of this section:
(1) A first violation is a Class 1 misdemeanor, and the court, in addition to any other sentence, shall order that the person complete a drug and alcohol evaluation and complete supervised probation using evidence-based sentencing practices, which may include the HOPE probation program and other programs as established in chapter 16-22;
(2) A second violation is a Class 1 misdemeanor, and the court, in addition to any other sentence, may sentence the person to a period of up to one year in jail, and shall sentence the person to a period of supervised probation using evidence-based practices, which may include the HOPE probation program and other programs as established in chapter 16-22, and order that the person complete a drug and alcohol evaluation and complete any other recommended course of treatment; and
(3) A third or subsequent violation, occurring within ten years of the person's first conviction, is a Class 6 felony.