Mental health

I’m currently 28 weeks pregnant, and my depression has come back so extreme it’s making me so nervous. If something were to happen could my boyfriend take custody of my daughter after she’s born because of my mental state? I’ve started seeing my therapist more often, and have talked to my doctor about starting a medication that’s ok during pregnancy. But I feel like I’m slipping away and it’s happening fast..