knitr::opts_chunk$set(fig.width=6, fig.height = 4)
medinetparser
is a package meant to facilitate analysis of schedules generated by the Medinet Scheduling system, developed by Medical Networks Scandinavia AB, for analysis in R, aiding scheduling and follow up. This project is in no way connected to the developers of Medinet.
Chances are you will already have finished installing the medinetparser
package, as you are reading this vignette. But just as a quick recap, this is how you install the package from GitHub.
install.packages('devtools', repos = 'https://cloud.r-project.org/')
library(devtools)
install_github('JonasEngstrom/medinetparser', build_vignettes = TRUE)
library(medinetparser)
Medinet Parser currently does not support scraping data directly from Medinet, as this would require handling login credentials. Therefore data must first be downloaded manually, by following the subsequent steps.
Go to the Medinet Website.
Log in.
If you work in several departments, you will be prompted to choose one at this point. If not, skip ahead to the next step.
Click Schema.
Make sure Schemavy is set to Vecka vs användare.
Choose the weeks you are interested in analyzing.
Use the web brower’s save command.
Save the page in HTML format. This will be your input file to Medinet Parser.
To load a Medinet schedule in R, use the function load_tidy_schedule()
. It takes a file path as an argument and returns a tibble.
example_schedule <- load_tidy_schedule('./medinetschedule.html')
The tibble can then be used with all the standard tidverse functions.
All of the examples below assumes that the tibble example_schedule
has been loaded using the load_tidy_schedule()
function.
library(ggplot2) library(lubridate) library(tidyverse)
To quickly get an overview of the distribution of shifts per doctor the tally_shifts()
function can be used to return a tally table.
example_schedule %>% tally_shifts()
To plot a bar graph essentially showing the same information as the tally table above but on a population level, the plot_shift_type_by_frequency()
function can be used. This function is likely more useful on a subset of the data.
example_schedule %>% filter(date %within% ('2022-03-01' %--% '2022-03-31'), doctor_name == 'Johansson, Karl') %>% plot_shift_type_by_frequency() + ggtitle('Shift Distribution for Dr. Karl Johansson')
Use the plot_shifts_per_doctor()
function to plot a stacked bar graph of the shift distribution of the different doctors compared to each other. Bars are stacked by type of shift and their length represents the total number of shifts worked by a doctor.
on_call_shifts <- c('Pjour', 'Mjour', 'Bjour') example_schedule %>% filter(shift_type %in% on_call_shifts) %>% plot_shifts_per_doctor() + ggtitle('On-Call Shifts Per Doctor')
Use the plot_difference_from_mean()
to plot the number of shifts a doctor works as a difference from the mean number of shifts all doctors work. The length of the bars represent the shift number delta between the number of shifts worked by a doctor and the arithmetic mean number of shifts worked by all doctors.
time_off <- c('Ej J', 'Tjl', 'JK', 'Övr', 'FL', 'Utb', 'Rnd') example_schedule %>% filter(wday(date, week_start = 1) %in% c(6,7), !(shift_type %in% time_off)) %>% plot_difference_from_mean() + ggtitle('Difference from Mean Number of Weekend Shifts')
The function get_min_max_dates()
is mainly meant to be used for generating titles in the plotting functions in the package, but could pontentially be used in generating reports et cetera. It is therefore described at the end of this vignette.
example_schedule %>% get_min_max_dates()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.