How does Turbotax/Brokerage distinguish between HSA withdrawal for excessive contribution vs distribution for a medical expense?

I over contributed about $300 to my HSA for 2016. I assumed I will receive a tax form for 2017 withdrawal for taking money out of my HSA due to excessive contribution. How does my HSA know that this is an excessive contribution? Will Turbotax be able to distinguish between excessive contribution vs medical expenses for 2017 tax returns in 2018?