As soon as a person is prescribed anti psychotics or anti depressants, or deemed to be a danger to themselves or others, they should be reported, flagged, and evaluated, and their guns secured where they cannot control access to them. When they are 'better', they get them back. If they never get 'better', they never get them back.
It's a slippery slope, with HIPAA and all, and I know it will affect a lot of people who would never cowardly shoot up a school and kill a bunch of babies, but it also isn't the mentally well adjusted people who are doing this shit.