CEHR-XGPT is a general-purpose foundation model for electronic health record (EHR) data, integrating three essential capabilities—feature representation, zero-shot prediction, and synthetic data generation—into a single architecture. To support temporal inference on clinical sequences, it incorporates a novel temporal token-based learning framework that explicitly encodes the patient's dynamic temporal course into the model structure. It demonstrates robust performance across all three tasks and generalizes effectively to external datasets through vocabulary expansion and fine-tuning. This versatility enables rapid model development, cohort discovery, and patient outcome prediction without task-specific retraining.