Preparing a schedule for physicians in the emergency room is a complex task, which requires taking into account a large number of (often conflicting) rules, related to various aspects: limits on the number of consecutive shifts or weekly hours, special rules for night shifts and weekends, seniority rules, vacation periods, individual preferences,... In this paper, we present a mathematical programming approach to facilitate this task. The approach models the situation in a major hospital of the Montreal region (approximately 20 physicians are members of the working staff). We show that the approach can significantly reduce the time and the effort required to construct a six-month schedule. A human expert, member of the working staff, typically requires a whole dedicated week to perform this task, with the help of a spreadsheet. With our approach, a schedule can be completed in less than one day. Our approach also generates better schedules than those produced by the expert, because it can take into account simultaneously more rules than any human expert can do.