
604 N.W.2d 482 (2000)
2000 SD 8
STATE of South Dakota, Plaintiff and Appellee,
v.
Michael J. ANDERSON, Defendant and Appellant.
No. 20852.
Supreme Court of South Dakota.
Considered on Briefs September 13, 1999.
Decided January 19, 2000.
*483 Mark Barnett, Attorney General, Grant Gormley, Assistant Attorney General, Pierre, South Dakota, Attorneys for plaintiff and appellee.
Jessica S. Cain, Osborn Law Office, Redfield, South Dakota, Attorneys for defendant and appellant.
PER CURIAM.
[¶ 1.] Michael John Anderson pled guilty but mentally ill to aggravated assault. The judgment of conviction states "that a factual basis existed for the plea." On appeal Anderson contends that the trial court failed to establish a factual basis for finding him mentally ill. We reverse and remand.

FACTS
[¶ 2.] After three significant people in his life died in 1995, Anderson began experiencing paranoia, hearing voices, and attempting suicide. He was hospitalized at McKennan Hospital and diagnosed as paranoid schizophrenic. He was fifteen years old.
[¶ 3.] During the next three years, Anderson, though on medication, had a history of suicide attempts. He was involved in in-patient programs at McKennan Hospital and the South Dakota Human Services Center in Yankton and counseling programs in the Watertown area. He quit school. He was placed at the Prairie Hills and Summit Oaks facilities for juvenile offenses.
[¶ 4.] In June 1998 Anderson got his own apartment. He quit taking his medication. He gained friends when his apartment became home to a perpetual party. He was evicted and moved to his parents' home. He started hearing voices and becoming more paranoid.
[¶ 5.] On July 18, 1998, Anderson was convinced that the house was filling up with gas and would blow up and that Dutch elm disease was rotting away his skin. He barricaded himself in the home with a shotgun. Detective Schickedanz was dispatched to defuse the situation since he had a rapport with Anderson from a prior police standoff and was now on Anderson's crisis management team.
[¶ 6.] When Schickedanz made contact, Anderson "pulled the shotgun up to his shoulder and pointed it at me, and told me to take the vest off, and I could kill you... I could blow your head off." Later in the standoff he told Schickedanz that he felt suicidal and wanted to make the police kill him. After five hours, Anderson put down the shotgun and surrendered to Schickedanz. A homemade bomb was later found in Anderson's house. At the preliminary hearing Schickedanz testified that he knew Anderson's diagnosis but was not qualified to characterize it as a mental illness. He did testify that during the standoff he believed that Anderson, at *484 times, knew what he was doing and at other times was hearing voices.
[¶ 7.] Anderson, then nineteen years old, was charged with aggravated assault. He pled not guilty. Anderson's court appointed attorney gave notice of his intention to introduce expert evidence relating to Anderson's mental condition before, during, and after the alleged crime. SDCL 23A-10-3. The trial court granted the defense motion to appoint Dr. Robert Packard, a PhD psychologist, to assist the defense as long as Packard's reports would be shared with the state.
[¶ 8.] The plea hearing was on October 28, 1998. Anderson and the state agreed that he would enter a plea of guilty but mentally ill in exchange for the state's recommendation that he receive a suspended imposition of sentence. The court accepted the agreement after questioning Anderson about it and explaining that it was not bound to suspend imposition of sentence and could impose fifteen years in prison. Anderson then pled guilty but mentally ill. Anderson asked the court to accept a psychological report prepared by Dr. Packard. It, along with the preliminary hearing testimony, Anderson argued, supported a factual basis for a plea of guilty but mentally ill. The court continued the matter for a week in order to conduct a hearing on Anderson's mental condition.
[¶ 9.] On November 4, 1998 the court held a "hearing to determine whether or not the court will accept the defendant's plea in this matter." Although Anderson had Dr. Packard subpoenaed to testify, he had decided that the Packard report spoke for itself[1] and "by stipulation  stipulation and agreement, I'd ask the Court to take judicial notice of the report and establish that as a factual basis for the guilty but mentally ill plea." The state agreed that "there is factual basis for the guilty but mentally ill plea based upon that report and the testimony at the preliminary hearing." Based upon this the court found "that there is a factual basis for concluding that the defendant was mentally ill at the time that this offense was committed." The court canvassed Anderson's rights with him and Anderson agreed with the state's recitation of the facts of the crime and answered four brief trial court questions regarding it. The court did not question him about his mental state and whether he knew right from wrong at the time of the offense.
[¶ 10.] At the sentencing hearing a month later Anderson's attorney addressed the court and said, in part:
Mr. Anderson stands before you this morning very sorry for what he has done. I think the Court has to realize and this is substantiated by letters, the evaluation by Dr. Packard done approximately a month and a half ago, there is also an attachment, a letter from Linda Schoepp, his mental health counselor from the Boys' and Girls' Club, it's - Michael has a[sic] illness. And at the time of this incident he was ill. And that's undisputed. And unrefuted. His illness did not rise to the level of insanity to where he didn't know right from wrong. However, it did affect his judgment. And I would like the Court to take those factors into consideration.
Anderson requested a suspended imposition of sentence.
[¶ 11.] While the state concurred in Anderson's sentence request the trial court was concerned with Anderson's increasingly *485 serious problems, his lack of success with medication regulation, and his danger to the public. It sentenced him to three years in the penitentiary, noting:
I'm going to impose a penitentiary sentence. You will not be thrown, I don't believe, it's not up to this Court, but I
don't believe you will be thrown in the general prison population as such. I think it will only be a short period of time and you will most likely be transferred to Yankton for some treatment and adjustments of your medication. I think thereafter you will have the opportunity to learn a job skill probably in the Springfield facility. All of that I think is going to in the long run do you much better when you come back and have to live in this community on your own. And that's what the Court is going to do.
[¶ 12.] After the judgment of conviction was filed on December 9, 1998 Anderson retained new counsel. She filed Anderson's notice of appeal to this Court on January 7, 1999 and represented him at the February 24, 1999 sentence review hearing. At this hearing, Anderson contended that he should be allowed to withdraw his plea because the court did not impose the suspended sentence recommended by the state and the defense. He also claimed that the presentence report was inaccurate and raised concerns that he was in the general prison population where he was not receiving proper medication.
[¶ 13.] At the review hearing, Anderson's psychologist, Dr. Packard, did testify that he believed that, at the time of the police standoff, Anderson was "in the state of severe paranoid delusion and that he was almost completely under the control of those delusions at that time." An individual experiencing a psychotic break does not functionally have the ability to distinguish right from wrong and he explained:
They may have some theoretical understanding of it, but the delusional thinking is so overpowering at that particular time anyway, that that, at that time, functionally, no. They are thinking and feeling and acting strictly on the basis of the truth that they know, which is delusional. And so, no, there is no intrusion of right and wrong and of reality is minimal at best and has no functional significance in the person's actions when they are in the midst of a full-fledged psychotic break.
[¶ 14.] At the close of the hearing the court indicated that it would "most likely" modify the sentence if, in fact, Anderson was not receiving treatment for his schizophrenia. He had a court service officer investigate and subsequently denied the motion for reduction of sentence.

ISSUE
[¶ 15.] Did the trial court establish a factual basis for finding that Anderson was mentally ill at the time of the offense?

DISCUSSION
[¶ 16.] There is a legal distinction between mere mental illness (a disorder which impairs a person's judgment, but not to the extent that he is incapable of knowing the wrongfulness of his act) and insanity (not being capable of knowing the wrongfulness of one's acts). State v. Whitney, 486 N.W.2d 269 (S.D.1992); SDCL 22-1-2(20); SDCL 22-1-2(24). Consequently, if a defendant is insane at the time of the commission of a crime, a plea of guilty is not a legally appropriate plea. Whitney, 486 N.W.2d at 272.
[¶ 17.] Consequently, there are prerequisites that must be met before a trial court can accept a plea of guilty but mentally ill.
Defendants in criminal cases are sometimes willing to enter guilty pleas in circumstances which do not justify a guilty plea. That is one of the reasons trial courts are required to establish a factual basis, on the record, before accepting a guilty plea. SDCL 23A-7-2. Similarly, with guilty but mentally ill pleas the trial court must establish a factual basis on the record which justifies a finding that the criminal defendant *486 was mentally ill at the time of the alleged offense. SDCL 23A-7-16.

* * *
The trial court must establish a factual basis before accepting a plea of guilty but mentally ill. SDCL 23A-7-16.
Whitney, 486 N.W.2d at 272. A trial court may not accept a guilty but mentally ill plea until the requirements of SDCL 23A-7-16 have been fulfilled:
In addition to the requirements of §§ 23A-7-4 and 23A-7-5, if a defendant charged with a felony pleads guilty but mentally ill, the court may not accept the plea until the defendant has been examined by a licensed psychiatrist and the court has examined the psychiatric reports. The court shall hold a hearing on the defendant's mental condition and if there is a factual basis on which the court can conclude that the defendant was mentally ill at the time of the offense, the plea shall be accepted.
[¶ 18.] In Whitney, 486 N.W.2d at 273, this Court held that the trial court erred in accepting a plea of guilty but mentally ill because there was no factual basis establishing that Whitney knew right from wrong at the time of the alleged offense. Under lengthy questioning by the trial court Whitney maintained that he did not know he was doing anything wrong at the time of the alleged offense. Although the trial court relied upon psychiatrists' reports to find that Whitney was capable of understanding right from wrong, this court's review of the reports revealed only minimal information on Whitney's state of mind and no opinion on whether he could distinguish right or wrong at the time of the charged incident. We reversed the conviction and remanded to the trial court so that Whitney could be thoroughly examined by a psychiatrist so the trial court could determine if he could distinguish right from wrong at the time of the alleged offense.
[¶ 19.] In the case before us, we, too, must reverse the conviction and remand to the trial court. Anderson was not examined by a licensed psychiatrist and consequently the trial court could not examine psychiatric reports before concluding that Anderson was mentally ill and accepting the plea. Instead the trial court relied on the preliminary hearing transcript and the psychological evaluation to establish Anderson's mental illness. Detective Schickedanz was the only witness at the preliminary hearing and objections to defense questions attempting to get his opinion on whether Anderson was mentally ill were sustained. The psychological report concluded that there was reason to assume that Anderson was "psychotic" at the time of the incident. The psychologist did not give an opinion, nor was he asked to give an opinion, on whether Anderson could distinguish right from wrong at the time of the incident. And, while the trial court questioned Anderson very briefly about pointing a shotgun at Detective Schickedanz and threatening him, it did not question him at all about his state of mind.
[¶ 20.] In determining whether there is a factual basis for a plea of guilty but mentally ill, " the trial court may admit transcripts of testimony, oral testimony, or other sworn statements or tangible evidence which will satisfy the court of the existence of the factual basis for the plea.'" Whitney, 486 N.W.2d at 272 (quoting State v. Sutton, 317 N.W.2d 414, 416 (S.D.1982)). However, a court is precluded from accepting such a plea until a) the defendant has been examined by a licensed psychiatrist, b) the court has examined the psychiatric report, c) the court has held a hearing on defendant's mental condition, and d) there is a factual basis on which the court can conclude the defendant was mentally ill at the time of the offense. SDCL 23A-7-16.
[¶ 21.] During these proceedings Anderson was evaluated by a psychologist who prepared a report. He was not, however, *487 evaluated by a licensed psychiatrist,[2] as SDCL 23A-7-16 specifically requires, and psychiatric reports were neither prepared or examined. Therefore, we reverse and remand for proceedings consistent with this opinion.
[¶ 22.] MILLER, Chief Justice, and SABERS, AMUNDSON, KONENKAMP and GILBERTSON, Justices, participating.
NOTES
[1]  The Packard report concluded:

In summary, Mike's primary problem appears to be his thought disorder, specifically paranoid schizophrenia, and indeed his highest score on the MMPI-2 is on the scale for psychotic symptomatology (T=114). Though I did not evaluate Mike at the time of his altercation with law enforcement I think there is reason to assume that he was psychotic at that time, and that his thought disorder was a significant mitigating factor relative to the criminality of his behavior. Recent history suggests that his current medication regimen is adequate to keep his behavior under control and within acceptable social norms.
[2]  This is despite the fact that the psychological report revealed that a Sioux Falls psychiatrist, Dr. Bahnson, originally diagnosed Anderson when he was fifteen years old. At the time of sentencing, Anderson's attorney told the court that Dr. Bahnson was again caring for Anderson.
