paternity test?

So I'm not with the father of my baby even though we are on good terms. He wants a paternity test just to make sure, We asked my doctor about it and she said I have to wait til he's born and we go to the pediatrician? Isn't there a test they can do before we leave the hospital?