
412 N.W.2d 119 (1987)
Ron EVERITT, Petitioner and Appellant,
v.
Herman SOLEM, Warden, South Dakota State Penitentiary, Respondent and Appellee.
No. 15413.
Supreme Court of South Dakota.
Considered on Briefs January 13, 1987.
Decided September 9, 1987.
*120 Richard Braithwaite, Sioux Falls, for petitioner and appellant.
Mark V. Meierhenry, Atty. Gen., Pierre, and Gary W. Conklin, State's Atty., Lake Andes, for respondent and appellee.
BRADSHAW, Circuit Judge.
This is an appeal from the order denying habeas corpus relief. The circuit court issued a certificate of probable cause pursuant to SDCL 21-27. Appellant Ron Everitt, (Everitt), contends that the plea-taking judge had an insufficient basis to accept a plea of guilty but mentally ill. We disagree and affirm the order.
On September 30, 1985, Everitt entered the Commercial State Bank in Wagner, South Dakota. He lit a package of firecrackers and threw them on the floor of the bank lobby. A shotgun, which was the object of a raffle, was on display in the lobby. Everitt removed the shotgun from the display case and loaded it with shells he had with him. He proceeded behind the teller line and threw a check on the counter made out to himself for $125. He then grabbed approximately $7,726 from the cash drawer. On the way out of the bank, Everitt unloaded the shotgun and returned it to the display case.
Everitt was charged with first degree robbery and grand theft. At his arraignment Everitt entered a plea of not guilty and not guilty by reason of insanity. A plea bargain was subsequently entered into resulting in the state dismissing the grand theft charge and the entry of a plea of guilty but mentally ill to the first degree robbery charge. Prior to accepting Everitt's plea, the plea-taking judge held a hearing on Everitt's mental condition. Everitt testified at some length at that hearing and introduced four exhibits bearing upon his past and present mental condition.
The sole issue on appeal is whether the evidence before the trial court was sufficient to support its determination that there was a factual basis for accepting a plea of guilty but mentally ill. Before we reach that question, however, we must make the fundamental determination of whether or not this case falls within the scope of review of habeas corpus.
This court recently reviewed the availability of habeas corpus relief, and concluded that the scope of review is limited because the remedy is in the nature of a collateral attack upon a final judgment. *121 Goodroad v. Solem, 406 N.W.2d 141 (S.D. 1987). SDCL 21-27-16.
For the purpose of this case, it may simply be said that habeas corpus can be used only to review (1) whether the court had jurisdiction of the crime and the person of the defendant; (2) whether the sentence was authorized by law; and (3) in certain cases, whether an incarcerated defendant has been deprived of basic constitutional rights. Goodroad, supra; Logan v. Solem, 406 N.W.2d 714 (S.D.1987).
The requirement that the trial court determine that there is a factual basis for accepting the plea is statutory. SDCL 23A-7-14; Goodroad, supra; Logan, supra; State v. King, 400 N.W.2d 878 (S.D. 1987). Failure of the trial court to comply with SDCL 23A-7-14 may be grounds for appeal, but it does not reach the constitutional or jurisdictional proportions necessary to bring the question within the purview of habeas corpus. In Goodroad, supra, 406 N.W.2d at 143, we said, "`Habeas corpus cannot be utilized as a substitute for an appeal' [citations omitted]. Habeas corpus is not the proper remedy to correct irregular procedures, rather, in the context of post-conviction attacks on the conviction itself, habeas corpus reaches only jurisdictional error."
Errors and irregularities in the proceedings of a court having jurisdiction of the person, subject matter and power to decide questions of law, are not reviewable though they may have been grounds for reversal on direct appeal. Jurisdiction is the power to hear and determine a controversy and to render judgment in accord with law. Excepting those actions in which the court may lose jurisdiction by a denial of due process, [citation omitted] this power includes the power to decide wrongly as well as rightly, to render an erroneous judgment as well as a correct one.... If error occur the remedy is by appeal.
Goodroad, supra, 406 N.W.2d at 143, quoting State ex rel. Ruffing v. Jameson, 80 S.D. 362, 366, 123 N.W.2d 654, 656 (1963). In this case, the trial court had jurisdiction of the person and of the subject matter before it. The sentence was authorized by law. Everitt has not been deprived of basic constitutional rights. Therefore, the issue on appeal is not properly reviewable in a habeas corpus proceeding and the order denying habeas corpus relief is affirmed.
This could end the discussion. In view of the fact that the trial court did rule that a factual basis was established, we will examine the decision as we did in Goodroad, supra.
Everitt alleges that there was not a sufficient showing that he was mentally ill at the time of the offense. The prerequisites to acceptance of the guilty but mentally ill plea are contained in SDCL 23A-7-16:
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.
Mental illness is defined in SDCL 22-1-2(22):
[A] substantial psychiatric disorder of thought, mood or behavior which affects a person at the time of the commission of the offense and which impairs a person's judgment, but not to the extent that he is incapable of knowing the wrongfulness of his act. Mental illness does not include abnormalities manifested only by repeated criminal or otherwise antisocial conduct [.]
At Everitt's arraignment and mental condition hearing, Everitt testified extensively and introduced exhibits bearing upon his past and present mental condition which supported the claim of mental illness. He introduced hospital records from six previous hospitalizations for mental problems between December 16, 1982 through April 26, 1984. Everitt was diagnosed as schizophrenic. Everitt now contends that such information has no probative value since *122 the statutory definition of mental illness requires that the mental condition affect the person at the time of the commission of the event. Everitt, however, introduced the records at the time of the arraignment and mental condition hearing. It seems rather incongruous for him now to argue that such testimony was irrelevant. In any event, although these records do not determine Everitt's mental condition at the specific time of the robbery, they do show that he has been mentally ill in the recent past. Such evidence is valuable and relevant when considered as part of the total cumulative evidence from which the trial court could make its subjective conclusion that Everett was mentally ill at the time of the offense. In the analogous situation of determining whether a competency hearing is required prior to accepting a plea of guilty, we have held that prior medical opinions are factors to be considered. Withorne v. Solem, 385 N.W.2d 506 (S.D.1986).
Everitt was admitted to the South Dakota Human Services Center from October 3, 1985, to October 10, 1985, pursuant to a court order for psychiatric examination in keeping with the statutory requirement that a defendant be examined by a licensed psychiatrist. During this time, and again on January 22, 1986, Dr. Franklin Johnson examined Everitt. Dr. Johnson's evaluation, which Everitt introduced at the mental condition hearing, stated:
His mental illness does not result in any specific impairment of judgment, although it is clear at times he practices poor judgment....
Summary and Conclusion ... It is clear that this man does have a chronic mental illness that at times causes serious problems for him ... It is my opinion, also, that he meets the criteria for the statute that defines `guilty but mentally ill'.
Dr. Johnson's statement that Everitt's mental illness does not have any specific impairment of judgment may tend to contradict his conclusion that Everitt meets the statutory definition of mental illness. This court, however, cannot determine the effect, if any, that Dr. Johnson's report had on the plea-taking judge. If there is a contradiction, such would only affect the weight given to the doctor's testimony. The finder of fact is entitled to place whatever weight he chooses upon the testimony of an expert. State v. Graves, 83 S.D. 600, 163 N.W.2d 542 (1969). Also, since this matter was tried to the court, the court must determine the weight of the evidence and the credibility of the witnesses. SDCL 15-6-52(a).
While Everitt was at the Human Services Center in October 1985, he was also examined by Dr. Ulises Pesce. Dr. Pesce expressed the impression in one of Everitt's exhibits received by the trial court, "That he is suffering from a psychotic disorder. Most likely at the time of the crime he was also psychotic as the illness that he suffers from is a chronic one and has started several years ago...." This report indicates that Everitt was able to know the wrongfulness of his conduct.
The last piece of evidence offered by Everitt was a report from Dr. Walter Turke regarding his examination of Everitt at the Minnehaha County Jail on February 6, 1986. Dr. Turke, a licensed psychiatrist, stated, "With reference to the current charges, it appears that `guilty but mentally ill' is an appropriate statement."
At the habeas corpus hearing Everitt contended that Dr. Turke had misinterpreted the statute defining mental illness and had now concluded that, with reference to the criminal charges against Everitt, "guilty but mentally ill" was not an appropriate statement. At the habeas corpus hearing, Dr. Turke testified that he was not aware of the statutory definition of mental illness when he made his initial report and that Everitt's condition did not meet South Dakota's definition of mental illness. The state then introduced a letter from Dr. Turke dated November 7, 1986, in which Dr. Turke again concluded, "This man has a chronic mental illness dating back to the age of 23 when he first began significant mood swing associated with psychotic episodes...." The testimony of Dr. Turke at the habeas corpus hearing is irrelevant for the purposes of this appeal. We are only concerned with determining *123 whether the plea-taking circuit court followed the prerequisites to acceptance of a plea of guilty but mentally ill and the definition of mental illness and whether the court at the time of the mental condition hearing was given a factual basis sufficient to conclude that Everett was mentally ill at the time of the offense. A change of testimony, additional testimony or additional evidence might be grounds for a new trial or some other relief but they are not appropriate for granting of habeas corpus relief. By having Everitt evaluated by a psychiatrist, examining the psychiatrist's reports, and holding a hearing on Everitt's mental condition, which included extensive testimony by Everitt, the plea-taking judge complied with all the requirements of SDCL 23A-7-16 and had an opportunity to determine from the totality of evidence before it that a factual basis existed for acceptance of the plea.
In reviewing the circuit court decision, this court will not upset factual findings unless they are clearly erroneous. SDCL 15-6-52(a). Spirit Track v. State, 272 N.W.2d 803 (S.D.1978); Gregory v. State, 325 N.W.2d 297 (S.D.1982). In this case, we cannot say that finding a factual basis for the plea of guilty but mentally ill was clearly erroneous. Therefore, the order denying habeas corpus relief is affirmed.
WUEST, C.J., and MORGAN, J., concur.
HENDERSON, J., concurs in result.
SABERS, J., concurs specially.
BRADSHAW, Circuit Judge, sitting for MILLER, J., disqualified.
HENDERSON, Justice (concurring in result).
As Goodroad, cited in the majority opinion, is recent and compelling precedent to decide this case, I concur in that portion of this opinion up to, and including, this sentence: "Therefore, the issue on appeal is not properly reviewable in a habeas corpus proceeding and the order denying habeas corpus relief is affirmed."
After the above-stated quote, the balance of the opinion is surplusage. Nonconstitutional and nonjurisdictional defects cannot be reviewed on habeas corpus. I dissented in Logan v. Solem, 406 N.W.2d 714, 719 (S.D.1987), as a constitutional infirmity existed; here, I can join this opinion (conceding, by hypothesis, that procedural error exists) because there exists only a statutory infirmity.
SABERS, Justice (concurring specially).
I write specially again to point out that habeas corpus reaches jurisdictional error, constitutional error, all "causes" listed in SDCL 21-27-16(1) through (7), and other illegal detentions, including those resulting from failure to comply with "substantive statutory procedures." Security Sav. Bank v. Mueller, 308 N.W.2d 761, 762-63 (S.D.1981). See also my special concurrences in Goodroad v. Solem, 406 N.W.2d 141, 146 (S.D.1987) and in Podoll v. Solem, 408 N.W.2d 759, 761 (S.D.1987).
