The distinction usually has something to do with guilt.
ES tut mir leid is something you say, if you regret something that you -or someone you feel responsible for- has done and want to say sorry.
I‘m sorry that I broke your Glasses
Es tut mir leid, dass ich Deine Brille zerbrochen habe
DAS tut mir leid is something you say, if you feel pitty for something that happened to somebody without you feeling guilty for it.
Someone tells you, that someone else broke his glasses
Did you know, that Fred broke my glasses? - Oh, What a shame
Wusstest Du, dass Fred meine Brille zerbrochen hat? - Oh, das tut mir leid.
In your example „Es tut mit leid“ could be used es well but it would imply one of two things: either Misses Miller is the reason why the other woman does not feel good, or if Misses Renger startet crying after responding then Misses Miller could say „Es tut mir leid“ for asking and making her cry.