Large language models (LLMs) prompted with electronic health record (EHR) data have predicted clinical outcomes less accurately than locally trained machine-learning models. We developed VEX-EHR by extending the vocabulary of a 12-billion-parameter open-weight LLM (weights publicly available) with 17,601 clinical and audit-log codes from 170,483 patients' records at one academic medical center, continuing its pretraining on those 2019-2024 records (4.7 billion tokens) and fine-tuning it per task. AUROCs were 0.917 for next-24-hour discharge, 0.715 for 30-day readmission and 0.847 for intensive care unit acute kidney injury, against 0.868, 0.677 and 0.828 for gradient-boosted trees and 0.848, 0.650 and 0.791 for CEHR-BERT, an EHR foundation model. Continued pretraining added 0.031-0.053 AUROC on every task. With 10% of the labels, VEX-EHR exceeded both comparators using all labels for discharge, and CEHR-BERT for readmission, valuable where labels are costly. Adapted by continued pretraining, open-weight LLMs can outperform traditional machine learning in EHR-based prediction.