instruction: give me the number of patients with diagnoses icd9 code 40391 who had chemistry lab test.
response: SELECT COUNT(DISTINCT demographic.subject_id) FROM demographic INNER JOIN diagnoses ON demographic.hadm_id = diagnoses.hadm_id INNER JOIN lab ON demographic.hadm_id = lab.hadm_id WHERE diagnoses.icd9_code = "40391" AND lab."CATEGORY" = "Chemistry"