Treat the cause (including giving analgesics for pain and optimizing the environment to minimize confusion) and manage any remaining agitation with a sedative drug such as lorazepam, propofol, dexmedetomidine, or ketamine.