instruction: calculate the number of patients with chest pain - r/o pericardial disease diagnosed until 2 years ago.
response: SELECT COUNT(DISTINCT patient.uniquepid) FROM patient WHERE patient.patientunitstayid IN (SELECT diagnosis.patientunitstayid FROM diagnosis WHERE diagnosis.diagnosisname = 'chest pain - r/o pericardial disease' AND DATETIME(diagnosis.diagnosistime) <= DATETIME(CURRENT_TIME(), '-2 year'))