Praise be to Allah.
It is permissible for one who is sick to break his fast, and he has to make up the days that he does not fast because of sickness, because Allaah says (interpretation of the meaning):
“and whoever is ill or on a journey, the same number [of days which one did not observe Sawm (fasts) must be made up] from other days”
The kind of sickness which means that a person is allowed not to fast is severe sickness which causes hardship or harm to the person if he fasts, or which it is feared will make the sickness worse or delay recovery because of fasting. The scholars also said that this applies if it is feared that a person may become sick because of fasting.
If your sickness falls into any of these categories (as appears to be the case), it is permissible for you not to fast, because diagnostic imaging helps to determine the sickness and thus prevent it getting worse or delaying recovery.
But if your sickness does not fall into any of these categories, then it is not permissible for you to break your fast, and you should try to do the imaging at night if you can, or wait until Ramadaan is over.
Shaykh Muhammad al-Saalih al-‘Uthaymeen said:
The person who is sick with a temporary illness falls into one of three categories:
1 – Those for whom fasting is not difficult and does not cause hardship. They have to fast and are not excused.
2 – Those for whom fasting is difficult but does not cause harm. It is makrooh for them to fast because that means they are rejecting a concession granted to them by Allaah, as well as being hard on themselves.
3 – Those for whom fasting is harmful. It is haraam for them to fast because that means they are bringing harm upon themselves. Allaah says (interpretation of the meaning):
“And do not kill yourselves”
“and do not throw yourselves into destruction”
According to the hadeeth, the Prophet (peace and blessings of Allaah be upon him) said: “There should be neither harming nor reciprocating harm.” Narrated by Ibn Maajah and al-Haakim. Al-Nawawi said: it has isnaads which strengthen one another. Whether or not fasting is harmful for a sick person is known either from the person feeling that himself or a trustworthy doctor telling him of that.
If a sick person breaks his fast, he has to make up the number of days that he missed when he recovers. If he dies before recovering, then that obligation no longer applies because the command is to make up the fasts from other days, but he did not live to see those other days.
Fusool fi’l-Siyaam wa’l-Taraaweeh (part 3).
And Allaah knows best.