Certainly the hospitals are governed by the provinces. However, part XX.1 of the Criminal Code does set out a whole regime to deal with mentally disordered accused who fall under their purview. It's one of those areas of the law that's very much intertwined. It's a mix of federal legislation, provincial legislation, and medical practice.
On June 12th, 2013. See this statement in context.