Upgrade to Pro — share decks privately, control downloads, hide ads and more …

NHS R/Pycom 2024 - Unleashing the Power of Path...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Sammi Rosser Sammi Rosser
November 27, 2024
13

NHS R/Pycom 2024 - Unleashing the Power of Pathway Simulation

Discrete Event Simulation (DES) is a powerful tool for modelling queuing problems, allowing complex questions about pathways and resourcing to be explored before making costly and potentially risky changes to health services. However, there are barriers to its adoption: dedicated commercial software is prohibitively expensive, while free code-based open-source options are powerful and flexible but can be difficult to get started with and often lack the ability to clearly and engagingly visualise the model’s inner workings for stakeholders.

This talk provides a brief introduction to DES before covering a range of efforts that are underway within our team to overcome these problems and make DES an accessible modelling approach for everyone working in healthcare: building a repository of adaptable models for a variety of common pathways in healthcare; writing a free ebook in Quarto to give people a clear way to learn; building interactive tools to teach the underlying concepts to non-technical audiences; and creating a simple yet flexible visualisation package to generate animations showing the flow of entities within the simulated system, helping to make the models more understandable. While the work primarily revolves around the SimPy package in Python, several elements have potential to be adapted for use with Python’s ciw package or R’s simmer package. With the first version of the book available, several example models created, and the visualisation package due to be released in late 2024, now is a great time to start exploring the world of pathway simulation!

Avatar for Sammi Rosser

Sammi Rosser

November 27, 2024

Transcript

  1. Unleashing the Power of Unleashing the Power of Pathway Simulation

    Pathway Simulation Sammi Rosser Health Service Modelling Associates Programme
  2. About Me Former NHS Analyst/Data Scientist MSc Health Data Science

    @ Exeter Now a HSMA trainer @ Exeter ( / ) Mainly a Pythonista these days (but I ❤️ R too) Obsessed with Quarto, Streamlit, Simulation, Maps & Dataviz PenCHORD PenARC  Add Me On LinkedIn  Follow Me On GitHub
  3. The Health Service Modelling Associates is a 15 month data

    science and operational research training and mentoring programme. Supported by the NIHR PenARC and the NHS Digital Academy, the full programme is provided free of charge to people working in health, social care and policing and is accredited by AphA.  Visit Our Website for Free Training  Subscribe to our YouTube Channel  Follow us on GitHub
  4. Pathway Simulation: Why? Your emergency department is struggling. You could

    try a range of different things… increase the number of staff available to register, triage or treat increase the number of rooms or beds increase the rate at which tests can be processed add a new step in the process with a different kind of practitioner completely redesign the pathway Which of these is the right answer?
  5. Queue, Queue, Barney McGrew Healthcare tends to be full of

    queueing problems like this one. People attending a walk-in clinic or emergency department People calling a telephone-based service like 111 or a mental health crisis line People on a cancer diagnosis and treatment pathway People waiting to be assessed for ADHD and Autism, or on the waiting list for a gender clinic People waiting for a series of treatment with a mental health practitioner might have one, several or many appointments
  6. Pathway Parts Healthcare systems are full of resources People 👩🏻‍⚕️

    👩🏿‍⚕️ 👨🏽‍⚕️ 👨🏽‍⚕️ 👩🏾‍⚕️ Equipment 🔬🩺 Rooms & cubicles 🏥 Beds 🛌🏻 🛌🏽 🛌🏿 🛌🏻 🛌🏼 🛌🏽 🛌🏿 Treatments 💉 🩹 💊 Vehicles 🚑 🚁 🚗 These resources experience demand from entities. These entities might be People (in person) 🤒 🤢 🤧 People (on the phone) ☎️ Test Requests 🩻 🧪
  7. Pathways and Queues As these entities move through a pathway

    - a series of steps where these resources are used - queues can build up where there isn’t enough resource.
  8. Queue What? And these pathways are often very complicated! There

    are lots of moving parts, and lots of variation. Variation in when, and how frequently, people arrive Variation in how long an activity in the pathway takes Variation in the pathways people take within a single system
  9. The Problem with Pathways Making changes to pathways can be

    costly slow unsafe! And even if you do fix the original problem you were trying to solve, there’s a risk of knock-on effects elsewhere in the pathway that you didn’t foresee.
  10. The Future Problems with Pathways And even if you avoid

    that…. A system that is coping now might not cope all the time if demand increases if resource temporarily decreases
  11. It’s All a Simulation On HSMA, we teach a couple

    of different computer simulation techniques. System Dynamics High-level technique that’s often suited to uncovering fundamental issues with pathway or wider healthcare system design Agent-Based Simulation (ABS) Individual-level modelling that is particularly interested in the impact of individuals’ decisions and interactions Discrete Event Simulation (DES) Modelling focussing on the flow of entities through a pathway and use of resources, allowing detailed investigation of capacity, queues and waits
  12. It’s Our DEStiny What we generally want to tackle our

    pathway problems in healthcare is Discrete Event Simulation (DES) In a DES…
  13. DES to the Rescue DES is so powerful because it

    gives us an in-silico (computer-based) reproduction of our pathway to play around with. We can make any change we want (e.g. more resources, higher demand, new pathway design) safely and for free and see what impact it has on any metric we care to measure: how long people wait at each step of the pathway people meeting targets (e.g. 4 hour wait) how much of the time the resources are utilised for And so on!
  14. Variation That randomness and variation in our healthcare systems that

    we mentioned before? DES can cope really well with that! Let’s imagine that people turn up to our system, on average, every 10 minutes. However, sometimes no-one turns up for half an hour, and other times 3 people turn up simultaneously. By using distributions we can produce random times that mimic real-world patterns.
  15. Randomness Taking it even further, we can harness that variation

    for making the most of our models. We can hold the random patterns consistent and change resource levels or pathway design We can hold resources or pathway design consistent and allow randomness This allows us to be sure the changes we’re testing really are responsible for the differences This allows us to test our system in multiple parallel universes, running it tens or even hundreds of times!
  16. Exploring Impacts In our models, we can then summarise the

    performance of a given set of parameters across multiple runs.
  17. Comparing Performance And we can provide visualiations to compare the

    impact of changing parameters - here, for example, adding one extra stabilisation bay.
  18. A Note About Modelling Your DES won’t be a perfect

    one-to-one reproduction of the pathway you are modelling. We have to make certain assumptions and simplifications, and we can’t capture every complexity. However… • George E. P. Box All models are wrong, but some are useful
  19. DES is popular! On the HSMA programme, we’ve had over

    35 projects using DES in some capacity A third of the registered projects this year use DES (as opposed to machine learning, ABS, system dynamics, natural language processing, geographical modelling) It’s also frequently used in the team PenCHORD
  20. Example 1: Bladder Cancer Pathway In this project, a DES

    model of the bladder cancer pathway at Royal Cornwall Hospitals Trust (RCHT) exposed two key system bottlenecks. A delay between patients being referred and receiving their surgery A delay waiting for the nurse specialist to contact the patient to discuss their diagnosis and treatment options The model was used to support an on-the-spot rewrite of the pathway, resulting in multi-week reductions to waiting times. PenCHORD  Find Out More
  21. Example 2: Vaccination Clinic This project looked at the design

    of a COVID-19 vaccination clinic in North Devon, exploring queue lengths car park capacity times for each step of the vaccination process The model identified potential issues with the original proposed plans, and was used to refine the plans to enable a safe but efficient delivery of the vaccination programme. HSMA  Find Out More
  22. Example 3: Emergency Department Model This project looked at ways

    to improve Urgent Treatment Care (UTC) performance. The team wanted to know What further staff and resources would be required for any variations in patient attendance How changes in the patient pathway would reduce bottlenecks (e.g what would be the impact of front-loading diagnostics?) The model identified a need for additional rooms and the ED was redesigned as a result. HSMA  Find Out More
  23. Example 4: Mental Health Assessment Pathway Model This project created

    a simulation model of a mental health assessment pathway. The trust in question was piloting an approach that would allow patients to book their appointments themselves. The model was used to help predict the number of appointment slots required at each site show that allowing queue-sharing between smaller groups of sites would significantly reduce the wait times PenCHORD  Find Out More
  24. Example 5: Children’s Neurodiversity Assessment Pathway This project created a

    model of a paediatric neurodevelopmental (ADHD + autism) pathway. Waits had increased to a 2 years on average. The team wanted to understand where current bottlenecks in the process were what level of staffing would be needed to clear the existing backlog and maintain a steady state The model showed that recruiting an extra lead clinician would not address the bottleneck - but an additional second assessor would. HSMA  Find Out More
  25. Other Projects You can find details about all of our

    previous and current Discrete Event Simulation projects  on the HSMA website
  26. The DES Playground This site was designed to help teach

    the key concepts of discrete event simulation to non-technical beginners. It uses browser-based Python, so calculations can be slow on mobile devices and won’t work on Firefox!  Click here to visit!
  27. Drag & Drop There are various paid, closed-source drag-and-drop software

    tools for doing DES (but we won’t talk about them here). If you don’t code, there is the free and open source (FOSS) tool . JaamSim
  28. DES in Python In Python, there are a range of

    packages for DES. is quite popular. I’ve also heard good things about But HSMA has used and taught for several years. It’s mature, stable, reliable and flexible. Salabim ciw simpy
  29. HSMA Training on DES The DES lectures and activities from

    this year’s HSMA can be found on our website. Intro to DES • What DES is and where it may be useful • The key terminology associated with DES e.g. resources, entities, sinks • How to simplify a real-world pathway modelling problem into a conceptual model  Module Link SimPy for DES • The features of the SimPy package • How to write simple simulations with SimPy • Multi-step pathways • Branching pathways and optional steps Advanced Simpy • Warm-up Periods • Priority-based Queuing • Resource Unavailability • Lognormal Distributions • Reneging • Balking • Jockeying
  30. The Little Book of DES We have also put together

    a free eBook that serves as a handy reference to doing DES with SimPy. It’s packed with code snippets you can use and modify and goes beyond the lecture content, including • appointment-based models • reproducibility • parallelisation • and more!  Click here to view the eBook
  31. HSMA Training on Web App Interfaces for DES While creating

    these models and running a range of parameters yourself can be really powerful, getting the models into the hands of stakeholders can really enhance their adoption. Frameworks like can help you to quickly create interactive web app front-ends for your app. Streamlit
  32. The HSMA Book of Streamlit This free eBook walks you

    through a range of Streamlit concepts. It then goes on to providing a walk- through of how to create a simple front-end for any DES and deploying that on a free online hosting platform.  Click here to view the eBook
  33. Pathway Visualisation As part of creating the DES playground, I

    put together the visualisation you saw in the previous slide. It really resonated with people - so we wanted to make more use of it! We know that one of the big limitations of simpy (and other FOSS code- based options) is not being able to produce quick and simple visualisations to show to stakeholders.
  34. The vidigi package The package is designed to be a

    flexible library for creating these animated visualisations for any simulation. Under the hood, it makes use of animated scatterplots. However, it adds a range of additional helper functions to process event logs into the format required lay out the animation add icons for resources and entities It’s hosted on PyPI - so you can pip install it! vidigi Plotly’s pip install vidigi
  35. ‘Resourceless’ queues in vidigi It is flexible for simulations that

    use both traditional simpy resources, or steps can just be represented as ‘queues’.
  36. Simulation Library This is an early-stage piece of work! To

    go along with vidigi, I’m working on collating and visualising models from across healthcare systems. At present, there is A simple emergency department An orthopaedic surgery unit A simple community-based service with a single appointment A complex community-based service with varying numbers of appointments and a per-clinician caseload  Click here for the code repository  Click here to try them out
  37. Model Reproducibility Reproducibility and reusability of models is crucial. I

    want to take a moment to highlight . This is a that is trying to ensure good reproducibility of healthcare simulation models. They are also creating best-practice examples in Python and R and reproducing models from published scientific papers. STARS UKRI-funded project
  38. The STARS Framework Essential Components Open license Dependency management Model

    created using free and open-source software (FOSS) Minimum documentation Research artefact meta data (ORCID ID + citation info) Remote code repository Open science archive Optional Components Enhanced documentation Documentation hosting Online coding environment Model interface Web app hosting
  39. Summary DES is an amazing option for tackling your pathway

    problems With ever-growing resources and community experience out there, it’s a great time to get started FOSS libraries allow us to adapt and reuse models - but follow guidance to make it as easy as possible for people to stand on your shoulders!