Prior studies of the impact of psychiatric comorbidity on outcomes after acute myocardial infarction (AMI) have frequently relied on inpatient secondary diagnosis codes. This study compared associations between psychiatric comorbidity and AMI outcomes that were derived using secondary diagnosis codes and codes captured from prior outpatient encounters. Retrospective cohort study analyzing 21 745 patients admitted in 2004 to 2006 to Veterans Health Administration hospitals with AMI using administrative data. Psychiatric comorbidity was identified using (1) secondary inpatient diagnosis codes from the index hospitalization and (2) diagnoses from prior outpatient encounters. Outcomes included 30- and 365-day mortality and the receipt of coronary revascularization within 30 days of admission. Generalized estimating equations and Cox proportional hazards were used to adjust mortality and receipt of revascularization for demographic and clinical variables. Psychiatric disorders were identified in 2285 (10%) patients from inpatient secondary diagnosis codes and 5225 (24%) patients from prior outpatient codes. Patients with psychiatric comorbidity had higher adjusted 30- and 365-day mortality, based on outpatient codes (odds ratios, 1.19 [95% CI, 1.09 to 1.30] and 1.12 [95% CI, 1.03 to 1.22], respectively), but similar mortality based on inpatient codes (odds ratios, 0.89 [95% CI, 0.69 to 1.01] and 0.93 [95% CI, 0.82 to 1.06], respectively). In contrast, patients with psychiatric comorbidity had lower receipt of coronary revascularization based on outpatient codes (hazard ratio, 0.92; [95% CI, 0.85 to 0.99], but similar receipt based on inpatient codes (hazard ratio, 1.00 [95% CI, 0.91 to 1.10]). Inpatient secondary diagnosis codes identified fewer patients with psychiatric comorbidity than prior outpatient codes. Moreover, associations with AMI outcomes differed for the 2 approaches. These findings raise potential concerns about the validity and reliability of psychiatric inpatient secondary diagnosis in estimating the impact of psychiatric comorbidities on AMI outcomes and in developing risk-adjustment models.