Having x-rays done does not affect the fast, and it is not regarded as one of the things that invalidate the fast, unless the patient takes medicine or is told by the doctor to eat or drink something before the x-ray (or other procedure), in which case the fast is broken because of eating or drinking.
Carrying out the examination does not affect the fast of the one who does it. We have already explained in the answer to question no. 20710 and 22757 that the correct scholarly view is that touching a non-mahram woman does not invalidate wudoo’.
It is not permissible for a man to treat a non-mahram woman or vice versa except in cases of necessity, and necessity should be evaluated in a proper manner. It is not permissible to uncover for the slightest reason or the slightest sickness, and it is not permissible to look at more than the site of pain that needs to be uncovered. And it is not permissible for the medic and the patient to be alone together. The answer to question no. 2198 explains the ruling on men treating women.
It is haraam for a man to touch a non-mahram woman and vice versa. Putting on gloves makes the matter less serious if it is essential for treatment.
And Allaah knows best.