\clearpage
write(formats2h2("Generate the sick child observation subsection"), stderr())
r h1_spa_sco
The objective of the sick child observation protocol is: \begin{itemize} \item to understand the impact of intervention(s) on healthcare provider's adherence to practice and quality of care \begin{itemize} \item critical components of IMCI assessment, diagnosis, management \item inform understanding of correctness of severity classification \item patient-centeredness of care (respectful care) \end{itemize} \item to evaluate the implementation of interventions \begin{itemize} \item functionality, use of and communication about pulse oximetry, including correctness of use \item functionality, use of and communication about CDSA, including correctness of use \end{itemize} \end{itemize}
n <- nrow(spa_sco_data) cond <- n > 0 spa_sco_heatmap_cap <- paste("Sick child observation", heatmap_cap, sep=' - ')
r n
submissions
timci::generate_calendar_heatmap2(spa_sco_data, date, legendtitle = "Number of submissions")
names(spa_sco_data) <- gsub("-", "_", names(spa_sco_data), fixed = TRUE)
all <- spa_sco_data %>% rename(young_infant = "child_identification_young_infant", facility_name = "facility_identification_fname", district = "facility_identification_district", child_id = "child_identification_pid", hcp_id = "hcp_identification_hcpid")
all <- all %>% dplyr::mutate(quarter = dplyr::case_when( as.Date(date) <= as.Date(Sys.getenv("TIMCI_SPA_Q1_END_DATE")) ~ "Q1", as.Date(date) > as.Date(Sys.getenv("TIMCI_SPA_Q1_END_DATE")) ~ "Q2") )
all <- all %>% dplyr::mutate(quarter = dplyr::case_when( as.Date(date) <= as.Date(Sys.getenv("TIMCI_SPA_Q1_END_DATE")) ~ "Q1", as.Date(date) > as.Date(Sys.getenv("TIMCI_SPA_Q1_END_DATE")) & as.Date(date) <= as.Date(Sys.getenv("TIMCI_SPA_Q2_END_DATE")) ~ "Q2", as.Date(date) > as.Date(Sys.getenv("TIMCI_SPA_Q2_END_DATE")) ~ "Q3") )
all <- all %>% dplyr::mutate(quarter = dplyr::case_when( as.Date(date) <= as.Date(Sys.getenv("TIMCI_SPA_Q2_END_DATE")) ~ "Q2", as.Date(date) > as.Date(Sys.getenv("TIMCI_SPA_Q2_END_DATE")) ~ "Q3") )
obs_count <- all %>% dplyr::group_by(facility_name) %>% dplyr::summarise("Observed children" = n_distinct(child_id), "Observed providers" = n_distinct(hcp_id)) %>% bind_rows(dplyr::summarise(., across(where(is.numeric), sum), across(where(is.character), ~"Total"))) %>% rowwise() %>% dplyr::mutate(Total = sum(c_across(where(is.numeric)), na.rm = TRUE)) obs_count %>% kableExtra::kbl(booktabs = TRUE, linesep = "", align = c("c", "c", "c"), caption = "Number of observed participants (children and providers)") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(obs_count)/2) * 2, background = striped_row_bg)
The number of consultation observations to be done depends on the numbers of providers seeing children under 5 at the facility: \begin{itemize} \item 1 provider: 14-18 observations \item 2 providers: 10-12 observations per provider \item 3 providers: 8-10 observations per provider \item 4 providers: 6-8 observations per provider \item 5 providers: 5-7 observations per provider \item 6 providers: 5-6 observations per provider \end{itemize}
q1_count <- all %>% dplyr::filter(quarter == "Q1") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q1)" = n_distinct(child_id)) q2_count <- all %>% dplyr::filter(quarter == "Q2") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q2)" = n_distinct(child_id)) obs_count <- merge(x = q1_count, y = q2_count, by = c("facility_name", "hcp_id"), all = TRUE)
obs_count %>% kableExtra::kbl(booktabs = TRUE, longtable = TRUE, linesep = "", align = c("c", "c", "c"), caption = "Number of consultation observations by providers in Q1 and Q2") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
q3_count <- all %>% dplyr::filter(quarter == "Q3") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q3)" = n_distinct(child_id)) obs_count <- merge(x = obs_count, y = q3_count, by = c("facility_name", "hcp_id"), all = TRUE) obs_count %>% kableExtra::kbl(booktabs = TRUE, longtable = TRUE, linesep = "", align = c("c", "c", "c", "c"), caption = "Number of consultation observations by providers in Q1, Q2 and Q3") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
obs_count <- all %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("Observed children" = n_distinct(child_id)) obs_count %>% kableExtra::kbl(booktabs = TRUE, longtable = TRUE, linesep = "", align = c("c", "c", "c"), caption = "Number of consultation observations by providers") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
d1 <- "Kaliua" q2_count <- all %>% dplyr::filter(district == d1) %>% dplyr::filter(quarter == "Q2") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q2)" = n_distinct(child_id)) q3_count <- all %>% dplyr::filter(district == d1) %>% dplyr::filter(quarter == "Q3") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q3)" = n_distinct(child_id)) obs_count <- merge(x = q2_count, y = q3_count, by = c("facility_name", "hcp_id"), all = TRUE) obs_count %>% kableExtra::kbl(booktabs = TRUE, longtable = TRUE, linesep = "", align = c("c", "c", "c"), caption = paste0("Number of consultation observations by providers in ", d1)) %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
d2 <- "Sengerema" q2_count <- all %>% dplyr::filter(district == d2) %>% dplyr::filter(quarter == "Q2") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q2)" = n_distinct(child_id)) q3_count <- all %>% dplyr::filter(district == d2) %>% dplyr::filter(quarter == "Q3") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q3)" = n_distinct(child_id)) obs_count <- merge(x = q2_count, y = q3_count, by = c("facility_name", "hcp_id"), all = TRUE) obs_count %>% kableExtra::kbl(booktabs = TRUE, linesep = "", align = c("c", "c", "c"), caption = paste0("Number of consultation observations by providers in ", d2)) %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
d3 <- "Tanga" q2_count <- all %>% dplyr::filter(district == d3) %>% dplyr::filter(quarter == "Q2") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q2)" = n_distinct(child_id)) q3_count <- all %>% dplyr::filter(district == d3) %>% dplyr::filter(quarter == "Q3") %>% dplyr::group_by(facility_name, hcp_id) %>% dplyr::summarise("N obs. children (Q3)" = n_distinct(child_id)) obs_count <- merge(x = q2_count, y = q3_count, by = c("facility_name", "hcp_id"), all = TRUE) obs_count %>% kableExtra::kbl(booktabs = TRUE, linesep = "", align = c("c", "c", "c"), caption = paste0("Number of consultation observations by providers in ", d3)) %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::collapse_rows(columns = 1, valign = "top")
all <- all %>% rename(back_from_lab = "child_identification_back_from_lab") summary <- list( "Summary" = list( "Initial consultation" = ~qwraps2::n_perc(back_from_lab == 0, prec), "Back from lab" = ~qwraps2::n_perc(back_from_lab == 1, prec) ) ) out <- format_summary_table(all, summary, facility_name) all <- all %>% dplyr::filter(back_from_lab == 0) out %>% kableExtra::kbl(booktabs = TRUE, linesep = "", align = c("c", "c"), caption = "Type of observation") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1, color = total_row_ft2, background = total_row_bg2, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(out)/2) * 2, background = striped_row_bg)
timci::heatmap_wday_hourofday(all, 'start')
all_q2 <- all %>% dplyr::filter(quarter == "Q2") if (!is.null(all_q2)) { timci::heatmap_wday_hourofday(all_q2, 'start') }
all_q3 <- all %>% dplyr::filter(quarter == "Q3") if (!is.null(all_q3)) { if (nrow(all_q3)>0) { timci::heatmap_wday_hourofday(all_q3, 'start') } }
all_q1 <- all %>% dplyr::filter(quarter == "Q1") if (!is.null(all_q1)) { timci::heatmap_wday_hourofday(all_q1, 'start') }
all_q2 <- all %>% dplyr::filter(quarter == "Q2") if (!is.null(all_q2)) { if (nrow(all_q2)>0) { timci::heatmap_wday_hourofday(all_q2, 'start') } }
all_q3 <- all %>% dplyr::filter(quarter == "Q3") if (!is.null(all_q3)) { if (nrow(all_q3)>0) { timci::heatmap_wday_hourofday(all_q3, 'start') } }
summary <- list( "Summary" = list( "0-59 days" = ~qwraps2::n_perc(young_infant == 1, prec), "2-59 months" = ~qwraps2::n_perc(young_infant == 0, prec) ) ) out <- format_summary_table(all, summary, facility_name) out %>% kableExtra::kbl(booktabs = TRUE, linesep = "", align = c("c", "c"), caption = tcap_age_category) %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1, color = total_row_ft2, background = total_row_bg2, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(out)/2) * 2, background = striped_row_bg)
all$symptoms_lethargic[is.na(all$symptoms_lethargic)] <- 0 all$symptoms_convulsing[is.na(all$symptoms_convulsing)] <- 0 summary <- list( "Summary" = list( "Unconscious" = ~qwraps2::n_perc(symptoms_unconscious == 1, prec), "Lethargic" = ~qwraps2::n_perc(symptoms_lethargic == 1, prec), "Convulsing" = ~qwraps2::n_perc(symptoms_convulsing == 1, prec) ) ) out <- format_summary_table(all, summary, facility_name) out %>% kableExtra::kbl(booktabs = TRUE, linesep = "", longtable = TRUE, align = c("c", "c", "c"), caption = tcap_observed_danger_signs) %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1, color = total_row_ft2, background = total_row_bg2, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(out)/2) * 2, background = striped_row_bg)
all$symptoms_conv_hist_asked[is.na(all$symptoms_conv_hist_asked)] <- 0 all$symptoms_conv_hist_present[is.na(all$symptoms_conv_hist_present)] <- 0 summary <- list( "Summary" = list( "Asked" = ~qwraps2::n_perc(symptoms_conv_hist_asked == 1, prec), "Present" = ~qwraps2::n_perc(symptoms_conv_hist_present == 1, prec) ) ) out <- format_summary_table(all, summary, facility_name) out %>% kableExtra::kbl(booktabs = TRUE, linesep = "", longtable = TRUE, align = c("c", "c"), caption = "History of convulsions") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1, color = total_row_ft2, background = total_row_bg2, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(out)/2) * 2, background = striped_row_bg)
all$symptoms_resp_asked[is.na(all$symptoms_resp_asked)] <- 0 all$symptoms_resp_present[is.na(all$symptoms_resp_present)] <- 0 all$symptoms_resp_onset_asked[is.na(all$symptoms_resp_onset_asked)] <- 0 summary <- list( "Summary" = list( "Asked" = ~qwraps2::n_perc(symptoms_resp_asked == 1, prec), "Present" = ~qwraps2::n_perc(symptoms_resp_present == 1, prec), "Onset asked" = ~qwraps2::n_perc(symptoms_resp_onset_asked == 1, prec) ) ) out <- format_summary_table(all, summary, facility_name) out %>% kableExtra::kbl(booktabs = TRUE, linesep = "", longtable = TRUE, align = c("c", "c", "c"), caption = "Cough/Difficulty breathing") %>% kableExtra::kable_styling(latex_options = c("HOLD_position", "repeat_header"), font_size = table_fs) %>% kableExtra::row_spec(0, bold = TRUE) %>% kableExtra::row_spec(1, color = total_row_ft2, background = total_row_bg2, bold = TRUE) %>% kableExtra::row_spec(1:(nrow(out)/2) * 2, background = striped_row_bg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.