What is the ruling for vaginal bleeding that happens after surgery or consuming a certain type of medication?
Imam al-Khatib al-Syarbini explained, when vaginal bleeding happens or continues to happen, then the woman has to avoid performing prayer and matters that are prohibited during menstruation. Then, she should wait and examine the blood for a whole day and night (24 hours). If the bleeding is continuous or in a fatrah state, which means if cotton is inserted in the vagina and removed, blood is observed for 24 hours continuously or intermittently, then it is ruled as menstruation blood. If it does not reach 24 hours, then it is not menstruation blood but it is considered as fasad blood. If it is fasad blood then she should replace all the obligatory prayers she missed when she was experiencing vaginal bleeding. 
The minimum duration of vaginal bleeding for it to be considered as menstruation blood is for a whole day and night. Whilst the maximum duration for menstruation is 15 days. 
If bleeding persists after this duration, then it is ruled as istihadah blood or vaginal bleeding due to certain illnesses. Istihadah blood is defined as an illness that results in vaginal bleeding that is excreted through the vein at the end of the vagina known as al-‘azil (العاذل). 
Istihadah blood invalidates ablution but it does not obligate the obligatory bath and prayer and fasting is still an obligation for her. A woman who experiences istihadah should wash the blood, wear a diaper, and perform the ablution for every obligatory prayer before praying.
This is in accordance with a hadith from Aisyah R.Anha who said, Fatimah binti Abu Hubaish came to see the Messenger PBUH and asked:
يَا رَسُولَ اللَّهِ إِنِّى امْرَأَةٌ أُسْتَحَاضُ فَلاَ أَطْهُرُ أَفَأَدَعُ الصَّلاَةَ فَقَالَ رَسُولُ اللَّهِ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ: لاَ إِنَّمَا ذَلِكِ عِرْقٌ وَلَيْسَ بِحَيْضَةِ فَإِذَا أَقْبَلَتْ حَيْضَةُ فاترُكي الصَّلاَةَ فإِذَا ذَهَبَ قدرها فَاغْسِلِى عَنْكِ الدَّمَ وَصَلِّى
“I am a woman whose blood keeps flowing, and I am never purified; Shall I, therefore, abandon prayer?” He replied, “No that is only a vein and is not menstruation; so, when your menstruation comes on abandon prayer, and when it ends wash the blood from yourself and then pray.” 
Regarding the characteristics of istihadhah blood, there is a hadith from Fatimah binti Abu Hubaish R.Anha, she experiences istihadhah and Rasullullah PBUH said:
إِذَا كَانَ دَمُ الْحَيْضَةِ فَإِنَّهُ دَمٌ أَسْوَدُ يُعْرَفُ فَإِذَا كَانَ ذَلِكَ فَأَمْسِكِى عَنِ الصَّلاَةِ فَإِذَا كَانَ الآخَرُ فَتَوَضَّئِى وَصَلِّى فَإِنَّمَا هُوَ عِرْقٌ
“If it is menstrual blood then it is the blood that is black and recognizable, so stop praying, and if it is other than that then perform Wudu’, for it is just a vein.” 
It can be understood from this hadith that if a woman can differentiate the colours of the blood, then the stronger blood is menstruation blood while the weaker blood is istihadah blood. How should one differentiate the strong and weak characteristics of blood? According to Habib Hasan bin Ahmad bin Muhammad bin Salim al-Kaf:
- Strong blood occurs not less than the minimum duration for menstruation; a whole day and night.
- Strong blood happens not more than the maximum duration for menstruation; 15 days and 15 nights.
- Weak blood occurs not less than the maximum duration of menstruation; 15 days and 15 nights.
- Weak blood happens continuously without any breaks (without naqa’ or alternates with strong blood) 
If one of these conditions isn’t fulfilled, then one should follow what is usual. I’m inclined to state that the bleeding that happens after surgery or consumption of medications and it happens during when it is not the time for the menstruation of the woman, then the blood is considered as istihadah. Whereas, if the bleeding happens during the usual time of menstruation until the maximum duration of menstruation, then it is menstruation blood. Wallahua’lam.