All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Our answer to your question is summarized as follows:
First: If you meant that you committed Zina (adultery) willingly without any compelling, then you must repent to Allah The Almighty from this major sin, and repentance from this sin is by regretting what you did, abandoning it, and determining not to do to it in the future, and ensure to be away from the reasons that lead to this sin, such as mixing with men or secluding with them, talking to them. Knowing that whoever sincerely repents to Allah, Allah accepts his repentance.
Second: the fetus, after the mentioned period, his soul has been blown into him, and aborting him is prohibited, and you must repent from that sin. Besides, you must pay Diyah (blood-money). Diyah of the fetus is one-tenth of the mother’s Diyah. The blood-money can be estimated by gold or silver, or by an animal of livestock from camels, cows, or sheep. If his mother is a free Muslim then the blood-money for it is equal to five camels, because the blood-money of his mother is fifty camels, and if the blood-money is estimated in gold, then his blood-money is equal to fifty mithqals of gold, because the blood-money of his mother is five hundred Mithqal, and fifty Mithqal is equal to fifty golden dinars, because a gold dinar is equal to one Mithqal according to our fatwa, and fifty dinars equals 212.5 grams of pure gold, or its equivalent in currencies, and if the blood-money is estimated in silver, then the blood-money for the fetus is equal to six hundred dirhams of silver, because the blood-money for his mother is six thousand dirhams, and the six hundred silver dirhams are equal to one thousand seven hundred and eighty-five grams. If the blood-money is estimated in cows, then the blood-money for the fetus is ten cows, because the blood-money of his mother is one hundred cows, and if it is measured in sheep, then the blood-money of the fetus is one hundred sheep because the blood-money of his mother is one thousand sheep.
Third: If you did the abortion by yourself, by drinking medicine or something like that, then you must pay the blood-money, but if the person who did the abortion was a doctor or someone else upon your request, then the blood-money must be paid by him, and as for you, you must repent only. Ibn Qudamah said in Al-Mughni: whenever the committer cooperates with the causing person, then the indemnity shall be the responsibility of the committer, not the causing person.
Fourth: The blood-money of the fetus shall be paid to his heirs, even if he was a child of adultery. Although you are his mother, you do not have the right to inherit anything from the blood-money as long as you cause him to abort. The author of (Az-Zad) said: “Whoever alone kills his bequeather or takes part in killing him (whether directly or as a cause) without any lawful reason, he shall not inherit him. Also, it was stated in (Kashf Al-Qina’): "The one who orders unlawful killing does not inherit anything from the murdered person, because he caused the killing.”
Fifth: Scholars have different opinions about the obligation of expiation for aborting the fetus. Some of them are of the view that it is obligatory as killing a soul according to Qiyas (Analogy), because it establishes a right of Allah, not for humans; this view was adopted by Shafi’is and Hanbalis. In contrast, some other scholars are of the view that it is not obligatory because the Prophet, sallallahu ‘alayhi wa sallam, sentenced a woman who killed a fetus to give Ghirah (a slave or bondmaid) as a blood-money. And this view was adopted by the Hanafis and the Malikis, and according to the opinion that it is obligatory, it is the responsibility of the one who committed the abortion himself.
Sixth: as for the funeral prayer for him (the fetus), scholars have a different opinion in this regard, whether the funeral prayer is required for the aborted fetus by Sharee’ah or not. Ibn Qudamah said in (Al-Mughni) reporting the statements of scholars about the funeral prayer for the aborted fetus if he did not initiate crying (on delivery), Imam Ahmed said, if he turned four months, then he should be washed (Ghusl) and his funeral prayer shall be performed, the same opinion was adopted by Saeed ibn Al-Musayyib, Ibn Sireen, and Is'haaq . Abdullah ibn Omar performed a funeral prayer for his grandson, who was born dead. Al-Hasan, Ibrahim, Al-Hakam, Hammad, Malik, Al-Awza`i and As'hab Ar-Rai’ (Abu Hanifa’s companions) said: A funeral prayer shall not be performed for him unless he initiates crying (on delivery). And according to fatwas on our website, a funeral prayer shall be performed for him if he turns four months.
Seventh: You did not clarify what the hospital did with the corpse of the aborted fetus. If the hospital took over the process of burying it, then there is no problem, but if they threw it or burned it or something like that, and did not bury it, then it was mandatory to shroud or wrap it in a cloth and then bury it. It is not supposed to be thrown or burnt. Although scholars have different opinions about funeral prayer and Ghusl for the aborted fetus, all agreed that it must be wrapped in a cloth and buried. It was stated in Al-Mawsoo'ah Al-Fiqhiyyah (Encyclopedia of Jurisprudence): “There is no difference in opinion among the majority of the scholars that if the aborted fetus was recognized partly, then it must be wrapped in a cloth and buried. If it was delivered dead then no funeral prayer is required but it must be buried. As for his Ghusl, there is a difference in opinion between scholars, some of them are of the view that Ghusl is obligatory if the soul was blown into him, while other scholars see that Ghusl for the aborted fetus is disliked. Some other scholars see that Takfeen (wrapping in white clothing) is obligatory, while some others see that it is enough to wrap it in a cloth.
Allah knows best.