count_patients_with_flags function

Count the number of patients with particular flags