The structure of the sentence is not correct. Here there are two independent clauses and one dependent cause which are broken as follows.
(i) I have just learned - MC
(ii) that the medication I have been taking all those year - NC
(iii) may have been causing harm/harming my health.- Ad C
The structure of (ii) and (iii) needs correction /modification as follows:
(ii) that the medication under which I have been all those years.
(iii)might have been causing harm to my health
Hence the sentence will be like this:
I have just learned that the medication under which I have been all those years might have been causing harm to my health.
Student or Learner