Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines

Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines preview image

1 collaborator

Air_avatar Alfredo Ramirez (Author)

Tags

virus-spread, hospital-capacity 

Tagged by Alfredo Ramirez about 1 year ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.4.0 • Viewed 331 times • Downloaded 36 times • Run 0 times
Download the 'Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

This model shows how the conditions of the health infrastructure and the supply of medicines in a geographical space with a certain population can modify the control of a virus infection and impact the reduction of the number of deaths.

The model has two types of agents: people and units.

The personal agent has the following characteristics: + status = susceptible, infected, recovered or deceased + ticks-infected = time in ticks that agent is infected + severity = 0 (low) not require hospitalization; 1 (mid) requires revision at hospital; 2 (high) requires hospitalization + chance-of-dead = increase when not getting attention or hospitalization or medicines + p-mobility = speed of agent's mobility + h-target = hospital where agent will be attended + attended = status of attention + time-at-unit = time spent at hospital + days-at-unit = days at hospital + received-medicine = status of received medicines

The unit agent has the following features: + u-beds = number of beds available + u-medics = number of medics available + u-medicines = number of medicines available

The agent person has the following actions: + If the agent is not infected: + Moving in the world. + If the agent is infected: + Check if there are neighbors and infect them. + Identify a hospital and go to it. + If you are turned away by the hospital to continue your movement in the world.

The unit agent has the following actions: + Check if there are beds, doctors and medicines. + Calculate the consultation and hospital stay times per patient attended. + Update the number of beds, doctors, and medicines.

Global actions: + Update agent statuses to change their shape and color. + Calculate and update sums of infected, recovered and deceased people.

HOW IT WORKS

SETUP The initialization of the model generates an infected person with the lowest severity and the lowest probability of dying; The severity can be low, medium or high and the probability of dying increases for all infected agents with each time interval and decreases only under specific conditions when receiving care in the hospital.

Values are assigned to the variables that will be used during the model: + pop-susceptible = counts susceptible population + pop-infected = counts infected population + pop-recovered = counts recovered population + pop-deceased = counts deceased population + time-infection = number of ticks that persons remains infected + kapa = percentage of deceased + seconds = used for execution time + normal-speed = normal agents' speed + high-speed = when an agent is infected it's urgent to arrive to hospital + time-revision = ticks needed to check agents at hospital + days-hospitalized = ticks conversion to days to calculate medicines per day at hospital + dead-possibility = random possibility to compare with kapa

Values for increasing-decreasing chance-of-dead + lgm = low getting medicine + hh = high hospitalized + hdm = high daily medicine + hgm = high getting medicine + daily-increase = if not getting treatment will increase chance-of-dead daily + p-deceased = percentage of deceased + p-recovered = percentage of recovered + p-susceptible = percentage of not infected

GO 1. The simulation starts with all agents in motion. 2. Each infected agent checks on their neighbors and, if there are agents nearby, they become infected. Once infected, it is determined if care is required in a hospital (this applies only to medium and high severity), a hospital is identified, and the direction and speed to it is changed. 3. Once the unit is reached the agent stops and it is determined if there are doctors, beds and medicines. 4. If these elements do not exist, the agent leaves the unit. If doctors exist, a medical consultation is provided, and if there are stocks of medicines they are provided to the agent. 5. If hospitalization is required, it is verified that there is availability of beds, and when the patient is admitted, he receives medication daily for up to 10 days. 6. Only admission to hospital and the allocation of medications decreases the probability of death in the patient. 7. The infection period is close to 21 days, calculating that 100 ticks represent 1 day, after that period it is verified if the agents recover or die. Mortality is determined by the kapa factor whose value is 15%, based on data from the World Health Organization for the CODIV-19 virus. This factor is modified by the probability of death of each agent, so care and medications are crucial to minimize mortality. 8. Sate of agents are updated.

HOW TO USE IT

Use the "setup" button to initialize the model, and "go" button to run the simulation.

ATTENTION: if only one agent is infected with no dispersions of infection, please press again the setup button and run again the model.

INPUTS The default values allow a simulation of the model under normal conditions for the value determined by the "population" control. Additional controls allow you to change the following:

  • Number of hospitals. From 1 to 3 units available, each unit is located at a geometric distance from the other to avoid several units in the same place or too close to each other.
  • Number of beds per hospital. Determines how many high-severity patients can be hospitalized.
  • Number of doctors per hospital. Determines how many physicians can provide consultations, either to assign medications to patients of medium severity or to allow admission to patients of high severity.
  • Stock of medicines. Determine the number of medications to be used in medical consultation and hospitalization.

THINGS TO NOTICE

OUTPUTS + The model provides information related to agent behavior. The number of susceptible people, infected in their three levels of severity, deceased and recovered, is shown in a SIRD-style graph. + In addition, the number of beds available for each unit is shown and contiguously, how many agents have been left without hospitalization due to the lack of beds. + In the same way, it shows how many doctors are available per unit and contiguously the number of patients who do not receive medical attention due to lack of doctors. + Finally, the stock of medicines in each unit is shown, contiguously showing how many patients are left without receiving medicines either due to lack of stock, or because there was no doctor who could provide them with the medicine or because they could not enter the hospital to receive medicine.

Agents show different statuses, identified by their shape and color: + normal agent = gray circle not filled + infected low severity = yellow circle filled + infected mid severity looking hospital = red arrow filled + infected mid severity attended = red circle filled + infected mid severity not attended = red circle not filled + infected high severity looking hospital = maroon arrow filled + infected high severity attended = maroon circle filled + infected high severity not attended = maroon circle not filled + infected high severity hospitalized = maroon star + infected high severity not hospitalized = maroon x + recovered agent = green + + deceased agent = blue x

THINGS TO TRY

The user is invited to change the values of population, hospitals, doctors and medicines so that they can review how the dispersion of the infected behaves and how having availability of the elements affects to reduce deaths.

EXTENDING THE MODEL

This model will be modified to allow the addition of resources and the search for optimal values based on demand and deaths, this to allow the allocation of sufficient economic resources that do not represent economic losses to countries or states.

NETLOGO FEATURES

  • It was necessary to calculate the dispersion of the hospitals based on a polygon and its vertices, to ensure that they will not be generated in very close locations and this will modify the perception of the operation of the model.

  • Time is a concept that must be calculated by fine-tuning with each execution, for this exercise it was determined that 100 ticks corresponded to 1 day, this after performing several runs varying the speed of the agents (fd command), the value of frame rate and the size of the world.

  • A modified function initially proposed by Ulrich was used to position the hospitals' identification tag under the agent icon.

  • An Output box was used to show relevant messages to the user since there is no pop-up window.

RELATED MODELS

Spread of Desease, Virus, epiDEM basic

CREDITS AND REFERENCES

Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines © 2024 by Alfredo Israel Ramírez Mejía is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International https://creativecommons.org/licenses/by-nc-sa/4.0/

aisrael.ramirez.mejia@gmail.com

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

;; 100 ticks = 1 day
globals[
  pop-susceptible       ; counts susceptible population
  pop-infected          ; counts infected population
  pop-recovered         ; counts recovered population
  pop-deceased          ; counts deceased population
  pop-density           ; population density
  time-infection        ; number of ticks that persons remains infected
  kapa                  ; percentage of deceased
  seconds               ; used for execution time
  normal-speed          ; normal agents' speed
  high-speed            ; when an agent is infected it's urgent to arrive to hospital
  time-revision         ; ticks needed to check agents at hospital
  days-hospitalized     ; ticks convesrion to days to calculate medicines per day at hospital
  dead-possibility      ; random posibility to compare with kapa
  ; values for increasing-decreasing chance-of-dead
  lgm   ; low getting medicine
  hh    ; high hospitalized
  hdm   ; high daily medicine
  hgm   ; high getting medicine
  daily-increase ; if not getting treatment will increase chance-of-dead daily
  p-deceased    ; percentage of deceased
  p-recovered   ; percentage of recovered
  p-susceptible ; percentage of not infected
  acc-infected          ; infected population accumulator
]

breed [persons person]  ; principal agents that represent persons
breed [units unit]      ; agents that represents hospital units
breed [banners banner]  ; simple label to identify hospital units

; specification for persons
persons-own[
  status                ; susceptible, infected, recovered or deceased
  ticks-infected        ; time in ticks that agent is infected
  severity              ; 0 (low) - not require hospitalization; 1 (mid) - requires revision at hospital; 2 (high) - requires hospitalization
  chance-of-dead        ; increase when not getting attention or hospitalization or medicines
  p-mobility            ; speed of agent's mobility
  h-target              ; hospital where agent will be attended
  attended              ; status of attention
  time-at-unit          ; time spent at hospital
  days-at-unit          ; days at hospital
  received-medicine     ; status of received medicines
]

; specification for hospital units
units-own [
  u-beds        ; number of beds available
  u-medics      ; number of medics available
  u-medicines   ; number of medicines available
]

to setup
  ca
  reset-ticks
  reset-timer

  ; initialize values
  set pop-susceptible population - 1
  set pop-infected 0
  set pop-recovered 0
  set pop-deceased 0
  set pop-density (population / (world-height * world-width) )
  set acc-infected 0

  set time-infection 210      ; 21 days of infection
  set kapa 0.15               ; 15% of total infected people will die
  set normal-speed 0.5
  set high-speed 1

  set time-revision 10        ; ticks needed to check a person at hospital
  set days-hospitalized 20    ; max of days that a person can be hospitalized

  set	lgm	 0.3
  set	hh	 0.5
  set	hdm	 0.8
  set	hgm	 0.5
  set daily-increase 0.05

  ask patches[
    set pcolor white
  ]

  ; person initialize
  create-persons population[
    move-to one-of (patches with [not any? turtles-here])   ; initial position, ensure that two persons don't use same patch

    set status "susceptible"          ; all agents are suceptible
    set ticks-infected 0              ; counts how many ticks person is infected
    set severity 0                    ; not used until agents gets infected
    set chance-of-dead 0              ; not used until agents gets infected
    set p-mobility normal-speed       ; agent moves at normal speed
    set h-target nobody               ; while not infected, agent is not looking hospital
    set attended 0                    ; when receives attention at hospital it could take values: 1, 2, 3 or 4 used for statistical info
    set time-at-unit 0                ; count how many ticks agent is at hospital unit receiving attention
    set days-at-unit 0                ; count how many days agent is hospitalized
    set received-medicine 0           ; not need medicine so far
    update-status                     ; updates color and shape
  ]

  ; calculus for position hospital units in a polygon vertex, so they don't render closer to another
  let radius ( world-width / 2.5 )
  let angle ( 360 / hospitals )
  let rotation random 360

  ; initialize hospital units
  create-units hospitals [
    set shape "hospital2"
    set size 2
    set color cyan
    set u-beds beds                   ; beds defined by slider
    set u-medics medics               ; medics defined by slider calculated as follows medics for shift: 10 at morning, 10 at evening 5 at night
    set u-medicines medicines         ; number of treatments a hospital can provide, 1 per consultation and 1 per day at hospital
    ; calculations to move the hospital to a polygon vertex
    let x ( radius * sin ((who - hospitals) * angle) )
    let y ( radius * cos ((who - hospitals) * angle) )
    let xn ( x * cos(rotation) - y * sin(rotation) )
    let yn ( y * cos(rotation) + x * sin(rotation) )
    setxy xn yn
    ; set the label under the icon
    set label-color [ 0 0 0 128 ]               ; label in black color with 50% transparency
    attach-banner who ( xn + 1 ) ( yn - 1.7 )   ; label sets the id of agent
  ]

  ; initialize the first infected person
  ask one-of persons [
    set status "infected"
    set ticks-infected 1                ; tick 1 of infection
    set pop-infected (pop-infected + 1) ; update count of infected population
    set severity 0                      ; always initialize with the lower severity
    set chance-of-dead 1                ; normal chance, depends of posibility determined by kapa
    update-status
  ]
end 

to go
  if all? persons [ status != "infected" ] [       ; stops simulation when infected people is 0
    ifelse pop-recovered = 1 [
      output-print "Not enough infections. Run again!"
    ][
      set p-susceptible ( pop-susceptible / population ) * 100
      set p-deceased ( pop-deceased / acc-infected ) * 100
      set p-recovered ( pop-recovered / population ) * 100
      output-print word "Percentage of Not infected   = " word ( precision p-susceptible 2 ) "%"
      output-print word "Percentage of Decease        = " word ( precision p-deceased 2 ) "%"
      output-print word "Percentage of Recovered      = " word ( precision p-recovered 2 ) "%"
    ]
    stop
  ]

  ; main process, checks mobility of agents, infection and hospitals consuming
  ask persons with [ status != "deceased"] [
    ; if not infected agent is not looking for hospital and moves normally
    ifelse h-target = nobody [
      rt random 20
      lt random 20
    ][
      ; in case that agent is assigned to an hospital
      ; check if agent has arrived to hospital and stops moving
      if any? units-on patch-ahead 1 [
        set p-mobility 0

        ; actions for agents with severity = 1 (med)
        if severity = 1 [
          if attended = 0 [                                     ; check if agent has no received attention
            ask h-target [
              ifelse u-medics > 0 [                             ; check if there are medics available
                set u-medics ( u-medics - 1)                    ; assigns medic
                ask myself [
                  set attended 1                                ; agent is attended (for medical consultation)
                ]
              ][
                ask myself [
                  set h-target nobody                           ; if not medics available, agent leaves hospital
                  set p-mobility normal-speed                   ; and change to normal speed moving
                  set attended 2                                ; agent didn't receive attention (for medical consultation)
                  set received-medicine 3                       ; not getting medicines by insufficient medics
                ]
              ]
            ]
          ]
          if attended = 1 [                                     ; if agents is attended
            set time-at-unit ( time-at-unit + 1 )               ; counts how many ticks is at consultation
            if time-at-unit > time-revision [                   ; when consultation ends medics is reasigned to hospital
              ask h-target [
                set u-medics ( u-medics + 1 )
                ifelse u-medicines > 0 [                        ; if there are medicines available agents gets one
                  set u-medicines ( u-medicines - 1 )
                  ask myself [
                    set received-medicine 1                     ; getting medicines
                    set chance-of-dead ( chance-of-dead * lgm ) ; chance of dead decreased, lgm
                  ]
                ][
                  ask myself [
                    set received-medicine 2                     ; not getting medicines by insufficient stock
                  ]
                ]
              ]
              set h-target nobody                               ; when agent gets attended, no more looking for unit
              set p-mobility normal-speed
            ]
          ]
          update-status
        ]

        ; actions for agents with severity = 2 (high)
        if severity = 2 [
          if attended = 0 [
            ask h-target [
              ifelse u-medics > 0 [
                set u-medics ( u-medics - 1)
                ask myself [
                  set attended 1                                ; agent is attended (for medical consultation)
                ]
              ][
                ask myself [
                  set h-target nobody
                  set p-mobility normal-speed
                  set attended 2                                ; agent didn't receive attention (for medical consultation)
                  set received-medicine 3                       ; not getting medicines by insufficient medics
                ]
              ]
            ]
          ]
          if attended = 1 [
            set time-at-unit ( time-at-unit + 1 )
            if time-at-unit > time-revision [                       ; if medical consultation is finished, free medics and check if it can be hospitalized
              ask h-target [
                set u-medics ( u-medics + 1 )
                ifelse u-beds > 0 [                                 ; if bed is available then is assigned to agent and decreased from count
                  set u-beds ( u-beds - 1)
                  ask myself [
                    set attended 3                                  ; agent is hospitalized
                    set chance-of-dead ( chance-of-dead * hh )     ; chance of dead decreased, hh
                  ]
                ][
                  ask myself [
                    set attended 4                                  ; agents isn't hospitalized
                    ;set chance-of-dead ( chance-of-dead * hnh )     ; chance of dead increased, hnh
                    ask h-target [
                      ifelse u-medicines > 0 [                        ; if there are medicines available agents gets one
                        set u-medicines ( u-medicines - 1 )
                        ask myself [
                          set received-medicine 1                     ; getting medicines
                          set chance-of-dead ( chance-of-dead * hgm ) ; chance of dead decreased, hgm
                        ]
                      ][
                        ask myself [
                          set received-medicine 4                     ; not getting medicines by insufficient beds
                        ]
                      ]
                    ]
                    set h-target nobody                             ; if there is not beds, agent leaves hospital
                    set p-mobility normal-speed
                  ]
                ]
              ]
            ]
          ]
          if attended = 3 [                                     ; if agent is hospitalized, count days
            set time-at-unit ( time-at-unit + 1 )
            if time-at-unit > 10 [                              ; if times count 10, a day has passed and medicine is given to agent, if available
              set days-at-unit ( days-at-unit + 1 )
              set time-at-unit 0
              ask h-target [
                ifelse u-medicines > 0 [
                  set u-medicines ( u-medicines - 1 )
                  ask myself [
                    set received-medicine 1                     ; getting medicines
                    set chance-of-dead ( chance-of-dead * hdm ) ; chance of dead decreased every day getting medicines, hdm
                  ]
                ][
                  ask myself [
                    set received-medicine 2                     ; not getting medicines by insufficiente stock
                  ]
                ]
              ]
            ]
          ]
          update-status
        ]
      ]
    ]

    fd p-mobility                                           ; move agent based on speed calculated in above actions
  ]



  ; infect other agents
  ask persons with [ status = "infected" ][
    let nb (other persons) in-radius 0.1 with [ status = "susceptible" ]      ; check for agents nearby with susceptible status and infect them
    if nb != nobody[
      ask nb [
        set status "infected"
        set pop-infected (pop-infected + 1)                                   ; update count for infected population
        set acc-infected (acc-infected + 1)                                   ; accumulates infected population
        set pop-susceptible (pop-susceptible - 1)                             ; update count for susceptible population
        set severity random 3                                                 ; assign a random severity
        if severity = 0 [
          set chance-of-dead 1                                                ; basic dead rate, death depends totally by kapa
        ]
        if severity != 0 [
          set h-target one-of units                                           ; if severity is med or high then look for an hospital
          face h-target                                                       ; set direction toward hospital
        ]
        if severity = 1 [
          set chance-of-dead 1.25                                             ; chance of dead increased by severity in 25%, based on basic death rate = 1
        ]
        if severity = 2 [
          set p-mobility high-speed                                           ; if severity is high, speed up agent movility
          set chance-of-dead 1.5                                              ; chance of dead increased by severity in 50%, based on basic death rate = 1
        ]
        update-status
      ]
    ]
    if ( attended = 2 ) or ( attended = 4 ) or ( received-medicine != 1 )[
      set chance-of-dead ( chance-of-dead + chance-of-dead * daily-increase ) ; increase daily if not hospitalized or getting treatment
    ]
    set ticks-infected (ticks-infected + 1)                                   ; increase count of ticks infected
  ]

  ; check for recovered or decesased agents
  ask persons with [ status = "infected" ][
    if ticks-infected > time-infection [                                      ; check if time of infection has reached to end
      set dead-possibility random-float 1                                      ; calculate if agent will die or not, based on kapa value
      ifelse severity = 0 [                                                   ; if severity is low, agent gets recovered
        set status "recovered"
        set pop-recovered (pop-recovered + 1)
        set p-mobility normal-speed
        set h-target nobody
      ][
        if attended = 3 [                                                     ; if agent was hospitilized, free the bed
          ask h-target [
            set u-beds ( u-beds + 1 )
          ]
        ]
        ifelse dead-possibility <= ( kapa * chance-of-dead ) [                 ; agent dies if dead-posibility is between 0 an kapa, chance-of-dead increments posibility
          set status "deceased"
          set pop-deceased (pop-deceased + 1)
        ][
          set status "recovered"
          set pop-recovered (pop-recovered + 1)
          set p-mobility normal-speed
          set h-target nobody
        ]
      ]
      set pop-infected (pop-infected - 1)
      update-status
    ]
  ]

  tick
  set seconds timer
end 

; update shape and color by condition of agent
; normal agent                                = gray circle not filled
; infected low severity                       = yellow circle filled
; infected mid severity looking hospital      = red arrow filled
; infected mid severity attended              = red circle filled
; infected mid severity not attended          = red circle not filled
; infected hihg severity looking hospital     = maroon arrow filled
; infected hihg severity attended             = maroon circle filled
; infected hihg severity not attended         = maroon circle not filled
; infected hihg severity hospitalized         = maroon star
; infected hihg severity not hospitalized     = maroon x
; recovered agent                             = green +
; deceased agent                              = blue x

to update-status
  (ifelse
    status = "susceptible"
    [
      set color gray + 2
      set size 0.6
      set shape "circle 3"
    ]
    status = "infected"
    [
      (ifelse
        severity = 0 [
          set size 0.6
          set shape "circle 4"
          set color [255 145 0]
        ]
        severity = 1 [
          set color [255 0 0]
          (ifelse
            attended = 0 [
              set size 0.8
              set shape "navigation"
            ]
            attended = 1 [
              set size 0.6
              set shape "circle 4"
            ]
            attended = 2 [
              set size 0.6
              set shape "circle 3"
            ]
          )
        ]
        severity = 2 [
          set color [155 15 15]
          (ifelse
            attended = 0 [
              set size 0.8
              set shape "navigation"
            ]
            attended = 1 [
              set size 0.6
              set shape "circle 4"
            ]
            attended = 2 [
              set size 0.6
              set shape "circle 3"
            ]
            attended = 3 [
              set size 0.9
              set shape "star"
            ]
            attended = 4 [
              set size 0.8
              set shape "x"
            ]
          )
        ]
      )
    ]
    status = "recovered"
    [
      set color [21 176 26]
      set size 0.6
      set shape "cross"
    ]
    status = "deceased"
    [
      set color [0 0 255]
      set size 0.7
      set shape "x"
    ]
  )
end 

; function to place label

to attach-banner [lbl lx ly]
  hatch-banners 1 [
    set size 0
    set label lbl
    setxy lx ly
    create-link-from myself [
      tie
      hide-link
    ]
  ]
end 

There are 3 versions of this model.

Uploaded by When Description Download
Alfredo Ramirez about 1 year ago Updated Info Tab Download this version
Alfredo Ramirez about 1 year ago Percentage of deceased people recalculated, based only in infected people. Download this version
Alfredo Ramirez about 1 year ago Initial upload Download this version

Attached files

File Type Description Last updated
Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines.png preview Preview for 'Virus Spread with Hospital Capacities of Hospital Beds, Medics and Medicines' about 1 year ago, by Alfredo Ramirez Download

This model does not have any ancestors.

This model does not have any descendants.