<?xml version="1.0"?>
<law><site_title>Virginia Decoded</site_title><site_url>https://vacode.org</site_url><law_id>361095</law_id><section_number>37.2-847</section_number><catch_line>Duty of attorney for Commonwealth</catch_line><edition url="https://vacode.org/2026/" slug="2026" current="TRUE" last_updated="2026-08-02">2026</edition><structure><unit label="title" level="1" order_by="85" identifier="37.2">Behavioral Health and Developmental Services</unit><unit label="subtitle" level="2" order_by="3" identifier="III">Admissions and Dispositions</unit><unit label="chapter" level="3" order_by="1" identifier="8">Emergency Custody and Voluntary and Involuntary Civil Admissions</unit><unit label="article" level="4" order_by="8" identifier="8">Testing Legality of Detention</unit></structure><text>
						<section><p>In any case to test the legality of the detention of a person pursuant to this article, whether by <span class="dictionary">habeas corpus</span> or otherwise, the attorney for the Commonwealth of the county or city in which the <span class="dictionary">hearing</span> is held shall, on request of the director of the <span class="dictionary">facility</span> or other institution having or claiming <span class="dictionary">custody</span> of the person, represent the Commonwealth in opposition to any such <span class="dictionary">petition</span>, <span class="dictionary">appeal</span>, or procedure for the discharge of the person from <span class="dictionary">custody</span>.</p></section></text><history>Code 1950, &#xA7; 37-125; 1950, p. 916; 1968, c. 477, &#xA7; 37.1-104.2; 1972, c. 639; 2005, c. 716.</history><metadata></metadata></law>
