Background: Surgical site infection (SSI) surveillance is a labor-intensive endeavor. We present the design and retrospective cohort validation of a multivariable algorithm to screen for SSI in patients undergoing hip replacement surgery, permitting real-time case detection, and reducing the number of clinical records to be reviewed manually. Methods: We designed a multivariable algorithm using extreme gradient-boosting (XGBoost) to screen for SSI in patients undergoing hip replacement surgery. The development and validation cohort included all healthcare episodes dating from the initial hospital admission for surgery until 90 days after joint replacement (n=19661) between January 2014 and December 2021 from four hospitals in Madrid, Spain. A NLP pipeline was implemented to obtain text variables from free-text fields of the EHR. Clinical, prescription, microbiology, and laboratory variables were also collected. Episodes were split randomly into training (70%) and testing (30%) datasets. Hyperparameters were adjusted to penalize false negatives. Findings: The presence of positive microbiological cultures, the text variable 'infection', and the prescription of clindamycin were strong markers of SSI. Statistical analysis of the final model indicated a high sensitivity (99.18%) and specificity (91.01%) with an F1-score of 0.32, AUC of 0.989 and accuracy of 91.27%. The model correctly classified 5129 episodes as negative for SSI, with only one case of SSI escaping detection (NPV 99.98%). Interpretation: We conclude that the combination of NLP and extreme gradient boosting is a sensitive tool for SSI surveillance in hip replacement surgery, permitting real-time, semi-automatic surveillance. In practice, our results translate as an 88.95% reduction in the total volume of clinical records to be reviewed manually. To the best of our knowledge, this is the first time that an algorithm incorporating data from multiple sources using NLP and extreme gradient boosting has been developed for orthopedic SSI surveillance. Funding: This study did not receive any funding.