Foundation models for electronic health records: representation dynamics and transferability