IF
- a person was admitted to a hospital for treatment of mental illness or serious emotional disturbance under any provision of this title other than chapter 6, part 5 of this title, AND
- the person no longer meets the standards under which the admission took place, AND
- the person’s detention is not otherwise authorized under the part under which the person was admitted,
THEN
- the person shall be discharged.