Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#211 Index Functions #244

Merged
merged 9 commits into from
May 31, 2022
Merged

#211 Index Functions #244

merged 9 commits into from
May 31, 2022

Conversation

catherineholland1
Copy link
Contributor

Closes #211

Index for the createslf package

https://rstudio.nhsnss.scot.nhs.uk/s/fb83f2b0fcee94585df6f/files/Source%20Linkage%20Files/docs/reference/index.html

renamed some functions to explain better what they do adding in get_ / convert_

hope the categories makes sense, any suggestions welcome

@catherineholland1 catherineholland1 added the enhancement New feature or request label May 31, 2022
@catherineholland1 catherineholland1 requested a review from a team May 31, 2022 09:04
@catherineholland1 catherineholland1 self-assigned this May 31, 2022
@catherineholland1 catherineholland1 requested review from Moohan and removed request for a team May 31, 2022 09:04
@Moohan
Copy link
Member

Moohan commented May 31, 2022

See r-lib/pkgdown#1964 which should hopefully make this nicer in the future!

@Moohan Moohan force-pushed the function_ref_index branch from 3604853 to b884ee0 Compare May 31, 2022 12:22
@Moohan Moohan enabled auto-merge (squash) May 31, 2022 13:37
@Moohan Moohan merged commit 5566232 into main-R May 31, 2022
@Moohan Moohan deleted the function_ref_index branch May 31, 2022 15:08
catherineholland1 added a commit that referenced this pull request Jun 14, 2022
* Create functions reference index

* start to categorise functions

* build reference site and page

* rename of some function to add `convert_`

* rename dd_period function

* function index

* Add write data functions

* Fix missed reference to a renamed function.

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: James McMahon <[email protected]>
catherineholland1 added a commit that referenced this pull request Jun 21, 2022
* a&e extract test script

* edit to how new file being read in - .rds

* Style with {styler} (GitHub action)

* # 96 Mental Health Extract (#238)

* mental health extract conversion
edit of mental extract name

* delete old ltc file

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

* addition of monthly rows to vars function

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: catherineholland1 <[email protected]>

* File permissions fix (#210)

* Add functions to wrap `write_*`

These functions should correct the file permission issues on write, they also compress in a consistent way by default.

* Apply new function to files.

Removed references to haven and readr for the writing of zsav and rds files. Also removed the compression arguments as they are no longer needed.

* Remove or reorder package loading

* Style with {styler} (GitHub action)

* add missing pipe

* Style with {styler} (GitHub action)

* Update Production_scripts/Create_slf_lookups/lookup_gp_practice.R

Co-authored-by: Jennit07 <[email protected]>

Co-authored-by: Moohan <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennit07 <[email protected]>

* #87 Community Mental Health Extract (#236)

* community mental health extract conversion

* Style with {styler} (GitHub action)

* Update Production_scripts/Process_extracts/extract_cmh.R

Remove unnecessary sort

* Update Production_scripts/Process_extracts/extract_cmh.R

Keep dates as dates

* Style with {styler} (GitHub action)

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: catherineholland1 <[email protected]>
Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Moohan <[email protected]>

* Care home open data (#228)

* Change care home costs to extract from the Open Data platform

* Interpolate missing costs as the average of surrounding years

* Add a plot to check costs over time

* Amend check mode (#214)

* Remove check_mode in functions

* include check_mode when writing file out

* Remove check_mode in functions

* include check_mode when writing file out

* Make RDS the default file path
use "..." to specify ext = zsav for SPSS files

* update cost scripts with check_mode

* New LTCs path function

* Update lookup scripts with check_mode

* update sc lookups with check_mode

* Update extract scripts with check_mode

* Review LTCs and Deaths files

* Revert gp lookup to previous commit (approved)
For some reason this was an older version so i have reverted this back to the latest on github. May have occurred when putting scripts into folders

* Update documentation

* Use string instead of numeric

* update tests to include ext = "zsav"

* Add rds compression

* Style with {styler} (GitHub action)

* Add SPSS compression

* Make the LTC flags an integer

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

* Bring back the dev SOP

* Remove unnecessary code

* Write the Open Data practice details file out as `rds` as well as `zsav`

* Fix some issues with the GP practice lookup script

Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Moohan <[email protected]>

* Rename extract test function (#242)

* edit to extract function name

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

* Adding @description to produce_source_acute_tests documentation

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: catherineholland1 <[email protected]>
Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Moohan <[email protected]>

* Add action to label PRs based on status

* #211 Functions reference index (pkgdown) (#244)

* Create functions reference index

* start to categorise functions

* build reference site and page

* rename of some function to add `convert_`

* rename dd_period function

* function index

* Add write data functions

* Fix missed reference to a renamed function.

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: James McMahon <[email protected]>

* Update pr-triage.yml

Fix typo

* Fix some build errors/warnings. (#247)

The `surpressWarnings` is needed as `{slfhelper}` loads `{fst}` which produces the warning:
```
fst package v0.9.8
Warning message:
package ‘fst’ was built under R version 3.6.3
```
I could/should probably suppress this more cleverly in slfhelper itself!

The `get_practice_details` test failure is just because we now also produce an rds version. These errors will become more common as we make rds versions and eventually stop producing zsav versions, so we just need to stay on top of them.

* #89 NRS Deaths Extract (#234)

* nrs deaths extract script

* Style with {styler} (GitHub action)

* Update Production_scripts/Process_extracts/extract_nrs_deaths.R

Don't change dates to numeric types.

* Update Production_scripts/Process_extracts/extract_nrs_deaths.R

* Remove the sort

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: James McMahon <[email protected]>

* split up of care home extract - care home name lookup

* Style with {styler} (GitHub action)

* include permission fix (#252)

This should stop the problem of permissions changing for the group to read only

* Maternity tests (#201)

* Fix Typo in maternity extract
This was dropping the costs variables

* Fix cost typo in maternity extract/function
Was dropping cost variables - identified in the tests

* produce maternity tests

* Update documentation

* Add `dplyr::select`

* Simplify documentation links

* Style with {styler} (GitHub action)

* - check data read in correctly
- rename of extract test function
- deletion of materinity test function (not needed anymore)
- check

Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Moohan <[email protected]>
Co-authored-by: Catherine Holland <[email protected]>

* Update main-R to master (after June 2022 update) (#219)

* Add some variables to the GP cluster file

These are needed for the Source Platform Matrix dashboard which uses the same lookup. I also trimmed some of the code.

* Use a name lookup so we use names instead of codes.

* Add GitHub action TODO to Issue

I made a PR to the action repo so that R is now an accepted language, hopefully, this action will be useful by creating a GitHub issue whenever we add a TODO comment to code.

[https://github.com/marketplace/actions/todo-to-issue](https://github.com/marketplace/actions/todo-to-issue)

* Create pull_request_template.md (#245)

* Create pull_request_template.md

Creating a PR template, essentially to add a checklist to every PR for easy review.

I've tried to keep the checklist short - only the top-level / most important checks. Feel free to add / remove or edit.

* Update .github/PULL_REQUEST_TEMPLATE/pull_request_template.md

Co-authored-by: Catherine Holland <[email protected]>

* June 22 update (#218)

* Use the 'snapshot' versions of the Social Care tables (#203)

* Use snapshot data in care homes

* remove sc_latest_validated_period macro

* Use snapshot data in homecare

* Use snapshot data - Demog/client file

Co-authored-by: Jennifer Thom <[email protected]>

* Update SPD and SIMD macros

New 2022 file

* Update latest/previous update macros

Now Jun_2022 and Mar_2022

* Change `cij_marker` to numeric on read in.

B01 (acute), B02 (maternity) and B04 (mental health). These are the same for all years.

I made the changes in RStudio which has stripped whitespace from the end of the lines on saving.

* Change usage of `cij_marker` in C01

* Change `cij_marker` from string to numeric in C02 (DD linking)

Previously we set an empty string to be 'user missing', now the `cij_marker` is a numeric, any missing values will be 'system missing'.

* Increase the length of `cij_marker` as a string in C07

* Use `cij_marker` as a numeric in D01

* Missed cij_marker string to sysmis in C02 (DD linking)

* BUG - use Alter type (AMIN)

problem with running homelessness linkage in C03 where the type is more than string length 1

* Add June 2022 update to NEWS.md

* Replace the SPSS code with some comments and code which will create an error

This doesn't delete the file, so it will still be there as a reminder to use the R code but it can't accidentally be used anymore.

If it is used e.g. in existing production jobs it will create an error and print the messages to the output.

We still need the SPSS test file.

It's also worth noting that all the SPSS code will be kept in the git history.

* Make a copy before re-saving the zsav version.

It will only delete the copy if the code all successfully executes and the 'new' zsav and fst versions exist and are bigger than 0 Bytes which can sometimes happen.

Also, rename the argument from `file` to `path`

* Add explicit call to readr

No longer need to load packages as all of the calls are explicit in the functions.

* Rename file variables to *_path

This just makes it clear that the functions are passing file paths, not the actual files themselves.

* Use `set_names` so that any returned list will be named too

* Update NEWS.md

* Update NEWS.md

* Fix the CH costs year

The year in the spread sheet (e.g. 2018) refers to the end of the year, therefore the 2018 column contains costs for 2017/18, not 2019/20 as we were using.

* BUG - Fix overcounting of preventable beddays

We were previously counting the beddays for the whole year on every episode. So if a CIJ had 2 episodes it would have 2X the correct number of beddays etc.

* use zsav instead of sav for SPD file

* Update NEWS.md

* Update NEWS.md

* Add home care costs (#217)

* Create lookup for Home Care costs

* Fix bug - should be removing bad dates

* Rename fixed hours variable to make pivot simpler

* Include cost variables

Match from the costs lookup and multiply by hours.

* Use maximum compression for write out

* Style

* Add cost variables to SPSS yearly home care code

* style SPSS

* Add Home Care cost variables to the episode file

* Add Home Care cost variables to the Individual file.

* specify health_board.x in facet wrap
This was preventing the charts from populating on the last graph

* Declare hc cost vars in older years (ep file)

* Declare hc cost vars in older years (indiv file)

* Use latest_update object

Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>

* Correct erroneous reference to COSLA (#222)

Also, fix some spelling mistakes 🙄

* BUG - change string to sysmis

* Update NEWS.md

* Correctly uplift costs for future years in CH costs

* Update GP Cluster script to latest update

* Fix minor bug - two postcodes were lower case

Converting to upper case still didn't make them match but it doesn't hurt either!

* Change SPD file path to `zsav`

* Create simple tests for the GP Prac lookup

Inspired by the Postcode tests - can be used for looking into the issue of missing Practice names.

* Rename SPD tests script so it sorts after the main script

* Fix for client file variable names

It seems `elderly_frail` has been renamed `elder_frail` in the snapshot as compared to the 'full' version. I suspect that's a mistake so I just renamed the variable on read-in back to `elderly_frail` rather than edit it in the rest of our code.

* Update DD period

* Make changes to GLS coding (#227)

* Make changes to GLS coding

Option 1 - Not sure if this will be implemented but this is the most likely I think.

This will need replicating to the R code if/when we implement it.

* Update NEWS.md

* Take the latest 20 quarters of Cluster data.

Keep only the latest practice name/cluster for each practice.

Can only take 20 because of issues with the open data - this should either be fixed on the platform or with an update to the `phsopendata` package. See [this issue](Public-Health-Scotland/phsopendata#8 (comment)).

* Minor - tidy up whitespace in tests file

* Keep some extra variables in the GP lookup but don't use them in SLF

* Apply changes for GP prac in the episode file too

* Update NEWS.md

* Use missed Snapshot data

A-T and SDS for 2017/18 missed

* Update home care latest_update to June 2022

* Update IT extract Ref

* BUG - Partially revert changes to GP prac matching

I messed it up as I didn't read the code properly!

* Update cij_ppa logic for a numeric cij_marker

* Update NEWS.md

* Update monthly cost variables for all changed costs 

The main issue this change fixes is that previously only the monthly variables for A&A were being updated after cost_total_net was for both A&A and FV. This change fixes that.

It also adds some extra selections to make extremely clear what is being affected.

With the new year selector we could in theory run this code on every year as it would only actually do anything for `year >= "1819"`, this is like the R version.

* Update NEWS.md

* Use the 1415 NSU cohort in the indiv file

We missed this when we added the 1415 cohort!

* BUG - fix identification of Care Home CIJ records.

This code highlights the first Care Home episode in the CIJ so that we only count things once. However for people with no Care Home episodes at all (everyone in older years) it was flagging their first episode (in the whole file) as `1` and so they were being counted as having a CH CIJ despite having no CH episodes.

* Update NEWS.md

* Fix - duplicate rows being created in HC costs (#246)

This was the issue which was causing the apparent doubling of hours for some LAs. We were getting duplicates for the CA names, which meant we had some duplicate rows in the costs and then when the costs were matched on duplicate episodes for all of the affected LAs.

* minor fix - usage of function without loading the package

* Add all years to the fst list (functions will skip files needed)

* Tidy up the messaging output

* Update NEWS.md

* More fixes for the fst code

* Update NEWS.md

Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>

* Update Production_scripts/Create_social_care_lookups/lookup_care_home_name.R

Co-authored-by: James McMahon <[email protected]>

* function to clear up care home names - edit to R script

* Style with {styler} (GitHub action)

* Document with {roxygen2} (GitHub action)

* edits to year and date functions to make more robust

* Update R/clean_up_text_variables.R

Co-authored-by: James McMahon <[email protected]>

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

* tests created for text function

* Style with {styler} (GitHub action)

* fix issue in paths missing }

* min/max date change

* Update R/get_fy_dates.R

Co-authored-by: James McMahon <[email protected]>

* Update Production_scripts/Create_social_care_lookups/lookup_care_home_name.R

Co-authored-by: James McMahon <[email protected]>

* Update tests/testthat/test-clean_up_free_text.R

Co-authored-by: James McMahon <[email protected]>

* Document with {roxygen2} (GitHub action)

* Style with {styler} (GitHub action)

* Document with {roxygen2} (GitHub action)

* edits to fy dates functions - added testing

* fix conflict

* Style with {styler} (GitHub action)

* Document with {roxygen2} (GitHub action)

* checking the code runs okay - fixed one little thing

Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: Catherine Holland <[email protected]>
Co-authored-by: catherineholland1 <[email protected]>
Co-authored-by: James McMahon <[email protected]>
Co-authored-by: Moohan <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennit07 <[email protected]>
Co-authored-by: Jennifer Thom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants