
160 P.3d 624 (2007)
342 Or. 697
STATE of Oregon, Plaintiff-Relator,
v.
David O. BURLESON, Defendant, and
John Doe or Jane Doe, Adverse Party.
CC 060432571; SC S054377.
Supreme Court of Oregon.
Argued and Submitted May 7, 2007.
Decided June 1, 2007.
Paul L. Smith, Assistant Attorney General, Salem, argued the cause for Plaintiff-Relator. With him on the brief were Hardy Myers, Attorney General, and Mary H. Williams, Solicitor General.
Marc D. Blackman, Ransom Blackman, Portland, argued the cause for Adverse Party. With him on the brief was Kendra M. Matthews.
Douglas E. Beloof, Margaret Garvin, Greg A. Rios, Kim Montagriff, Portland, and Erin *626 K. Olson, Law Office of Erin Olson, PC, Portland, filed a joint brief on behalf of amici curiae National Crime Victim Law Institute and Oregon Trial Lawyers Association.
Before DE MUNIZ, Chief Justice, and GILLETTE, BALMER, KISTLER, WALTERS, and LINDER, Justices.[**]
DE MUNIZ, C.J.
In this mandamus proceeding, we consider whether the trial court abused its discretion in denying a motion to hold a grand jury witness (witness) in remedial contempt for refusing to identify the victims of an alleged crime. In denying the contempt motion, the trial court also implicitly denied the state's motion to compel the witness to identify the victims or to produce documents that would identify them. We conclude that the trial court correctly denied the contempt motion, but should have granted the motion to compel production of full and unredacted medical records in the possession of witness. We therefore shall issue a peremptory writ of mandamus.

I. FACTS AND PROCEDURAL HISTORY
At the behest of the Multnomah County District Attorney, a grand jury began an investigation of defendant, an anesthesiologist. Defendant had acted as an anesthesiologist for surgery performed by witness and his clinic. The staff at the clinic reported seeing defendant inappropriately touching two adult patients while they were anesthetized.
The clinic reported defendant's alleged behavior to the Board of Medical Examiners (BME) and gave the BME redacted copies of the victims' medical records. Because the matter involved criminal conduct, the BME referred the matter to the district attorney for prosecution. The district attorney filed an information charging defendant with two counts of sexual abuse. Before submitting the matter to the grand jury, the district attorney issued a subpoena duces tecum to witness for the victims' medical records. Witness gave the district attorney redacted copies of the medical records that did not identify the victims. The state filed a motion to compel, and witness opposed the motion.
The trial court held a hearing at which witness's counsel summarized the testimony that witness and his staff would offer. The evidence indicated that both victims were concerned about undergoing treatments. Witness also believed, as their treatment provider, that the victims would forgo necessary care if they learned what defendant had done.
The trial court denied the motion to compel as premature. The court concluded that witness may appear before the grand jury and explain to the grand jury why he had provided only redacted copies of the medical records to the district attorney. The grand jury then could decide whether to accept that explanation. The court also determined that the records should be kept confidential because of their relationship to grand jury proceedings.
The state issued another subpoena duces tecum to witness. Witness appeared before the grand jury. The grand jury directed witness to disclose the identities of the victims and to produce unredacted records. After witness refused, the grand jury requested that witness be held in contempt.
The state then moved the trial court to impose a remedial sanction of contempt. At that time, the state also renewed its motion to compel. As to the merits of the contempt motion, the trial court understood the underlying issue to be whether it should issue an order requiring witness to provide the testimony and to produce the evidence that the grand jury sought. The state argued that the names of the victims were necessary to the investigation because, at a minimum, the state needed to question those victims about the effect of anesthesia on them and whether they had any recollection of the events in question. In addition, according to the state, such information was necessary to determine what kind of crime defendant may have committed and how the state would characterize and charge that crime. See, e.g., ORS *627 163.427(1)(a)(C) (whether victim was "physically helpless" may constitute element of crime of first-degree sexual abuse).
The trial court issued a written order in which it made findings of fact, indicating that the victims were being treated for conditions that would require additional care. The trial court found that disclosing to the victims the fact of the inappropriate contact might cause them to forgo necessary medical care in the future.
In its conclusions of law, the trial court determined that the information soughtthe names of the victimswas information that was both relevant and not privileged, but the court further determined that such information "[was] not necessary to the return of a valid indictment." The trial court also opined that the information sought "may be irrelevant to the resolution of criminal charges the grand jury may return against [defendant] because he may seek to resolve those charges by agreement or stipulation, as he did in the investigation by the Board of Medical Examiners." The trial court then concluded that, under ORS 136.617, even if the information was relevant and not privileged, it did not have to order witness to testify if it found "that to do so would be clearly contrary to the public interest."[1] The trial court concluded that the facts "demonstrate[d] that it would be clearly contrary to the public interest to require [witness] to provide the identification information * * * being sought by the grand jury because the immediate adverse consequences of doing so substantially outweigh the grand jury's limited need for this information." As a result, the trial court denied the state's motion to hold witness in remedial contempt. Implicitly, based on its analysis under ORS 136.617, it also denied the motion to compel.
The state filed a petition in this court for an alternative or peremptory writ of mandamus, seeking to compel the trial court to enforce the grand jury subpoena. This court issued an alternative writ, directing the trial court to vacate its order or, in the alternative, show cause for not doing so within 14 days. The trial court did not vacate its order. The parties then fully briefed this matter, and the court heard oral argument before the matter was submitted for decision.

II. APPROPRIATENESS OF MANDAMUS REMEDY
Mandamus is an extraordinary remedy, Sexson v. Merten, 291 Or. 441, 445, 631 P.2d 1367 (1981), and may serve only to enforce a known, clear legal right, Ross v. County Court of Marion, 147 Or. 695, 700, 35 P.2d 484 (1934). This court, in its discretion, may accept original jurisdiction in mandamus proceedings. Or Const, Art VII (Amended), § 2; ORS 34.120(2). Ordinarily, the court will not issue a writ of mandamus if there is a plain, speedy, and adequate remedy in the ordinary course of the law, such as an appeal. See ORS 34.110 (providing standard).
Witness argues that the state has an adequate remedy by appeal, citing ORS 33.125(2). That statute provides that a party against whom a judgment of contempt has been imposed may challenge that sanction by appeal. In fact, ORS 33.125(1) requires that a trial court enter a judgment if it imposes a contempt sanction. In this matter, the trial court did not impose the state's requested remedial contempt sanction, much less enter a judgment. If the trial court refuses to impose remedial contempt sanctions, requested before entry of judgment in a related proceeding, then the trial court must include its ruling on contempt as part of the judgment in the underlying case. ORS 33.125(3)(b). Here, the underlying case is the criminal proceeding against defendant. See ORS 33.055(3) (motion to impose remedial sanctions "shall be filed in the proceeding to which the contempt is related, if there is a related proceeding"). The state thus could not appeal the trial court order at issue here until the trial court entered a final judgment in defendant's criminal case. Likewise, an order denying a motion to compel grand jury testimony is not immediately appealable. See State v. Threet, 294 Or. 1, 7, 653 P.2d 960 *628 (1982) (motion to compel grand jury testimony under ORS 136.617 not appealable as "special statutory proceeding"). As a result, the state faces irreparable injury, because the absence of the names of the victims could undermine the effectiveness of the investigation and prosecution. We conclude that the state does not have an adequate remedy by appeal. Hence, it is appropriate for us to consider this matter in mandamus.

III. STANDARD OF REVIEW
A. Mandamus
Although a writ of mandamus "may require [a] court, corporation, board, officer or person to exercise judgment, or proceed to the discharge of any functions, it shall not control judicial discretion." ORS 34.110. In a mandamus proceeding, this court may consider whether a trial court's actions are outside the permissible range of discretionary choices open to the trial court. State ex rel Keisling v. Norblad, 317 Or. 615, 623, 860 P.2d 241 (1993). Within that framework, a claim of legal error underlying a trial court's exercise of discretion may be raised in a mandamus proceeding. Id.
B. Contempt
The standard of review in matters of remedial contempt, when the sanction does not include confinement, requires a review of the facts for clear and convincing evidence. See ORS 33.055(11) (providing standard). As a general rule, a contemnor may not attack the underlying order or judgment that he or she violated in appealing a judgment of contempt. Barrett and Barrett, 320 Or. 372, 380, 886 P.2d 1 (1994). Ordinarily, the legal standard alleged to have been violated is a given, and the question for decision is whether the facts support the conclusion that the alleged contemnor willfully violated the judicial command.

IV. ANALYSIS
A. Grand Jury
Although the role of the grand jury has developed over centuries and its origins are somewhat obscure, see State v. Gortmaker, 295 Or. 505, 510-12, 668 P.2d 354 (1983) (discussing history of grand jury at common law), its function as an accusatory body serves a crucial role in protecting individual liberties. The grand jury serves as a brake on the state's potential abuse of the accusatory process. Without the grand jury, presumably the prosecutor alone would decide which persons to accuse of major crimes, without supervision or control by other branches of government. Instead, the constitution provides an institution in which a group of ordinary citizens must approve of the initiation of the state power to accuse citizens of major crimes. As often is the case with important government activities, the constitution requires that two branches of government must agree before moving forward with significant consequences that might adversely affect citizens. See Or Const, Art III, § 1 (separation of powers). In this instance, it is the executive branch, in its prosecutorial function, and the judicial branch, in the form of the grand jury, that must agree before a criminal process may go forward. Although some scholars consider the grand jury to be almost entirely independent from government, including the judicial branch, the Oregon Constitution indicates that the grand jury function, at a minimum, is related to the judicial branch, because it is mentioned within the judicial article. See Or Const, Art VII (Amended), § 5 (listing provisions regarding grand juries that legislature must enact). Although the grand jury is related to the judicial branch, it is not a court, and, as we explain below, that observation has important implications for this case.
Several statutes define the role and proper activities of the grand jury and its relationship to the prosecutor. "A grand jury is a body of seven persons drawn from the jurors in attendance upon the circuit court at a particular jury service term, having the qualifications prescribed by ORS 10.030 and sworn to inquire of crimes committed or triable within the county from which they are selected." ORS 132.010. "The district attorney shall institute proceedings before magistrates for the arrest of persons charged with or reasonably suspected of public offenses, when the district attorney has information that any such offense has been committed, *629 and attend upon and advise the grand jury when required." ORS 8.670.
Although the grand jury is independent, the prosecutor ordinarily has an active role in the grand jury process. "The district attorney, when required by the grand jury, must prepare indictments or presentments for it and attend its sittings to advise it in relation to its duties or to examine witnesses in its presence." ORS 132.340. "The district attorney may submit an indictment to the grand jury in any case when the district attorney has good reason to believe that a crime has been committed which is triable within the county." ORS 132.330. Despite the prosecutor's active advisory role, however, the grand jury must make its own decisions. "The grand jury shall retire into a private room and may inquire into crimes committed or triable in the county and present them to the court, either by presentment or indictment[.]" ORS 132.310. "The grand jury may indict a person for a crime when it believes the person guilty thereof, whether such person has been held to answer for such crime or not." ORS 132.380. In deciding whether to issue an indictment, subject to some exceptions, "the grand jury shall receive no other evidence than such as might be given on the trial of the person charged with the crime in question." ORS 132.320(1).
B. Discovery and enforcement power
The grand jury is a powerful discovery tool in the hands of the prosecution. As part of a criminal investigation, witnesses may be summoned to the grand jury to testify or produce documents and things. "The district attorney may issue subpoenas subscribed by the district attorney for witnesses within the state in support of the prosecution or for such other witnesses as the grand jury directs to appear before the grand jury upon an investigation pending before it." ORS 136.563.
Although, as we observed, the grand jury works with the prosecutor, this court has determined that the grand jury, not the prosecutor, is the actor that drives the investigative process of the grand jury. The grand jury must determine the questions that must be answered and, in particular, those that demand additional inquiry after a witness refuses to testify. As this court has explained:
"The prosecutor has authority to subpena [sic] witnesses `to appear before the grand jury upon an investigation pending before it.' ORS 136.563. The inquisitorial power to compel testimony resides in the grand jury, not in the district attorney. It is his function to `attend upon and advise the grand jury when required.' ORS 8.670, and, `when required by the grand jury, * * * to examine witnesses in its presence.' ORS 132.340. No doubt in this capacity he also serves the grand jury in obtaining such aid from the court as the grand jury may request. But the qualifying phrase in ORS 132.340, `when required by the grand jury,' is not meaningless. It reflects the historic independence of the grand jury's role from that of the prosecutor about which grand jurors should be clearly informed. A grand jury confronted by a witness who explains his reasons for not wishing to answer a question may choose not to press the question. In such a case, the prosecutor could hardly ask the court on behalf of the grand jury to order the witness to answer his question."
State ex rel Frohnmayer v. Sams, 293 Or. 385, 388, 648 P.2d 364 (1982). It is for those reasons that it would be inappropriate, in grand jury matters, to establish the procedure that exists in civil litigation, in which a witness may object to producing documents in advance of the scheduled date of production and force the party seeking evidence then to seek a motion to compel. See ORCP 55 B (so providing). In grand jury matters, Sams establishes that the decision to press for the production of evidence must come from the grand jury after the witness has refused to cooperate fully.
The Court of Appeals has issued an opinion that offers an insightful analysis of the procedures for seeking a contempt sanction. Shortly after this court issued its opinion in Sams, the Court of Appeals considered the proper sequence for refusals to testify or offer evidence before the grand jury. In State ex rel Grand Jury v. Bernier, 64 Or. App. 378, 668 P.2d 455 (1983), the state appealed *630 from the dismissal of a motion for an order to show cause why the defendant should not be held in contempt for refusing to answer questions before a grand jury. The trial court stated that "`one who claims a privilege should not be required to gamble his liberty * * * without a prior impartial adjudication of the validity of the claimed privilege following a demand for testimony from the grand jury.'" Id. at 381, 668 P.2d 455 (quoting from trial court order). In other words, one does not risk contempt merely by asserting an objection to produce evidence; instead, one risks contempt for violating a court order to produce evidence. As the Court of Appeals reasoned:
"[T]he validity of defendant's refusal should have been adjudicated before contempt proceedings could begin. We conclude that a witness before a grand jury who declines to answer particular questions has not [refused to answer as a witness] until there is an adjudication of the justification for the refusal, a court order to answer the questions[,] and a subsequent refusal by the witness."
Id. The Court of Appeals continued:
"A witness who asserts a privilege or other similar ground for refusal to answer should not be forced to guess whether his refusal is justified or whether he is subject to contempt. His refusal should be treated similarly to an objection in trial in open court; until there is a ruling by the court on the objection, the failure to respond is not contemptuous. Grand jury witnesses are not required to answer every question put to them. `Refusal to answer as a witness' implies that the refusal is unjustified, and whether the refusal is legally unjustified is a determination to be made by the court, not by the prosecutor or the grand jury."
Id. at 382, 668 P.2d 455 (emphasis in original).
The statutory definition of contempt generally establishes that there must be a violation of a court order, rather than limited compliance with the terms of a subpoena, for there to be a basis for a contempt sanction. Under the general statutes governing contempt, the definition of contempt of court requires that the alleged contemnor wilfully engage in one of the following:
"(a) Misconduct in the presence of the court that interferes with a court proceeding or with the administration of justice, or that impairs the respect due the court.
"(b) Disobedience of, resistance to or obstruction of the court's authority, process, orders or judgments.
"(c) Refusal as a witness to appear, be sworn or answer a question contrary to an order of the court.
"(d) Refusal to produce a record, document or other object contrary to an order of the court.
"(e) Violation of a statutory provision that specifically subjects the person to the contempt power of the court."
ORS 33.015(2). Most of the foregoing instances of contempt require a violation of a court order or other form of judicial authority. However, a grand jury subpoena or other form of grand jury request issued in the name of the district attorney is not a court order, nor does it represent some other form of judicial authority for purposes of ORS 33.015(2).
The applicable statutes and Sams indicate that the proper procedure for seeking a contempt sanction, based on a witness's refusal to answer a particular request in a grand-jury subpoena, is as follows: (1) the prosecutor issues a subpoena to the witness to appear before a grand jury; (2) the witness attends the grand jury, but fails to respond fully to the subpoena, either by a partial refusal to testify or partial refusal to produce documents; (3) the grand jury decides that it wants a fuller response and directs the prosecutor to seek a motion to compel in the trial court; (4) if the evidence sought is "such as might be given on the trial of the person charged with the crime in question," ORS 132.320(1), then the trial court must issue the order to compel, unless some statutory exception applies. Once the court has issued the order, if a witness fails to comply, then it is an instance of contempt at that point, but not before.
*631 C. Disposition of motions
At this point, we must bear in mind the procedural posture of this case. Before witness testified before grand jury, the state moved to compel production of the unredacted records and the trial court denied the motion as premature. After witness appeared before the grand jury and testified, but refused to name the victims and produce the unredacted documents, the state moved for contempt. The parties stipulated to incorporating all arguments and evidence presented at the prior hearing. In addition, the state renewed its motion to compel. The trial court acknowledged that it was inquiring into the merits of the motion to compel as well as the motion to hold witness in contempt, and the trial court implicitly denied that motion based on its analysis of ORS 136.617. Although the trial court did not specifically indicate that it had ruled on the motion to compel, it ruled on the contempt issue by declining to compel witness to produce the unredacted records or reveal the victims' names. As previously noted, the trial court declined to compel further information from witness, concluding that to do so "would be clearly contrary to the public interest."
The trial court was correct in denying the motion to hold witness in contempt, because, as we have explained, witness did not violate a court order in refusing to testify. However, that was not the basis that the trial court gave for its ruling.
In refusing to hold witness in contempt, the trial court, in effect, analyzed the merits of the motion to compel. In determining the fundamental question whether witness should provide the information that the grand jury requested, the trial court chose to apply a statute, ORS 136.617, that applies only when a witness refuses to answer questions before the grand jury because the witness fears self-incrimination. If a witness refuses to cooperate before a grand jury on the ground that the witness may be incriminated by his or her testimony or production of documents, the legislature has created special procedures for the state to seek the court's assistance in quickly determining whether the witness must testify. See ORS 136.617 (specifying procedures that apply when "a witness refuses to testify or produce evidence of any kind on the ground that the witness may be incriminated thereby" (emphasis added)); ORS 33.085 (establishing procedure in support of ORS 136.617). When that is the case, "[t]he court shall order the witness to testify regarding the subject matter under inquiry upon such showing of reasonable cause or shall order the production of evidence upon a finding that no privilege protects the evidence sought, unless the court finds that to do so would be clearly contrary to the public interest."[2] ORS 136.617. Here, as noted, the trial court purported to rely on ORS 136.617 in refusing to compel witness to testify and provide evidence.
In relying on ORS 136.617, however, the trial court erred. ORS 136.617, by its own explicit limitations, had no application to this case. See Threet, 294 Or. at 7, 653 P.2d 960 (ORS 136.617 applies to only witness refusal to produce evidence based on self-incrimination). In particular, witness did not assert his right to be free from the risk of self-incrimination and cooperated with the grand jury except to the extent that he refused to identify the victims or produce documents that would identify the victims.[3]
The trial court, while correctly denying the state's motion for contempt, should have granted the state's motion to compel. The trial court itself concluded that the evidence sought was relevant and not privileged. The grand jury is entitled to evidence that "might be given on the trial of the *632 person charged with the crime in question." ORS 132.320(1). As a matter of diligence, the prosecutor must identify victims and interview them about facts likely to lead to the production of admissible evidence. The identity of victims of crime is the most basic kind of evidence given at trial. Accordingly, we issue a peremptory writ ordering the circuit court to grant the state's motion to compel production of full and unredacted medical records.[4]
Peremptory writ to issue.
NOTES
[**]  Durham, J., did not participate in the decision of this case.
[1]  ORS 136.617 provides a procedure whereby a prosecuting attorney may move a court to order witness testimony or production of evidence in certain circumstances. Among other things, it sets out the "contrary to the public interest" standard that the trial court relied on below.
[2]  We note that testimony or evidence that is protected by the right against self-incrimination, but compelled under the procedures outlined in ORS 136.617, may not be used against the witness in any criminal prosecution. See ORS 136.619 (so stating).
[3]  ORCP 55 G, operating in conjunction with ORS 136.600, also does not apply to this proceeding. That rule applies, by its terms, to instances in which a judge or justice issued the subpoena, or when an action is pending before a court. It does not purport to address grand jury proceedings.
[4]  In a series of orders, the trial court sealed the contents of the court file, because the information pertained to a grand jury investigation. Grand jury proceedings are conducted in secret. See ORS 132.060 (oath of secrecy); ORS 132.090 (restricting access to grand jury proceedings). The Oregonian filed a motion in the trial court, seeking to unseal the documents. The trial court responded by unsealing a portion of the documents. After the state filed its mandamus petition in this court, this court ordered that the materials filed in this court be treated in accordance with ORAP 3.07, which governs the procedures for protecting confidential and sealed documents in appeals. The Oregonian then filed a motion in this court, seeking to intervene in these proceedings and seeking access to the court documents filed in this court. This court granted the motion to intervene, but deferred the motion to unseal. The information in this case falls within the ambit of grand jury secrecy, subject to the supervision of the trial court. In this opinion, we have ruled on the mandamus petition before us and have decided to issue the peremptory writ granting relief to the state and return this matter to the trial court. In light of the further proceedings necessary in the trial court, we refer The Oregonian's motion to unseal the documents to the trial court. See ORAP 3.07(5) ("The appellate court may * * * remand the motion [to inspect material] to the trial court for a ruling.").
