
241 P.3d 573 (2010)
Dustin J. MERRYFIELD, Appellant,
v.
STATE of Kansas, et al., Appellees.
No. 103,394.
Court of Appeals of Kansas.
October 22, 2010.
*575 Dustin J. Merryfield, of Larned, appellant pro se.
C. William Ossmann, chief of litigation, and Danny J. Baumgartner, litigation attorney, of Kansas Department of SRS, for appellees.
Before McANANY, P.J., BUSER and LEBEN, JJ.
LEBEN, J.
For more than a decade, Dustin Merryfield has been confined at the Larned State Hospital under the Kansas Sexually Violent Predator Act, K.S.A. 59-29a01 et seq. He has filed a habeas-corpus petition under K.S.A. 60-1501 raising claims that go to the core of the Kansas treatment program for sexual predators: Merryfield claims that the program is run so poorly that it doesn't offer a realistic opportunity to cure or improve the mental abnormality for which he has been involuntarily confined. We must reverse the district court summary dismissal of Merryfield's petition because it raises constitutional claims of potential merit.
We also reverse the district court's decision refusing to appoint counsel to represent Merryfield in this habeas action. While there is no general right to counsel in civil habeas cases, the constitutionality of the Kansas Sexually Violent Predator Act depends upon the procedural rights given to those who are involuntarily committed under its provisions. The Kansas Legislature has explicitly provided a right to counsel to such persons during annual review hearings and has explicitly provided a right to counsel in K.S.A. 60-1501 proceedings to those involuntarily committed under other similar statutes. We therefore conclude that in the case of habeas actions brought by persons confined pursuant to the Kansas Sexually Violent Predator Act, those persons have a constitutional right to counsel if the district court determines that their petitions cannot be summarily dismissed.

FACTUAL BACKGROUND
Since December 2000, Dustin Merryfield has been confined under the Kansas Sexual Predator Treatment Program at Larned State Hospital. He was put in the program's intensive-treatment unit after he hit a staff member, verbally threatened other staff members, and destroyed property during a routine room search. See Merryfield v. Turner, 2008 WL 4239118, at *1 (Kan.App.2008) (unpublished opinion), rev. denied 288 Kan. 832 (2009). The intensive-treatment unit seeks to help patients with anger, stress tolerance, and decision-making so that they can be successful upon return to the regular treatment program.
Merryfield's current K.S.A. 60-1501 petition claims the treatment program does not provide constitutionally adequate care and treatment for his mental and personality disorders. After serving the petition, Merryfield made several discovery requests of the Department of Social and Rehabilitation Services, seeking both documents and admissions. At the department's request, the district court delayed discovery until it had determined whether Merryfield's petition stated any potentially valid clams. The district court also deferred ruling on Merryfield's request for an attorney until the department responded to the petition.
The department filed a motion to dismiss, claiming that Merryfield's petition failed to meet the standards for a viable constitutional claim, i.e., that he hadn't alleged either shocking or intolerable confinement conditions *576 or continuing mistreatment of a constitutional nature. The district court agreed and summarily dismissed Merryfield's petition because Merryfield had not presented a substantial question of law or a factual dispute requiring trial. The district court then denied appointment of counsel because Merryfield hadn't presented a substantial question of law or factual dispute requiring trial. The district court determined that the request for discovery was moot because the petition was being dismissed. Merryfield has appealed all of these rulings to our court.

I. Because Merryfield Has Alleged Continuing Mistreatment of a Constitutional Nature, His Petition Cannot Be Summarily Dismissed.

Merryfield's petition raises a litany of claims asserting that the Kansas Sexual Predator Treatment Program can't give him the appropriate treatment that could lead to his release. He specifically claimed that: (1) the program's therapists weren't adequately trained; (2) the intensive-treatment unit forces treatment by withholding items of comfort if the patient refuses treatment; (3) it isn't effective to show him obscene materials during therapy sessions to achieve the goal of teaching that possessing such materials is wrong; (4) individual therapy sessions are needed but not provided; and (5) effective treatment methods are hindered by overriding security measures and the lack of funds and resources.
A person involuntarily confined in the Kansas Sexual Predator Treatment Program may petition the court under K.S.A. 60-1501 for a declaration that the confinement is wrongful. Johnson v. State, 289 Kan. 642, 648, 215 P.3d 575 (2009). To avoid summary dismissal, the petition must allege either (1) shocking or intolerable conduct or (2) continuing mistreatment of a constitutional nature. 289 Kan. at 648, 215 P.3d 575. The petition may be summarily dismissed if it does not make such allegations or if it can be established from incontrovertible facts that no cause for granting relief exists. 289 Kan. at 648-49, 215 P.3d 575. On appeal from a summary dismissal, we review the matter without any required deference to the district court because we have equal access to the petition and court files. See 289 Kan. at 649, 215 P.3d 575.
Merryfield's allegations do not meet the standard for shocking conduct. To meet that test, the United States Supreme Court has said that the governmental actor's behavior must be "so egregious, so outrageous, that it may fairly be said to shock the contemporary conscience." County of Sacramento v. Lewis, 523 U.S. 833, 847 n. 8, 118 S.Ct. 1708, 140 L.Ed.2d 1043 (1998). That standard is a bit subjective, but the Johnson case provides some guidance. If the state hospital staff showed a complete indifference to their obligation to provide treatment to Merryfield, that could qualify as outrageous conduct. See Johnson, 289 Kan. at 653, 215 P.3d 575. But as was the case in Johnson, the allegations here are primarily that treatment is being provided, but it's ineffective. That does not show conduct so outrageous as to shock the contemporary conscience. 289 Kan. at 652-53, 215 P.3d 575.
As to the alternative grounds for reliefcontinuing mistreatment of a constitutional naturethe United States Supreme Court has not said what specific elements or characteristics comprise a constitutionally adequate civil-commitment program for sex offenders who are a continuing risk to society. See Johnson, 289 Kan. at 653-54, 215 P.3d 575. We must balance the individual's liberty interest against the government's reasons for restraining liberty. Youngberg v. Romeo, 457 U.S. 307, 320-21, 102 S.Ct. 2452, 73 L.Ed.2d 28 (1982). In balancing these interests in the context of treatment programs for civilly confined sex offenders, one federal appellate court has held that the treatment programs must provide a realistic opportunity for the offenders to be cured or improve the condition for which they were committed, see Sharp v. Weston, 233 F.3d 1166, 1172 (9th Cir.2000), while another held that the conditions and duration of confinement must at least bear a reasonable relationship to providing treatment rather than mere preventive detention. Cross v. Harris, 418 F.2d 1095, 1106-07 (D.C.Cir.1969). Indeed, the United States Supreme Court's decision upholding the constitutionality of the *577 original Kansas law for civil commitment of sexual predators was based in part on the provision of appropriate treatment. See Kansas v. Hendricks, 521 U.S. 346, 368-69, 117 S.Ct. 2072, 138 L.Ed.2d 501 (1997). Due process of a civilly committed sex offender requires that the conditions and duration of confinement bear some reasonable relation to the purpose for which the person has been committed. Seling v. Young, 531 U.S. 250, 265, 121 S.Ct. 727, 148 L.Ed.2d 734 (2001). One important purpose of Merryfield's commitment is for treatment of the mental abnormality that led to his confinement as a dangerous sex offender. See K.S.A. 59-29a01 (establishing civil commitment process "for the potentially long-term control, care and treatment of sexually violent predators"); K.S.A. 59-29a07(a) (allowing commitment of dangerous sex offenders into state custody "for control, care and treatment until such time as the person's mental abnormality or personality disorder has so changed that the person is safe to be at large"); K.S.A.2009 Supp. 59-29a22(b)(3) (recognizing committed sex offender's "right to receive prompt and adequate treatment, rehabilitation and educational services appropriate for such patient's condition").
Merryfield's allegations, if true, establish that the treatment program does not provide a realistic opportunity for him to be cured or to substantially improve his condition. Those allegations are sufficient to withstand summary dismissal. We have summarized Merryfield's allegations for the purposes of our opinion, but we note that he did provide more specific allegations than we have summarized here. For example, he made specific allegations about the lack of qualifications of individual therapists and about the ineffectiveness of some of the treatment methods, such as group sessions and the showing of obscene materials in treatment sessions. We recognize that courts should defer to the judgment of professionals in what conditions and treatment methods are needed. See Youngberg, 457 U.S. at 322-23, 102 S.Ct. 2452; Allison v. Snyder, 332 F.3d 1076, 1079 (7th Cir.2003). But such a judgment call would not be made at the summary-dismissal stage when the petition may be dismissed only if incontrovertible facts establish that the petitioner is not entitled to relief.
In addition to his claim that the treatment actually provided to him has been constitutionally inadequate, Merryfield made one facial challenge to the overall validity of K.S.A.2009 Supp. 59-29a22, the statute under which he has been confined. He argued that this statute wrongfully limited his right to receive treatment upon the availability of state and federal funds to provide that treatment. But a facial challengein which a party does not have to show factually that the statute is being applied in an unconstitutional mannermust fail if "there is any reasonable way to construe the statute as constitutionally valid." In re Tax Appeal of Weisgerber, 285 Kan. 98, 102, 169 P.3d 321 (2007). Merryfield correctly notes that the statutory recognition of his "right to receive prompt and adequate treatment, rehabilitation and educational services appropriate to [his] condition" is only granted "within the limits of available state and federal funds." K.S.A.2009 Supp. 59-29a22(b)(3). But we are to construe statutes to be constitutional if possible, State v. Laturner, 289 Kan. 727, 735, 218 P.3d 23 (2009), and a state may not withhold needed treatment from a civilly committed sex offender based on a claim that funds are lacking. Ohlinger v. Watson, 652 F.2d 775, 779 (9th Cir.1980); Turay v. Seling, 108 F.Supp.2d 1148, 1151 (W.D.Wash. 2000). Moreover, K.S.A. 59-29a09 explicitly provides that the confinement "of persons under this act shall conform to constitutional requirements for care and treatment." We therefore construe K.S.A.2009 Supp. 59-29a22(b)(3) to grant the right to adequate treatment meeting constitutional standards but to condition any treatment beyond that constitutionally required minimum level upon the availability of funds. Thus, while the statute survives a facial constitutional challenge, Merryfield still will have the opportunity to prove at a hearing that a lack of funding has resulted in his treatment falling below constitutional standards.
Merryfield has also contended that the Kansas Sexually Violent Predator Act violates equal protection by treating sexual predators different than people civilly committed *578 under the Care and Treatment Act for Mentally Ill Persons, K.S.A. 59-2945 et seq., and the Care and Treatment Act for Persons with an Alcohol or Substance Abuse Problem, K.S.A. 59-29b45 et seq.
Status as a sex offender is not a suspect class, like race or national origin, for equal-protection analysis. See United States v. LeMay, 260 F.3d 1018, 1030 (9th Cir.2001); Hines v. Addison, 117 Fed.Appx. 713, 715 (10th Cir.2004) (unpublished opinion). Thus, the Act will be constitutional if the classification bears a rational relationship to a legitimate government objective. State v. Mueller, 271 Kan. 897, 903, 27 P.3d 884 (2001), cert. denied 535 U.S. 1001, 122 S.Ct. 1570, 152 L.Ed.2d 491 (2002). But to violate equal protection, the disparity in treatment must be between persons with indistinguishable situations. 271 Kan. at 903, 27 P.3d 884. The legislature explicitly recognized that sexually violent predators have special treatment needs and present special risks to society:
"Because the existing civil commitment procedures under K.S.A. 59-2901 et seq. and amendments thereto are inadequate to address the special needs of sexually violent predators and the risks they present to society, . . . a separate involuntary civil commitment process for the potentially long-term control, care and treatment of sexually violent predators is necessary." K.S.A. 59-29a01.
Merryfield argues that this intent shows that the legislature merely wanted to provide sexually violent predators with specialized treatment, not "a whole new level of confinement." Contrary to his argument, the legislature further deemed it "necessary to house involuntarily committed sexually violent predators in an environment separate from persons involuntarily committed under" the statute for the commitment of the mentally ill. K.S.A. 59-29a01.
The legislature has declared that sexually violent predators are different from other civilly committed persons with respect to treatment and risk, and those legislative findings pass muster on this facial challenge to the statute's constitutionality. Merryfield had the threshold burden to establish that sexually violent predators are similarly situated to others confined for mental illness with respect to treatment needs and risks to society. See People v. Ranscht, 173 Cal. App.4th 1369, 1372, 93 Cal.Rptr.3d 800 (2009); Varnum v. Brien, 763 N.W.2d 862, 882 (Iowa 2009). He has not done so. Thus, the department can subject those found to be sexually violent predators to treatment and confinement conditions different from those of other civilly committed persons without violating the Equal Protection Clause. See In re Detention of Samuelson, 189 Ill.2d 548, 562-63, 244 Ill.Dec. 929, 727 N.E.2d 228 (2000); In re Detention of Williams, 628 N.W.2d 447, 451-53 (Iowa 2001); Pedersen v. Plummer, 120 Fed.Appx. 665, 666-67 (9th Cir.2004) (unpublished opinion); Brull v. Kansas Dept. of SRS, 2010 WL 3984998, at *7 (Kan.App.2010) (unpublished opinion); but see People v. McKee, 47 Cal.4th 1172, 1203-04, 104 Cal.Rptr.3d 427, 223 P.3d 566 (2010) (remanding equal-protection claim for evidentiary hearing under strict-scrutiny test).

II. Merryfield Is Entitled to the Appointment of Counsel.

Merryfield sought the appointment of counsel in the district court; that court denied that request based on its conclusion that Merryfield had not presented a viable issue for an evidentiary hearing. Because we have reversed that finding, we must consider whether Merryfield is entitled to counsel on remand. He argues a right to counsel on both a constitutional and statutory basis.
He bases the statutory argument on K.S.A. 22-4503(a), which provides a right to counsel in habeas proceedings brought by persons involuntarily committed on account of mental illness. Because he too is civilly committed, he argues that the statute should apply to him. If it doesn't, then he argues that he has been denied equal protection because other similarly situated people have a statutory right to counsel and he doesn't.
K.S.A. 22-4503(a) does not provide a right to counsel to Merryfield. By its terms, only "[a] person subject to an order or commitment pursuant to K.S.A. 22-3428 or K.S.A. 59-2965" is given a right to counsel in habeas *579 proceedings. Merryfield is confined under K.S.A. 59-29a07, part of the Kansas Sexually Violent Predator Act, not under K.S.A. 22-3428 (applicable to persons acquitted in criminal cases on account of mental disease or defect) or K.S.A. 59-2965 (applicable to persons committed on account of mental illness).
Of course, our inquiry does not stop with the statute; Merryfield has also claimed a constitutional right to counsel. Before discussing that in detail, we must place his habeas petition under K.S.A. 60-1501 in context. The writ of habeas corpus allows a person held by the government to challenge the lawfulness of the confinement, a quintessential right in our nation. When used by a person already convicted of a crime, the habeas petition is usually a collateral attack on the fairness of the procedures used to obtain that conviction. In that context, in which a defendant has already had a right to counsel through the criminal case, including an appeal, there generally is no constitutional right to counsel in the postconviction habeas case, which is civil in nature, not criminal. See Pennsylvania v. Finley, 481 U.S. 551, 555, 107 S.Ct. 1990, 95 L.Ed.2d 539 (1987); Brown v. State, 278 Kan. 481, 483, 101 P.3d 1201 (2004) (citing Finley).
But the traditional habeas context at issue in Finley, in which a person is held in custody based on conviction for a crime, is not Merryfield's case at all. He is detained not as punishment for a crime but for purposes of treatment and public safety. He has been involuntarily committed in a civil proceeding, not a criminal one. The United States Supreme Court has recognized a limited right to counsel under the Fourteenth Amendment's Due Process Clause in some civil proceedings. See In re Gault, 387 U.S. 1, 41, 87 S.Ct. 1428, 18 L.Ed.2d 527 (1967) (holding that a juvenile has a constitutional right to counsel in delinquency proceedings despite designation of such proceedings as civil in nature). But Merryfield's case also differs from Gault and most other cases in which a right to counsel has been recognized because the right to counsel usually has been recognized in the case resulting in the initial deprivation of liberty, not a later proceeding raising a collateral attack. E.g., Project Release v. Prevost, 722 F.2d 960, 976 (2d Cir.1983) ("A right to counsel in civil commitment proceedings may be gleaned from the Supreme Court's recognition that commitment involves a substantial curtailment of liberty and thus requires due process protection."); Jenkins v. Director, Va. Ctr. for Behav. Rehab., 271 Va. 4, 15-16, 624 S.E.2d 453 (2006) (person subject to involuntary civil commitment, including sexually violent predator, has constitutional right to counsel at all significant stages of the proceeding).
We conclude that Merryfield's situation differs substantially from the traditional habeas context at issue in Finley where no constitutional right to counsel exists and that a constitutional right to counsel must be recognized whenever a person in his position has presented a petition under K.S.A. 60-1501 that is not subject to summary dismissal. As our court emphasized in In re Care & Treatment of Miles, 42 Kan.App.2d 471, 476, 213 P.3d 1077 (2009), the rights available to persons confined under the Kansas Sexually Violent Predator Act are critical to the constitutionality of the entire statutory scheme. Merryfield's issues here go to the heart of the program's constitutionality. His liberty interest is manifest, and he contendswith sufficient basis to warrant an evidentiary hearingthat the treatment provided to him is so ineffective that it could never give him the help he would need to regain his freedom. A person like Merryfield, who has been involuntarily committed in a civil proceeding that explicitly recognizes that the detention may be for a long-term period more than a decade so far for Merryfield must be entitled to the assistance of counsel in the resolution of such substantial claims.
This result is supported by both due-process and equal-protection analysis. Courts have recognized a constitutional due-process right to counsel at all significant stages of the proceedings in states where there wasn't a statutory right to counsel in the initial commitment stage. E.g., United States v. Abregana, 574 F.Supp.2d 1123, 1140-41 (D.Hawai`i 2008); Jenkins, 271 Va. at 16, 624 S.E.2d 453 (2006); State ex rel. Seibert v. Macht, 244 Wis.2d 378, 387-89, 627 N.W.2d 881 (2001). A K.S.A. 60-1501 *580 petition must present a claim of constitutional mistreatment, and the failure to provide appropriate procedural rights for the presentation of such claims in Merryfield's circumstance would violate due process. We therefore conclude that when the K.S.A. 60-1501 claims of a civilly committed sexual predator are not subject to summary dismissal, counsel must be appointed to represent the petitioner. Merryfield's claim that the treatment program is so poor that he will never regain his liberty is certainly among the most significant that could be brought by a person confined under the Kansas program for treatment of sexually violent offenders.
With respect to equal protection, we have already noted that the right to counsel in habeas cases is provided to persons civilly committed after being found guilty of certain offenses based on a claim of mental defect and to those civilly committed for general mental illness. The right to counsel in habeas cases is also provided in Kansas to inmates who have been imprisoned after felony convictions when their habeas motions under K.S.A. 60-1507 cannot be summarily dismissed. See K.S.A. 22-4506(b). In this situation, we are looking not at the different treatment needs or risk profiles of these groups; rather, we are looking at their ability to access the courts with the assistance of counsel. The legislature has not explicitly noted any difference between these groups with respect to their need for counsel to assist in presenting claims of unconstitutional confinement or treatment in court. With respect to assistance of counsel in presenting such claims, the legislature treats these groups differently: those who have been committed to the treatment program for sexual predators, those civilly committed for mental illness, and inmates convicted of felonies.
We will assume for purposes of our analysis that the most deferential equal-protection analysisthe rational-basis testapplies. Even under that test, however, we can discern no rational purpose for denying counsel to those in the sexual-predator treatment program while providing it to all of the others we've mentioned. Civilly committed sexually violent predators are constitutionally guaranteed more considerate confinement conditions than prisoners. Hendricks, 521 U.S. at 363, 117 S.Ct. 2072. There is no rational basis for making it fundamentally more difficult for those committed to the sexual predator treatment program to seek court redress for unconstitutional conduct including conduct that suggests the constitutionality of the entire program may be questionedthan other civilly committed individuals or inmates. See Macht, 244 Wis.2d at 387-89, 627 N.W.2d 881 (basing right to counsel in part on equal-protection analysis).
One provision in the Kansas Sexually Violent Predator Act, K.S.A. 59-29a06(b), provides a right to counsel "[a]t all stages of the proceedings" under that Act. But it's unclear whether the issues Merryfield has raised here can be raised in those proceedings, which are focused on the mental condition of the person confined or proposed for confinement, not upon the treatment provided while confined. Either way, the existence of that statute also supports our equal-protection analysis. If the claims that Merryfield has brought in this K.S.A. 60-1501 petition could be raised during the annual review hearings provided under the Kansas Sexually Violent Predator Act, it would be unreasonable that Merryfield could receive the assistance of counsel for such claims in that annual review hearing but not at any other time. More likely, because the annual review hearings are focused on the mental status of the person confined, the issues Merryfield has raised in his K.S.A. 60-1501 petition would not properly be considered during an annual review hearing. Yet these issues are integral to the constitutionality of the program, andif his allegations are proved truethe annual review hearings would become an empty exercise. Again, there is no rational basis to deny a right to counsel in the K.S.A. 60-1501 proceeding in this circumstance, yet grant counsel for the annual review hearings.

III. The District Court's Discovery Ruling Is Subject to Reconsideration on Remand.

Merryfield also claims on appeal that the district court should not have dismissed his claims without first allowing discovery. The *581 department did not respond to this point, but we have already determined that the case must be remanded for an evidentiary hearing. The district court denied Merryfield's discovery request solely on the basis that Merryfield had not submitted a claim that survived summary dismissal, so the district court will have further opportunity to consider whether discovery will be allowed on remand.
We have held that ordinary civil discovery methods do not apply in the context of a habeas proceeding under K.S.A. 60-1507 in which an inmate is confined and the habeas action challenges the former criminal proceeding that resulted in imprisonment. See LaPointe v. State, 42 Kan.App.2d 522, 550-51, 214 P.3d 684 (2009), rev. denied 290 Kan. ___ (2010); see also Bankes v. Simmons, 265 Kan. 341, Syl. & 1, 963 P.2d 412, cert. denied 525 U.S. 1060, 119 S.Ct. 629, 142 L.Ed.2d 567 (1998). But part of the basis for that rule is that the relevant facts are primarily tied to a record that had already been developed in the underlying criminal case, 42 Kan.App.2d at 551, 214 P.3d 684, yet Merryfield's challenge to his civil confinement involves his current treatment, not the record of a past proceeding. We express no opinion regarding whether formal discovery mechanisms like requests for documents or admissions mayor shouldbe granted to Merryfield on remand. That issue has not been briefed by the parties to this appeal.
We reverse the district court's judgment and remand the case for further proceedings consistent with this opinion.
