Private practice: It goes like most cases go but the court may be possibly be able to see the records (or not). If the patient still doesn't want the court to see the records you aren't supposed to show the court, even if it's court-ordered unless it's under very specific circumstances, but those have to be detailed to you by the court.
You may get called by the court or other state agencies or employees. You need to enforce boundaries. Some of them might expect you to give out information when you were not given permission. If you are not a state employee you aren't supposed to share information without the patient's permission under usual HIPAA guidelines.
State employee: If you are, however, a state employee, you can share information if there's an actual treatment purpose for it. E.g. during my forensic evaluations, the records in the state forensic unit were open to the court. The court then took steps to shield much of that from the public but that too was at times open depending on the material and the case.
e.g. If I was still working for the state of Ohio and the governor called me up about a specific patient and wanted questions answered that were highly treatment relevant, I can give that information out. After all he's the top guy in the hospital administration of a STATE hospital. The governor never called me, but his office did call 1 person above me on a few occasions such as the judge or the hospital CCO.
I currently have a court-ordered case now and I'm very close to terminating the patient. Wow what a hot-bed cluster B mess. I can't talk about it cause of HIPAA and the circumstances are one of those things where you couldn't believe it otherwise but I got all parties verifying the stuff is true.
The patient in this case is court-ordered but she told them she would see me. I never had any directive from the court, so unless that happens, my part in this issue is no different than any other treatment provider. So, for example, if I terminate her, yeah she's still court-ordered for treatment but now with someone else. The court can't make me treat her.