I have a drug allergy.

Literal

Medicine [to-に] allergy [subj-が] exist-[polite-ます].

薬に is locative/target-に, not dative — 'an allergy exists with respect to medicine.' The pattern [allergen]に+アレルギーがある is the standard medical-intake template for declaring a drug allergy. アレルギー itself is borrowed from German 'Allergie' via Meiji- and early Shōwa-era medical vocabulary.