When Doctors Are on Leave, Code Takes the Lead: A Python-Based System for Automated Doctor Duty Allocation

This abstract has open access
Abstract Description
Abstract ID :
HAC52
Submission Type
Authors: (including presenting author): :
Sin CS(1)
Affiliation: :
(1) Department of Medicine, North District Hospital
Keyword 1: :
Python
Keyword 2: :
Duty Allocation
Keyword 3: :
Leave Management System
Keyword 4: :
Computer Program
Keyword 5: :
Human Resource Management
Keyword 6: :
Smart Hospital
Introduction: :
Assigning doctors to cover colleagues who are on leave is a tedious and time-consuming task. It requires cross-referencing multiple data sources, including call rosters, leave records, staff ranks, and ward assignments. When staff numbers are large and leave patterns are complex, manual assignment becomes error-prone. Leave requests may also arise at short notice, such as urgent or sick leave, placing pressure on coordinators to amend coverage arrangements immediately. Delays may occur if the coordinator is occupied, and the lack of transparency in manual assignment can lead to doubts regarding fairness. With advances in Information and Communication Technology (ICT), programming languages such as Python and JavaScript have become increasingly accessible and maintainable. Computer-based duty allocation systems have the potential to enhance productivity, improve accuracy, increase transparency, and minimize delays. We share our experience in developing and implementing a Python program to automate leave-covering duties. The system extracts data from multiple databases, assigns doctors according to predefined criteria, and outputs allocations and statistics in formats tailored to different stakeholders. A contingency list is also generated to facilitate the management of ad hoc leave requests.
Objectives: :
To develop a computer program to allocate doctors covering duties
Methodology: :
A Python program comprising approximately 1,200 lines of code was developed. Prior to each month, ward assignments, doctor ranks, call rosters, and leave records for the upcoming month are stored in a designated data folder. The program reads these files and standardizes doctor identities across databases using fuzzy name matching against a reference library. Additional libraries interpret various call and leave statuses, such as official release, half-day leave, and post-call leave. Frontline doctors and senior doctors are then processed separately. For frontline assignment, each on-leave doctor is allocated a predefined number of covering doctors per day. Assignments follow three prioritized principles: 1. Intra-day fairness – doctors without existing coverage duties are prioritized to avoid overloading specific individuals. 2. Continuity of care – doctors who covered the same colleague on the previous day are given higher priority to ensure consistent patient management. 3. Inter-day fairness – a cumulative tally is maintained, with doctors who have previously undertaken more coverage assigned lower priority. These principles are applied iteratively on a day-by-day basis until all working days are assigned. For senior doctors, frontline doctors are assigned workload scores based on rank and experience. Senior workload is calculated daily. When a senior doctor is on leave, frontline doctors previously supervised by that senior are redistributed among others. The same principles of intra-day fairness, continuity of care, and inter-day fairness are applied, with priority given to seniors with lower cumulative workload scores. The program includes validation checks to avoid common errors such as double assignments or assigning duties to doctors on leave. Results are displayed for user approval. Upon confirmation, the program outputs the final allocation in multiple formats: Excel files to display daily leave and coverage details, daily coverage responsibilities for each working doctor, and a heatmap visualizes senior workload distribution. Monthly tallies for both frontline and senior staff are generated for reference and for use in subsequent allocation cycles. The program also produces a contingency list identifying doctors with the lowest workload at any given time, to facilitate rapid response to last-minute leave requests. Coordinators and administrative staffs can readily consult this list to streamline real-time duty allocation. Assignment principles, results, statistics, and contingency plans are made available to departmental staff for review, feedback, and continuous improvement.
Result & Outcome: :
Our department has implemented the Python program since October 2025. Administrative staff acclaimed the system, reporting a substantial reduction in assignment workload and enhanced clarity. Frontline staffs have also expressed high satisfaction with the new approach, as it makes all relevant statistics readily accessible and enables a transparent, equitable allocation process. Human resource (HR) management is a key application domain for ICT. Organizations increasingly recognize the importance of ICT in maximizing HR effectiveness. Early stages of ICT adoption often involve digitizing call and leave records, enabling clearer data representation, easier manipulation, and reduction of transcription errors. The Hospital Authority (HA) has actively implemented ICT solutions to address HR challenges. Under the “Smart Hospital” initiative, the HA Go mobile application allows staff to submit leave and call requests electronically and review remaining leave balances. To our knowledge, we are among the first HA departments to employ a computer program for doctor duty allocation. This approach offers several advantages. First, it is fast and efficient, generating all required documents within seconds. Second, it reduces errors associated with manual processing, particularly in cases of similar staff names or complex leave arrangements. Third, it enhances transparency by implementing department-endorsed assignment principles consistently, thereby minimizing human bias and strengthening staff confidence in fairness. Fourth, it enables flexible data representation, such as converting views from “who covers whom” to “who is covering today,” which would be labor-intensive if done manually. Finally, it allows sophisticated adjustment logic, such as normalizing coverage load according to actual working days, preventing staff returning from prolonged leave from being disproportionately burdened. Potential limitations include reliance on programming expertise. While end-users without programming backgrounds can operate the system once established, software updates, debugging, and algorithm modifications require developer involvement. Programmatic allocation is also not fail-safe; rare edge cases may reveal software bugs. Therefore, human review and confirmation remain essential before implementation.

Abstracts With Same Type

11 visits