Novel and automated means of opioid use and relapse risk detection are needed. Unstructured electronic medical record data, including written progress notes, can be mined for clinically relevant information, including the presence of substance use and relapse-critical markers of risk and recovery from opioid use disorder (OUD). In this study, we used natural language processing (NLP) to automate the extraction of opioid relapses, and the timing of these occurrences, from veteran patients' electronic medical record. We then demonstrated the utility of our NLP tool via analysis of pre-/post-COVID-19 opioid relapse trends among veterans with OUD. For this demonstration, we analyzed data from 107,606 veterans OUD enrolled in Veterans Health Administration, comparing a pandemic-exposed cohort (