Reinfection affected 3.7–4.8% of COVID-19 survivors globally. No statistical validation was reported in retrospective or cross-sectional studies that used large-sample data from routine laboratory testing to detect reinfections. Therefore, we create and validate an algorithm (RCOVID) to detect COVID-19 reinfection cases in a large sample database. We apply RCOVID in three versions of simulation database with of valid and invalid cases of COVID-19 reinfection based on the CDC definition. Additionally, we tested the RCOVID in a real-world routine exam database with 10,539,186. The algorithm detects precisely all infections of the simulated database, with 100% of sensitivity, specificity, and Kappa agreement. Finally, in the real-world database with 7,393,829 valid notifications (after cleaning) and 2,321,185 cases of infections, RCOVID detected 142,308 first reinfections, 4,384 second reinfections, and 110 third reinfections, and 1 case of fourth reinfections. RCOVID is a reliable tool valid to detect COVID-19 reinfection cases in large sample routine exams.