Is the foetal heartbeat an indication that the soul has been breathed into it?
Question

I know that the soul is not breathed into the foetus until after 120 days. So how can there be a foetal heartbeat when a scan is carried out eight or twelve weeks after the pregnancy began? How can that be the case?.
Praise be to Allah.We should differentiate in this case between two kinds of life: 
Life like that of plants, which is different from inanimate objects, because with this life, an entity grows and increases in its presence, and it weakens and dies without it. This is a special kind of life and has nothing to do with the presence of the soul.
Animal life, which is that which is connected to the breathing of the soul into it. 
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: 
Life is of two types: the life of animals and the life of plants. The life of animals is distinguished by senses, voluntary movement; the life of plants is growth and nourishment.
End quote from Majmoo‘ al-Fataawa, 21/98 
Once this is understood, we know that animal life is the kind of life that is is distinguished by the breathing in of the soul. As for plant life, there is no breathing in of the soul. 
The life of the foetus in the mother’s uterus is like that of plants; it grows and is nourished, and it moves involuntarily, like the movement of some plants, or like the movement of the sun, or the opening of flowers, and the like. 
But after the soul is breathed into it, its movements become voluntary, as in the case of animal life. 
Involuntary movements are indicative of the growth of the foetus, but they are not an indication of the soul having been breathed into it. This is unlike voluntary movements which can only occur after the soul has been breathed into the body of the foetus. 
By the same token, there is no connection between the foetal heartbeat and the difference of opinion among the scholars concerning the time when the soul is breathed into the foetus, because the foetal heartbeat begins on the twenty-second day after conception. Those who differ from the majority concerning the time when the soul is breathed into the foetus said that the soul is breathed into it on the fortieth day or later. This confirms what we have said about the foetal heartbeat being an involuntary movement, which is indicative of growth, not of the presence of the soul. Scientists and doctors determine that the foetus is alive through voluntary movements only. 
Ibn al-Qayyim (may Allah have mercy on him) said: If it is asked: Before the soul is breathed into it, does the foetus move and feel things or not? The answer is that it has movements of growth and nourishment like plants, and these movements of growth and nourishment are not voluntary. Then when the soul is breathed into it, its senses and voluntary movements are joined to its movements of growth and nourishment.
End quote from at-Tibyaan fi Aqsaam al-Qur’aan, p. 218 
What Ibn al-Qayyim (may Allah have mercy on him) said is supported by modern doctors. 
Dr. Muhammad ‘Ali al-Baarr (may Allah bless him) said: Before the soul is breathed into it, the foetus makes movements of growth and nourishment; indeed the heart begins to beat from the twenty-second day after conception, and the circulatory system begins to operate from that moment. Yet despite that, none of the scholars of Islam said that the soul is breathed into the foetus at that stage. 
What concerns us here is confirmation that the fuqaha’ did not regard involuntary movements as an indication of the soul being present. On the contrary, they did not regard the beating of the heart and the presence of the circulatory system in the foetus as evidence of the soul having been breathed into it; rather they regarded all of that as being like the growth of plants, and there is no indication in that that the soul has been breathed into the foetus. 
This is a strong indication that they did not regard the circulatory system as being an indication of the presence of the soul, because it is possible for there to be a complete circulatory system and a heart that beats, without there being any soul present. This is precisely what doctors say, because the heart may continue to beat and the circulatory system may continue to operate with the help of drugs and means, and pump that takes care of the respiratory function, but the person who is in this situation is not regarded as being alive; rather he is dead if his brain has died, according to specific conditions that must be met in order to diagnose brain death.
End quote from Ma al-Farq bayn al-Mawt al-Ilkiniki wa’l-Mawt ash-Shar‘i? 
And Allah knows best.