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

Sc latest quarter #1012

Merged
merged 12 commits into from
Oct 16, 2024
12 changes: 8 additions & 4 deletions R/read_lookup_sc_client.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
#' @export
#' @family process extracts
read_lookup_sc_client <- function(fyyear,
sc_dvprod_connection = phs_db_connection(dsn = "DVPROD")) {

Check warning on line 13 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=13,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.
check_year_format(fyyear)
year <- convert_fyyear_to_year(fyyear)

# read in data - social care 2 client
client_data <- dplyr::tbl(sc_dvprod_connection, dbplyr::in_schema("social_care_2", "client")) %>%

Check warning on line 18 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=18,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 99 characters.
dplyr::collect()

client_data <- client_data %>%
dplyr::select(
"sending_location",
"social_care_id",
Expand Down Expand Up @@ -79,10 +76,17 @@
.data$financial_year,
.data$financial_quarter
) %>%
dplyr::rename("mental_health_disorders" = "mental_health_problems")
dplyr::rename("mental_health_disorders" = "mental_health_problems") %>%
dplyr::collect()

latest_quarter <- client_data %>%

Check warning on line 82 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=82,col=3,[object_usage_linter] local variable 'latest_quarter' assigned but may not be used
dplyr::arrange(desc(financial_quarter)) %>%

Check warning on line 83 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=83,col=20,[object_usage_linter] no visible global function definition for 'desc'

Check warning on line 83 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=83,col=25,[object_usage_linter] no visible binding for global variable 'financial_quarter'

Check warning on line 83 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=83,col=25,[object_usage_linter] no visible binding for global variable 'financial_quarter'
dplyr::pull(financial_quarter) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("Social care client lookup for Year {fyyear} is up to {latest_quarter}."))

Check warning on line 86 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=86,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 114 characters.
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved


if (!fs::file_exists(get_sandpit_extract_path(type = "client", year = fyyear))) {

Check warning on line 89 in R/read_lookup_sc_client.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_client.R,line=89,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 83 characters.
client_data %>%
write_file(get_sandpit_extract_path(type = "client", year = fyyear))

Expand Down
12 changes: 8 additions & 4 deletions R/read_lookup_sc_demographics.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
#' @return a [tibble][tibble::tibble-package]
#' @export
#'
read_lookup_sc_demographics <- function(sc_dvprod_connection = phs_db_connection(dsn = "DVPROD")) {

Check warning on line 8 in R/read_lookup_sc_demographics.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_demographics.R,line=8,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 99 characters.
sc_demog <- dplyr::tbl(
sc_dvprod_connection,
dbplyr::in_schema("social_care_2", "demographic_snapshot")
) %>%
dplyr::collect()

sc_demog <- sc_demog %>%
dplyr::select(
"latest_record_flag",
"period",
Expand All @@ -25,7 +22,14 @@
"chi_postcode",
"submitted_postcode",
"chi_gender_code"
)
) %>%
dplyr::collect()

latest_quarter <- sc_demog %>%

Check warning on line 28 in R/read_lookup_sc_demographics.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/read_lookup_sc_demographics.R,line=28,col=3,[object_usage_linter] local variable 'latest_quarter' assigned but may not be used
dplyr::arrange(desc(period)) %>%
dplyr::pull(period) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("Demographics data is up to {latest_quarter}."))
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved


if (!fs::file_exists(get_sandpit_extract_path(type = "demographics"))) {
Expand Down
13 changes: 9 additions & 4 deletions R/read_sc_all_alarms_telecare.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ read_sc_all_alarms_telecare <- function(sc_dvprod_connection = phs_db_connection
at_full_data <- dplyr::tbl(
sc_dvprod_connection,
dbplyr::in_schema("social_care_2", "equipment_snapshot")
) %>% dplyr::collect()

at_full_data <- at_full_data %>%
) %>%
dplyr::select(
"sending_location",
"social_care_id",
Expand All @@ -27,7 +25,14 @@ read_sc_all_alarms_telecare <- function(sc_dvprod_connection = phs_db_connection
"service_end_date",
"service_start_date_after_period_end_date"
) %>%
dplyr::distinct()
dplyr::distinct() %>%
dplyr::collect()

latest_quarter <- at_full_data %>%
dplyr::arrange(desc(period)) %>%
dplyr::pull(period) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("Alarm Telecare data is up to {latest_quarter}."))
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved

if (!fs::file_exists(get_sandpit_extract_path(type = "at"))) {
at_full_data %>%
Expand Down
13 changes: 9 additions & 4 deletions R/read_sc_all_care_home.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ read_sc_all_care_home <- function(sc_dvprod_connection = phs_db_connection(dsn =
ch_data <- dplyr::tbl(
sc_dvprod_connection,
dbplyr::in_schema("social_care_2", "carehome_snapshot")
) %>% dplyr::collect()

ch_data <- ch_data %>%
) %>%
dplyr::select(
"ch_name",
"ch_postcode",
Expand All @@ -29,7 +27,14 @@ read_sc_all_care_home <- function(sc_dvprod_connection = phs_db_connection(dsn =
"ch_discharge_date",
"age"
) %>%
dplyr::distinct()
dplyr::distinct() %>%
dplyr::collect()

latest_quarter <- ch_data %>%
dplyr::arrange(desc(period)) %>%
dplyr::pull(period) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("Care Home data is up to {latest_quarter}."))
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved

if (!fs::file_exists(get_sandpit_extract_path(type = "ch"))) {
ch_data %>%
Expand Down
13 changes: 9 additions & 4 deletions R/read_sc_all_home_care.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ read_sc_all_home_care <- function(sc_dvprod_connection = phs_db_connection(dsn =
home_care_data <- dplyr::tbl(
sc_dvprod_connection,
dbplyr::in_schema("social_care_2", "homecare_snapshot")
) %>% dplyr::collect()

home_care_data <- home_care_data %>%
) %>%
dplyr::select(
"sending_location",
"sending_location_name",
Expand Down Expand Up @@ -46,7 +44,14 @@ read_sc_all_home_care <- function(sc_dvprod_connection = phs_db_connection(dsn =
.data$period
)) %>%
# drop rows start date after end date
dplyr::distinct()
dplyr::distinct() %>%
dplyr::collect()

latest_quarter <- home_care_data %>%
dplyr::arrange(desc(period)) %>%
dplyr::pull(period) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("Home Care data is up to {latest_quarter}."))
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved

if (!fs::file_exists(get_sandpit_extract_path(type = "hc"))) {
home_care_data %>%
Expand Down
12 changes: 8 additions & 4 deletions R/read_sc_all_sds.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ read_sc_all_sds <- function(sc_dvprod_connection = phs_db_connection(dsn = "DVPR
sc_dvprod_connection,
dbplyr::in_schema("social_care_2", "sds_snapshot")
) %>%
dplyr::collect()

sds_full_data <- sds_full_data %>%
dplyr::select(
"sending_location",
"social_care_id",
Expand All @@ -28,7 +25,14 @@ read_sc_all_sds <- function(sc_dvprod_connection = phs_db_connection(dsn = "DVPR
"sds_start_date_after_end_date", # get fixed
"sds_start_date_after_period_end_date" # get removed
) %>%
dplyr::distinct()
dplyr::distinct() %>%
dplyr::collect()

latest_quarter <- sds_full_data %>%
dplyr::arrange(desc(period)) %>%
dplyr::pull(period) %>%
head(1)
cli::cli_alert_info(stringr::str_glue("SDS data is up to {latest_quarter}."))
lizihao-anu marked this conversation as resolved.
Show resolved Hide resolved

if (!fs::file_exists(get_sandpit_extract_path(type = "sds"))) {
sds_full_data %>%
Expand Down
Loading