Question for those in United States

What happens if you commit yourself to the psych ward for suicidal thoughts while pregnant?

Should I let my obgyn know I’m having these thoughts first?

I’m not going to act on them but I’ve been hitting myself hard enough to leave bruises on my thighs and I’ve been having the urge to cut (I’ve cut previously;clean for 2 years).

These thoughts are consuming and it’s so hard.....

I want to get help but I don’t want to lose my baby.... help me please