Surgical Outcome Data Simulator
Model was written in NetLogo 5.0.1
•
Viewed 255 times
•
Downloaded 15 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;; VARIABLES SET AS SLIDERS IN DISPLAY ;; Number_Of_High_Risk_Surgeons ;; Level_Of_Base_Risk ;; Level_Of_Extra_Risk ;; GLOBAL BREEDS breed [surgeons surgeon] ;; A turtle species to represent surgeons breed [plotpoints plotpoint] ;; A turtle species to represent plot points breed [graphers grapher] ;; A turtle species to represent graph axis points ;; GLOBAL VARIABLES ;; ================ globals[ activity_distribution ;; Variable to hold list of procedures by surgeon surgeons_hirisk ;; Number of high risk surgeons surgeons_hirisk_scale ;; Hi Risk Scale Level surgeons_baserisk ;; Base risk of procedure total_patients ;; Total patients in model total_deaths ;; Total deaths in model mean_rate ;; Mean rate of deaths according to model max_yrealm ;; the maximum x value in the dataset max_xrealm ;; the maximum y value in the dataset * 1.2 xscale ;; scale factor to fit the above into a 30 point grid yscale ;; scale factor to fit the above into a 20 point grid plotpoints_scale ;; holding variable plotpoints_increment ;; holding variable surgeons_revealed scenario_active ] ;; 'TURTLE' VARIABLES ;; ================== surgeons-own[ surgeon_risk ;; RISK OF SURGEON surgeon_activity ;; NUMBER OF CASES SURGEON DOES surgeon_deaths ;; NUMBER OF DEATHS SURGEON ESTIMATED surgeon_rate ;; INFERRED RATE surgeon_rate_plot ;; INFERRED RATE SCALED TO GRAPH - Y VALUE surgeon_activity_plot ;; INFERRED ACTIVITY SCALED TO GRAPH - X VALUE surgeon_clicked ;; USED FOR MOUSE INTERACTION ] plotpoints-own[ plotpoint_type ;; TYPE OF PLOTPOINT plotpoint_count ;; COUNT OF ACTIVITY AT PLOTPOINT plotpoint_se ;; THE SE FOR THE PLOTPOINT plotpoint_lcl2 ;; LCL 2SEs FOR PLOTPOINT plotpoint_lcl3 plotpoint_ucl2 plotpoint_ucl3 ] ;; MAIN PROCEDURE ;; ============== to SIMULATE IF scenario_active = 0 [setup-procedure] set scenario_active 1 activate-mouse end to setup-procedure clear-all reset-ticks set-default-shape plotpoints "dot" set-default-shape surgeons "circle" ask patches [set pcolor white] ;; BEGIN BY SETTING UP SOME OVERALL VARIABLES set surgeons_hirisk Number_Of_High_Risk_Surgeons set surgeons_hirisk_scale Level_Of_Extra_Risk set surgeons_baserisk Level_Of_Base_Risk / 100 ;; POPULATE THE ACTIVITY DISTRIBUTION USING VASCULAR DATA ACTIVITY RATES (TAKEN FROM VASCULAR DATASET AT http://www.vsqip.org.uk/surgeon-level-public-reporting/) set activity_distribution [248 237 228 210 210 202 176 172 164 156 155 147 146 140 139 138 138 137 136 134 134 128 126 126 125 119 117 117 115 114 112 110 108 107 106 106 105 104 104 104 102 101 101 100 99 99 98 96 95 93 92 92 92 91 90 90 89 89 89 88 87 87 86 85 85 84 84 84 83 83 82 81 81 80 78 78 77 76 76 76 76 75 75 75 74 74 74 74 73 72 72 72 72 71 71 71 70 70 70 70 69 69 68 67 66 66 66 66 66 65 65 65 65 64 63 63 62 62 62 62 61 60 60 60 59 59 59 58 58 58 57 55 55 55 55 54 54 53 53 53 53 52 52 52 51 51 50 50 50 50 49 49 48 48 47 47 47 47 46 46 46 45 44 44 44 44 43 43 43 43 42 42 42 41 41 40 40 40 40 40 39 39 39 39 38 38 38 37 37 37 37 37 37 37 37 36 36 36 36 36 35 35 35 35 35 34 34 34 34 34 34 33 33 33 33 32 32 32 32 32 32 32 31 31 31 31 31 30 30 30 30 29 29 29 29 29 28 28 28 28 27 27 27 27 27 27 27 26 26 26 26 26 26 26 25 25 24 24 24 24 24 24 24 24 24 24 23 23 23 23 23 23 23 22 22 22 22 22 22 22 22 21 20 20 20 20 20 20 20 20 19 19 19 19 19 19 18 18 18 18 18 18 18 18 17 17 17 17 16 16 16 16 16 16 15 15 15 14 14 14 14 14 14 14 14 14 14 14 13 13 13 13 13 13 13 13 12 12 12 12 12 12 12 11 11 11 11 11 11 11 11 11 11 11 11 11 11 10 10 9 9 9 9 8 8 8 7 7 7 7 7 7 7 6 6 6 6] ;; CREATE SURGEONS ALL INITIALLY WITH LOW RISK create-surgeons 377 [set surgeon_risk surgeons_baserisk set color blue set size 0.25 set heading 0] ;; ASK EACH SURGEON TO SELECT A NUMBER OF PATIENTS BY PICKING SEQUENTIALLY FROM THE ACTIVITY DISTRIBUTION ask surgeons [set surgeon_activity item who activity_distribution] ;; ASK 'N' SURGEONS TO BECOME HI RISK ask n-of surgeons_hirisk surgeons [set surgeon_risk surgeon_risk * surgeons_hirisk_scale] ;; ASK EACH SURGEON TO OPERATE ON EACH PATIENT IN THEIR CARE, WITH A CHANCE OF DEATH EACH TIME ask surgeons[let temp_patients surgeon_activity ;; TEMP VARIABLE OF PATIENTS REMAINING set total_patients total_patients + surgeon_activity ;; ADD THIS SURGEONS PATIENTS TO THE TOTAL let temp_deaths 0 ;; TEMP VARIABLE OF NUMBER OF DEATHS, INITIALLY 0 while [temp_patients > 0] ;; LOOP AS LONG AS PATIENTS ARE LEFT TO TREAT BY... [IF random-float 1 < surgeon_risk [set temp_deaths temp_deaths + 1] ;; ...TREATING ONE OF THEM, RECORDING OUTCOME IF DEATH... set temp_patients temp_patients - 1] ;; ...THEN REDUCE NUMBER OF PTS TO BE TREATED BY 1, AND LOOP set surgeon_deaths temp_deaths ;; AFTER ALL PTS TREATED, RECORD TOTAL NO OF DEATHS set total_deaths total_deaths + temp_deaths] ;; ADD THIS TOTAL TO THE TOTAL NUMBER OF DEATHS IN THE MODEL ;; ONCE ALL OPERATIONS DONE, ASK EACH SURGEON TO SET THEIR DEATH RATE, AND UPDATE GLOBAL RATE ask surgeons[IFELSE surgeon_activity = 0 [set surgeon_rate 0] ;; SET RATE AS 0 IF THEY OPERATED ON NO PATIENTS [set surgeon_rate surgeon_deaths / surgeon_activity] ] ;; SET RATE AS NUMBER OF DEATHS BY TOTAL ACTIVITY set mean_rate total_deaths / total_patients ;; SET OVERALL MEAN RATE AS TOTALS ;; CALCULATE CONTROL LIMITS set plotpoints_scale 1 ;; SET PLOTPOINT SCALE TO 0 create-plotpoints 500 [setxy 0 0 set plotpoint_type 1 set color green] ;; CREATE 50 PLOTPOINTS TO GENERATE CONTROL LIMITS FROM ask surgeons with-max [surgeon_activity] [set max_xrealm surgeon_activity] ;; SET MAX OF XREALM AS TOP PATIENT ACTIVITY ask surgeons with-max [surgeon_rate] [set max_yrealm (1.2 * surgeon_rate)] ;; SET MAX OF YREALM AS TOP SURGEON RATE + 20% set plotpoints_increment max_xrealm / 500 set xscale max_xrealm / 30 ;; CREATE A SCALE FACTOR FOR X TO FIT ON PLOT set yscale max_yrealm / 20 ;; CREATE A SCALE FACTOR FOR Y TO FIT ON PLOT set plotpoints_scale 1 ;; CREATE AN INCREMENT BASED ON 50ths of PLOT ask plotpoints with [plotpoint_type = 1] ;; ASK THESE PLOTPOINTS ONE AT A TIME TO... [set plotpoint_count plotpoints_increment * plotpoints_scale ;; SET THEIR COUNT (NUMBER OF PROCEDURES) set plotpoint_se (sqrt ((mean_rate * (1 - mean_rate)) / plotpoint_count)) ;; WORK OUT THEIR STANDARD ERROR set plotpoint_lcl2 (mean_rate - (2 * plotpoint_se)) / yscale ;; CALCULATE A LCL/UCL AT EACH LEVEL set plotpoint_lcl3 (mean_rate - (3 * plotpoint_se)) / yscale ;; set plotpoint_ucl2 (mean_rate + (2 * plotpoint_se)) / yscale ;; set plotpoint_ucl3 (mean_rate + (3 * plotpoint_se)) / yscale ;; set plotpoints_scale plotpoints_scale + 1] ;; MOVE SCALE VARIABLE ON ONE POINT FOR NEXT ITERATION ask plotpoints with [plotpoint_type = 1][ IF plotpoint_lcl2 < 0 [set plotpoint_lcl2 0] IF plotpoint_lcl3 < 0 [set plotpoint_lcl3 0] IF plotpoint_ucl2 > 20 [set plotpoint_ucl2 20] IF plotpoint_ucl3 > 20 [set plotpoint_ucl3 20]] ;; CREATE THE DISPLAY create-graphers 1 [setxy 0 20 set color black pen-down facexy 0 19] ;; DRAW AXIS LINES ask graphers [forward 20 facexy 1 0 forward 30 set color black set size 0.005] create-graphers 1 [setxy 0 0 set color black set size 0.005 set label 0] ;; CREATE LABELS ON LINES create-graphers 1 [setxy 0 20 set color black set size 0.005 set label precision 2 max_yrealm] ;; AS ABOVE create-graphers 1 [setxy 30 0 set color black set size 0.005 set label max_xrealm] ;; AS ABOVE create-graphers 1 [setxy 28 18.4 set color green set size 0.3 set shape "circle"] create-graphers 1 [setxy 28 17.4 set color yellow set size 0.3 set shape "circle"] create-graphers 1 [setxy 28 16.4 set color orange set size 0.3 set shape "circle"] create-graphers 1 [setxy 28 15.4 set color blue set size 0.3 set shape "circle"] create-graphers 1 [setxy 28 14.4 set color red set size 0.5 set shape "circle"] create-graphers 1 [setxy 27 14 set color white set size 0.05 set shape "dot" set label "High Risk Surgeon" set label-color black] create-graphers 1 [setxy 27 18 set color white set size 0.05 set shape "dot" set label "Mean" set label-color black] create-graphers 1 [setxy 27 17 set color white set size 0.05 set shape "dot" set label "2 S.E." set label-color black] create-graphers 1 [setxy 27 16 set color white set size 0.05 set shape "dot" set label "3 S.E." set label-color black] create-graphers 1 [setxy 27 15 set color white set size 0.05 set shape "dot" set label "Surgeon" set label-color black] create-graphers 1 [setxy 2.3 19.9 set color white set size 0.05 set shape "dot" set label "Death Rate" set label-color black] create-graphers 1 [setxy 20 -1 set color white set size 0.05 set shape "dot" set label "Number of Operations per Surgeon" set label-color black] ask surgeons [set surgeon_rate_plot surgeon_rate / yscale ;; PLOT THE SURGEONS set surgeon_activity_plot surgeon_activity / xscale ;; setxy surgeon_activity_plot surgeon_rate_plot] ;; ask plotpoints with [plotpoint_type = 1] ;; PLOT THE LCL AND UCL [hatch-plotpoints 1 [setxy (plotpoint_count / xscale) (plotpoint_lcl2) set color yellow set plotpoint_type 2] hatch-plotpoints 1 [setxy (plotpoint_count / xscale) (plotpoint_lcl3) set color orange set plotpoint_type 3] hatch-plotpoints 1 [setxy (plotpoint_count / xscale) (plotpoint_ucl2) set color yellow set plotpoint_type 4] hatch-plotpoints 1 [setxy (plotpoint_count / xscale) (plotpoint_ucl3) set color orange set plotpoint_type 5] setxy (plotpoint_count / xscale) (mean_rate / yscale)] ask plotpoints [set size 0.25] ask plotpoints with [ycor = 0][die] ask plotpoints with [ycor = 20][die] If mouse-inside? = true [activate-mouse] end ;; BUTTON SUBROUTINES ;; ================== to activate-mouse display IF surgeons_revealed = 0 [ask surgeons with [color = green] [set size 0.25]] if mouse-down? [let candidate min-one-of surgeons [distancexy mouse-xcor mouse-ycor] if [distancexy mouse-xcor mouse-ycor] of candidate < 1 [watch candidate while [mouse-down?] [display ask subject [ set surgeon_clicked 1 IF surgeon_risk = surgeons_baserisk [set color green set size 0.75] IF surgeon_risk > surgeons_baserisk [set color red set size 0.75]]] ask surgeons with [surgeon_clicked > 0 AND color = green][set size 0.25 set surgeon_clicked 0] reset-perspective ]] end ;; TOGGLE FOR HIGH RISK SURGEONS to reveal-highrisk set surgeons_revealed 1 ask surgeons with [surgeon_risk > surgeons_baserisk][set color red set size 0.75] end ;; SHOW LABELS ON SURGEONS to show-deaths ask surgeons [set label surgeon_deaths set label-color black] end
There is only one version of this model, created about 11 years ago by Christopher Chiswell.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Surgical Outcome Data Simulator.png | preview | Preview for 'Surgical Outcome Data Simulator' | about 11 years ago, by Christopher Chiswell | Download |
This model does not have any ancestors.
This model does not have any descendants.