Praise be to Allah.
If a sick person is unable to pray standing, he should pray sitting; if he is unable to do that, then he should pray lying on his side. If he is not able to do that, then he should pray in whatever position he is able to. What is required is to do wudoo’ and cleanse himself of impurity; if he is unable to do wudoo’, he should do tayammum (“dry ablution”); if he is unable to do tayammum or to remove any impurity, he should pray as he is, because Allah, may He be exalted, says (interpretation of the meaning): “So fear Allah as much as you are able” [at-Taghaabun 64:16].
See the answers to questions no. 106758 and 105356. See also the essay at-Tahaarah wa’s-Salaah li Ahl al-A‘dhaar by Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him).
Based on that, the prayer that you offered in this situation was valid, and you do not have to repeat it, because that was what you were able to do at that time, and the bleeding of nifaas (following the miscarriage) had not yet begun at that point.
If a woman miscarries, then she comes under the ruling of nifaas (postpartum bleeding) if the fetus had developed human features, which is after eighty days of pregnancy. If she bleeds following the miscarriage, or one or two days before it, that comes under the rulings on nifaas, if the blood that appeared before it was connected to the miscarriage or birth, and was accompanied by indications of that, such as contractions or the pain of birth.
With regard to “water”, or discharge in which there is no blood, that appears before delivery, it does not come under the rulings on nifaas.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked:
Three days before giving birth, there was some discharge of water accompanied by some pain; is this nifaas?
He (may Allah have mercy on him) replied:
This is not nifaas, because nifaas is blood, not water.
Moreover, it is not nifaas unless it is accompanied by contractions, one or two days before giving birth. But if it is a long time before the expected time of giving birth, it is not nifaas, because nifaas is the bleeding that occurs at the time of birth, or two or three days before that, accompanied by contractions. As for water [discharge without blood], it is not nifaas. End quote.
Fataawa Noor ‘ala ad-Darb
Based on that:
If the water that came out when you were in the hospital was accompanied by blood, then this bleeding was nifaas, and you did not have to pray in that case.
But if there was no blood, then it was not the blood of nifaas, and in this case you had to pray however you could at that time, as explained above.
And Allah knows best.