The hospital can detain you if you have a behavioral health or substance abuse problem AND the court grants their petition to have you temporarily committed. Then you'll be held for observation in a psychiatric unit.