We know that the only reason they want the records is for their database. There is no valid reason for the government to want any medical records. A court could request them for a case like insurance fraud or malpractice, but that is not what is happening here.
HIPAA is a federal law that prohibits the unauthorized disclosure of personal medical records. However, it has an exception for law enforcement subpoenas. That is the loophole they are using to target transgender children.