Leveraging the Structure of Medical Data for Improved Representation Learning