Abstract
<jats:p>Forecasting a patient's laboratory measurements at future clinical visits from longitudinal electronic health records (EHRs) can support disease monitoring and treatment planning in the context of personalized medicine. However, accurate prediction remains challenging since patients exhibit complex and highly individualized clinical trajectories. Here, we present LaBERT, a transformer-based model trained to forecast future laboratory measurements of a patient given information available at the current and previous clinical visits. Evaluated on 583,535 clinical visits from 255,769 patients in the MIMIC-IV database, LaBERT consistently outperformed baseline methods, reducing mean squared error from 0.77 to 0.53 and improving the coefficient of determination (R2) from 0.29 to 0.51. Medication perturbation analysis further showed that LaBERT learns treatment-related information that is clinically meaningful. In particular, we showed that using the originally prescribed medications, LaBERT predicted future patient states more accurately than when using randomized medication sets in 81% of visits. Furthermore, our controlled counterfactual analyses reproduced established pharmacological effects, including warfarin-associated increases in international normalized ratio (INR) and heparin-associated increases in activated partial thromboplastin time (aPTT), consistently across multiple prediction horizons. These findings establish LaBERT as a model for forecasting future laboratory measurements from longitudinal EHRs and provide a foundation for treatment-dependent patient-state simulation and personalized clinical decision support.</jats:p>