; (ii) by striking record referred to in subsection (a) and inserting substance use disorder patient record ; and (iii) by striking subsection (g) and inserting subsection (h) ; and (C) by amending paragraph (2) to read as follows: (2) Permitted disclosure Whether or not the patient with respect to whom any substance use disorder patient record referred is maintained gives written consent, the content of such record may be used or disclosed as follows: (A) In connection with the provision of medical services or health care to substance use disorder patients consistent with the allowable uses and disclosures to carry out treatment, payment, or health care operations as described in section 164.506 of title 45, Code of Federal Regulations, or any successor regulation. (B) To qualified personnel for the purpose of conducting scientific research, management audits, financial audits, or program evaluation, but such personnel may not identify, directly or indirectly, any individual patient in any report of such research, audit, or evaluation, or otherwise disclose patient identities in any manner. ; (6) in subsection (d), as so redesignated— (A) by striking Except as authorized and all that follows through may be used and inserting the following: (1) In general Except as authorized by an appropriate order of a court of competent jurisdiction granted after application showing good cause therefor, including the need to avert a substantial risk of death or serious bodily harm: (A) No substance use disorder patient record may be used or disclosed to a law enforcement official