|
2 | 2 |
|
3 | 3 | <!-- badges: start -->
|
4 | 4 | [](https://www.repostatus.org/#wip)
|
5 |
| - |
6 | 5 | <!-- badges: end -->
|
7 | 6 |
|
8 | 7 | ## Purpose
|
9 | 8 |
|
10 |
| -An app to compare schemes' mitigator selections as part of the National Hospital Programme (NHP) modelling process. It's [deployed to Posit Connect](https://connect.strategyunitwm.nhs.uk/nhp/mitigator-comparisons/). |
| 9 | +An app built with [{shiny}](https://shiny.posit.co/), [{golem}](https://thinkr-open.github.io/golem/) and [{bslib}](https://rstudio.github.io/bslib/) to explore and compare schemes' mitigator selections as part of the National Hospital Programme (NHP) modelling process. |
| 10 | + |
| 11 | +This tool is designed primarily for use by model-relationship managers (MRMs) in discussion with schemes so that the mitigator selections can be refined before being finalised. |
| 12 | + |
| 13 | +The app is [deployed to Posit Connect](https://connect.strategyunitwm.nhs.uk/nhp/mitigator-comparisons/) (login/permissions required). |
11 | 14 |
|
12 |
| -This tool is designed for use by model-relationship managers (MRMs) in discussion with schemes so that the mitigator selections can be refined before being finalised. Also, some of the scheme-level code here may support a standalone national-level report that's being developed separately. |
| 15 | +## Run the app |
13 | 16 |
|
14 |
| -This app replaces an original static report ([deployment](https://connect.strategyunitwm.nhs.uk/nhp/mitigators-comparison-report), [source](https://github.com/The-Strategy-Unit/nhp_peers_params)) that started to become tricky to manage and interpret without interactivity. |
| 17 | +### Deploy |
15 | 18 |
|
16 |
| -## Requirements |
| 19 | +You can redeploy the app to Posit Connect using the `dev/03_deploy.R` script. |
| 20 | +This usually happens after a new GitHub release/Git tag. |
17 | 21 |
|
18 |
| -Some environmental variables are needed to fetch data, for example. You will need to add a `.Renviron` file to the project directory that contains the variables named in the `.Renviron.example` file. You can ask a member of the Data Science team for the values to populate this file. Remember to restart your session after you've updated your `.Renviron` file. |
| 22 | +The script checks for the 'app ID' in the `rsconnect/` folder of your local project root, which is generated when you first deploy. |
| 23 | +Otherwise you can find the ID by opening the app from the Posit Connect 'Content' page and then looking for 'Content ID' in the Settings > Info panel of the interface. |
19 | 24 |
|
20 |
| -## Techincal |
| 25 | +### Locally |
21 | 26 |
|
22 |
| -### Major packages |
| 27 | +You can run the app locally, but some environmental variables are needed to fetch data, for example. |
| 28 | +You will need to add a `.Renviron` file to the project directory that contains the variables named in the `.Renviron.example` file. |
| 29 | +You can ask a member of the Data Science team for the values to populate this file. |
| 30 | +Remember to restart your session after you've updated your `.Renviron` file. |
23 | 31 |
|
24 |
| -The app is built with [{shiny}](https://shiny.posit.co/), the [{golem}](https://thinkr-open.github.io/golem/) Shiny-as-a-package framework and [{bslib}](https://rstudio.github.io/bslib/) for theming. |
| 32 | +## Data |
25 | 33 |
|
26 |
| -### Mitigator data |
| 34 | +### Mitigators |
27 | 35 |
|
28 |
| -The mitigators for each scheme's model scenarios are stored on Azure as large json files. One small element of these files is the 'params' item, which includes the mitigator selections. |
| 36 | +The mitigators for each scheme's model scenarios are stored on Azure as large json files. |
| 37 | +One small element of these files is the 'params' item, which includes the mitigator selections. |
29 | 38 |
|
30 |
| -To avoid the app having to read the entire json file for each scheme's model scenario, there is a system to pre-prepare the params alone. [A scheduled Quarto document on Posit Connect](https://connect.strategyunitwm.nhs.uk/nhp/tagged-runs-params-report/) has code to select the appropriate json file, extract the params and [save them as an RDS file to a pin](https://connect.strategyunitwm.nhs.uk/content/32c7f642-e420-448d-b888-bf655fc8fa8b/) on Posit Connect; it also saves [a CSV file to another pin](https://connect.strategyunitwm.nhs.uk/content/811dbaf9-18fe-43aa-bf8e-06b0df66004e/) that contains metadata about the model scenarios. The app then reads data from these pins using [the {pins} package](https://pins.rstudio.com/). A [blogpost by the Data Science team](https://the-strategy-unit.github.io/data_science/blogs/posts/2024-05-22-storing-data-safely/#posit-connect-pins) contains note on authenticating RStudio with Posit Connect, should you need to. |
| 39 | +To avoid the app having to read the entire json file for each scheme's model scenario, there is a system to pre-prepare the params alone. |
| 40 | +[A scheduled Quarto document on Posit Connect](https://connect.strategyunitwm.nhs.uk/nhp/tagged-runs-params-report/) has code to select the appropriate json file, extract the params and [save them as an RDS file to a pin](https://connect.strategyunitwm.nhs.uk/content/32c7f642-e420-448d-b888-bf655fc8fa8b/) on Posit Connect; it also saves [a CSV file to another pin](https://connect.strategyunitwm.nhs.uk/content/811dbaf9-18fe-43aa-bf8e-06b0df66004e/) that contains metadata about the model scenarios. |
| 41 | +The app then reads data from these pins using [the {pins} package](https://pins.rstudio.com/). |
| 42 | +A [blogpost by the Data Science team](https://the-strategy-unit.github.io/data_science/blogs/posts/2024-05-22-storing-data-safely/#posit-connect-pins) contains note on authenticating RStudio with Posit Connect, should you need to. |
31 | 43 |
|
32 |
| -Schemes run many scenarios, but the app only displays data from a single json. The correct file is read because the MRMs tell the Data Science team which particular scenario should be labelled on Azure with a 'run stage' of 'initial', 'intermediate' or 'final'. There's [a handy lookup table](https://connect.strategyunitwm.nhs.uk/nhp/tagged_runs/nhp-tagged-runs.html) where you can see which files have been labelled for each scheme. |
| 44 | +Schemes run many scenarios, but the app only displays data from a single json. |
| 45 | +The correct file is read because the MRMs tell the Data Science team which particular scenario should be labelled on Azure with a 'run stage' of 'final' (the default) 'intermediate' or 'initial'. |
| 46 | +There's [a handy lookup table](https://connect.strategyunitwm.nhs.uk/nhp/tagged_runs/nhp-tagged-runs.html) (login/permissions required) where you can see which files have been labelled for each scheme. |
33 | 47 |
|
34 |
| -### Supporting data |
| 48 | +### Supporting |
35 | 49 |
|
36 |
| -Supporting data is fetched from Azure. This includes lookups for mitigators and schemes, as well as data from the National Elicitation Exercise (NEE). |
| 50 | +Supporting data is fetched from Azure. |
| 51 | +This includes lookups for mitigators and schemes, as well as data from the National Elicitation Exercise (NEE). |
0 commit comments