{"id":29100037,"url":"https://github.com/pythonhealthdatascience/pydesrap_stroke","last_synced_at":"2025-07-28T14:33:05.613Z","repository":{"id":284579331,"uuid":"955363563","full_name":"pythonhealthdatascience/pydesrap_stroke","owner":"pythonhealthdatascience","description":"Reproducible analytical pipeline (RAP) for Python discrete-event simulation (DES) implementing the Stroke Capacity Planning Model from Monks et al. 2016.","archived":false,"fork":false,"pushed_at":"2025-06-16T12:31:12.000Z","size":65298,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-16T13:44:58.832Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pythonhealthdatascience.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-26T14:21:57.000Z","updated_at":"2025-06-16T12:30:28.000Z","dependencies_parsed_at":"2025-06-16T13:47:41.378Z","dependency_job_id":"a5d59975-c9c3-44ac-8efd-04994b63496a","html_url":"https://github.com/pythonhealthdatascience/pydesrap_stroke","commit_stats":null,"previous_names":["pythonhealthdatascience/stroke_rap_python","pythonhealthdatascience/pydesrap_stroke"],"tags_count":1,"template":false,"template_full_name":"pythonhealthdatascience/pydesrap_mms","purl":"pkg:github/pythonhealthdatascience/pydesrap_stroke","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonhealthdatascience%2Fpydesrap_stroke","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonhealthdatascience%2Fpydesrap_stroke/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonhealthdatascience%2Fpydesrap_stroke/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonhealthdatascience%2Fpydesrap_stroke/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pythonhealthdatascience","download_url":"https://codeload.github.com/pythonhealthdatascience/pydesrap_stroke/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pythonhealthdatascience%2Fpydesrap_stroke/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262471429,"owners_count":23316681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-28T17:38:24.494Z","updated_at":"2025-06-28T17:39:03.526Z","avatar_url":"https://github.com/pythonhealthdatascience.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Stroke capacity planning model: python DES RAP\n\n[![python](https://img.shields.io/badge/-Python_3.13.1-blue?logo=python\u0026logoColor=white)](https://www.python.org/)\n![licence](https://img.shields.io/badge/🛡️_Licence-MIT-green.svg?labelColor=gray)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15574906.svg)](https://doi.org/10.5281/zenodo.15574906)\n[![Tests](https://github.com/pythonhealthdatascience/pydesrap_stroke/actions/workflows/tests.yaml/badge.svg)](https://github.com/pythonhealthdatascience/pydesrap_stroke/actions/workflows/tests.yaml)\n[![Linting](https://github.com/pythonhealthdatascience/pydesrap_stroke/actions/workflows/lint.yaml/badge.svg)](https://github.com/pythonhealthdatascience/pydesrap_stroke/actions/workflows/lint.yaml)\n[![ORCID](https://img.shields.io/badge/ORCID_Amy_Heather-0000--0002--6596--3479-A6CE39?\u0026logo=orcid\u0026logoColor=white)](https://orcid.org/0000-0002-6596-3479)\n\n\u003c/div\u003e\n\nThis repository applies the [Python DES RAP Template](https://github.com/pythonhealthdatascience/pydesrap_mms) to a real-life example:\n\n\u003e Monks T, Worthington D, Allen M, Pitt M, Stein K, James MA. A modelling tool for capacity planning in acute and community stroke services. BMC Health Serv Res. 2016 Sep 29;16(1):530. doi: [10.1186/s12913-016-1789-4](https://doi.org/10.1186/s12913-016-1789-4). PMID: 27688152; PMCID: PMC5043535.\n\nModel diagram:\n\n![](images/stroke_rehab_design.png)\n\n\u003cbr\u003e\n\n## Installation\n\nClone the repository locally:\n\n```\ngit clone https://github.com/pythonhealthdatascience/pydesrap_stroke.git\ncd pydesrap_stroke\n```\n\nUse the provided `environment.yaml` file to set up a Python environment with `conda`:\n\n```\nconda env create --file environment.yaml\nconda activate\n```\n\nThe provided `environment.yaml` file is a snapshot of the environment used when creating the repository, including specific package versions. You can update this file if necessary, but be sure to test that everything continues to work as expected after any updates. Also note that some dependencies are not required for modelling, but instead served other purposes, like running `.ipynb` files and linting.\n\nAs an alternative, a `requirements.txt` file is provided which can be used to set up the environment with `virtualenv`. This is used by GitHub actions, which run much faster with a virtual environment than a conda environment. However, we recommend locally installing the environment using conda, as it will also manage the Python version for you. If using `virtualenv`, it won't fetch a specific version of Python - so please note the version listed in `environment.yaml`.\n\n\u003cbr\u003e\n\n## How to run\n\nThe simulation code is provided as a **package** within `simulation/`. There are notebooks executing the model and analysing the results in `notebooks/`.\n\nTo run the model with base parameters once or with replications:\n\n```\nfrom simulation.parameters import Param\nfrom simulation.runner import Runner\n\nparam = Param()\nrunner = Runner(param=param)\n\nsingle_result = runner.run_single(run=0)\nrep_results = runner.run_reps()\n```\n\nExample altering the model parameters:\n\n```\nfrom simulation.parameters import Param, ASUArrivals, RehabRouting\nfrom simulation.runner import Runner\n\n# Modified one of the arrival rates, some routing probabilities, and the\n# number of replications\nparam = Param(\n    asu_arrivals=ASUArrivals(tia=10),\n    rehab_routing=RehabRouting(neuro_esd=0.2, neuro_other=0.8),\n    number_of_runs=10\n)\nrunner = Runner(param=param)\nrep_results = runner.run_reps()\n```\n\n### Generating the results from the article\n\nThe original study used Simul8. Each of the outputs from that article have been replicated in this repository using Python:\n\n* Figure 1. Simulation probability density function for occupancy of an acute stroke unit.\n* Figure 3. Simulated trade-off between the probability that a patient is delayed and the no. of acute beds available.\n* Table 2. Likelihood of delay. Current admissions versus 5% more admissions.\n* Table 3. Results of pooling of acute and rehab beds.\n* Supplementary Table 1. Likelihood of delay. Current admissions versus No Complex neurological patients.\n* Supplementary Table 3. Likelihood of delay. Current admissions versus ring fenced acute stroke beds.\n\nTo generate these, simply execute `notebooks/analysis.ipynb`.\n\n#### Examples\n\n**Figure 1**\n\nOriginal:\n\n![](docs/article/fig1.png)\n\nFrom this repository:\n\n![](outputs/figure1_asu.png)\n\n**Figure 3**\n\nOriginal:\n\n![](docs/article/fig3.png)\n\nFrom this repository:\n\n![](outputs/figure3_asu.png)\n\n\u003cbr\u003e\n\n## Run time and machine specification\n\nThe run time for this analysis (`notebooks/analysis.ipynb`) is 10 seconds. This was on an Intel Core i7-12700H, 32GB RAM, Ubuntu 24.04.1.\n\nThe other notebooks generate results for tests and illustrate other functionality (e.g. importing parameters from csv, running with logs), and these just take a second or two.\n\n\u003cbr\u003e\n\n## Citation\n\nFor this applied example, please cite either:\n\n\u003e Heather, A. (2025). Stroke capacity planning model: python DES RAP. GitHub. https://github.com/pythonhealthdatascience/pydesrap_stroke.\n\u003e\n\u003e Heather, A. (2025). Stroke capacity planning model: python DES RAP. Zenodo. https://doi.org/10.5281/zenodo.15574906.\n\nThis example is built using the [Python DES RAP Template](https://github.com/pythonhealthdatascience/pydesrap_mms). Please also cite the original template:\n\n\u003e Heather, A. Monks, T. (2025). Python DES RAP Template. Zenodo. https://doi.org/10.5281/zenodo.14622466. GitHub. https://github.com/pythonhealthdatascience/pydesrap_mms.\n\nA `CITATION.cff` file is also provided.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonhealthdatascience%2Fpydesrap_stroke","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpythonhealthdatascience%2Fpydesrap_stroke","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpythonhealthdatascience%2Fpydesrap_stroke/lists"}