An Agent-Based Model of Emergency Department Dynamics Under Capacity Constraints
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
(a general understanding of what the model is trying to show or explain)
HOW IT WORKS
(what rules the agents use to create the overall behavior of the model)
HOW TO USE IT
(how to use the model, including a description of each of the items in the Interface tab)
THINGS TO NOTICE
(suggested things for the user to notice while running the model)
THINGS TO TRY
(suggested things for the user to try to do (move sliders, switches, etc.) with the model)
EXTENDING THE MODEL
(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest)
CREDITS AND REFERENCES
(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
Comments and Questions
;; ========================================== ;; ER Treatment Model ;; ========================================== breed [patients patient] globals [ patients-saved patients-died patients-died-in-er er-room-loads empty-tick treatment-interval er-overload-risk ] patients-own [ health speed being-treated? ] patches-own [ er-id ] ;; ---------------- SETUP ---------------- to setup clear-all set patients-saved 0 set patients-died 0 set patients-died-in-er 0 set empty-tick -1 ;; NEW parameters set treatment-interval 3 set er-overload-risk 10 setup-boundary setup-corridors setup-entrance setup-er-rooms label-hospital-zones setup-patients reset-ticks end ;; ---------------- ENVIRONMENT ---------------- to setup-boundary ask patches [ if pxcor = max-pxcor or pxcor = min-pxcor or pycor = max-pycor or pycor = min-pycor [ set pcolor white ] if pcolor != white [ ifelse (pxcor + pycor) mod 2 = 0 [ set pcolor 9 ] [ set pcolor 8 ] ] ] end to setup-entrance ask patches with [ pxcor > -3 and pxcor < 3 and pycor > -3 and pycor < 3 ] [ set pcolor 7 ] end to setup-corridors ask patches with [ abs pxcor <= 1 and abs pycor <= 14 ] [ set pcolor 6 ] ask patches with [ abs pycor <= 1 and abs pxcor <= 14 ] [ set pcolor 6 ] end to-report entrance-patches report patches with [ pxcor > -3 and pxcor < 3 and pycor > -3 and pycor < 3 ] end ;; ---------------- ER ROOMS ---------------- to setup-er-rooms set er-room-loads n-values num-er-rooms [0] ask patches with [pcolor = green] [ set pcolor black set er-id nobody ] let s er-size if num-er-rooms >= 1 [ ask patches with [ pxcor >= (-14) and pxcor < (-14 + 2 * s) and pycor <= (14) and pycor > (14 - 2 * s) ] [ set pcolor green set er-id 0 ] ] if num-er-rooms >= 2 [ ask patches with [ pxcor <= (14) and pxcor > (14 - 2 * s) and pycor <= (14) and pycor > (14 - 2 * s) ] [ set pcolor green set er-id 1 ] ] if num-er-rooms >= 3 [ ask patches with [ pxcor >= (-14) and pxcor < (-14 + 2 * s) and pycor >= (-14) and pycor < (-14 + 2 * s) ] [ set pcolor green set er-id 2 ] ] if num-er-rooms >= 4 [ ask patches with [ pxcor <= (14) and pxcor > (14 - 2 * s) and pycor >= (-14) and pycor < (-14 + 2 * s) ] [ set pcolor green set er-id 3 ] ] end to-report er-patches report patches with [pcolor = green] end ;; ---------------- PATIENTS ---------------- to setup-patients create-patients initial-patients [ move-to one-of entrance-patches set size 1.2 set shape "person" set health max list 1 (initial-severity + random 3 - random 3) set speed max list min-speed ((sqrt health / 10) * speed-factor) set being-treated? false update-colour set label precision health 0 set label-color white ] end ;; ---------------- MAIN LOOP ---------------- to go if empty-tick != -1 and ticks >= empty-tick + 10 [ stop ] if (not any? patients) and empty-tick = -1 [ set empty-tick ticks ] ask patients [ ;; ER patients handled first if being-treated? [ receive-treatment update-colour set label precision health 0 stop ] ;; death outside ER if health <= 0 [ set patients-died patients-died + 1 die ] deteriorate decide-movement set speed max list min-speed ((sqrt health / 10) * speed-factor) update-colour set label precision health 0 ] tick end ;; ---------------- HEALTH LOGIC ---------------- to deteriorate set health health - deterioration-rate if health < 0 [ set health 0 ] end to receive-treatment if not member? patch-here er-patches [ stop ] let id [er-id] of patch-here ;; intermittent treatment if ticks mod treatment-interval = 0 [ if random-float 100 < er-success-rate [ set health health + treatment-rate ] ] ;; deterioration continues let er-deterioration deterioration-rate * er-deterioration-factor set health health - er-deterioration ;; acute overload shock if random-float 100 < er-overload-risk [ set health health - deterioration-rate ] ;; ER death if health <= 0 [ set patients-died-in-er patients-died-in-er + 1 set er-room-loads replace-item id er-room-loads max list 0 (item id er-room-loads - 1) die ] ;; recovery if health >= target-health [ set patients-saved patients-saved + 1 set er-room-loads replace-item id er-room-loads max list 0 (item id er-room-loads - 1) die ] end ;; ---------------- MOVEMENT ---------------- to decide-movement if health < critical-threshold [ move-to-er ] if health >= critical-threshold [ wander ] end to wander if speed > 0.01 [ let turn-angle (max-turn-angle * (health / 100)) rt random-float turn-angle - random-float turn-angle attempt-move ] end to move-to-er let target one-of er-patches if target != nobody [ face target attempt-move ] if member? patch-here er-patches [ let id [er-id] of patch-here let current-load item id er-room-loads if (not being-treated?) and current-load < er-capacity and health < target-health [ set being-treated? true set er-room-loads replace-item id er-room-loads (current-load + 1) ] ] end to attempt-move if speed < 0.01 [ stop ] let next-patch patch-ahead speed if next-patch != nobody and [pcolor] of next-patch = white [ set heading heading + 180 + random 60 - random 60 fd speed * 0.5 stop ] if next-patch != nobody and [pcolor] of next-patch = 6 [ fd speed * 1.2 ] if next-patch = nobody or [pcolor] of next-patch != 6 [ fd speed ] end ;; ---------------- VISUAL STATE ---------------- to update-colour if being-treated? [ set color green ] if not being-treated? and health >= 50 [ set color blue ] if not being-treated? and health < 50 and health >= critical-threshold [ set color yellow ] if not being-treated? and health < critical-threshold [ set color red ] end to label-hospital-zones ask patch 1 0 [ set plabel "ENTRY" set plabel-color black ] if num-er-rooms >= 1 [ ask patch -12 12 [ set plabel "ER-1" set plabel-color black ] ] if num-er-rooms >= 2 [ ask patch 12 12 [ set plabel "ER-2" set plabel-color black ] ] if num-er-rooms >= 3 [ ask patch -12 -12 [ set plabel "ER-3" set plabel-color black ] ] if num-er-rooms >= 4 [ ask patch 12 -12 [ set plabel "ER-4" set plabel-color black ] ] end
There is only one version of this model, created about 3 hours ago by Pratham Prakash.
Attached files
| File | Type | Description | Last updated | |
|---|---|---|---|---|
| An Agent-Based Model of Emergency Department Dynamics Under Capacity Constraints.png | preview | Preview for 'An Agent-Based Model of Emergency Department Dynamics Under Capacity Constraints' | about 3 hours ago, by Pratham Prakash | Download |
This model does not have any ancestors.
This model does not have any descendants.
Download this model