When to get Rhogam shot??

Alissa

I have A- blood and my husband has O+, which means our baby has positive blood and I will need a Rhogam shot. When do I need this and can it cause a miscarriage if I’m this early?