
608 P.2d 1203 (1980)
45 Or.App. 495
Edward William MUELLER, Appellant,
v.
Hoyt C. CUPP, Superintendent, Oregon State Penitentiary, Respondent.
No. 111,898; CA 16176.
Court of Appeals of Oregon.
Argued and Submitted February 15, 1980.
Decided March 24, 1980.
*1204 Michael Curtis, Salem, argued the cause and filed the brief for appellant.
Thomas H. Denney, Asst. Atty. Gen., Salem, argued the cause for respondent. With him on the brief were James A. Redden, Atty. Gen., and Walter L. Barrie, Sol. Gen., Salem.
Before BUTTLER, P.J., and GILLETTE and ROBERTS, JJ.
GILLETTE, Judge.
Petitioner, an inmate at the Oregon State Penitentiary, petitioned for a writ of habeas corpus alleging that respondent and his subordinates denied petitioner needed medical care and discriminated against him in terms of eligibility for work release because of his medical problems. Petitioner sought to compel immediate medical care and an end to the discrimination. The circuit court granted the defendant's motion to strike petitioner's amended replication because of lack of jurisdiction. Petitioner declined to plead further and the court entered an order dismissing the petition. We reverse.
This action is brought pursuant to ORS 34.310 which states, in part, that:
"* * * Every person imprisoned or otherwise restrained of his liberty, within this state, except in the cases specified in ORS 34.330, may prosecute a writ of habeas corpus to inquire into the cause of such imprisonment or restraint, and if illegal, to be delivered therefrom."
Petitioner is not challenging the legality of his imprisonment; rather, his claim is based on the treatment, or lack thereof, that he is receiving. The issue to be decided is whether this action, which is basically an action concerning conditions of confinement, can properly be brought as a habeas corpus action.
Traditionally, a writ of habeas corpus could only be used where a prisoner was challenging the legality of his confinement and was seeking release from that confinement. Courts expanded the scope of the writ to include cases where the prisoner was not challenging the judgment of conviction itself but rather "the legality of additional measures of imprisonment or restraint * * * beyond the initial restraint" of imprisonment itself. Penrod/ Brown v. Cupp, 283 Or. 21, 24, 581 P.2d 934, 936 (1978). The writ was for a time also extended in Oregon to include cases where the prisoner's sole claim concerned the legality of the treatment he or she was receiving. *1205 In Newton v. Cupp, 3 Or. App. 434, 437, 474 P.2d 532, 534 (1970), we stated that "habeas corpus is available in Oregon to test the constitutionality of treatment afforded an inmate of a penal institution."
An important reason for our decision in Newton was the fact that, at the time, prisoners convicted of a felony were denied by statute the right to pursue ordinary civil remedies against illegal treatment. Id., at 439, 474 P.2d 532. In 1975, the legislature abolished civil death of prisoners; this gave them recourse to ordinary civil remedies. ORS 137.275. Despite the repeal of "civil death" and the resulting availability of other remedies, however, the Oregon Supreme Court nevertheless subsequently concluded that "the writ of habeas corpus remains available to challenge alleged deprivations of a prisoner's rights" where the deprivations complained of relate solely to the prisoner's treatment in prison. Penrod/Brown v. Cupp, supra, at 23-24, 581 P.2d at 935. However, the court in Penrod limited the instances in which prisoners could challenge the conditions of their confinement in this way. In order to bring such an action, two essential elements must exist. The petitioner must show (1) a need for immediate judicial attention either because of the "urgency of the harm to which the prisoner claims to be exposed or * * * [judicial scrutiny] is found to be required as a matter of constitutional law", and (2) the lack of any other adequate and timely remedy. Penrod/Brown v. Cupp, supra, at 28, 581 P.2d at 937.
Petitioner suffers from diabetes. He alleges that, when he was first incarcerated, prison officials failed to supply him with a diabetic's diet or insulin and that, as a result, he suffered a diabetic coma. Since that time he has received insulin but not the necessary diabetic diet. He claims to be going blind as a consequence. Petitioner alleges that prison officials have refused to provide him with the necessary surgery to arrest this deterioration in his eyesight. Additionally, he claims that they have also refused to provide him with the surgery needed to correct a congenital heart defect from which he suffers.
While petitioner does not claim a constitutional violation, he does allege a deprivation "which, if true, would require immediate judicial scrutiny." Penrod/Brown v. Cupp, supra, at 28, 581 P.2d at 937. Taking the allegations in his complaint as true, it is apparent that petitioner states a claim which requires immediate attention because of "the urgency of the harm" to which he claims to be exposed. Penrod/Brown v. Cupp, supra, at 28, 581 P.2d 934. The facts alleged, if true, show that he will suffer irreparable and immediate harm if he is not provided the diet he needs.[1]
The question remains as to whether there are other remedies available to petitioner which would prevent him from pursuing his claim by writ of habeas corpus. The alternative remedies said to be available to petitioner are a petition for writ of mandamus or a civil action seeking injunctive relief.
A writ of mandamus, like a writ of habeas corpus, is an extraordinary remedy to be used only where there is no other adequate remedy in the ordinary course of the law. ORS 34.110.[2] We can perceive no reason for preferring mandamus over habeas corpus, inasmuch as both are extraordinary writs.
The petitioner could also bring an ordinary civil action asking for a mandatory injunction. However, this remedy is neither *1206 timely nor adequate. A central characteristic of the writ of habeas corpus "is the speed with which it triggers a judicial inquiry." Penrod/Brown v. Cupp, supra, at 27, 581 P.2d at 937. ORS 34.370.[3] In this case, petitioner alleges facts that demonstrates a need for speedy court intervention and resolution. A civil action would not be a sufficiently timely remedy. See Penrod/Brown v. Cupp, supra, at 27, 581 P.2d 934.
We conclude that petitioner's claim is one that can be properly brought by writ of habeas corpus. He alleges facts that demonstrate the need for immediate judicial intervention because of the harm to which he claims to be exposed and we find no adequate and timely alternative available to him.
Reversed and remanded.
NOTES
[1]  Because of the disposition we made of this case, we need not decide whether the allegation of heart difficulties, standing alone, would justify intervention by habeas corpus.
[2]  ORS 34.110 states:

"A writ of mandamus may be issued to any inferior court, corporation, board, officer or person, to compel the performance of an act which the law specially enjoins, as a duty resulting from an office, trust or station; but though the writ may require such court corporation, board, officer or person to exercise its or his judgment, or proceed to the discharge of any of its or his functions, it shall not control judicial discretion. The writ shall not be issued in any case where there is a plain, speedy and adequate remedy in the ordinary course of the law."
[3]  ORS 34.370 provides, in part:

"The court or judge to whom the petition is presented must allow the writ without delay, unless it appears from the petition itself, or from the documents annexed thereto, that the person for whose relief it is intended is by the provisions of ORS 34.310 to 34.730 prohibited from prosecuting the writ. * * *"
