I need help

If I go check myself into a psychiatric hospital in order to prevent myself from trying to hurt myself while pregnant will they take my child from me when I give birth?