The tax code is not the fair housing act.
After doing more checking, my original analysis is wrong, but it is not an open and shut case. It will depend on your exact facts and circumstances.
This is not part of the tax regulations, but it indicates how the IRS will handle such cases if you are audited.
"The costs of buying, training, and maintaining a service animal to assist an individual with mental disabilities may qualify as medical care if the taxpayer can establish that the taxpayer is using the service animal primarily for medical care to alleviate a mental defect or illness and that the taxpayer would not have paid the expenses but for the disease or illness."
"A taxpayer who claims that an expense of a peculiarly personal nature is primarily for medical care must establish that fact. The courts have looked toward objective factors to determine whether an otherwise personal expense is for medical care: the taxpayer’s motive or purpose for making the expenditure, whether a physician has diagnosed a medical condition and recommended the item as treatment or mitigation, linkage between the treatment and the illness, treatment effectiveness, and proximity in time to the onset or recurrence of a disease" "A personal expense is not deductible as medical care if the taxpayer would have paid the expense even in the absence of a medical condition."
<a rel="nofollow" target="_blank" href="
https://www.irs.gov/pub/irs-wd/10-0129.pdf">https://www.irs.gov/pub/irs-wd/10-0129.pdf</a>
So if you are audited, you would bear the burden of proof for all these factors. That you did not own the dog before, only bought the dog because you were advised to by your doctor to treat a mental defect or illness, and would not have bought the dog if you did not have an illness.