"Gender" is a social construct and is shorthand for culturally-bound sex-role stereotypes. "Gender" and "gender identity" have no more bearing on, for example, appropriate doses of medication, signs and symptoms of various medical conditions, blood transfusion, etc. than Religion.
Sex is biological reality and it really does matter a lot in health care and medicine.
If "Gender" is being used as a synonym for "Sex" then this compromises patients safety, as the patient might volunteer that their "gender" is female when they are actually male, or the reverse, or that they are "non-binary", or any other made-up, fashionable "gender". If so, vital information on "sex" is compromised.
Expand the question to be explicit about its actual meaning and it is obvious how ridiculous, irrelevant and therefore impertinent it is:
"Do you identify with the culturally-bound sex-role stereotypes of masculinity or femininity?"
The OP is being extremely responsible in her efforts to ensure patient safety and her concern about avoiding distressing or confusing her patients, whatever their age, should be applauded not mocked.