How can a doctor tell when a woman is having a miscarriage?

Varies. When a women who is pregnant has cramping and bleeding, the suspicion is that she may be miscarrying. If an ultrasound shows a non-viable pregnancy, then it becomes almost certain. If there is a viable pregnancy, even with cramping and bleeding - only time will tell if a miscarriage will occur.