Nearly 40,000 military personnel have been given diagnoses of post-traumatic stress disorder since 2003, Pentagon records show.