Merrimack County Superior Court Judge Richard McNamara ruled Wednesday that Exeter Hospital produced no evidence to suggest that the Department of Health and Human Services failed to comply with state and federal law in its investigation at Exeter Hospital.

“The court ruled that the state’s outstanding requests for information from Exeter Hospital regarding the hepatitis C outbreak are lawful and appropriate,” Associate Attorney General Anne M. Edwards said in a prepared statement. “The court rejected all of Exeter Hospital’s arguments to the contrary.”

Attorneys for the hospital had asked the judge to keep its patient records shielded from state health officials until they provide more specific information about their search. They also called for a judgment declaring the state must allow Exeter Hospital to review all patient records being sought in the hepatitis C investigation before they can be released.

Scott O’Connell, the hospital’s lawyer, called the state’s actions abusive and over the top, and insisted the hospital would be violating both state and federal law if it provided investigators unfettered access to its records system.

Former hospital worker David Kwiatkowski has been charged with stealing drugs from the hospital’s cardiac catheterization unit and replacing them with tainted syringes that were later used on patients.

Thirty-two Exeter Hospital patients have been found to have the same strain of the liver-destroying virus Kwiatkowski carries, and information gathered by public health officials suggests more are possible, attorney Jeanne Herrick said on behalf of the state at an October court hearing.

While both sides agreed that the state is legally allowed to collect only the minimum amount of information necessary for its investigation, the hospital argued it should be the gatekeeper in terms of allowing access to that information. But Herrick said the state has a right to broad access to review information, while extracting only the minimum amount necessary.

That’s what happened from the time the investigation started in May until July, when the hospital abruptly stopped cooperating, she said.

In his Oct. 31 ruling, McNamara indicated that the law “explicitly bestows the responsibility of conducting outbreak investigations while simultaneously protecting certain health information to the trained professionals of the DHHS,” according to an announcement released by the attorney general’s office Thursday.

“With the court’s clear pronouncement of Public Health’s authority, we trust that Exeter Hospital will fully cooperate with the investigation and provide access to its business and medical records and staff for interviews so that we can efficiently and effectively determine the scope of the outbreak, identify all patients who may have been exposed so that they may get access to care and determine the mechanism in all cases so that future incidents may be avoided,” Dr. Jose Montero, director of the Division of Public Health Services, said in a prepared statement.

Exeter Hospital also released a statement Thursday evening. The hospital supports the court’s decision, which “provides important guidance,” and will help the hospital meet its obligations, according to the statement.

“The Court pointed out that the State needs to follow very specific, CDC-sanctioned protocols in collecting data from Exeter Hospital’s electronic medical record system and can only obtain the minimum amount of information necessary to complete its investigation ...” the statement reads. “We remain confident that seeking judicial guidance was the right thing to do on behalf of our patients.”

Kwiatkowski, a traveling medical worker whom prosecutors describe as a “serial infector,” was hired in Exeter in April 2011 after working in 18 hospitals in Arizona, Georgia, Kansas, Maryland, Michigan, New York and Pennsylvania.

He moved from hospital to hospital despite having been fired twice over allegations of drug use and theft, and thousands of patients in those states are being tested to see if they, too, were infected with hepatitis C, a sometimes life-threatening virus. A handful of patients in Kansas have been found to carry the same strain Kwiatkowski carries.

Kwiatkowski, who has told authorities he did not steal or use drugs, has pleaded not guilty to illegally obtaining drugs and tampering with a consumer product.

Foster’s staff writer Jim Haddadin and Holly Ramer of The Associated Press contributed to this report.