Kela corona indicators and a web app on reimbursed medicine consumption

Categories: open data

The virus has troubled the world the whole year and does not seem to cease soon. There were plenty of Corona related dashboards and visualizations around in April/May, but it seems that the buzz has calmed down a bit. I bloggerd (in Finnish) about corona data api of Finnish Institute for Health and Welfare in March published a daily updating dashboard SARS-Cov-2 Timeline Trajectories: Health Districts in Finland based on their reliable api.

Corona has also affected what I do at work and we have created together with colleagues two separate resources for tracking the effect of corona on Kela benefits.

koronamittarit.kela.fi (corona indicators) provides data and analysis on several Kela benefits at daily, weekly and monthly resolutions in terms of number of applications, number of recipients and on the performance of Kela customer service. Site is refreshed every weekday at 10am.

Purchased prescription medicines in Finland- web app provides a dynamic access to information on reimbursable prescription medicines in terms of costs, number of purchases and number of patients on a weekly basis in 2019 and 2020 at the national level as well as health district level.

Both application provide open data in addition to their simplistic analysis. Data on corona indicators is documented on the website (in Finnish only) and can be doanloaded from Github. Data from medicine app can be accessed also at Github.

There are examples on how to get started with the data both about corona indicators and medicine data. The easiest way to get started is to create an account in rstudio.cloud, copy the code snippets and begin to wonder! Below is one more example!

library(dplyr)
library(readr)
library(forcats)
cols(
  etuus = col_character(),
  vuosi = col_integer(),
  aikatyyppi = col_character(),
  kuukausi = col_integer(),
  viikko = col_integer(),
  paiva = col_date(),
  viikonpaiva = col_character(),
  alue = col_character(),
  ikaluokka = col_character(),
  sukupuoli = col_character(),
  saapuneet_hakemukset = col_double(),
  updated = col_datetime()
) -> data_cols

dat <- readr::read_csv("https://raw.githubusercontent.com/kelaresearchandanalytics/koronamittarit/master/docs/data/data_etuudet.csv", 
                       col_types = data_cols) %>% 
  # releveloidaan ikäluokka
  mutate(ikaluokka = factor(ikaluokka),
         ikaluokka = fct_relevel(ikaluokka, c("kaikki","alle 25"))) %>% 
  # Etuuksien järjestys
  mutate(etuus = factor(etuus, levels = c("Työttömyysturva",
                                          "Yrittäjien työmarkkinatuki",
                                          "Yleinen asumistuki", 
                                          "Perustoimeentulotuki",
                                          "Sairauspäiväraha",
                                          "Tartuntatautipäiväraha",
                                          "Epidemiatuki")),
         vuosi = factor(vuosi)) %>% 
  arrange(etuus,viikko,paiva)
head(dat)
## # A tibble: 6 x 19
##   etuus vuosi aikatyyppi kuukausi viikko paiva      viikonpaiva alue  ikaluokka
##   <fct> <fct> <chr>         <int>  <int> <date>     <chr>       <chr> <fct>    
## 1 Työt… 2020  paiva             1      1 2020-01-01 keskiviikko Koko… kaikki   
## 2 Työt… 2020  paiva             1      1 2020-01-02 torstai     Koko… kaikki   
## 3 Työt… 2020  paiva             1      1 2020-01-03 perjantai   Koko… kaikki   
## 4 Työt… 2020  paiva             1      1 2020-01-04 lauantai    Koko… kaikki   
## 5 Työt… 2020  paiva             1      1 2020-01-05 sunnuntai   Koko… kaikki   
## 6 Työt… 2019  viikko           NA      1 NA         <NA>        Koko… kaikki   
## # … with 10 more variables: sukupuoli <chr>, saapuneet_hakemukset <dbl>,
## #   data <chr>, saajat_kaikki <lgl>, saajat_uudet <lgl>,
## #   saajakotitaloudet_kaikki <lgl>, saajakotitaloudet_uudet <lgl>,
## #   saajaruokakunnat_kaikki <lgl>, saajaruokakunnat_uudet <lgl>, updated <dttm>
levels(dat$etuus)[levels(dat$etuus) == "Työttömyysturva"] <- "Unemployment benefit"
levels(dat$etuus)[levels(dat$etuus) == "Yrittäjien työmarkkinatuki"] <- "Unemployment benefit for self-employed"
levels(dat$etuus)[levels(dat$etuus) == "Yleinen asumistuki"] <- "Housing benefit"
levels(dat$etuus)[levels(dat$etuus) == "Perustoimeentulotuki"] <- "Social assistance"
levels(dat$etuus)[levels(dat$etuus) == "Sairauspäiväraha"] <- "Sickness allowance"
levels(dat$etuus)[levels(dat$etuus) == "Tartuntatautipäiväraha"] <- "Infectious disease allowance"
levels(dat$etuus)[levels(dat$etuus) == "Epidemiatuki"] <- "Temporary compensation due to an epidemic outbreak for basic social assistance clients"



library(ggplot2)
datplot <- dat %>% 
  dplyr::filter(aikatyyppi == "viikko",
         ikaluokka == "kaikki",
         sukupuoli == "kaikki",
         alue == "Koko Suomi") %>% 
  mutate(viikko = as.integer(viikko))

ggplot(datplot, 
       aes(x = viikko, 
           y = saapuneet_hakemukset, 
           color = vuosi, 
           fill = vuosi)) +
  geom_line() +
  geom_point(shape = 21, color = "white", size = 1.6,  show.legend = FALSE) +
  facet_wrap(~etuus, ncol = 1, scales = "free_y") +
  scale_x_continuous(breaks = 1:max(datplot$viikko)) +
        labs(fill = NULL, 
             color = NULL, 
             y = NULL,
             title = "Applications per week",
             subtitle = "number of applications received at Kela per week",
             x = "Viikko") +
        scale_fill_manual(values = c("#3F679F","#F15B23")) +
        scale_color_manual(values = c("#3F679F","#F15B23")) +
  theme_light() +
        theme(legend.position = "right", 
              legend.direction = "vertical",
              panel.grid.minor = element_blank()) +
        scale_y_continuous(labels = function(x) format(x, big.mark = " ",
                                                       scientific = FALSE),
                           limits = c(0,NA))

See also