Not OP. If my doctors and hospitals would give it to me in a good and easily-collatable format, then I and who knows how many other people would gladly donate it to science or for research purposes. Heck some people have this tendency to donate actual body parts and their entire bodies to science, so it's not a big stretch to say some would donate this sort of personal information for a purpose of their own choosing.
This isn't a fully settled debate (including your salary example) so you can't just assume one side is right and argue it as if it's some unquestionable human right.
Many healthcare providers now have APIs for patients to download their data in standard HL7 FHIR and/or CDA format. You should ask about this, and if they don't have it then consider switching providers. All modern EHRs have that functionality built in so for providers it's simply a matter of switching it on.
However, most of that data is useless for research purposes. Even if the format complies with industry standards the quality is often bad with many data elements lacking consistent coding. You can't just feed clinical data from a bunch of different random sources into a research project and expect to get accurate results: it's a garbage in / garbage out issue. That's why most clinical research studies involve just a few provider organizations so that the researchers can properly configure the systems and train the clinicians on consistent data entry.
This isn't a fully settled debate (including your salary example) so you can't just assume one side is right and argue it as if it's some unquestionable human right.