The Department of Human Services shall assure confidentiality to individuals who are the subject of research by the state authority or are recipients of substance misuse or substance use disorder information, assessment, or treatment from a licensed or approved program. The commissioner shall withhold from all persons not connected with the conduct of the research the names or other identifying characteristics of a subject of research unless the individual gives written permission that information relative to treatment and recovery may be released. Persons authorized to protect the privacy of subjects of research may not be compelled in any federal, state or local, civil, criminal, administrative or other proceeding to identify or disclose other confidential information about the individuals. Identifying information and other confidential information related to substance misuse or substance use disorder information, assessment, treatment, or aftercare services may be ordered to be released by the court for the purpose of civil or criminal investigations or proceedings if, after review of the records considered for disclosure, the court determines that the information is relevant to the purpose for which disclosure is requested. The court shall order disclosure of only that information which is determined relevant. In determining whether to compel disclosure, the court shall weigh the public interest and the need for disclosure against the injury to the patient, to the treatment relationship in the program affected and in other programs similarly situated, and the actual or potential harm to the ability of programs to attract and retain patients if disclosure occurs. This section does not exempt any person from the reporting obligations under section 626.556, nor limit the use of information reported in any proceeding arising out of the abuse or neglect of a child. Identifying information and other confidential information related to substance misuse or substance use disorder, assessment, treatment, or aftercare services may be ordered to be released by the court for the purpose of civil or criminal investigations or proceedings. No information may be released pursuant to this section that would not be released pursuant to section 595.02, subdivision 2.