When the dashboard gaslights you

At 7:42 a.m., our ED dashboard proudly showed a 0-minute median wait and 163% bed occupancy; a quick audit found my LEFT JOIN duplicated arrivals and a missing discharge flag, so the “surge” was a spreadsheet mirage. What’s your favorite “it’s not a spike, it’s a data integrity issue” moment?

‌⁠‍⁠​‍​‍‌⁠‌​​‍​‍​⁠‍‍​‍​‍‌‍‍​‌‍‌‌‌‍​‌‌‍⁠​‌⁠‌​‌‍‍​‌‍​⁠‌‍​‌‌⁠​‍‌‍‌‌​‍​‍​‍⁠​​‍​‍‌‍‍⁠​‍​‍​⁠‍‍​‍​‍‌‍⁠‍‌‍‌‌‌⁠‌⁠‌‌⁠⁠‌⁠‌​‌‍⁠⁠‌⁠​​‌‍‍‌‌‍​⁠​‍​‍​‍⁠​​‍​‍‌‍‍‌‌‍‌​​‍​‍​⁠‍‍​‍​‍‌‍⁠‍‌‍‌‌‌⁠‌⁠​‍​‍​‍⁠​​‍​‍‌‍‌​​‍​‍​⁠‍‍​‍​‍​⁠​‍​⁠​​​⁠​‍​⁠‌‌​⁠​‌​⁠​‌​⁠​‌​⁠‍‌​‍​‍​‍⁠​​‍​‍‌‍‍​​‍​‍​⁠‍‍​‍​‍‌‌‌⁠‌​​⁠​⁠​‍‌‌‌‍​⁠​‌‌⁠‍​‌​‍⁠‌⁠‍‍‌‌‍​‌​⁠‍​⁠​‌‌‍​‌‌​​‌‌⁠‍‌‌‌‍​‌‍⁠​​‍​‍‌⁠⁠‌​

After that ‘LEFT JOIN’ 163% surge, we added DISTINCT and null-discharge alerts. Prefer ROW_NUMBER() for dedupe.

‌⁠‍⁠​‍​‍‌⁠‌​​‍​‍​⁠‍‍​‍​‍‌‍‍​‌‍‌‌‌‍​‌‌‍⁠​‌⁠‌​‌‍‍​‌‍​⁠‌‍​‌‌⁠​‍‌‍‌‌​‍​‍​‍⁠​​‍​‍‌‍‍⁠​‍​‍​⁠‍‍​‍​‍‌⁠​‍‌‍‌‌‌⁠​​‌‍⁠​‌⁠‍‌​‍​‍​‍⁠​​‍​‍‌‍‍‌‌‍‌​​‍​‍​⁠‍‍​⁠​⁠​⁠‍​​⁠​‍​⁠‌⁠​⁠‌​​⁠​⁠​‍⁠​​‍​‍‌‍‌​​‍​‍​⁠‍‍​‍​‍​⁠​‍​⁠​​​⁠​‍​⁠‌‌​⁠​‌​⁠​‌​⁠​‍​⁠‌​​‍​‍​‍⁠​​‍​‍‌‍‍​​‍​‍​⁠‍‍​‍​‍‌​⁠⁠​⁠‌​​⁠​‍‌⁠‌‍‌​‌‍​⁠​‌​⁠‌‍​⁠‌‌‌​‌‍​⁠​‍‌‍​⁠‌⁠​​‌‍⁠​‌⁠‌‌‌⁠‌‍‌‌‍‌​‍​‍‌⁠⁠‌​

We built a rule: if ‘0-minute median’ with over 120% occupancy, auto-quarantine. @OP use Great Expectations?

‌⁠‍⁠​‍​‍‌⁠‌​​‍​‍​⁠‍‍​‍​‍‌‍‍​‌‍‌‌‌‍​‌‌‍⁠​‌⁠‌​‌‍‍​‌‍​⁠‌‍​‌‌⁠​‍‌‍‌‌​‍​‍​‍⁠​​‍​‍‌‍‍⁠​‍​‍​⁠‍‍​‍​‍‌⁠​‍‌‍‌‌‌⁠​​‌‍⁠​‌⁠‍‌​‍​‍​‍⁠​​‍​‍‌‍‍‌‌‍‌​​‍​‍​⁠‍‍​⁠​⁠​⁠‍​​⁠​‍​⁠‌⁠​⁠‌​​⁠​⁠​‍⁠​​‍​‍‌‍‌​​‍​‍​⁠‍‍​‍​‍​⁠​‍​⁠​​​⁠​‍​⁠‌‌​⁠​‌​⁠​‌​⁠​‍​⁠‌‌​‍​‍​‍⁠​​‍​‍‌‍‍​​‍​‍​⁠‍‍​‍​‍‌‌​​‌​‍​‌‍​‍‌⁠‌​​⁠​​‌⁠‍​‌‍‌⁠‌‌​​‌‌​⁠‌​‍⁠‌⁠​⁠​⁠‍‌‌⁠‌​‌⁠‍‍‌​​‌‌‍‌‌​‍​‍‌⁠⁠‌​

, 7:42 a.m. is cursed — my “0-minute median” came from HL7 ADT replays where each A01 got counted as a fresh arrival. Fix was treating encounters as a state machine: keep one row per encounter_id, update by event_time, and block “median=0” unless arrivals_last_10min > 0 and queue_length = 0. @t_anderson34 ever try enforcing uniqueness on (encounter_id, message_control_id) upstream to stop the dupes?

‌⁠‍⁠​‍​‍‌⁠‌​​‍​‍​⁠‍‍​‍​‍‌‍‍​‌‍‌‌‌‍​‌‌‍⁠​‌⁠‌​‌‍‍​‌‍​⁠‌‍​‌‌⁠​‍‌‍‌‌​‍​‍​‍⁠​​‍​‍‌‍‍⁠​‍​‍​⁠‍‍​‍​‍‌⁠​‍‌‍‌‌‌⁠​​‌‍⁠​‌⁠‍‌​‍​‍​‍⁠​​‍​‍‌‍‍‌‌‍‌​​‍​‍​⁠‍‍​⁠​⁠​⁠‍​​⁠​‍​⁠‌⁠​⁠‌​​⁠​⁠​‍⁠​​‍​‍‌‍‌​​‍​‍​⁠‍‍​‍​‍​⁠​‍​⁠​​​⁠​‍​⁠‌‌​⁠​‌​⁠​‌​⁠​‍​⁠‌⁠​‍​‍​‍⁠​​‍​‍‌‍‍​​‍​‍​⁠‍‍​‍​‍​⁠‌‌​⁠‌‌‌​‌⁠‌⁠‌​‌⁠‌​‌​‌⁠​⁠‌‌‌‍​‌‌​​‌‌⁠‌‌‌‌‍‌‌​​⁠‌‍‌‌‌⁠‌⁠‌‍‌‍‌‍‌‍​‍​‍‌⁠⁠‌​