(a)
Notwithstanding Chapter 7 (commencing with Section 120975) and Chapter 8 (commencing with Section 121025) of Part 4, identifying information and other records of the diagnosis, prognosis, testing, or treatment of any person relating to the human immunodeficiency virus (HIV) shall be disclosed in a criminal investigation for a violation of Section 120291 if authorized by an order of a court of competent jurisdiction granted after application showing good cause therefor. Any order of the court shall be issued in accordance with the following conditions:
(1)
An order shall not be based on the sexual orientation of the defendant.
(2)
In deciding whether to issue an order, the court shall weigh the public interest and the need for disclosure against any potential harm to the defendant, including, but not limited to, damage to the physician-patient relationship and to treatment services. Upon the issuance of an order of this nature, the court, in determining the extent to which any disclosure of all or any part of any record is necessary, shall impose safeguards determined appropriate by the court against unauthorized disclosure. However, the court shall not order disclosure under this paragraph for any purpose other than a proceeding under this section. Any order for disclosure under this subdivision shall limit disclosure to those who need the information for the proceeding, and shall direct those to whom disclosure is made to make no further disclosure without permission of the court. The court shall grant permission for further disclosure when necessary for a proceeding under this section. Any disclosure in violation of an order issued under this section shall be remedied or punished as provided in Section 120980.
(b)
Nothing in this section is intended to compel the testing to determine the HIV status of any victim of an alleged crime or crimes.
(c)
Nothing in this section is intended to restrict or eliminate the anonymous AIDS testing programs provided for in Sections 120885 to 120895, inclusive. Identifying characteristics of persons who submit to that testing shall not be ordered disclosed pursuant to this section, nor shall an order be issued authorizing the search of the records of a testing program of that nature.