Building a real-world hospital nurse shift scheduler is fundamentally different from generic employee timetabling. In 24/7 clinical wards (ICU, Emergency, Internal Medicine), breaking a single rest constraint can trigger dangerous Quick Returns (e.g., finishing an overnight shift at 08:00 and returning the same day) and accelerate nurse burnout.
While developing Axis Puls — a web/PWA/Android shift scheduling platform for hospitals and shift-based teams — we recently open-sourced our zero-dependency Python & TypeScript reference library for calculating statutory nursing working hours under Iran's Clinical Staff Productivity Promotion Law (Articles 2 & 5):
- Open-Source MIT Repository: github.com/axispuls/iran-nursing-productivity-law-calc
- Interactive Web Calculator (no signup): Nursing Work-Hours Calculator
- Live Browser Shift Arranger Sandbox (EN/FA/AR/DE): axispuls.ir/demo/?lang=en
The 4 Hard Constraints Every Clinical Scheduler Must Enforce
- Minimum 12-Hour Inter-Shift Rest & Zero Quick Return: Any transition from Night (
20:00–08:00) to Morning (08:00–14:00) or same-day Evening must be strictly blocked by the solver rather than silently accepted to fill coverage gaps. - Dynamic Weekly Required Hours (36h–44h/week): Starting from a
44hbase (6-day week), seniority (1–5h), ward hardship (0.5–2h), and non-standard rotating shifts (0–1h) reduce weekly required duty by up to8h/week. - Shift Multipliers & Dual Overtime Caps: Overnight and official holiday shifts carry a
1.5×effective multiplier. Overtime must be checked simultaneously against half of monthly required hours and the80h/monthexecutive bylaw ceiling, with a hard12hconsecutive duty cap. - Transparent Unfilled Slots Over Silent Rule Violations: When a ward lacks enough eligible nurses on a given date, a trustworthy scheduler flags the unfilled slot for the head nurse instead of breaking safety rules behind the scenes.
Quick Example in Python (moh_calc.py)
from moh_calc import PRESETS, calculate_nursing_hours res = calculate_nursing_hours(PRESETS["icu"]) print(res.weekly_required_hours) # 38.0 print(res.monthly_required_hours) # 158.33 print(res.effective_hours) # 210.0 print(res.difference_hours) # 51.67 print(res.status) # "ok" If you work on workforce optimization, healthcare IT, or constraint-satisfaction scheduling, feel free to inspect the MIT code on GitHub or test our live RAM-isolated shift arranger at axispuls.ir/demo/?lang=en — no login required.