GithubHelp home page GithubHelp logo

nhs-r-community / nhsrwaitinglist Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 0.0 4.01 MB

R-package to implement the waiting list management approach described in this paper by Fong et al: https://www.medrxiv.org/content/10.1101/2022.08.23.22279117v1.full-text

Home Page: https://nhs-r-community.github.io/NHSRwaitinglist/

License: Other

R 100.00%
queuing-theory nhs package

nhsrwaitinglist's Introduction

All Contributors

Lifecycle: experimental R-CMD-check Codecov test coverage

NHSRwaitinglist

An R-package to implement the waiting list management approach described in the paper Understanding Waiting Lists Pressures by Fong et al.

Installation

You can install the current version of {name of package} from GitHub with:


# install.packages("remotes")
remotes::install_github("nhs-r-community/NHSRwaitinglist", build_vignettes = TRUE)

Contributing

If you want to learn more about this project, please join the discussion at the NHS-R Community Slack group and the specific channel #managing-waiting-lists.

Please see our guidance on how to contribute.

This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

The simplest way to contribute is to raise an issue detailing the feature or functionality you would like to see added, or any unexpected behaviour or bugs you have experienced.

Pull-Request workflow

You are welcome to also submit Pull Requests and, as the main branch is protected and won't accept pushes directly even if you have been added to the repository as a member, the workflow will be (from your own forked repository if you are not a member, or a clone of the repository if you are a member):

  • Create new branch with a descriptive name
  • Commit to the new branch (add code or delete code or make changes)
  • Push the commits
  • Create a pull-request in GitHub to signal that your work is ready to be merged
  • Tag one or more reviewers (@ThomUK and @ChrisMainey) so that your contribution can be reviewed and merged into main

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Jacqueline Grout
Jacqueline Grout

๐Ÿค”

This project follows the all-contributors specification. Contributions of any kind welcome!

nhsrwaitinglist's People

Contributors

allcontributors[bot] avatar chrismainey avatar jacgrout avatar lextuga007 avatar matt-dray avatar neilwalton avatar petersnhs avatar thomuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nhsrwaitinglist's Issues

Add sections into function reference page of pkgdown site

The function reference page lists all the functions, which can be clicked to see a rendering of the help files.

These can be grouped into sections with short preambles to make it easier for users to understand the intent of the functions. See the example for {dplyr}'s site, for example. These groups can be declared in _pkgdown.yml.

Provide headings for (1) wl_* functions, (2) simulation, (3) 'building block' functions, etc. What should these groupings be?

Makes sense to wait for the function names to be confirmed before doing this.

Equity in waiting lists

Is there any scope for the package to include or extend to Gini coefficient of inequalities to answer if waiting lists are equitable?

Adding metadata, descriptions and examples to the first functions

I've translated Neil's functions into R package format and added Roxygen skeletons. 'Roxygen2' is a package for writing the metadata for your R package. It creates tags for each function, where you can add your text to describe things, then R builds into the package help files. See the example function: here.

This is where we'd like you to get involved:

  • Clone the repository on to your machine
  • Create a new branch for your changes
  • Pick one of the functions in the R folder, and a comment below to show which one you are taking, to reduce any duplication
  • Add some description to the metadata tags, and an example (make some numbers up to plug into the function). Definitions can be found in the paper here, or webinar here
  • Commit your changes to your branch, and push to changes to GitHub. You may need to set the 'upstream' (tell GitHub how to tie your branch up to a GitHub one), but it should tell you: git push --set up-stream origin branchname changing "branchname" to your branch.
  • Go back to the repository on GitHub and make a 'Pull request' (this means you are requesting to merge your changes into the main branch.

If you get stuck on any of it, do ask for help. It's tricky first time round, but we don't make any progress if we don't have a go!

Rename `F` argument

Rename argument the F in thetarget_capacity() function. Related to #29.

Graduating this from the discussion in #10 to a proper issue now that it causes the linter to complain (it's not camel case, technically, and also has the connotation of FALSE).

Possibilities mentioned in the discussion by @ThomUK:

  • capacity_variability
  • capacity_variance (could be confused with variance)
  • variability_factor

Fixed synthetic data set

From the catch up on 12th April 2024 we discussed a fixed synthetic dataset which would complement the issue #23 and was also discussed in relation to the {NHSRdatasets} package.

Points to consider are if this should be a standalone data set if it's generalised enough and could be used for other example analysis and if that is the case, whether that go into the existing {NHSRdatasets} package or its own. A data set that's very specific to the examples of this package would suggest it's better placed here rather than somewhere else that would result in a dependency in the packages.

This doesn't necessarily have to be instead of the function and could complement the flexibility that generating particular data could offer.

Any other views on this are very welcome!

Check ROxygen tags

Make sure function shave return tag, and check for appropriate use of details.

Add additional Open Gov licence

I think, given there's a crown copyright on public sector outputs and the Open Gov licence is encouraged by GDS, we should dual licence this (and potentially everything in the NHS-R organisation). I do this on my own organisations GitHub.

Create a reporting function for waiting list pressure across multiple sites and specialties

Take the output from the calculation function written in issue #25, and use it to produce an Rmd or Quarto html report summarising and visualising the waiting list position.

The return will be an html report containing an overview of the waiting list, and a dynamic table allowing various columns to be sorted (eg. by highest pressure, longest wait, etc). It may also contain some overview charts (eg comparing hospital sites, specialties, etc).

Create a function to make synthetic raw data

To be used in documentation and potentially during testing.

The function could be called something like create_waitinglist(n = 1000), which would return a dataframe of 1000 patients with columns for:

  • Hospital Site
  • Specialty
  • OPCS4 Code
  • Referral datetime
  • Treatment datetime
  • Removal without treatment datetime

Add function input checks

Accept only 'correct' argument inputs for each function. Provide useful error messaging to users on failure.

This will impact the range of tests that can be developed as part of #7.

It's probably best to put these checks in a utils.R file, given that similar checks can be used across functions.

This applies to the core functions that exist at time of writing. More checks will be required as the package's functionality expands.

Perhaps start with base stop() to begin with. Could make later use of the {cli} package for a slicker interface.

average_wait() function requires factor to be pre-calculated

I think this was touched upon at the last Teams meeting, but the function for 'average_wait' is actually the target mean wait required to achieve the specified waitlist performance criteria (is this correct?). Now that I am reading the documentation I think that there is some room for confusion and the code examples will make more sense if the function could be named 'mean_target_wait'.

I'm also thinking that instead of specifying a factor to achieve your desired performance % it would be better if you could specify the proportion and have the function do the factor calculation.

For example if I had a waitlist target of 95% of patients to be seen within 42 days I could call the function thus:

mean_target_wait(42,0.95)

This may have consequences for the other functions, but I think end users would assume they can just put their targets directly into the code without having to do some pre-calculations.

Apologies if I have misunderstood anything!

Provide more informative warning when argument vectors are recycled

Let the user know about mismatches in input-vector lengths. Related to #28.

Use {cli} and ... approach as per #50 to accept the length of any number of arguments, check them for length and report back to the user. Will likely need to be a tryCatch() to suppress the default R message and replace with our own.

We're doing this to provide a nicer user-interface. The default warning is terse:

> 1:2 + 1:3
[1] 2 4 4
Warning message:
In 1:2 + 1:3 :
  longer object length is not a multiple of shorter object length

And it prints multiple times with multiple violations:

> 1:2 + 1:3 + 1:4
[1] 3 6 7 6
Warning messages:
1: In 1:2 + 1:3 :
  longer object length is not a multiple of shorter object length
2: In 1:2 + 1:3 + 1:4 :
  longer object length is not a multiple of shorter object length

It's probably fine not to warn when one of the arguments is length 1, though. There's no warning for this in base either.

> 1 + 1:2
[1] 2 3

average_wait() function has ambiguous name

The function for 'average_wait' is actually the target mean wait required to achieve the specified waitlist performance criteria (is this correct?). Now that I am reading the documentation I think that there is some room for confusion and the code examples will make more sense if the function could be named 'mean_target_wait'.

Tests for new wl_* functions

Test coverage has dropped from 100% to 22% now the new functions are included.

Once the functions are stable, we need to write tests.

Create a data dictionary vignette

A document outlining the common terms use within the package. The aim is to help us align to:

  • Consistent variable names (within the pacakage)
  • Consistent "english" names (when describing the concepts represented by the variables)

This issue is to create a first version, which can be merged and added to as the package develops.

Create a bulk calculation function for multiple sites and specialties

The package is going to be used to process raw data into helpful visualisations for decision-makers.

Write a function to take data in the cleaned form (produced by issue #24), and to apply the package calculations.

The function will return a data frame of calculated data, including results for:

  • Load
  • Target queue size
  • Target capacity
  • Waiting list pressure

This result will be consumed by multiple downstream reporting functions, to visualise the information in different ways (eg. by specialty, by hospital site, by priority ranking)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.