(a) Definitions. --
(1) In this section the following words have the meanings indicated.
(2) "Court record" means an official record of a court about a proceeding that the clerk of a court or other court personnel keeps. "Court record" includes an index, a docket entry, a petition or other pleading, a memorandum, a transcription of proceedings, an electronic recording, an order and a judgment.
(3) "Seal" means to remove information from public inspection in accordance with this section.
(4) "Sealing" means:
(A) With respect to a record kept in a courthouse, removing to a separate secure area to which persons who do not have a legitimate reason for access are denied access;
(B) With respect to electronic information about a proceeding on the website maintained by the magistrate court, circuit court or the Supreme Court of Appeals, removing the information from the public website; and
(C) With respect to a record maintained by any law-enforcement agency, by removing to a separate secure area to which persons who do not have a legitimate reason for access are denied access.
(b) Written request. -- Either party to a petition filed pursuant to this article may file a written request with the clerk to seal all court records relating to the proceeding.
(c) Timing. -- A request for sealing under this section may not be filed within two years after the entry of a final order, or the denial or dismissal of the petition.
(d) Notice, hearing and findings. --
(1) On the filing of a request for sealing under this section, the court shall schedule a hearing on the request.
(2) The court shall give notice of the hearing to the parties.
(3) After the hearing, the court shall order the sealing of all court records relating to the proceeding if the court finds:
(A) Good cause to grant the request. In determining whether there is good cause to grant the request to seal court records, the court shall balance the privacy and potential danger of adverse consequences to the parties against the potential risk of future harm and danger to the petitioner and the community; and
(B) That none of the following are pending at the time of the hearing:
(I) A temporary personal safety order or protective order issued against the respondent in a proceeding between the petitioner and the respondent; or
(ii) A criminal charge against the respondent arising from an alleged act described in subsection (a) section four of this article in which the petitioner is the victim.
(e) Access to a sealed record. --
(1) This section does not preclude the following persons from accessing a sealed record for a legitimate reason:
(A) A law-enforcement officer;
(B) An attorney who represents or has represented the petitioner or the respondent in a proceeding;
(C) A prosecuting attorney; or
(D) An employee of the Department of Health and Human Resources.
(2) (A) A person not listed in subdivision (1) of this subsection may subpoena or file a motion for access to a record sealed under this section.
(B) If the court finds that the person has a legitimate reason for access, the court may grant the person access to the sealed record under the terms and conditions that the court determines.
(C) In ruling on a motion under this subdivision, the court shall balance the person's need for access to the record with the respondent's right to privacy and the potential harm of unwarranted adverse consequences to the respondent that the disclosure may create.
(f) Compliance with order. -- Within sixty days after entry of an order under subdivision (3), subsection (d) of this section, each custodian of court records that are subject to the order of sealing shall advise in writing the court and the parties of compliance with the order.