Welcome back to the Wefugees Community and thank you for your question!
No! Your doctor is not allowed to forward your medical file or any information to the BAMF if you have not given him/her the permission to do so. Medical staff is required to work confidentially by law - even if people are considered as staying in Germany "illegally". Did this happen to you?