LOS ANGELES (CN) — A California law requiring psychotherapists to report patients who look at child pornography on the internet does not violate patients’ privacy — even if the patients are teenagers sexting nude selfies to each other, an appellate court ruled Monday.

“The privacy interest of patients who communicate that they watch child pornography is outweighed by the state’s interest in identifying and protecting sexually abused children,” Division Two of the Second Appellate District ruled, affirming a judgment from Los Angeles Superior Court.

Therapy patients cannot expect privacy about a child pornography habit because having or viewing child porn is illegal, the three-judge panel said in a 36-page opinion.

“Not only is it illegal, the conduct is reprehensible, shameful and abhorred by any decent and normal standards of society,” Presiding Justice Roger Boren wrote for the unanimous panel.

Although the legal question centers on privacy rights, an important underlying issue is the tension between treating potential sexual predators and treating them.

At issue is a section of California’s Penal Code called the Child Abuse and Neglect Reporting Act, or CANRA. Since the 1980s, it has required certain professionals to inform law enforcement when they learn about someone who has made or exchanged child porn. A 2014 amendment updated the law to cover downloading, streaming or accessing child pornography through electronic or digital media, according to the appellate opinion.

Two marriage and family therapists and an alcohol and drug counselor sued to block the law in February 2015, saying it would scare off patients needing treatment.

The revised law would “induce patients to cease therapy, make them unlikely to disclose intimate details needed to provide effective therapy, or deter existing or potential patients with serious sexual disorders from obtaining therapy at all,” family therapists Don Matthews and Michael Alvarez and counselor William Owen claimed in their suit against Attorney General Kamala Harris and Los Angeles District Attorney Jackie Lacey.

The plaintiffs said the law could lead to prosecutions against consenting minors who send or receive sexting photos “that do not involve sexual abuse or exploitation.”

In scattered cases across the country, minors as young as 12 have been charged with child pornography for sending or receiving sexts, including in Pennsylvania and Iowa.

Los Angeles Superior Court Judge Michael Stern rejected the therapists’ lawsuit last year. On Monday, Justice Boren, joined by Justices Victoria Chavez and Brian Hoffstadt, said that even the strong right of privacy in Article I, Section 1 of the California Constitution is not absolute, and “must be balanced against other important interests.”

And child pornography “does not involve any ‘vital privacy interest,’” Boren wrote.

“The fact that a patient might share the information of his or her past criminal conduct in possessing Internet child pornography with a psychotherapist does not implicate a constitutionally protected privacy interest.”

Boren also rejected the therapists’ argument that the Legislature went too far in the 2014 amendment when it expanded CANRA from printing, copying or trading child pornography to simply downloading it.

“We discern no legal basis to distinguish between obscene images of children in prints or on the Internet, both of which involve ‘sexual exploitation’ of the most vulnerable members of society,” Boren wrote.

The Evidence Code privilege against patient-psychotherapist communication does not apply to child porn, according to a California Supreme Court ruling.

There is no constitutionally protected right to view such pornography, Boren held. “When patients seek medical treatment for their sexual disorders, they have no legally protected privacy interest in communicating that they have downloaded, streamed or accessed child pornography from the Internet.”

The same reasoning applies to the therapists’ claims about sexting. “Minors do not have a fundamental right to produce or possess child pornography, including viewing sexually explicit images of other minors,” the justice wrote.

Boren also rejected the plaintiffs’ contention that people who merely download child porn are unlikely to move on to “hands-on” sexual exploitation of children. “The claim that CANRA cannot be expanded to include Internet child pornography victims because they are ‘virtual’ and therefore are not harmed is patently absurd,” Boren said.

Finally, Boren ruled there is no guarantee in the U.S. Constitution to privacy in medical records. “California has a legitimate interest in the identification and protection of sexually exploited children, which is a reasonable exercise of its police power to address the problem of sexually exploited children on the Internet.”

Mark Hardiman, of Nelson Hardiman, lead attorney for the plaintiffs, did not return a call seeking comment on late Tuesday. The attorneys representing the state could not be reached.