It's very important to seek medical care. A greenish mucous like substance could be "meconium". This would be unusual at 31 weeks but with pregnancies we never take chances. If the substance is meconium, it would mean that the bag of water surrounding the baby has broken and the baby has had a bowel movement. This is possibly a very serious situation. If the substnace isn't meconium, it may just be mucous from the cervical glands as the cervix
softens. At any rate, the combination of feeling like something is wrong, headache, tightening, cramping and green mucous means that a woman needs to be seen and checked.