Hiring for tech roles? Toughbyte can help.

Modeling chaos. Managing complex medical simulations with statecharts

Building a training simulator for Emergency Departments means handling hundreds of concurrent processes: patient triage, resource allocation, and medical staff workflows during mass disaster scenarios. Traditional "if-else" logic quickly collapses into unmaintainable spaghetti code.

In this talk, I'll share my experience using xState to build a mass casualty training simulator for medical staff:

  • Actor model in practice: Spawn and manage hundreds of independent state machines (patients, doctors, equipment) that communicate via events without tight coupling

  • Deterministic state transitions: Replace nested if-statements and scattered business logic with explicit states and guards, making complex workflows predictable and testable

  • Event choreography: Coordinate cross-actor workflows (patient enters surgery → doctor becomes busy → equipment locks)