Date post: | 13-Dec-2015 |
Category: |
Documents |
Upload: | duncan-blackler |
View: | 218 times |
Download: | 0 times |
Computer simulation of patient flow through an operating suite
David E. Clark, MD FACSDepartment of Surgery,
Maine Medical Center, Portland ME
Stata Conference 2014
The problem
• Operating Rooms (ORs) may generate up to 40% of hospital revenue – efficiency is financially important
• Delays and rescheduling are frustrating and demoralizing for patients and staff
• In extreme cases, patient safety may suffer if vital resources are unavailable due to suboptimal management
Simulation Software
• Special-purpose simulation programs (e.g., Arena, Flexsim, Simulink) take care of “housekeeping” and displays, but may be expensive, restrict flexibility, and be more difficult to learn and debug
• General-purpose programming languages (including Stata) easily available, familiar, and flexible, but require the user to construct “housekeeping” and displays
Tools available in Stata
• Basic structure a matrix with rows (observations) and columns (up to 32,767 variables)
• Loops (“forvalues”, “foreach”)• Replication (“expand”, “expandcl”)• Reshaping (“wide”, “long”)• Summarization (“egen”) • Subroutines (“program”, “.do” files)• Time-to-event modeling (“streg”, etc.)• Reporting (“list”, “save”, “append”, “replace”)
Available hospital data
• Patients: Day, procedure, surgeon, scheduled OR/times (in/out etc.), actual OR/times, destination from OR (RR vs ICU), RR times, etc.
• Rooms: Availability for different types of procedures, at different times of day
• Policies: Staffing, scheduling, priority rules, “bumping”
Data Structure
• Must allow for transfer of information between patients and rooms
• Must allow for change in status over time
• Must allow for replication with different random variables
• Must allow for visualization of status, reporting of summary statistics, and modification of structural assumptions
Input distributions
• Time to event, bounded on (0,∞)
• Fit a parametric distribution (many possibilities)
• Model covariates using regression
• Derive transition probabilities (hazards)
0.0
02.0
04.0
06.0
08.0
1P
roba
bilit
y de
nsity
0 60 120 180 240 300 360 420 480 540 600Duration of operative procedure (minutes)
Methods: Derive distributions
• Patient data in normal (“long”) format
• Estimate two-parameter log-logistic distributions for procedure duration, recovery room duration, turnaround time
• Parametric time-to-event regression (“streg”) using predicted procedure duration, procedure type, surgeon, following self, first case, add-on case
Methods: Initialize patients/rooms
• For a given day, convert patient data to “wide” format – that is, all variables are in the same row
• Add room data on same row
For example, at 0600…
Rep Rsch
_P1
Tin
_P1
Tout
_P1
Stat
_P1
Rsch
_P2
Tin
_P2
Tout
_P2
Stat
_P2
Stat
_R1
Trem
_R1
1 1 0730 0930 Pre 1 1000 1300 N/A
Methods: Use replicants to create output distributions
• After initialization, “expand” 30 to 3000
• Run program and periodically
“egen mvar = mean(var)”
“egen sdvar = sd(var)”
etc.
to accumulate statistics of interest
• Display one realization of simulation
Methods: Step through entire day at 5-minute intervals
• Loop using “forvalues”
• Determine patient status at new time t, and whether status should change either deterministically (scheduled or actual) or probabilistically (simulated with random variables).
• Update room status depending on which patient is now in room and/or scheduled to be in room
Methods: Sequence of procedures at each time step
• Identify patients arriving in preop status• Move next priority patient to OR when
patient ready and room available• Move OR patient to RR if procedure
finished (random number exceeds hazard function at time t); restrict room for “turnaround time”
• Move RR patient out of RR if required time complete
Rep Rsch
_P1
Tin
_P1
Tout
_P1
Stat
_P1
Rsch
_P2
Tin
_P2
Tout
_P2
Stat
_P2
Stat
_R1
Trem
_R1
1 1 0730 0930 R1 1 1000 1300 P1 105
Example: Patient/room dataAt 0745, 0845, 0945
Rep Rsch
_P1
Tin
_P1
Tout
_P1
Stat
_P1
Rsch
_P2
Tin
_P2
Tout
_P2
Stat
_P2
Stat
_R1
Trem
_R1
1 1 0730 0930 R1 1 1000 1300 Pre P1 45
Rep Rsch
_P1
Tin
_P1
Tout
_P1
Stat
_P1
Rsch
_P2
Tin
_P2
Tout
_P2
Stat
_P2
Stat
_R1
Trem
_R1
1 1 0730 0930 RR 1 1000 1300 Pre Turn
Methods: Periodic adjustments
• Determine time remaining for current case in each room, total time remaining to complete all cases, free time remaining
• Reprioritize patients scheduled in each room, including new emergency cases
• Identify next case scheduled in room with greatest anticipated overtime, and reassign that case to room with greatest anticipated free time
Results: Output for a typical day
R1 R2 R3 R4 R5 R6 R7 R8
0700
0715
0730 P1 P11
0745 P1 P3 P5 P11 P18
0800 P1 P3 P5 P8 P11 P18 P23
0815 P1 P3 P5 P8 TURN P15 TURN P23
0830 P1 P3 P5 P8 TURN P15 TURN P23
0845 P1 P3 TURN P8 P12 P15 P19 P23
0900 P1 P3 TURN P8 P12 TURN P19 TURN
0915 P1 TURN TURN TURN TURN TURN TURN TURN
0930 TURN TURN TURN TURN TURN TURN
0945 TURN P4 P6 P9 P13 P16 P20 P24
Results
• Runtime about 10 minutes to simulate a 24-hour day with 300 replications – not affected much by number of replications
• Most time-consuming for computer (and most difficult to code) is reassignment of cases from overbooked rooms
• Limited by incomplete data on patient destination after Recovery Room
Validation: Cumulative statistics
Dashed: Mean scheduledSolid: Mean actualShaded: Simulated 90% CI
51
01
52
02
5
09:00 12:00 15:00 18:00 21:00
Friday OR Census
Solid: Mean actualShaded: Simulated 90% CI
51
01
52
02
5
09:00 12:00 15:00 18:00 21:00
Friday RR Census
Expand and modify
• Started small, now allow for 50-100 patients in 24 rooms
• Summarize multiple days with same structure (day of week, block schedule)
• Add information about RR destinations
• Verify assumptions about OR staffing RR staffing, scheduling policies, etc.
• Predict effects of changing staffing/policies
Conclusions
• Stata has some useful features for simulation and enables a working model
• Stata would be even better if commands could reference variable names, e.g., replace st_R7=3 if st_P3=7
• Plan to post improved version of this program on ideas.repec.org
• StataCorp and/or developers should take note of “SAS Simulation Studio”