Skip to content

Commit

Permalink
Quick addition of creating an excel output to enable
Browse files Browse the repository at this point in the history
  • Loading branch information
charlie-smith committed Sep 25, 2024
1 parent 4f61efa commit a92ccbf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
9 changes: 8 additions & 1 deletion 01_control/control_pre_shorewise.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ df_captnd_checked <- rbind.fill(
df_checked_dis) |>
save_captnd_checked()


rm(df_checked_demo,
df_checked_ref,
df_checked_apps,
df_checked_unav,
df_checked_diag,
df_checked_dis,
df_captnd_checked,
df)

# 4 - Create DQ heatmap reports -------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion 10_pre_shorewise_scripts/dq_reporting/arrange_dq_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
arrange_dq_df <- function(df){

level_order_hb2 <- setdiff(level_order_hb, "NHS Scotland")
level_order_hb2 <- c("NHS Scotland", test)
level_order_hb2 <- c("NHS Scotland", level_order_hb2)

df_arranged <- df |>
mutate(hb_name = factor(hb_name, levels = level_order_hb2),
Expand Down
29 changes: 29 additions & 0 deletions 10_pre_shorewise_scripts/dq_reporting/update_dq_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,35 @@ update_dq_values <- function(wb){
startCol = 2, startRow = 2, #headerStyle = style_text,
colNames = FALSE, withFilter = FALSE, keepNA = TRUE, na.string = "-")

# trend - alternative table with tic marks
df_trend2 <- read_parquet(paste0(pre_shorewise_output_dir, "/02_data_quality/captnd_dq_clean_all.parquet")) |>
mutate(header_date_month = format(as.Date(header_date_month), "%b %Y"),
value = str_to_title(value),
value = factor(value, levels = c("Known", "Missing", "Invalid", "Not Known"))) |>
arrange(header_date_month, dataset_type, hb_name, variable, value) |>
select(Month = header_date_month,
Dataset = dataset_type,
`Health Board` = hb_name,
Variable = variable,
`Submission Status` = submission_status,
PMS = pms,
`DQ Assessment` = value,
-count, -total, Proportion = proportion) |>
pivot_wider(names_from = Month, values_from = Proportion)

export(df_trend2,
file = paste0(pre_shorewise_output_dir, "/02_data_quality/captnd_dq_trend_summary"),
format = "xlsx")

# deleteData(wb, sheet = "Trend Summary", cols = 2:14, rows = 2:19681, gridExpand = TRUE)

# writeData(wb, sheet = "Trend Summary",
# x = df_trend2,
# startCol = 2, startRow = 2, #headerStyle = style_text,
# colNames = FALSE, withFilter = FALSE, keepNA = TRUE, na.string = "-")



# update references
vec_hb <- unique(df_trend$`Health Board`)
writeData(wb, sheet = "Refs",
Expand Down

0 comments on commit a92ccbf

Please sign in to comment.