
253 Kan. 163 (1993)
853 P.2d 56
STATE OF KANSAS, Appellant,
v.
WALTER WILLIAMSON, Appellee.
No. 68,528
Supreme Court of Kansas.
Opinion filed May 28, 1993.
Chris E. Biggs, county attorney, argued the cause, and Robert T. Stephan, attorney general, was with him on the brief for appellant.
Ralph DeZago, chief public defender, argued the cause, and David L. Dean, deputy public defender, was on the brief for appellee.
The opinion of the court was delivered by
DAVIS, J.:
The State appeals the dismissal of criminal charges, contending that the trial court exceeded its authority in dismissing the charges. We agree and reverse and remand for further proceedings.
Highly summarized, the facts are that the defendant, Walter Williamson, allegedly threatened his wife and daughter with a *164 knife. The defendant was arrested on probable cause by Officer Bobby Whitten of the Junction City Police Department for two counts of aggravated assault. Upon first appearance by the defendant, the court reviewed the officer's affidavit in support of the arrest, found probable cause for the arrest and detention, and ordered a complaint to be filed. The court found the defendant to be indigent, appointed the public defender's office to represent the defendant, and set bond in the amount of $5,000. Preliminary examination was set for August 6, 1992.
At this first appearance, the State informed the court that defendant had been hospitalized for paranoid schizophrenia within the last year and that the family believed that the incident arose because the defendant suffered a relapse. The State requested a competency examination, and the court responded by ordering an evaluation from the Pawnee Mental Health Center forthwith. Both parties agree that the report was to be a competency examination under the provisions of K.S.A. 1992 Supp. 22-3302. Within two days the court received a report from the Pawnee Mental Health Center prepared by Luther Wright, a registered psychologist, consisting of the following:
"I conducted a psychological assessment on Walter Williamson, Sr. (DOB: 10-19-92) (sic,) at Geary County Detention Center on July 31, 1992. It is my professional opinion that he has a schizophrenic process, and is in need of care and treatment. Due to this, it is felt that he needs hospitalization to receive proper treatment."
On August 3, 1992, the court called the matter on for an unscheduled hearing on defendant's motion to dismiss. The motion to dismiss is not contained in the record. The State waived notice. At that hearing defense counsel stated that the basis of the motion was State v. Montgomery, 14 Kan. App.2d 577, 796 P.2d 559 (1990), and similar cases. Montgomery, unlike this case, deals with two criminal statutes  one general, making a false writing, and one specific, giving a worthless check. In Montgomery, the court held that under the facts of the case, the more specific statute must be the basis for charges. Montgomery provides no basis for defendant's motion in this case, which concerns the State's choice between proceeding under a civil statute, commitment for care and treatment, or a criminal statute, aggravated assault. The court did not base its dismissal upon Montgomery.
*165 At the hearing on defendant's motion to dismiss, the court heard testimony from the defendant's wife of 30 years. She confirmed that the defendant had, within the past year, been hospitalized for paranoid schizophrenia. She testified that for the past several months, defendant had not taken his prescribed medication, but instead had flushed his medication down the toilet. In her opinion, her husband was in need of care and treatment, not jail. Based upon this evidence and based upon the report from the Pawnee Mental Health Center, the court dismissed the criminal charges. The court stated:
"For the Court to allow proceedings of a criminal nature, the Court must have before it a probable cause to believe that this man committed a crime. From the evidence presented this day in sworn testimony, the Court finds that there is now a lack of probable cause to support the criminal charges in this case.
"It is obvious from the testimony that this man is ill  both from the wife of 30 years, her testimony of his failure to take prescribed medicines, and also from the evaluation prepared by Luther Wright, registered psychologist.
"The Court would find that this man is in need of treatment, that it is a matter civil in nature, that there is a failure of probable cause at this time and the Court should not turn a blind eye to such evidence."
In concluding, the court advised the prosecutor:
"The Court wants to advise counsel that the actions which you have taken are not in the best interest of either the State or anyone else. And you have not taken into consideration the harm that you are doing, Mr. County Attorney, and you certainly should have considered that before filing criminal charges."
A county attorney or district attorney is the representative of the State in criminal prosecutions. As such, he or she controls criminal prosecutions. It is the county or district attorney who has the authority to dismiss any charge or to reduce any charge. State v. Turner, 223 Kan. 707, 709, 576 P.2d 644 (1978). The prosecuting attorney has broad discretion in discharging his or her duty. The scope of this discretion extends to the power to investigate and to determine who shall be prosecuted and what crimes shall be charged. State v. Dedman, 230 Kan. 793, 798, 640 P.2d 1266 (1982); State v. Blount, 13 Kan. App.2d 347, 351, 770 P.2d 852, rev. denied 245 Kan. 786 (1989). The prosecuting attorney has discretion to dismiss charges, and the court cannot refuse to allow a dismissal. Foley v. Ham, 102 Kan. 66, 67-72, *166 169 Pac. 183 (1917). Similarly, the court cannot restrain a prosecutor from prosecuting an action. State, ex rel., v. Rohleder, 208 Kan. 193, 195, 490 P.2d 374 (1971).
It is apparent from the record that upon hearing additional evidence after charges were filed, the trial court concluded that it made more sense to handle this case by way of civil commitment than by criminal charges. The court's determination was based upon its conviction that the defendant was mentally ill and better treated as one who was suffering from paranoid schizophrenia than as a criminal defendant. The court accomplished this by finding that, based upon the new evidence, probable cause no longer existed that the defendant committed a crime. In doing so, the court exceeded its authority.
State v. Dedman involved defendant's contention that the trial court erred in not requiring a rape victim to submit to a polygraph examination. In rejecting this contention, the court described the limitation on the trial court's power to interfere with prosecutorial functions:
"Further, such an order would involve a serious separation of powers question. `Generally speaking .. . the executive power is the power to enforce the laws, and the judicial power is the power to interpret and apply the laws in actual controversies.' Van Sickle v. Shanahan, 212 Kan. 426, Syl. ¶ 8, 511 P.2d 223 (1973). The prosecuting attorney is a member of the executive, not judicial, branch of government. Although the Kansas Constitution contains no express provision requiring the separation of powers, `separation is accomplished by the establishment of the three branches of government and the distribution of the various sovereign powers to each of them.' 212 Kan. at 440. Allowing judicial oversight of what is essentially a function of the prosecutor's office would erode that power." 230 Kan. at 797-98.
In this case, the decision to proceed with criminal rather than civil commitment for care and treatment was a decision within the discretion of the prosecutor's office. The court's dismissal, no matter how enlightened, amounts to an impermissible judicial intrusion into the prosecutor's function.
The court's action also runs afoul of the procedures set up by the legislature for determination of insanity within our criminal system of justice. In effect, the court's dismissal of the charges amounted to a determination that the defendant could not have violated the criminal law because he was mentally ill and needed *167 care and treatment for that illness. Thus, the court concluded that there was not probable cause to believe that the defendant committed an offense and dismissed the charges.
The determination of a defendant's competency to stand trial is governed by the provisions of K.S.A. 1992 Supp. 22-3302. While the court arguably ordered a competency evaluation in accordance with the statute, the resulting evaluation did not address the question of defendant's competency to stand trial. It was at this time incumbent upon the court to request a proper evaluation in accordance with K.S.A. 1992 Supp. 22-3302.
The defense of insanity within our criminal system depends upon the defendant's filing a notice of insanity pursuant to K.S.A. 1992 Supp. 22-3219. Once noticed, the determination is governed by the M'Naghten test in accord with the law. See State v. Boan, 235 Kan. 800, 686 P.2d 160 (1984); PIK Crim.2d 54.10 (1984 Supp.). The court in this case determined that no probable cause existed because the defendant was mentally ill. Its decision amounts to a determination that because of his illness at the time of the offense, an essential element of the offense was missing. This is not the court's function unless the court is the trier of fact, a notice of insanity has been given, and, based upon the evidence, the court concludes that the defendant is not guilty by reason of insanity.
Finally, K.S.A. 1992 Supp. 22-3428 provides for disposition of the case in the event defendant is acquitted by reason of insanity.
The defendant argues that the court would have had authority, at the time the initial affidavit of probable cause was presented, to determine that no probable cause existed to proceed with criminal charges. He argues that the court would have the same authority to dismiss for lack of probable cause at the preliminary examination stage based upon the evidence presented in this case. In both respects the defendant's argument lacks merit.
In this case, defendant has not yet disputed facts alleged in the officer's probable cause affidavit. Those facts establish probable cause that a crime was committed by the defendant. Beyond that, there may be serious questions about whether defendant is competent to stand trial and, if so, whether the defendant's mental condition is a defense to the crime charged. Our criminal code addresses both of these issues, and the code guides and *168 controls the discretion of the court in resolving these issues. The law does not permit the court to dismiss charges under the facts of this case, nor does the law permit the court to dismiss charges because in its opinion the matter is better handled by civil commitment for care and treatment. We therefore reverse and remand for further proceedings in accordance with this opinion.
Reversed and remanded for further proceedings.
