Skip to content

Commit

Permalink
Merge branch 'development' into targets/pass_all_data_to_episode_file
Browse files Browse the repository at this point in the history
  • Loading branch information
Moohan authored Aug 14, 2023
2 parents dd1a983 + 3820c19 commit 25220ef
Show file tree
Hide file tree
Showing 29 changed files with 298 additions and 574 deletions.
4 changes: 4 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Classificat
cls
cmh
CNWs
Comhairle
commhosp
congen
costincdnas
Expand Down Expand Up @@ -112,6 +113,7 @@ ltc
ltcs
lubridate
magrittr
Matern
Mcbride
mcmahon
MMMYY
Expand All @@ -137,6 +139,7 @@ outfile
pandoc
patflow
pattype
PCEC
phs
phsmethods
phsopendata
Expand Down Expand Up @@ -199,6 +202,7 @@ submis
tadm
tarchetypes
tbl
Telecare
telecare
testthat
thom
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [master, main, main-R]
branches: [master, main, development]
pull_request:
branches: [master, main, main-R]
branches: [master, main, development]

name: R-CMD-check

Expand Down
38 changes: 20 additions & 18 deletions R/add_smr_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,30 @@ add_smr_type <- function(recid,
recid == "HL1" & main_applicant_flag == "N" ~ "HL1-Other"
)
} else if (all(recid == "OoH")) {
smrtype <- dplyr::case_when(
consultation_type == "DISTRICT NURSE" ~ "OOH-DN",
consultation_type == "DOCTOR ADVICE/NURSE ADVICE" ~ "OOH-Advice",
consultation_type == "HOME VISIT" ~ "OOH-HomeV",
consultation_type == "NHS 24 NURSE ADVICE" ~ "OOH-NHS24",
consultation_type == "PCEC/PCC" ~ "OOH-PCC",
consultation_type == "COVID19 ASSESSMENT" ~ "OOH-C19Ass",
consultation_type == "COVID19 ADVICE" ~ "OOH-C19Adv",
consultation_type == "COVID19 OTHER" ~ "OOH-C19Oth",
smrtype <- dplyr::case_match(
consultation_type,
"DISTRICT NURSE" ~ "OOH-DN",
"DOCTOR ADVICE/NURSE ADVICE" ~ "OOH-Advice",
"HOME VISIT" ~ "OOH-HomeV",
"NHS 24 NURSE ADVICE" ~ "OOH-NHS24",
"PCEC/PCC" ~ "OOH-PCC",
"COVID19 ASSESSMENT" ~ "OOH-C19Ass",
"COVID19 ADVICE" ~ "OOH-C19Adv",
"COVID19 OTHER" ~ "OOH-C19Oth",
.default = "OOH-Other"
)
} else {
# Recids that can be recoded with no identifier
smrtype <- dplyr::case_when(
recid == "00B" ~ "Outpatient",
recid == "04B" ~ "Psych-IP",
recid == "AE2" ~ "A & E",
recid == "CH" ~ "Care-Home",
recid == "CMH" ~ "Comm-MH",
recid == "DN" ~ "DN",
recid == "NRS" ~ "NRS Deaths",
recid == "PIS" ~ "PIS"
smrtype <- dplyr::case_match(
recid,
"00B" ~ "Outpatient",
"04B" ~ "Psych-IP",
"AE2" ~ "A & E",
"CH" ~ "Care-Home",
"CMH" ~ "Comm-MH",
"DN" ~ "DN",
"NRS" ~ "NRS Deaths",
"PIS" ~ "PIS"
)
}

Expand Down
6 changes: 3 additions & 3 deletions R/aggregate_by_chi_zihao.R → R/aggregate_by_chi.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' @importFrom data.table .SD
#'
#' @inheritParams create_individual_file
aggregate_by_chi_zihao <- function(episode_file) {
aggregate_by_chi <- function(episode_file) {
cli::cli_alert_info("Aggregate by CHI function started at {Sys.time()}")

# Convert to data.table
Expand Down Expand Up @@ -191,12 +191,12 @@ vars_contain <- function(data, vars, ignore_case = FALSE) {
)
}

#' Aggregate CIS episodes
#' Aggregate Care Home episodes to ch_cis
#'
#' @description Aggregate CH variables by CHI and CIS.
#'
#' @inheritParams create_individual_file
aggregate_ch_episodes_zihao <- function(episode_file) {
aggregate_ch_episodes <- function(episode_file) {
cli::cli_alert_info("Aggregate ch episodes function started at {Sys.time()}")

# Convert to data.table
Expand Down
67 changes: 34 additions & 33 deletions R/convert_ca_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,40 @@
#' @family code functions
#' @seealso convert_sending_location_to_lca
convert_ca_to_lca <- function(ca_var) {
lca <- dplyr::case_when(
ca_var == "S12000033" | ca_var == "Aberdeen City" ~ "01",
ca_var == "S12000034" | ca_var == "Aberdeenshire" ~ "02",
ca_var == "S12000041" | ca_var == "Angus" ~ "03",
ca_var == "S12000035" | ca_var == "Argyll & Bute" ~ "04",
ca_var == "S12000026" | ca_var == "Scottish Borders" ~ "05",
ca_var == "S12000005" | ca_var == "Clackmannanshire" ~ "06",
ca_var == "S12000039" | ca_var == "West Dunbartonshire" ~ "07",
ca_var == "S12000006" | ca_var == "Dumfries and Galloway" ~ "08",
ca_var == "S12000042" | ca_var == "Dundee City" ~ "09",
ca_var == "S12000008" | ca_var == "East Ayrshire" ~ "10",
ca_var == "S12000045" | ca_var == "East Dunbartonshire" ~ "11",
ca_var == "S12000010" | ca_var == "East Lothian" ~ "12",
ca_var == "S12000011" | ca_var == "East Renfrewshire" ~ "13",
ca_var == "S12000036" | ca_var == "City of Edinburgh" ~ "14",
ca_var == "S12000014" | ca_var == "Falkirk" ~ "15",
ca_var %in% c("S12000015", "S12000047") | ca_var == "Fife" ~ "16",
ca_var %in% c("S12000046", "S12000049") | ca_var == "Glasgow City" ~ "17",
ca_var == "S12000017" | ca_var == "Highland" ~ "18",
ca_var == "S12000018" | ca_var == "Inverclyde" ~ "19",
ca_var == "S12000019" | ca_var == "Midlothian" ~ "20",
ca_var == "S12000020" | ca_var == "Moray" ~ "21",
ca_var == "S12000021" | ca_var == "North Ayrshire" ~ "22",
ca_var %in% c("S12000044", "S12000050") | ca_var == "North Lanarkshire" ~ "23",
ca_var == "S12000023" | ca_var == "Orkney" ~ "24",
ca_var %in% c("S12000024", "S12000048") | ca_var == "Perth and Kinross" ~ "25",
ca_var == "S12000038" | ca_var == "Renfrewshire" ~ "26",
ca_var == "S12000027" | ca_var == "Shetland Islands" ~ "27",
ca_var == "S12000028" | ca_var == "South Ayrshire" ~ "28",
ca_var == "S12000029" | ca_var == "South Lanarkshire" ~ "29",
ca_var == "S12000030" | ca_var == "Stirling" ~ "30",
ca_var == "S12000040" | ca_var == "West Lothian" ~ "31",
ca_var == "S12000013" | ca_var == "Na h-Eileanan Siar" | ca_var == "Comhairle nan Eilean Siar" ~ "32"
lca <- dplyr::case_match(
ca_var,
c("S12000033", "Aberdeen City") ~ "01",
c("S12000034", "Aberdeenshire") ~ "02",
c("S12000041", "Angus") ~ "03",
c("S12000035", "Argyll & Bute") ~ "04",
c("S12000026", "Scottish Borders") ~ "05",
c("S12000005", "Clackmannanshire") ~ "06",
c("S12000039", "West Dunbartonshire") ~ "07",
c("S12000006", "Dumfries and Galloway") ~ "08",
c("S12000042", "Dundee City") ~ "09",
c("S12000008", "East Ayrshire") ~ "10",
c("S12000045", "East Dunbartonshire") ~ "11",
c("S12000010", "East Lothian") ~ "12",
c("S12000011", "East Renfrewshire") ~ "13",
c("S12000036", "City of Edinburgh") ~ "14",
c("S12000014", "Falkirk") ~ "15",
c("S12000015", "S12000047", "Fife") ~ "16",
c("S12000046", "S12000049", "Glasgow City") ~ "17",
c("S12000017", "Highland") ~ "18",
c("S12000018", "Inverclyde") ~ "19",
c("S12000019", "Midlothian") ~ "20",
c("S12000020", "Moray") ~ "21",
c("S12000021", "North Ayrshire") ~ "22",
c("S12000044", "S12000050", "North Lanarkshire") ~ "23",
c("S12000023", "Orkney") ~ "24",
c("S12000024", "S12000048", "Perth and Kinross") ~ "25",
c("S12000038", "Renfrewshire") ~ "26",
c("S12000027", "Shetland Islands") ~ "27",
c("S12000028", "South Ayrshire") ~ "28",
c("S12000029", "South Lanarkshire") ~ "29",
c("S12000030", "Stirling") ~ "30",
c("S12000040", "West Lothian") ~ "31",
c("S12000013", "Na h-Eileanan Siar", "Comhairle nan Eilean Siar") ~ "32"
)
return(lca)
}
97 changes: 49 additions & 48 deletions R/convert_codes_to_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,39 @@
#'
#' @family code functions
convert_hscp_to_hscpnames <- function(hscp) {
hscpnames <- dplyr::case_when(
hscp == "S37000001" ~ "Aberdeen City",
hscp == "S37000002" ~ "Aberdeenshire",
hscp == "S37000003" ~ "Angus",
hscp == "S37000004" ~ "Argyll and Bute",
hscp == "S37000005" ~ "Clackmannanshire and Stirling",
hscp == "S37000006" ~ "Dumfries and Galloway",
hscp == "S37000007" ~ "Dundee City",
hscp == "S37000008" ~ "East Ayrshire",
hscp == "S37000009" ~ "East Dunbartonshire",
hscp == "S37000010" ~ "East Lothian",
hscp == "S37000011" ~ "East Renfrewshire",
hscp == "S37000012" ~ "Edinburgh",
hscp == "S37000013" ~ "Falkirk",
hscp == "S37000016" ~ "Highland",
hscp == "S37000017" ~ "Inverclyde",
hscp == "S37000018" ~ "Midlothian",
hscp == "S37000019" ~ "Moray",
hscp == "S37000020" ~ "North Ayrshire",
hscp == "S37000022" ~ "Orkney Islands",
hscp == "S37000024" ~ "Renfrewshire",
hscp == "S37000025" ~ "Scottish Borders",
hscp == "S37000026" ~ "Shetland Islands",
hscp == "S37000027" ~ "South Ayrshire",
hscp == "S37000028" ~ "South Lanarkshire",
hscp == "S37000029" ~ "West Dunbartonshire",
hscp == "S37000030" ~ "West Lothian",
hscp == "S37000031" ~ "Western Isles",
hscp == "S37000032" ~ "Fife",
hscp == "S37000033" ~ "Perth and Kinross",
hscp == "S37000034" ~ "Glasgow City",
hscp == "S37000035" ~ "North Lanarkshire"
hscpnames <- dplyr::case_match(
hscp,
"S37000001" ~ "Aberdeen City",
"S37000002" ~ "Aberdeenshire",
"S37000003" ~ "Angus",
"S37000004" ~ "Argyll and Bute",
"S37000005" ~ "Clackmannanshire and Stirling",
"S37000006" ~ "Dumfries and Galloway",
"S37000007" ~ "Dundee City",
"S37000008" ~ "East Ayrshire",
"S37000009" ~ "East Dunbartonshire",
"S37000010" ~ "East Lothian",
"S37000011" ~ "East Renfrewshire",
"S37000012" ~ "Edinburgh",
"S37000013" ~ "Falkirk",
"S37000016" ~ "Highland",
"S37000017" ~ "Inverclyde",
"S37000018" ~ "Midlothian",
"S37000019" ~ "Moray",
"S37000020" ~ "North Ayrshire",
"S37000022" ~ "Orkney Islands",
"S37000024" ~ "Renfrewshire",
"S37000025" ~ "Scottish Borders",
"S37000026" ~ "Shetland Islands",
"S37000027" ~ "South Ayrshire",
"S37000028" ~ "South Lanarkshire",
"S37000029" ~ "West Dunbartonshire",
"S37000030" ~ "West Lothian",
"S37000031" ~ "Western Isles",
"S37000032" ~ "Fife",
"S37000033" ~ "Perth and Kinross",
"S37000034" ~ "Glasgow City",
"S37000035" ~ "North Lanarkshire"
)
return(hscpnames)
}
Expand All @@ -66,22 +67,22 @@ convert_hscp_to_hscpnames <- function(hscp) {
#'
#' @family code functions
convert_hb_to_hbnames <- function(hb) {
hbnames <- dplyr::case_when(
hb == "S08000015" ~ "Ayrshire and Arran",
hb == "S08000016" ~ "Borders",
hb == "S08000017" ~ "Dumfries and Galloway",
hb == "S08000019" ~ "Forth Valley",
hb == "S08000020" ~ "Grampian",
hb == "S08000022" ~ "Highland",
hb == "S08000024" ~ "Lothian",
hb == "S08000025" ~ "Orkney",
hb == "S08000026" ~ "Shetland",
hb == "S08000028" ~ "Western Isles",
hb == "S08000029" ~ "Fife",
hb == "S08000030" ~ "Tayside",
hb == "S08000031" ~ "Greater Glasgow and Clyde",
hb == "S08000032" ~ "Lanarkshire"
hbnames <- dplyr::case_match(
hb,
"S08000015" ~ "Ayrshire and Arran",
"S08000016" ~ "Borders",
"S08000017" ~ "Dumfries and Galloway",
"S08000019" ~ "Forth Valley",
"S08000020" ~ "Grampian",
"S08000022" ~ "Highland",
"S08000024" ~ "Lothian",
"S08000025" ~ "Orkney",
"S08000026" ~ "Shetland",
"S08000028" ~ "Western Isles",
"S08000029" ~ "Fife",
"S08000030" ~ "Tayside",
"S08000031" ~ "Greater Glasgow and Clyde",
"S08000032" ~ "Lanarkshire"
)

return(hbnames)
}
67 changes: 34 additions & 33 deletions R/convert_sending_location_to_lca.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,40 @@
#'
#' @seealso convert_ca_to_lca
convert_sending_location_to_lca <- function(sending_location) {
lca <- dplyr::case_when(
sending_location == "100" ~ "01", # Aberdeen City
sending_location == "110" ~ "02", # Aberdeenshire
sending_location == "120" ~ "03", # Angus
sending_location == "130" ~ "04", # Argyll and Bute
sending_location == "355" ~ "05", # Scottish Borders
sending_location == "150" ~ "06", # Clackmannanshire
sending_location == "395" ~ "07", # West Dumbartonshire
sending_location == "170" ~ "08", # Dumfries and Galloway
sending_location == "180" ~ "09", # Dundee City
sending_location == "190" ~ "10", # East Ayrshire
sending_location == "200" ~ "11", # East Dunbartonshire
sending_location == "210" ~ "12", # East Lothian
sending_location == "220" ~ "13", # East Renfrewshire
sending_location == "230" ~ "14", # City of Edinburgh
sending_location == "240" ~ "15", # Falkirk
sending_location == "250" ~ "16", # Fife
sending_location == "260" ~ "17", # Glasgow City
sending_location == "270" ~ "18", # Highland
sending_location == "280" ~ "19", # Inverclyde
sending_location == "290" ~ "20", # Midlothian
sending_location == "300" ~ "21", # Moray
sending_location == "310" ~ "22", # North Ayrshire
sending_location == "320" ~ "23", # North Lanarkshire
sending_location == "330" ~ "24", # Orkney Islands
sending_location == "340" ~ "25", # Perth and Kinross
sending_location == "350" ~ "26", # Renfrewshire
sending_location == "360" ~ "27", # Shetland Islands
sending_location == "370" ~ "28", # South Ayrshire
sending_location == "380" ~ "29", # South Lanarkshire
sending_location == "390" ~ "30", # Stirling
sending_location == "400" ~ "31", # West Lothian
sending_location == "235" ~ "32" # Na_h_Eileanan_Siar
lca <- dplyr::case_match(
sending_location,
"100" ~ "01", # Aberdeen City
"110" ~ "02", # Aberdeenshire
"120" ~ "03", # Angus
"130" ~ "04", # Argyll and Bute
"355" ~ "05", # Scottish Borders
"150" ~ "06", # Clackmannanshire
"395" ~ "07", # West Dumbartonshire
"170" ~ "08", # Dumfries and Galloway
"180" ~ "09", # Dundee City
"190" ~ "10", # East Ayrshire
"200" ~ "11", # East Dunbartonshire
"210" ~ "12", # East Lothian
"220" ~ "13", # East Renfrewshire
"230" ~ "14", # City of Edinburgh
"240" ~ "15", # Falkirk
"250" ~ "16", # Fife
"260" ~ "17", # Glasgow City
"270" ~ "18", # Highland
"280" ~ "19", # Inverclyde
"290" ~ "20", # Midlothian
"300" ~ "21", # Moray
"310" ~ "22", # North Ayrshire
"320" ~ "23", # North Lanarkshire
"330" ~ "24", # Orkney Islands
"340" ~ "25", # Perth and Kinross
"350" ~ "26", # Renfrewshire
"360" ~ "27", # Shetland Islands
"370" ~ "28", # South Ayrshire
"380" ~ "29", # South Lanarkshire
"390" ~ "30", # Stirling
"400" ~ "31", # West Lothian
"235" ~ "32" # Na_h_Eileanan_Siar
)
return(lca)
}
Loading

0 comments on commit 25220ef

Please sign in to comment.