Home » Projects » Healthcare Associated Infection Simulator
patientsight intern project 2022

Intern Project

Healthcare Associated Infection Simulator

Fred McElwee spent two months this autumn exploring how to model healthcare associated infections.


Healthcare associated infections (HAIs), also known as hospital or healthcare acquired infections, can develop either as a direct result of healthcare interventions such as medical or surgical treatment, or from being in contact with a healthcare setting. HAIs pose a serious risk to patients, staff and visitors. They can cause significant morbidity to those infected and incur significant costs for the NHS. As a result, infection prevention and control are a key priority for the NHS.  

It is expensive, time consuming and often impractical to conduct trials on policies and interventions. Fred was challenged with creating a cost-effective way to assess the effect of different interventions in the spread of hospital acquired infections.

Developing a hospital acquired infection simulator

The first step was to model or simulate the spread of an infection within a hospital. Fred decided to use GAMA Platform, an open-source development environment for GAML, an agent-based modelling language.

Agent based modelling simulates the actions and interactions of agents (individual and/or collective entities) to understand the behaviour of a system. Due to the complexity of the hospital setting, agent-based modelling is an effective method of simulating the spread of infection within a healthcare system. 

Using GAMA, Fred created a simulator that models the movement of people (agents) within a hospital and the spread of an infection amongst them, with an output of the number of infected people and the level of infectivity of each room within the hospital. The simulator can test different interventions, such as masking policies, to evaluate their effectiveness in reducing the spread of HAIs and to evaluate their cost-benefit. 

The hospital acquired infection simulator was developed in 5 stages: 

  1. Creating a 3D model of a hospital
  2. Modelling the behaviour of people in a hospital
  3. Modelling the spread of an infection in a hospital
  4. Bringing everything together to create a HAI simulator
  5. Using the HAI simulator to evaluate strategies to reduce HAIs 

Creating a 3D model of a hospital

Shapefile shape format (.shp) files can be in uploaded into GAMA to give information about the place you are trying to simulate. A shapefile is a geospatial vector data storage format for storing the location, shape and attributes of geographic features. 

Shapefiles for the hospital floorplan and walls, hospital beds, benches and lifts were created in QGIS, an open source geographic information system (GIS) software.

Modelling the behaviour of people in a hospital 

The programming language used in GAMA is GAML – a cross between object-oriented programming languages (such as Java) and agent based modelling languages (such as Netlogo). 


  • Nurses 
  • Doctors 
  • Administrators 
  • Porters 
  • Patients
  • Visitors 


  • Shift times (specified start and finish times plus randomness of an hour either side of the time) 
  • Using the toilet 
  • Waiting in a waiting room  
  • Getting a lift from one floor to another 
  • Undergoing a procedure 
  • Transporting a patient in a hospital bed 

Modelling the spread of an infection in a hospital

The most common hospital HAIs in the UK include those caused by Methicillin-Resistant Staphylococcus Aureus (MRSA) and Clostridium difficile (C. difficile). To model the spread of these, three modes of infection were incorporated into the model:

  1. Close contact between people
  2. Aerosol transmission within a room
  3. Touching surfaces (e.g door handles) 

Bringing everything together to create a HAI simulator

Fred’s HAI simulator is made up of 3 elements: 

  1. GAMA files (.gml) with all the code that defines the simulator
  2. QGIS file where the shapes that make up the healthcare provider building(s) such floorplans, benches and lifts are defined
  3. A user interface (displayed in the image below)
    1. Left pane: An interactive dashboard for adjusting simulator parameters (e.g. number of infected people at start of simulation)
    2. Middle pane: A 2D reconstruction of what is being modelled, people moving (different colour different role), red blob when they get infected, yellow blob when they are exposed and blue blob when they are recovering
    3. Top right pane: A graph with number of people infected (y-axis) over time (x-axis) both overall and by mode of infection
    4. Bottom right pane: A heatmap of the infectivity of a room which is determined by the number of infected people in the room and the area of the room

Using the HAI simulator to evaluate strategies to reduce HAIs

One of the main aims of the project was to be able to evaluate interventions on their ability to reduce HAIs in a cost-effective manner.  

Fred explored evaluating the efficacy of mandatory mask wearing on reducing healthcare associated infections. To this end, Fred created mask wearing parameters which can be adjusted in the user interface as toggles. These parameters include defining which agents (doctors, nurses e.t.c.) are mandated to wear masks (True/False toggles) and by how much the infectivity by aerosol transmission and close contact is reduced when an agent is wearing a mask (as a percentage). 

To be able to compare two different scenarios defined by different parameters, the HAI simulator is able to run two simulations with different parameters in parallel to compare the spread of infection over time. In the video below, the user defines the parameters for two scenarios, one with no mandatory mask wearing and one with mandatory mask wearing for doctors, nurses, inpatients, outpatients, cleaners and visitors where infection by aerosol transmission or close contact by mask wearing is set as being reduced by 95%. The user then starts the simulation with 5 infected people and after 14 hours (under 2 minutes of simulation time) the number of infected people is reduced by 18% where mandatory mask wearing was implemented.

2022-11-17 09-57-21-2.mp4

This is "2022-11-17 09-57-21-2.mp4" by Health Data Insight CIC on Vimeo, the home for high quality videos and the people who love them.

To use the HAI simulator to assess the cost-benefit of implementing HAI reduction strategies, Fred used his health economist background to develop an incremental cost-effectiveness chart. This new feature allows repeat simulations to be performed for multiple individual strategies with unique pre-defined parameters. The average number of infected people at the end of the simulations is used to calculate the incremental cost and incremental Quality-Adjusted Life Years (QALYs) displayed on the chart. 

The incremental cost (y-axis) represents the change in cost (the cost of the strategy implementation plus the number of infected people multiplied by the cost of each agent being ill) caused by a strategy. The incremental QALYs (x-axis) represents the change in disease burden (the number of infected people multiplied by a value from 0-1 representing the percentage decrease in quality of life of each agent when infected) caused by a strategy.

In the below screenshot, the cost effectiveness for 3 different strategies with 500 simulations is represented. The lower the incremental cost and the higher the incremental QALYs (closer to zero) the better the strategy.

Final presentation

At the end of the two months Fred presented his progress to HDI and his presentation and demo can be seen in the video below.


This is "Internship2022_HAI_finalpresentation_compiled.mp4" by Health Data Insight CIC on Vimeo, the home for high quality videos and the people who love...

Future plans

Calibration of the model using real-world data is the next step with the aim of informing real-world decisions in the healthcare setting. Important necessary real-world data includes:

  1. Behavioural data (i.e. people movement) to accurately model the events that can potentially lead to infection transmission over time
  2. Infection models for each of the common infection species to accurately model the spread of infection over time
  3. Costings (i.e. staff salary, equipment) to accurately simulate and compare the cost-benefit of different implementation strategies 

Individual HAI simulators are required for each healthcare provider (i.e. hospital) using their unique floorplans and relevant infrastructure (doors, lifts, benches etc.); the number of each type of agent (doctors, nurses, inpatients etc.) and information on regular behaviours (shifts, visiting hours etc.). 

In addition, the ability to accurately reproduce a real-world healthcare-associated infection event would assist in confirming the validity of the HAI simulator.

Share This