Foundation Model of Electronic Medical Records for Adaptive Risk Estimation