Use of electronic health records for predictive modelling and cohort analysis in diabetes