Sometimes, a health care provider may use a blood test to diagnose ankylosing spondylitis. He or she may also perform a genetic test to check for the HLA-B27 gene.