Instructions:

Graph the data to show compliance by unit, analyze your findings, and provide recommendations for improvement. (Important context: Target Compliance = 90%)

Key:

Loading Packages

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.3.1
## Warning: package 'lubridate' was built under R version 4.3.1
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggplot2)

Loading Data

df = read_csv('ZSFG Flu and Pneumovax Audit.csv')
## Rows: 274 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (8): Date, Unit, Flu Vaccine screening completed correctly., Flu Vaccine...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Columns:

print(colnames(df))
## [1] "Date"                                                                                                        
## [2] "Unit"                                                                                                        
## [3] "Flu Vaccine screening completed correctly."                                                                  
## [4] "Flu Vaccine Information Sheet (VIS) provided to the patient."                                                
## [5] "Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR)."      
## [6] "Pneumovax Vaccine screening completed correctly."                                                            
## [7] "Pneumovax Vaccine Information Sheet (VIS) provided to the patient."                                          
## [8] "Documentation of Pneumovax vaccine administration is recorded on the Medication Administration Record (MAR)."

Preliminary Inspection:

head(df)
## # A tibble: 6 × 8
##   Date      Unit  Flu Vaccine screening completed corre…¹ Flu Vaccine Informat…²
##   <chr>     <chr> <chr>                                   <chr>                 
## 1 3/4/2018  B     N                                       <NA>                  
## 2 3/4/2018  B     N                                       <NA>                  
## 3 3/4/2018  B     N                                       <NA>                  
## 4 3/4/2018  B     N                                       <NA>                  
## 5 3/4/2018  B     Y                                       <NA>                  
## 6 2/28/2018 C     Y                                       Y                     
## # ℹ abbreviated names: ¹​`Flu Vaccine screening completed correctly.`,
## #   ²​`Flu Vaccine Information Sheet (VIS) provided to the patient.`
## # ℹ 4 more variables:
## #   `Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR).` <chr>,
## #   `Pneumovax Vaccine screening completed correctly.` <chr>,
## #   `Pneumovax Vaccine Information Sheet (VIS) provided to the patient.` <chr>,
## #   `Documentation of Pneumovax vaccine administration is recorded on the Medication Administration Record (MAR).` <chr>

Data Cleaning:

# converting the 'Y' and 'N' values to binary
df = df %>%
  mutate_at(vars(3:8), ~ as.double(recode(., "N" = '0.0', 'Y' = '1.0')))

Data Aggregation by Unit:

distinct_dates <- df %>%
  group_by(Unit) %>%
  summarise(distinct_dates = n_distinct(Date))

distinct_dates
## # A tibble: 6 × 2
##   Unit  distinct_dates
##   <chr>          <int>
## 1 A                 16
## 2 B                  4
## 3 C                 24
## 4 D                 25
## 5 E                  3
## 6 G                  2
average_rows_per_date <- df %>%
  group_by(Unit, Date) %>%
  summarise(rows_count = n()) %>%
  group_by(Unit) %>%
  summarise(average_patients_per_day = mean(rows_count))
## `summarise()` has grouped output by 'Unit'. You can override using the
## `.groups` argument.
average_rows_per_date
## # A tibble: 6 × 2
##   Unit  average_patients_per_day
##   <chr>                    <dbl>
## 1 A                         3.25
## 2 B                         2.5 
## 3 C                         3.67
## 4 D                         4.56
## 5 E                         2   
## 6 G                         2

Data Aggregation by Unit:

df_by_unit = df %>%
  select(-Date) %>%
  group_by(Unit) %>%
  summarise_all(
    list(
      Mean = ~ mean(., na.rm = TRUE),
      NA_Count = ~ sum(is.na(.)),
      Proportion_NA = ~ mean(is.na(.))
    )
  )

df_n_unit = df %>%
  group_by(Unit) %>%
  summarise(Observations = n())

df_by_unit <- left_join(df_by_unit, df_n_unit, by = "Unit")

# Print the joined dataframe
df_by_unit
## # A tibble: 6 × 20
##   Unit  Flu Vaccine screening co…¹ Flu Vaccine Informat…² Documentation of Flu…³
##   <chr>                      <dbl>                  <dbl>                  <dbl>
## 1 A                          0.980                  0.882                  0.9  
## 2 B                          0.6                    1                      0.333
## 3 C                          0.586                  0.923                  0.571
## 4 D                          1                      0.905                  0.571
## 5 E                          1                      1                      1    
## 6 G                          1                      1                      1    
## # ℹ abbreviated names: ¹​`Flu Vaccine screening completed correctly._Mean`,
## #   ²​`Flu Vaccine Information Sheet (VIS) provided to the patient._Mean`,
## #   ³​`Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR)._Mean`
## # ℹ 16 more variables:
## #   `Pneumovax Vaccine screening completed correctly._Mean` <dbl>,
## #   `Pneumovax Vaccine Information Sheet (VIS) provided to the patient._Mean` <dbl>,
## #   `Documentation of Pneumovax vaccine administration is recorded on the Medication Administration Record (MAR)._Mean` <dbl>, …

Summary: Flu Vaccine screening completed correctly

df1 <- df_by_unit %>%
  select(Unit, 
         Observations, 
         `Flu Vaccine screening completed correctly._Mean`,
         `Flu Vaccine screening completed correctly._NA_Count`,
         `Flu Vaccine screening completed correctly._Proportion_NA`)

colnames(df1) = c('Unit','Observations','Mean','n_na','proportion_na')

df1$color <- ifelse(df1$Mean < 0.9, "red", "grey")

df1
## # A tibble: 6 × 6
##   Unit  Observations  Mean  n_na proportion_na color
##   <chr>        <int> <dbl> <int>         <dbl> <chr>
## 1 A               52 0.980     3       0.0577  grey 
## 2 B               10 0.6       0       0       red  
## 3 C               88 0.586     1       0.0114  red  
## 4 D              114 1         1       0.00877 grey 
## 5 E                6 1         0       0       grey 
## 6 G                4 1         0       0       grey

Plotting df1:

ggplot(df1, aes(x = Unit, y = round(Mean * 100, 2), fill = color)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(round(Mean * 100, 2), "%"), fontface = "bold"), vjust = -0.5, size = 3, color = "black") +  # Add numerical values with percent signs
  scale_fill_identity() +
  geom_hline(yintercept = 90, linetype = "dotted") +
  geom_text(aes(x = Inf, y = 90, label = "Compliance Target"), hjust = 1, vjust = -0.5, color = "black") +  # Add "Compliance Target" text
  labs(x = "Unit", y = "Completion (%)", title = "Patients with Flu Vaccine Screening Completed Correctly by Unit") + # Modify the title
  theme_minimal() +
  theme(legend.position = "right") +
  guides(fill = guide_legend(title = "Color"))

Summary: Flu Vaccine Information Sheet (VIS) provided to the patient

df2 <- df_by_unit %>%
  select(Unit,
         Observations,
         `Flu Vaccine Information Sheet (VIS) provided to the patient._Mean`,
         `Flu Vaccine Information Sheet (VIS) provided to the patient._NA_Count`,
         `Flu Vaccine Information Sheet (VIS) provided to the patient._Proportion_NA`)

colnames(df2) = c('Unit','Observations','Mean','n_na','proportion_na')

df2$color <- ifelse(df2$Mean < 0.9, "red", "grey")

df2
## # A tibble: 6 × 6
##   Unit  Observations  Mean  n_na proportion_na color
##   <chr>        <int> <dbl> <int>         <dbl> <chr>
## 1 A               52 0.882    35         0.673 red  
## 2 B               10 1         7         0.7   grey 
## 3 C               88 0.923    49         0.557 grey 
## 4 D              114 0.905    72         0.632 grey 
## 5 E                6 1         4         0.667 grey 
## 6 G                4 1         0         0     grey

Plotting df2:

ggplot(df2, aes(x = Unit, y = round(Mean * 100, 2), fill = color)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(round(Mean * 100, 2), "%"), fontface = "bold"), vjust = -0.5, size = 3, color = "black") +  # Add numerical values with percent signs
  scale_fill_identity() +
  geom_hline(yintercept = 90, linetype = "dotted") +
  geom_text(aes(x = Inf, y = 90, label = "Compliance Target"), hjust = 1, vjust = -0.5, color = "black") +  # Add "Compliance Target" text
  labs(x = "Unit", y = "Completion (%)", title = "Flu Vaccine Information Sheet (VIS) Provided to the Patient by Unit") + # Modify the title
  theme_minimal() +
  theme(legend.position = "right") +
  guides(fill = guide_legend(title = "Color"))

Summary: Documentation of Flu vaccine administration is recorded

# Documentation of Flu vaccine administration is recorded
df3 <- df_by_unit %>%
  select(Unit,
         Observations,
         `Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR)._Mean`,
         `Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR)._NA_Count`,
         `Documentation of Flu vaccine administration is recorded on the Medication Administration Record (MAR)._Proportion_NA` )

colnames(df3) = c('Unit','Observations','Mean','n_na','proportion_na')

df3$color <- ifelse(df3$Mean < 0.9, "red", "grey")

df3
## # A tibble: 6 × 6
##   Unit  Observations  Mean  n_na proportion_na color
##   <chr>        <int> <dbl> <int>         <dbl> <chr>
## 1 A               52 0.9      42         0.808 grey 
## 2 B               10 0.333     7         0.7   red  
## 3 C               88 0.571    53         0.602 red  
## 4 D              114 0.571    86         0.754 red  
## 5 E                6 1         5         0.833 grey 
## 6 G                4 1         2         0.5   grey

Plotting df3:

ggplot(df3, aes(x = Unit, y = round(Mean * 100, 2), fill = color)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(round(Mean * 100, 2), "%"), fontface = "bold"), vjust = -0.5, size = 3, color = "black") +  # Add numerical values with percent signs
  scale_fill_identity() +
  geom_hline(yintercept = 90, linetype = "dotted") +
  geom_text(aes(x = Inf, y = 90, label = "Compliance Target"), hjust = 1, vjust = -0.5, color = "black") +  # Add "Compliance Target" text
  labs(x = "Unit", y = "Completion (%)", title = "Documentation of Flu Vaccine Administration is Recorded by Unit") + # Modify the title
  theme_minimal() +
  theme(legend.position = "right") +
  guides(fill = guide_legend(title = "Color"))

Summary: Pneumovax Vaccine screening completed correctly

# Pneumovax Vaccine screening completed correctly
df4 <- df_by_unit %>%
  select(Unit,
         Observations,
         `Pneumovax Vaccine screening completed correctly._Mean`,
         `Pneumovax Vaccine screening completed correctly._NA_Count`,
         `Pneumovax Vaccine screening completed correctly._Proportion_NA`)

colnames(df4) = c('Unit','Observations','Mean','n_na','proportion_na')

df4$color <- ifelse(df4$Mean < 0.9, "red", "grey")

df4
## # A tibble: 6 × 6
##   Unit  Observations  Mean  n_na proportion_na color
##   <chr>        <int> <dbl> <int>         <dbl> <chr>
## 1 A               52 0.885     0        0      red  
## 2 B               10 1         0        0      grey 
## 3 C               88 0.849     2        0.0227 red  
## 4 D              114 0.877     0        0      red  
## 5 E                6 1         0        0      grey 
## 6 G                4 1         0        0      grey

Plotting df4:

ggplot(df4, aes(x = Unit, y = round(Mean * 100, 2), fill = color)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(round(Mean * 100, 2), "%"), fontface = "bold"), vjust = -0.5, size = 3, color = "black") +  # Add numerical values with percent signs
  scale_fill_identity() +
  geom_hline(yintercept = 90, linetype = "dotted") +
  geom_text(aes(x = Inf, y = 90, label = "Compliance Target"), hjust = 1, vjust = -0.5, color = "black") +  # Add "Compliance Target" text
  labs(x = "Unit", y = "Completion (%)", title = "Pneumovax Vaccine Screening Completed Correctly by Unit") + # Modify the title
  theme_minimal() +
  theme(legend.position = "right") +
  guides(fill = guide_legend(title = "Color"))

Summary: Pneumovax Vaccine Information Sheet (VIS) provided to the patient

# Pneumovax Vaccine Information Sheet (VIS) provided to the patient
df5 <- df_by_unit %>%
  select(`Unit`,
         Observations,
         `Pneumovax Vaccine Information Sheet (VIS) provided to the patient._Mean`,
         `Pneumovax Vaccine Information Sheet (VIS) provided to the patient._NA_Count`,
         `Pneumovax Vaccine Information Sheet (VIS) provided to the patient._Proportion_NA`)

colnames(df5) = c('Unit','Observations','Mean','n_na','proportion_na')

df5$color <- ifelse(df5$Mean < 0.9, "red", "grey")

df5
## # A tibble: 6 × 6
##   Unit  Observations    Mean  n_na proportion_na color
##   <chr>        <int>   <dbl> <int>         <dbl> <chr>
## 1 A               52   0.818    41         0.788 red  
## 2 B               10   1         7         0.7   grey 
## 3 C               88   0.889    61         0.693 red  
## 4 D              114   0.870    91         0.798 red  
## 5 E                6 NaN         6         1     <NA> 
## 6 G                4   1         3         0.75  grey

Plotting df5:

ggplot(df5[df5$Unit != "E", ], aes(x = Unit, y = round(Mean * 100, 2), fill = color)) +
  geom_bar(stat = "identity") +
  geom_text(aes(label = paste0(round(Mean * 100, 2), "%"), fontface = "bold"), vjust = -0.5, size = 3, color = "black") +  # Add numerical values with percent signs
  scale_fill_identity() +
  geom_hline(yintercept = 90, linetype = "dotted") +
  geom_text(aes(x = Inf, y = 90, label = "Compliance Target"), hjust = 1, vjust = -0.5, color = "black") +  # Add "Compliance Target" text
  labs(x = "Unit", y = "Completion (%)", title = "Pneumovax Vaccine Information Sheet Provided to the Patient by Unit") + # Modify the title
  theme_minimal() +
  theme(legend.position = "right") +
  guides(fill = guide_legend(title = "Color"))