There are strict guidelines about what data can be shared for research purposes and researchers only get access to the data they need - not your full medical history.
Access is audited and you can request information on where and for what purposes your data is shared.
You can also easily opt out of your data being shared for research purposes.