http://www.austlii.edu.au/au/legis/sa/c ... s269c.htmlThe rationale is that the criminal law punishes people who have a mens rea(guilty mind). people who are so unwell they don't know what they are doing, for example think they are stabbing an evil alien, don't deserve to be punished. However they are detained to protect the community.
Look at the section and s268. The law specifically excludes people who take drugs from having a defence. However persons with mental health issues are often very vulnerable and fall into drug use. It then gets very complicated.
People who think everyone on antidepressants can use this defence are wrong. The defendant has to be seriously unwell before it works.
I'd say 75% of the jail population has some mental health issue. 80% would be there because of drugs. Only a very few people can use this particular defence.