If the court determines that the person was not admitted or committed under the governing provisions of this title or was not afforded due process of law, but that the person has a mental illness or serious emotional disturbance, or intellectual disability and because of the condition poses a likelihood of serious harm to the person or others as determined under § 33-6-501, the court may order the person returned to the hospital or treatment resource where the person was located on the date of filing the petition for not more than fifteen (15) days, exclusive of Saturdays, Sundays or holidays, if, and only if, a petition under chapter 6, part 5 of this title is filed immediately and is disposed of within fifteen (15) days of the court's order, exclusive of Saturdays, Sundays or holidays, unless the case is continued on request of petitioner; otherwise the person shall be released.
T.C.A. § 33-3-803