I agree with the first part, about the consent, but for the second part, about “at the time of the offence”, the Supreme Court has already ruled on it in the case of NCR. No one can bring up NCR other than the accused, unless the person is found guilty and they can raise reasonable grounds to have an assessment.
In the more serious examples, then, it's already in the accused's hands, and I think the court would follow that again in the future for sentencing.