-
Notifications
You must be signed in to change notification settings - Fork 2
demographics file #1202
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
Merged
Merged
demographics file #1202
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
1346f70
Change order - aligns with sc methods
Jennit07 b882590
Move postcode code to own section
Jennit07 30eb049
Add latest record flag notes from sc team
Jennit07 9e2c124
Style code
Jennit07 7c3b103
Move arrange to make it more clear this is done
Jennit07 887befd
Use SC methodology to select latest record flag
Jennit07 84813a3
remove redundant code
Jennit07 8e416f8
Merge branch 'dec25-update' into sc_latest_record_flag
OluwatobiOni 693ad34
sc: demog lookup by fy and align with sc
lizihao-anu 47d9110
sc: replace scid with latest grouped by anon_chi
lizihao-anu 0428f3c
sc: to adapt at with demog lookup
lizihao-anu c406c8b
sc: to adapt ch with demog lookup
lizihao-anu dd54988
sc: to adapt hc with demog lookup
lizihao-anu 3c21a08
sc: to adapt sds with demog lookup
lizihao-anu cf2773c
sc: to adapt join_sc_client with demog lookup
lizihao-anu 3a549d0
Style code
lizihao-anu a6d4166
Merge branch 'dec25-update' into ch_pc
lizihao-anu 8ac1f8c
Update documentation
lizihao-anu 885da83
bug fix for process_lookup_sc_demographics
lizihao-anu 5ae0fb7
Merge branch 'dec25-update' into ch_pc
Jennit07 cf0a31a
update targets and join_sc_client()
lizihao-anu 57be2ba
Merge branch 'dec25-update' into ch_pc
Jennit07 970694f
Merge branch 'dec25-update' into ch_pc
Jennit07 35f99d2
update process_lookup_sc_demographics.R
lizihao-anu 2f1fa7c
Merge branch 'ch_pc' of github.com:Public-Health-Scotland/source-link…
lizihao-anu 16e355b
Update documentation
lizihao-anu 01d2f15
remove latest_record_flag
lizihao-anu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #' Add financial year from Social Care period | ||
| #' Financial year format, eg 2024 | ||
| #' @param data social care data frame | ||
| #' | ||
| #' @returns social care data frame with financial year and financial quarter | ||
| add_fy_qtr_from_period <- function(data) { | ||
| data %>% | ||
| # create financial_year and financial_quarter variables for sorting | ||
| dplyr::mutate( | ||
| financial_year = as.numeric(stringr::str_sub(.data$period, 1, 4)), | ||
| financial_quarter = stringr::str_sub(.data$period, 6, 6) | ||
| ) %>% | ||
| # set financial quarter to 5 when there is only an annual submission - | ||
| # for ordering periods with annual submission last | ||
| dplyr::mutate( | ||
| financial_quarter = dplyr::if_else( | ||
| is.na(.data$financial_quarter) | | ||
| .data$financial_quarter == "", | ||
| "5", | ||
| .data$financial_quarter | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
|
|
||
| #' which_fy | ||
| #' Extract financial year from a date | ||
| #' | ||
| #' @param date a date variable | ||
| #' @param format calenddar year format 2024, or financial year format, 2425 | ||
| #' @returns financial year | ||
| which_fy <- function(date, format = c("year", "fyear")) { | ||
| year <- as.numeric(format(date, "%Y")) | ||
| month <- as.numeric(format(date, "%m")) | ||
|
|
||
| start_year <- ifelse(month < 4, year - 1, year) | ||
| end_year <- start_year + 1 | ||
| if (format == "year") { | ||
| return(start_year) | ||
| } else { | ||
| return(paste0(substr(start_year, 3, 4), substr(end_year, 3, 4))) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.