We obtained demographic and diagnostic data from patient records. Demographic data included age, sex, and race. Race was classified as white, black, other, or missing/not recorded. Additionally, each veteran’s zip code of residence was linked to US Census data to obtain the percentage of people living below the federal poverty line in that zip code as a proxy measure for socioeconomic status. Zip code data were missing in 4.3% of the sample and were imputed with single imputation. The socioeconomic status variable was categorized into fifths. All diagnoses were made during the year before each veteran’s start of observation. Diagnoses were categorized into substance use disorders, post-traumatic stress disorder, other anxiety disorders, depressive disorders, and bipolar or psychotic disorders. Additionally, we measured medical comorbidity using the Charlson comorbidity score. To assess acuity of mental health and substance use disorder, we also measured the number of related hospital admissions determined by VHA bed section codes in the year before the start of observation. Use of other drugs was assessed by examining the receipt of three categories of drugs in the year before the start of observation: antidepressants, antiepileptic and anti-parkinsonism drugs, and antipsychotic and neuroleptic drugs. These categories were the three most commonly identified classes of pharmaceuticals, after benzodiazepines, that were involved in deaths related to opioid overdose in the US in 2010