A federal appeals court ruled on Friday that a Florida law that discourages physicians from asking patients about guns is constitutional, despite doctor warnings that such questions are vital to their work.

The 11th U.S. Circuit Court of Appeals overturned a lower court decision that invalidated the 2011 law, advocated by guns rights groups. The law says that “unless information is relevant to patient’s medical care or safety or safety of others, inquiries regarding firearm ownership or possession should not be made.” It allows for disciplinary action against doctors who violate it.

“We find that the Act is a legitimate regulation of professional conduct,” the appeals court wrote in its 2-1 decision. “The Act simply codifies that good medical care does not require inquiry or record-keeping regarding firearms when unnecessary to a patient’s care.”

“It is not a physician’s business whether his or her patient chooses to exercise their fundamental, individual right to own a firearm,” Chris Cox, president of the National Rifle Association’s Institute for Legislative Action, said in a statement praising the decision.

The law met strong resistance from doctor groups, which filed the lawsuit to overturn it. They have argued that it violated doctors’ First Amendment rights and infringed on their responsibilities to their patients.

Mobeen Rathore, president of the Florida chapter of the American Academy of Pediatrics, one of the groups suing over the law, told TPM Tuesday that asking patients about any guns in their home is standard practice — akin to inquiring if somebody in the household smokes or if chemicals are kept in the home.

“The purpose of that is to give anticipatory guidance. You’d be surprised how many people do not know,” Rathore said. “If you have children in the home, children are inquisitive. They want to figure out what it is. Unfortunately, there have been many, many, many fatal incidents where a child playing with a gun, didn’t know what it was and got killed or hurt.”

That typical guidance includes keeping the gun in a locked box and keeping the firearm and ammunition separate, Rathore said. He also noted that patients are already allowed to decline to answer any questions about guns, though he added that “most patients do” answer.

The doctor groups plan to appeal the three-judge panel’s ruling in favor of the Florida law to the full appeals court, Rathore said. But while the legal challenge continues, other states are looking to adopting similar measures. The AAP said in a statement denouncing the decision that 10 other states have introduced a similar bill since Florida Gov. Rick Scott (R) signed it into law in 2011.

“It is almost a necessity to ask these questions,” Rathore told TPM. “Most of us believe if we don’t, we are not doing right by our patients.”