Background Clinical research focused on the burden and impact ofClostridioides difficileinfection (CDI) often relies upon accurate identification of cases using existing health record data. Use of diagnosis codes alone can lead to misclassification of cases. Our goal was to develop and validate a multi-component algorithm to identify hospital-associated CDI (HA-CDI) cases using electronic health record (EHR) data. Methods We performed a validation study using a random sample of adult inpatients at a large academic hospital setting in Portland, Oregon from January 2018 to March 2020. We excluded patients with CDI on admission and those with short lengths of stay (< 4 days). We tested a multi-component algorithm to identify HA-CDI; case patients were required to have received an inpatient course of metronidazole, oral vancomycin, or fidaxomicin and have at least one of the following: a positiveC. difficilelaboratory test or the International Classification of Diseases, Tenth Revision (ICD-10) code for non-recurrent CDI. For a random sample of 80 algorithm-identified HA-CDI cases and 80 non-cases, we performed manual EHR review to identify gold standard of HA-CDI diagnosis. We then calculated overall percent accuracy, sensitivity, specificity, and positive and negative predictive value for the algorithm overall and for the individual components. Results Our case definition algorithm identified HA-CDI cases with 94% accuracy (95% Confidence Interval (CI): 88% to 97%). We achieved 100% sensitivity (94% to 100%), 89% specificity (81% to 95%), 88% positive predictive value (78% to 94%), and 100% negative predictive value (95% to 100%). Requiring a positiveC. difficiletest as our gold standard further improved diagnostic performance (97% accuracy [93% to 99%], 93% PPV [85% to 98%]). Conclusions Our algorithm accurately detected true HA-CDI cases from EHR data in our patient population. A multi-component algorithm performs better than any isolated component. Requiring a positive laboratory test forC. difficilestrengthens diagnostic performance even further. Accurate detection could have important implications for CDI tracking and research.