update stat procedure to use qa_approved and secondary_flag