In my experience, ‘spotting’ of blood most commonly occurs following sex. This is often due to a raw area on the cervix, called an erosion, which is relatively common, and which presents no problem to either the baby or the mother. Usually, this loss is not associated with pain. It would not indicate imminent labour, or even be a reason to desist from sex (unless sex was very painful of course!)
Another possible cause for a pinkish loss and pain is an infection, and a hospital would detect this by taking a urine sample and an internal swab when they examined you internally. If an infection was found, you would receive antibiotics, as untreated infections close to the uterus can have the effect of starting off labour.