Yes having unpaid medical bills can affect your ability to purchase a house through a mortgage.
Having unpaid medical bills lowers your credit score and affects your credit rating which is used in the decision of qualifying you for a home mortgage to buy the house.
If your credit score is too low as a result of the unpaid medical bills then you can and most likely will be denied the approval of the home mortgage loan.
I wish that unpaid medical bills didn't affect a persons credit because it's hard to pay medical bills yourself because they are so darn expensive.
No one unless they are really rich will be able to cover outrageous medical bills but if you can you should work out a payment plan to try and pay some of the medical bill to keep it from affecting your credit score too much.