38 weeks pregnant and blood discharge

Hi ladies

I have been having brown discharge from yesterday morning. Yesterday afternoon my doc checked me for dilation and I was 1 cm dilated then in the evng I started seeing more dark brown blood clots when I pee. Went to hospital she checked my cervix again and said I am 1.5 cm dilated. In the midnight I had severe cramps 5 min apart. I had to rush to the hospital then they checked cervix again and said I was 3 cm dilated. They observed me for 2 more hours and checked if I am dilating or not. My contractions fell apart and it stopped at 3cm dilation. I came back home to wait for more frequent contractions. I have been having severe back pain and cramps with irregular timing and discharge as shown in below pic. Discharge is continuous and if I wipe it is still coming. This is my first baby I m not sure what is happening. Please help !