Diseases which affect immune function. They may be primary, in which case they are inherited defects in specific genes involved in immune function, or may occur secondary to viral infections such as HIV.