(a) To authorized licensing personnel who are employed by, or who are authorized representatives of, the State Department of Public Health, and who are licensed or registered health professionals, and to authorized legal staff or special investigators who are peace officers who are employed by, or who are authorized representatives of the State Department of Social Services, as necessary to the performance of their duties to inspect, license, and investigate health facilities and community care facilities and to ensure that the standards of care and services provided in such facilities are adequate and appropriate and to ascertain compliance with the rules and regulations to which the facility is subject. The confidential information shall remain confidential except for purposes of inspection, licensing, or investigation pursuant to Chapter 2 (commencing with Section 1250) of, and Chapter 3 (commencing with Section 1500) of, Division 2 of the Health and Safety Code, or a criminal, civil, or administrative proceeding in relation thereto. The confidential information may be used by the State Department of Public Health or the State Department of Social Services in a criminal, civil, or administrative proceeding. The confidential information shall be available only to the judge or hearing officer and to the parties to the case. Names which are confidential shall be listed in attachments separate to the general pleadings. The confidential information shall be sealed after the conclusion of the criminal, civil, or administrative hearings, and shall not subsequently be released except in accordance with this subdivision. If the confidential information does not result in a criminal, civil, or administrative proceeding, it shall be sealed after the State Department of Public Health or the State Department of Social Services decides that no further action will be taken in the matter of suspected licensing violations. Except as otherwise provided in this subdivision, confidential information in the possession of the State Department of Public Health or the State Department of Social Services shall not contain the name of the patient.