From e409ff865a539d2cb7f9ea01c48d9c737c1e167b Mon Sep 17 00:00:00 2001 From: Pranav Anbarasu Date: Mon, 3 Jun 2024 15:42:27 +0000 Subject: [PATCH 1/2] RMHDR-257 Fix parsing of device type string from summarized list of device type strings per participant --- scripts/process-data/participant_devices.R | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/process-data/participant_devices.R b/scripts/process-data/participant_devices.R index 919956c..f005b88 100644 --- a/scripts/process-data/participant_devices.R +++ b/scripts/process-data/participant_devices.R @@ -54,8 +54,14 @@ df_joined <- summarise(type = toString(sort(unique(type)))) %>% mutate(concept = "mhp:device") %>% rename(value = type) %>% - mutate(value = ifelse({grepl(", Apple Watch|Apple Watch, ", value)}, "Apple Watch", value)) %>% - filter(value != "Other") %>% + mutate(value = case_when( + stringr::str_detect(value, stringr::regex("Apple Watch", ignore_case = TRUE)) ~ "Apple Watch", + stringr::str_detect(value, stringr::regex("Garmin", ignore_case = TRUE)) ~ "Garmin", + stringr::str_detect(value, stringr::regex("Polar", ignore_case = TRUE)) ~ "Polar", + stringr::str_detect(value, stringr::regex("HRM808S", ignore_case = TRUE)) ~ "HRM808S", + .default = value + )) %>% + filter(value != "Other") %>% select(all_of(c("participantidentifier", "concept", "value"))) %>% ungroup() From 17a9948d44643d78d23262a3bd2e4c74a280dc76 Mon Sep 17 00:00:00 2001 From: Pranav Anbarasu Date: Mon, 3 Jun 2024 15:47:36 +0000 Subject: [PATCH 2/2] RMHDR-257 Use less strict pattern matching for exlcuding rows where "value" contains string "other" in any form --- scripts/process-data/participant_devices.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/process-data/participant_devices.R b/scripts/process-data/participant_devices.R index f005b88..3fa65dd 100644 --- a/scripts/process-data/participant_devices.R +++ b/scripts/process-data/participant_devices.R @@ -61,7 +61,7 @@ df_joined <- stringr::str_detect(value, stringr::regex("HRM808S", ignore_case = TRUE)) ~ "HRM808S", .default = value )) %>% - filter(value != "Other") %>% + filter(!stringr::str_detect(value, stringr::regex("Other", ignore_case = TRUE))) %>% select(all_of(c("participantidentifier", "concept", "value"))) %>% ungroup()