Emergency Handling Flow ======================= Emergency Resolution Flowchart ------------------------------- .. mermaid:: flowchart TD A[Field Team: Report Unavailable] --> B[EmergencyEvent Created] B --> C[Central Ops: Inform Customer of Delay] C --> D[Central Ops: Search Backup Teams in Zone] D --> E{Available Team Found?} E -->|Yes| F[Create EmergencyAssignment] F --> G[Create New Survey/Installation Assignment] G --> H[Notify Backup Team] H --> I[Backup Team Confirms & Executes] I --> J[Emergency Resolved] E -->|No| K[Search Adjacent Zones] K --> L{Available Team Found?} L -->|Yes| F L -->|No| M[Create PriorityReschedule] M --> N[Propose New Date to Customer] N --> O{Customer Confirms?} O -->|Yes| P[Update Survey/Installation Date] P --> J O -->|No| Q[Propose Alternative Date] Q --> N Backup Team Search Logic ------------------------- The backup search follows this priority order: 1. **Same zone, same specialization**: Teams in the same zone with matching ``team_type`` (survey or installation) and ``is_available=True`` 2. **Same zone, dual specialization**: Teams in the same zone with ``team_type='both'`` 3. **Adjacent zones**: Teams in neighboring zones (requires zone adjacency mapping) 4. **No backup found**: Fall through to priority reschedule Each team checked is logged as a ``BackupSearch`` record for audit trail. Resolution SLA -------------- - Emergency events should be resolved within **4 hours** of creation - Unresolved emergencies after 2 hours are escalated on the Central Ops dashboard - All emergency events appear as high-priority items in the Central Ops queue