Any licensed health professional or licensed hospital, including a hospital licensed by the Department of Health pursuant to § 32.1-123, administering treatment, or providing testing, or detention pursuant to the court's or magistrate's authorization as provided in this chapter shall have no liability arising out of a claim to the extent the claim is based on lack of consent to the treatment, testing or detention. Any such professional or hospital administering treatment with the consent of the person receiving or being offered treatment shall have no liability arising out of a claim to the extent it is based on lack of capacity to consent, if a court or a magistrate has denied a petition hereunder to authorize the treatment and the denial was based on an affirmative finding that the person was capable of making and communicating an informed decision regarding the proposed treatment.
Va. Code § 37.2-1106