Model validation
We validated the model on the testing set using a simulated prospective approach: for each patient we ordered all available variables (diagnoses, medications, lab tests), from oldest to newest, and calculated the cumulative score at each time point using the sum of the partial risk scores associated with each code or variable. Each patient’s overall risk-score at each time point was calculated by combining the partial risk scores preceding that time point. The patient’s score was interpreted using the maximal risk score obtained over time and compared to the thresholds selected during the training phase to achieve 90% and 95% specificities, respectively, and the sensitivity and timeliness of prediction at these levels of specificity were measured.The total risk score at time point t is calculated as the sum of all partial risk scores (PRSs) up to that time point (PRS i, j, k, …, z all occurred before time point t). The overall risk score (ORS) for each subject, is calculated using the maximal value of all total-risk-scores calculated.