Systems Library / Industry Applications / How to Automate Legal Deadline and Court Date Tracking
Industry Applications legal

How to Automate Legal Deadline and Court Date Tracking

Track court dates and filing deadlines with automated reminders.

Jay Banlasan

Jay Banlasan

The AI Systems Guy

Automating legal deadline and court date tracking prevents the kind of missed filing that ends careers. I built this after a paralegal told me they tracked 200+ deadlines across 50 active cases in a spreadsheet with color coding. One missed filter and a statute of limitations expires. This system tracks every deadline, sends graduated reminders, and escalates when something is about to slip.

What You Need Before Starting

Step 1: Build the Deadline Database

import sqlite3
from datetime import datetime

def init_deadline_db(db_path="legal_deadlines.db"):
    conn = sqlite3.connect(db_path)
    conn.execute("""
        CREATE TABLE IF NOT EXISTS deadlines (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            case_id TEXT,
            case_name TEXT,
            deadline_type TEXT,
            description TEXT,
            due_date TEXT,
            attorney TEXT,
            priority TEXT DEFAULT 'normal',
            status TEXT DEFAULT 'active',
            completed_date TEXT,
            notes TEXT,
            created_at TEXT
        )
    """)
    conn.execute("""
        CREATE TABLE IF NOT EXISTS reminders_sent (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            deadline_id INTEGER,
            reminder_type TEXT,
            sent_at TEXT
        )
    """)
    conn.commit()
    conn.close()

def add_deadline(case_id, case_name, deadline_type, description, due_date, attorney, priority="normal", db_path="legal_deadlines.db"):
    conn = sqlite3.connect(db_path)
    conn.execute("""
        INSERT INTO deadlines (case_id, case_name, deadline_type, description, due_date, attorney, priority, created_at)
        VALUES (?,?,?,?,?,?,?,?)
    """, (case_id, case_name, deadline_type, description, due_date, attorney, priority, datetime.utcnow().isoformat()))
    conn.commit()
    conn.close()

Step 2: Define Reminder Rules

REMINDER_SCHEDULE = {
    "statute_of_limitations": [
        {"days_before": 90, "type": "early_warning"},
        {"days_before": 30, "type": "urgent"},
        {"days_before": 14, "type": "critical"},
        {"days_before": 7, "type": "final"},
        {"days_before": 3, "type": "emergency"},
    ],
    "filing_deadline": [
        {"days_before": 14, "type": "early_warning"},
        {"days_before": 7, "type": "urgent"},
        {"days_before": 3, "type": "critical"},
        {"days_before": 1, "type": "final"},
    ],
    "court_date": [
        {"days_before": 14, "type": "preparation"},
        {"days_before": 7, "type": "prep_check"},
        {"days_before": 2, "type": "final_prep"},
        {"days_before": 1, "type": "tomorrow"},
    ],
    "discovery_deadline": [
        {"days_before": 21, "type": "early_warning"},
        {"days_before": 7, "type": "urgent"},
        {"days_before": 3, "type": "critical"},
    ]
}

Step 3: Build the Reminder Engine

from datetime import timedelta
import requests

def check_and_send_reminders(db_path="legal_deadlines.db"):
    conn = sqlite3.connect(db_path)
    active = conn.execute(
        "SELECT id, case_id, case_name, deadline_type, description, due_date, attorney, priority FROM deadlines WHERE status = 'active'"
    ).fetchall()
    
    sent_count = 0
    for deadline in active:
        did, case_id, case_name, dtype, desc, due, attorney, priority = deadline
        due_dt = datetime.fromisoformat(due)
        days_until = (due_dt - datetime.utcnow()).days
        
        schedule = REMINDER_SCHEDULE.get(dtype, REMINDER_SCHEDULE["filing_deadline"])
        
        for reminder in schedule:
            if days_until <= reminder["days_before"]:
                already_sent = conn.execute(
                    "SELECT id FROM reminders_sent WHERE deadline_id = ? AND reminder_type = ?",
                    (did, reminder["type"])
                ).fetchone()
                
                if not already_sent:
                    send_deadline_reminder(did, case_name, desc, due, attorney, reminder["type"], days_until)
                    conn.execute(
                        "INSERT INTO reminders_sent (deadline_id, reminder_type, sent_at) VALUES (?,?,?)",
                        (did, reminder["type"], datetime.utcnow().isoformat())
                    )
                    sent_count += 1
    
    conn.commit()
    conn.close()
    return sent_count

def send_deadline_reminder(deadline_id, case_name, description, due_date, attorney, reminder_type, days_left):
    severity = {"early_warning": "FYI", "urgent": "ACTION NEEDED", "critical": "CRITICAL", "final": "FINAL WARNING", "emergency": "EMERGENCY", "preparation": "PREP", "prep_check": "PREP CHECK", "tomorrow": "TOMORROW", "final_prep": "FINAL PREP"}
    
    message = f"[{severity.get(reminder_type, 'REMINDER')}] {case_name}\n{description}\nDue: {due_date} ({days_left} days)\nAssigned: {attorney}"
    
    requests.post("YOUR_SLACK_WEBHOOK", json={"text": message})

Step 4: Daily Deadline Report

def daily_deadline_report(db_path="legal_deadlines.db"):
    conn = sqlite3.connect(db_path)
    
    overdue = conn.execute("""
        SELECT case_name, description, due_date, attorney FROM deadlines
        WHERE status = 'active' AND due_date < date('now')
    """).fetchall()
    
    this_week = conn.execute("""
        SELECT case_name, description, due_date, attorney FROM deadlines
        WHERE status = 'active' AND due_date BETWEEN date('now') AND date('now', '+7 days')
        ORDER BY due_date
    """).fetchall()
    
    next_week = conn.execute("""
        SELECT case_name, description, due_date, attorney FROM deadlines
        WHERE status = 'active' AND due_date BETWEEN date('now', '+7 days') AND date('now', '+14 days')
        ORDER BY due_date
    """).fetchall()
    
    conn.close()
    
    lines = ["Daily Deadline Report", ""]
    if overdue:
        lines.append(f"OVERDUE ({len(overdue)}):")
        for o in overdue:
            lines.append(f"  {o[0]}: {o[1]} (was due {o[2]}) - {o[3]}")
    
    lines.append(f"\nThis Week ({len(this_week)}):")
    for t in this_week:
        lines.append(f"  {t[2]}: {t[0]} - {t[1]} ({t[3]})")
    
    lines.append(f"\nNext Week ({len(next_week)}):")
    for n in next_week:
        lines.append(f"  {n[2]}: {n[0]} - {n[1]} ({n[3]})")
    
    return "\n".join(lines)

if __name__ == "__main__":
    init_deadline_db()
    check_and_send_reminders()
    print(daily_deadline_report())

Step 5: Schedule It

0 7 * * * python3 /path/to/deadline_tracker.py
0 16 * * * python3 /path/to/deadline_tracker.py

Run it twice daily: morning to plan the day, afternoon to catch anything approaching.

What to Build Next

Add automatic deadline calculation. When you enter a triggering event (complaint filed, discovery served), the system calculates all downstream deadlines based on your jurisdiction's rules and adds them automatically.

Related Reading

Want this system built for your business?

Get a free assessment. We will map every system your business needs and show you the ROI.

Get Your Free Assessment

Related Systems