Most states have some form of this already.
Connecticut:
a person may not obtain a handgun eligibility certificate if he or she:
Has been discharged from custody within the preceding twenty years after having been found not guilty of a crime due to mental disease or defect pursuant to section 53a-13;
Has been confined in a mental hospital for persons with psychiatric disabilities within the preceding 12 months by order of a probate court.
Colorado:
None listed
Arizona:
Arizona prohibits possession of a firearm by any person who:
Has been found to constitute a danger to himself or herself or others pursuant to court order under section 36-540, and whose right to possess a firearm has not been restored pursuant to section 13-925.
Virginia:
Prohibits the:
Purchase, possession or transportation of any firearm by any person adjudicated "legally incompetent," "mentally incapacitated," or "incapacitated," whose competency or capacity has not been restored
Purchase, possession or transportation of a firearm by a person who has been involuntarily committed, during the period of commitment
And surprisingly, check out Texas:
A person is ineligible for a license to carry a concealed weapon if the person:
(1) has been diagnosed by a licensed physician as suffering from a psychiatric disorder or condition that causes or is likely to cause substantial impairment in judgment, mood, perception, impulse control, or intellectual ability;
(2) suffers from a psychiatric disorder or condition described by Subdivision (1) that: (A) is in remission but is reasonably likely to redevelop at a future time; or (B) requires continuous medical treatment to avoid redevelopment;
(3) has been diagnosed by a licensed physician, determined by a review board or similar authority, or declared by a court to be incompetent to manage the person's own affairs; or
(4) has entered in a criminal proceeding a plea of not guilty by reason of insanity.
The following constitutes evidence that a person has a psychiatric disorder or condition described by section (1), above:
(1) involuntary psychiatric hospitalization;
(2) psychiatric hospitalization;
(3) inpatient or residential substance abuse treatment in the preceding five-year period;
(4) diagnosis in the preceding five-year period by a licensed physician that the person is dependent on alcohol, a controlled substance, or a similar substance; or
(5) diagnosis at any time by a licensed physician that the person suffers or has suffered from a psychiatric disorder or condition consisting of or relating to:
(A) schizophrenia or delusional disorder;
(B) bipolar disorder;
(C) chronic dementia, whether caused by illness, brain defect, or brain injury;
(D) dissociative identity disorder;
(E) intermittent explosive disorder; or
(F) antisocial personality disorder.