how many patients died during the same hospital encounter after having been diagnosed until 3 years ago with hyp kid nos w cr kid v?
select count( distinct t2.subject_id ) from ( select t1.subject_id, t1.charttime, t1.hadm_id from ( select admissions.subject_id, diagnoses_icd.charttime, admissions.hadm_id from diagnoses_icd join admissions on diagnoses_icd.hadm_id = admissions.hadm_id where diagnoses_icd.icd9_code = ( select d_icd_diagnoses.icd9_code from d_icd_diagnoses where d_icd_diagnoses.short_title = 'hyp kid nos w cr kid v' ) ) as t1 group by t1.subject_id having min(t1.charttime) = t1.charttime and datetime(t1.charttime) <= datetime(current_time,'-3 year') ) as t2 join ( select patients.subject_id, admissions.hadm_id, patients.dod from admissions join patients on patients.subject_id = admissions.subject_id where patients.dod is not null and datetime(patients.dod) <= datetime(current_time,'-3 year') ) as t3 on t2.subject_id = t3.subject_id where t2.hadm_id = t3.hadm_id