
609 N.W.2d 123 (2000)
2000 SD 49
Lennis I. RENNICH-CRAIG, Petitioner and Appellant,
v.
Duane RUSSELL, Warden of the South Dakota Women's Penitentiary, Appellee.
No. 21044.
Supreme Court of South Dakota.
Considered on Briefs February 14, 2000.
Decided April 12, 2000.
*124 Lorrie A. Miner, Stiles Law Firm, Mitchell, South Dakota, Attorney for petitioner and appellant.
Mark Barnett, Attorney General, Gary Campbell, Assistant Attorney General, Pierre, South Dakota, Attorneys for appellee.
SABERS, Justice.
[¶ 1.] Lennis Rennich-Craig (Rennich) motioned for summary judgment that the trial court failed to hold a mental health hearing pursuant to SDCL 23A-7-16. The habeas court denied the motion and quashed the writ of habeas corpus. Rennich appeals. We reverse and remand.

FACTS
[¶ 2.] Rennich, born October 22, 1950, was charged with six forgeries and 20 burglaries in June of 1996. These crimes were committed between May 28 and June 10, 1996. On July 23, 1996, she appeared at her arraignment, waived the preliminary hearing and, pursuant to a plea agreement, entered a plea of guilty but mentally ill to one count of forgery and two counts of burglaries. The State dismissed the remaining 23 counts.
[¶ 3.] The trial court asked: "Is there a factual basis, which would include any reports from Community Counseling, to indicate the status of the [d]efendant's mental condition?" The State presented numerous documents to the court and replied:
Yes, Your Honor. We have the report from the police department for the check itself, the affidavit of forgery, and pictures of the [d]efendant negotiating this check at the ... [b]ank.

* * *
We also have the evaluation by Dr. Park, a psychiatrist at our mental health center, done earlier this year and also information from earlier this year from the Human Services Center outlining the [four] different medications the [d]efendant should be taking and what they are for.
*125 (emphasis added). There is no record indication that the court considered the information presented by the State. The State claims that the trial court, by merely accepting this information, substantially complied with SDCL 23A-7-16. However, the State does not substantiate when the trial court actually considered the information.[1] Instead, the record reflects that the trial court immediately determined that Rennich was "competent to enter a plea" and stated: "I will accept the plea of guilty but mentally ill, and also find that there is a factual basis for the plea."
[¶ 4.] Within the information received by the trial court were three sets of documents related to Rennich's mental health.
[¶ 5.] The first set involved four prescription documents from the South Dakota Human Services Center dated March 27, 1996. These documents set forth the name of the medication, its purpose, directions and possible side effects.
[¶ 6.] The second set was a psychologist's report dated February 13, 1996. The report indicated that Rennich recently attempted suicide and diagnosed her with posttraumatic stress disorder and clinical depression.
[¶ 7.] The third set involved two psychiatric evaluations completed by Dr. Choong-Geun Park. On March 7, 1996, Dr. Park noted that Rennich was unresponsive and in a "disassociative state." He diagnosed her with "acute stress disorder and recurrence of posttraumatic stress disorder."[2] The second evaluation, attached to the first, was dated March 8, 1996. It indicated that Dr. Park met with Rennich at the county jail.[3] He noted that she tried to communicate verbally, but "was not able to say a word." He also noted that she "is not aware of what she [was] charged with. She is not aware that she has to go to court for trial. She is not aware of the role of the district attorney or judge at the court hearing. [S]he is not able to cooperate with her lawyer to defend herself at the court hearing." His diagnosis of Rennich broadened from the previous day: (1) Acute Stress Disorder; (2) Conversion Disorder, Motor Deficit, Aphonia; (3) Antisocial Personality; and (4) rule out brief psychotic disorder." He concluded that she was not competent to stand trial.
[¶ 8.] On July 26, 1996, the trial court sentenced Rennich to 10 years in the South Dakota State Penitentiary on each of two counts of burglary and five years on one count of forgery, all sentences to be served consecutively. Rennich did not appeal.
[¶ 9.] On April 10, 1998, Rennich filed an application for writ of habeas corpus. Counsel was appointed and an amended petition for writ of habeas corpus was filed on August 18, 1998. The amended writ alleged that she: (1) received ineffective assistance of counsel; (2) was deprived of due process because (a) she was mentally ill when she entered her plea and (b) no mental health hearing was held in accordance with SDCL 23A-7-16; and (3) received cruel and unusual punishment.
[¶ 10.] On October 16, 1998, Rennich moved for summary judgment arguing *126 that the trial court failed to hold a competency hearing in direct violation of SDCL 23A-7-16. The habeas court determined that no genuine issues of material fact existed, but still denied the motion because the issue was a procedural defect, not a jurisdictional defect, and, therefore, could not be raised on habeas.
[¶ 11.] In November of 1998, Dr. David Bean, a psychiatric expert, was appointed to evaluate Rennich's "mental competency in 1996 during the various stages of the underlying legal [and] criminal proceedings." On April 27, 1999, after Rennich received Dr. Bean's report, she waived all the grounds for habeas relief except the issue within the motion for summary judgment. The writ was subsequently quashed and a certificate of probable cause was issued. Rennich appeals the habeas court's denial of her motion for summary judgment.[4]

STANDARD OF REVIEW
[¶ 12.] Our standard of review for a habeas appeal is well established.
Habeas corpus is not a substitute for direct review. Because habeas corpus is a collateral attack upon a final judgment, our scope of review is limited. On habeas review, the petitioner has the initial burden of proof. We review the habeas court's factual findings under the clearly erroneous standard.
Weddell v. Weber, 2000 SD 3, ¶ 13, 604 N.W.2d 274, 279 (quoting Sund v. Weber, 1998 SD 123, ¶ 12, 588 N.W.2d 223, 225) (other citations omitted)). Questions of law, however, are reviewed de novo. Jenner v. Dooley, 1999 SD 20, ¶ 11, 590 N.W.2d 463, 468.
[¶ 13.] WHETHER A TRIAL COURT'S VIOLATION OF A SUBSTANTIVE STATUTORY PROCEDURE IS SUBJECT TO CHALLENGE IN HABEAS CORPUS PROCEEDINGS.
[¶ 14.] In 1983, the South Dakota Legislature enacted SDCL 23A-7-16, which allowed a defendant to plead guilty but mentally ill.[5] The intent of this legislation *127 was to provide mental health treatment for those individuals whose defense falls short of legal insanity, but who, nevertheless, were in need of treatment for their mental illness. "One does not need to possess a medical degree with a specialty in psychiatry to realize that incarceration of a mentally ill defendant without structured psychiatric care will likely exacerbate the manifestations of his mental illness." Commonwealth v. Trill, 374 Pa.Super. 549, 543 A.2d 1106, 1120 (1988). See also People v. Blue, 428 Mich. 684, 411 N.W.2d 451, 455 (1987) (stating the purpose is two-fold: (1) to ensure that mentally ill defendants receive professional treatment while incarcerated; and (2) "to assure the public that a criminally responsible and mentally ill defendant will not be returned to [society] ... without having received necessary psychiatric care after sentencing.").
[¶ 15.] Before accepting a plea of guilty but mentally ill, the legislature requires that the defendant be "examined by a licensed psychiatrist and the court ... examine[] the psychiatric reports." SDCL 23A-7-16. The trial court is also statutorily required to "hold a hearing on the defendant's mental condition...." Id. "[I]f 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." Id. See also State v. Whitney, 486 N.W.2d 269, 272 (S.D. 1992) (stating that the factual basis must justify "a finding that the criminal defendant was mentally ill at the time of the alleged offense.").
[¶ 16.] The State argues that Rennich is not entitled to habeas corpus relief based on a statutory violation; i.e. that the trial court violated SDCL 23A-7-16 by failing to hold a mental health hearing before accepting Rennich's pleas of guilty but mentally ill. We disagree.
[¶ 17.] Since at least 1887, grounds on which habeas corpus relief may be granted in South Dakota have been set forth by the legislature. One of those grounds states that habeas relief may be granted when "the process is defective in some substantial form required by law." SDCL 21-27-16(3).
[¶ 18.] In Security Savings Bank v. Mueller, 308 N.W.2d 761, 762 (S.D.1981), this court was presented with a similar issue. In Security, an order to arrest Mueller was served after docketing the default judgment taken against him. However, SDCL 15-22-9 requires service before docketing the judgment. There was no direct appeal. Mueller filed a habeas petition and argued that service was improper under SDCL 15-22-9. The habeas court denied the writ. In reversing and remanding this decision, this court stated:
Although habeas corpus is not a substitute for direct appeal, appellant may assert jurisdictional errors which renders the first judgment void. In the context of habeas corpus, jurisdictional error is given an expansive construction. Of course, this includes personal and subject matter jurisdiction, but due process violations and compliance with substantive statutory procedures are also subject to challenge in habeas corpus proceedings.

Id. at 762-63 (internal citations omitted) (emphasis added).[6]
[¶ 19.] The United States Supreme Court has also determined that procedural errors so obvious as to result in an unfair hearing may be raised on habeas corpus. In Eagles v. United States ex rel. Samuels, 329 U.S. 304, 315, 67 S.Ct. 313, 319, 91 L.Ed. 308, 316 (1946), the United States Supreme Court stated: "[t]he function of habeas corpus is not to correct a practice but only to ascertain whether the procedure *128 complained of has resulted in an unlawful detention." Therefore, a petition for a writ of habeas corpus is available to remedy procedural errors made at trial if those procedures are of such a nature or magnitude to render the entire detention unlawful. Id. at 312, 67 S.Ct. at 318, 91 L.Ed. at 315.
[¶ 20.] Consequently, the issue is whether the trial court's failure to comply with SDCL 23A-7-16 is a substantive procedural error that resulted in an unlawful detention.
[¶ 21.] The failure to conduct a mental health hearing, as required by SDCL 23A-7-16, is not a mere irregularity. See our recent case of State v. Anderson, 2000 SD 8, ¶¶ 19-21, 604 N.W.2d 482, 486-87 (reversing and remanding Anderson's conviction for failure to comply with SDCL 23A-7-16). The trial court must conduct the hearing before the plea of guilty but mentally ill can even be accepted. By express statutory terms, the hearing and assessment process is mandatory and automatically triggered once the defendant attempts to enter a plea of guilty but mentally ill. The hearing cannot be waived or ignored. See Krause v. Fogliani, 82 Nev. 459, 421 P.2d 949, 951 (1966) (holding that "the court, sua sponte, was required to order a competency hearing. The failure of the defendant to request that hearing did not `waive' his right."). "[I]t is contradictory to argue that a defendant may be incompetent, and yet knowingly or intelligently `waive' h[er] right to have the court determine h[er] capacity to stand trial." Id. (quoting Pate v. Robinson, 383 U.S. 375, 384, 86 S.Ct. 836, 841, 15 L.Ed.2d 815, 821 (1966) (citing Taylor v. United States, 282 F.2d 16, 23 (8th Cir.1960)).
[¶ 22.] In determining whether a factual basis for a plea of guilty but mentally ill exists, "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)). Instead of appointing a licensed psychiatrist and holding a hearing to determine Rennich's mental health, the trial court concluded that a factual basis existed based on reports dated February 13, 1996, March 7-8, 1996 and March 27, 1996. Clearly those reports and documents do not establish that Rennich was mentally ill at the time she allegedly committed these crimes - from May 28 to June 6, 1996. Here, there is no factual basis because the prior evaluations of mental illness were not brought current to the time period when the crimes were committed. Nor does this review, if any, of unsworn documentary evidence constitute a hearing: "the mere consideration of a report moving across one's desk, is not a hearing." Commonwealth v. Davis, 531 Pa. 272, 612 A.2d 426, 429 (1992) (citation omitted). In failing to conduct the hearing, the trial court failed to perform its statutory responsibility to conduct an independent and meaningful procedure to timely and fully evaluate Rennich's mental health.
[¶ 23.] We determine that the failure to hold this mandatory hearing was "defective in [a] substantial form required by law." SDCL 21-27-16(3). This defect resulted in the unlawful detention of Rennich. Therefore, we reverse the habeas court's denial of Rennich's motion for summary judgment and remand so that Rennich can be evaluated by a licensed psychiatrist and a hearing can be held to determine whether she was mentally ill at the time these criminal offenses were committed.
[¶ 24.] AMUNDSON, Justice, concurs.
[¶ 25.] MILLER, Chief Justice, concurs specially.
[¶ 26.] KONENKAMP and GILBERTSON, Justices, dissent.
MILLER, Chief Justice (concurring specially)
[¶ 27.] I totally agree with Justice Konenkamp that a person on parole is not *129 entitled to bring a habeas corpus petition. However, if there is any evidence that such person is being physically confined or otherwise restrained of her liberty, then a habeas action is warranted. Because the scant record evidence indicates that Rennich may in fact be physically confined to the Kingsbury Manor, I concur with the majority opinion.
[¶ 28.] Although Rennich was ostensibly paroled, a condition of her parole agreement specifically states that she is to be "confined to the Kingsbury Memorial Manor for medical assistance and care." This provision implies the State intended that Rennich would remain within the facility; accordingly, such a condition was a restraint on her freedom. Additional support for this conclusion lies in the fact that the State has never argued Rennich was not in custody. In fact, Rennich's motion for transport to her habeas hearing, which "move[d] the court to allow [her] to attend the hearing," was denied. This also suggests that Rennich's freedom was restrained by the State, notwithstanding her status as a parolee.
[¶ 29.] Because there was evidence that Rennich was "confined" by the State, a habeas petition was an appropriate vehicle with which to reach the merits of the case.
KONENKAMP, Justice (dissenting).
[¶ 30.] We do not have authority to hear this habeas appeal because the Governor commuted the petitioner's sentence and she was placed on parole. Our statutes provide that habeas petitioners are not entitled to relief unless they are "committed or detained, imprisoned or restrained" of their liberty. SDCL 21-27-1. Habeas petitioners must specify in their petitions the facts concerning their detention and in whose custody they are detained. SDCL 21-27-3. The petitioner is certainly not in the custody of the one she alleges, respondent Duane Russell, the warden of the women's penitentiary. A writ issued to him would have no effect as he cannot deliver her or release her.
[¶ 31.] Concededly, parolees remain in the legal custody of the Department of Corrections and subject to the authority of the Board of Pardons and Paroles until their sentences expire. Nonetheless, parolees are not "imprisoned" or "detained" in physical custody and may not be placed back in prison unless they violate the conditions of their parole. People ex rel. Williams v. Morris, 44 Ill.App.3d 39, 2 Ill.Dec. 631, 357 N.E.2d 851, 853 (1976) ("Considering the history and nature of habeas corpus, we believe that actual custody is necessary for maintaining this action."). Furthermore, the petitioner is in no danger of losing her parole status. No one alleges that she has violated her parole conditions and she is not awaiting parole revocation proceedings.
[¶ 32.] Other states have held likewise, although there is a split of authority on whether parolees can maintain a state habeas corpus action. See Andrea G. Nadel, J.D., When is a Person in Custody of Governmental Authorities for Purpose of Exercise of State Remedy of Habeas CorpusModern Cases, 26 A.L.R.4th 455 (1983). However, the better reasoned decisions hold that persons on parole no longer have their liberty restrained to such a degree that they are entitled to the extraordinary relief afforded through habeas corpus proceedings. People ex rel. Wilder v. Markley, 26 N.Y.2d 648, 307 N.Y.S.2d 672, 255 N.E.2d 784 (N.Y.1970). See In re Painter, 85 S.D. 156, 179 N.W.2d 12, 13 (1970) (person free on bond not eligible for habeas relief).
[¶ 33.] The petitioner may have other remedies to challenge her conviction, but because she has been released from prison, habeas corpus is not a proper remedy. I would dismiss the petition.
[¶ 34.] GILBERTSON, Justice, joins this dissent.
NOTES
[1]  The State also argues that Rennich waived this issue for two reasons. First, the State claims that prior to the arraignment, Rennich agreed to the State's use of these documents to establish a factual basis for her mental illness. Second, Rennich did not object to the trial court's failure to hold a hearing before accepting her plea.
[2]  The posttraumatic stress disorder diagnosis stems from her being raped by an unknown assailant on April 7, 1993. Prior to the rape, family members and friends describe Rennich as a wonderful single-parent of three children who was attending Huron University. After the rape, her mental and physical condition deteriorated. Her family and friends stated that her criminal behavior was extremely "uncharacteristic." She also developed an eating disorder and a gambling addiction. She attempted suicide seven times in four and one-half years.
[3]  She was apparently in jail for an unrelated offense.
[4]  While in prison, Rennich developed a debilitating illness, reflex sympathetic dystrophy, which left her confined to a wheelchair. Consequently, the degree of care that she required was beyond that offered in the women's prison. Therefore, on October 1, 1998, Governor Janklow commuted Rennich's sentence conditioned on her signing a parole agreement with the Board of Pardons and Paroles. Pursuant to the agreement, Rennich is confined to the Kingsbury Memorial Manor in Lake Preston, South Dakota for medical assistance and care, subject to the usual terms and conditions of parole.

The following demonstrates some of the limitations of her parole: On October 16, 1998, Rennich formally requested that she be released from the Kingsbury Manor to attend the hearing on her Motion for Summary Judgment. The request, directed to the habeas court, involved the sheriff transporting her to the courthouse. The habeas court denied her request. Because Rennich is clearly under the custody and control of the State, this habeas action is not moot. See SDCL 21-27-1; Moeller v. Solem, 363 N.W.2d 412, 414 (S.D.1985) (holding that habeas corpus relief is available only to persons who are "committed, detained, imprisoned... or otherwise restrained of [their] liberty[.]").
In Moeller, the petitioner had completed his sentence and was attempting to get his conviction declared "null and void." In deciding whether the appeal was moot, we stated that "[a] case is moot when judgment, if rendered, will have no practical legal effect upon the existing controversy." Id. at 413. Because Moeller was not imprisoned or restrained of his liberty, the appeal was declared moot. Rennich's situation is substantially different from Moeller's because Rennich is under the control of the State, is in custody and her liberty is restrained by the State and our determination will have a substantial legal effect on the existing controversy.
[5]  Mental illness is defined by SDCL 22-1-2(24) as:

[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 be repeated criminal or otherwise antisocial conduct.
[6]  The State argues that the cases of Gross and Everitt support its argument that this issue can not be raised in habeas. However, the issue in both of these cases was whether there was a sufficient factual basis presented during the mental health hearing to support the trial court's acceptance of the plea of guilty but mentally ill. Gross v. Solem, 446 N.W.2d 49, 51 (S.D.1989); Everitt v. Solem, 412 N.W.2d 119, 120 (S.D.1987). Here, the issue is substantially different because there was no hearing. Therefore, these cases do not control.
