Since the question is NOT about any area of medicine, YES, I "do" think the legislature has the ability to restrict the what the doctor does. After all, they are ALREADY telling him that he can or cannot practice medicine at all. It's not a "free speech" issue.
And where do you draw the line with medicine? Just active treatment for patient complaints and not root causes? The legislature should be doing that, too? It should be up to the doctor to do ask such a question and not mandated or restricted. Giving permission to ask when a gun injury is involved is pointless because, with a gun injury, the police and, in the case of a minor, social services will be sticking their noses in big time. For doctors, an ounce of prevention is worth a pound of cure. My only issue with asking the question is that doctors not record the information and it be done informally.