OSCAR EMR is a Java/MySQL-based open-source EMR system for Canadian primary care physicians. Because of the widespread use of OSCAR in various care settings, statistical analysis, and visualization of the EMR data stored in OSCAR is a common use case. R has built in libraries for importing data from MySQL into the native data frames. Once imported, native functions of R can be leveraged for cleaning, analyzing, visualizing and reporting. Here is the simple code to import data from a backend MySQL database to R. Would you be interested in setting up an R script repository for common analytics use cases for OSCAR EMR?

# By Bell Eapen. Visit http://nuchange.ca for details.
# May 20, 2016
# -------------------------------------------------------
# load Libraries (Install libraries if required)
library(DBI)
library(RMySQL)

# Connect to Oscar database (substitute database credentials as needed)
con <-  dbConnect(RMySQL::MySQL(), username = "oscar", password = "oscar", host = "192.168.0.250", port = 3306, dbname = "oscar_test")

# Run an SQL query
oscar <- dbGetQuery(con, "SELECT * FROM batchEligibility WHERE responseCode >5 AND responseCode < 60")

head(oscar)

# It's polite to let the database know when you're done
dbDisconnect(con)
#> [1] TRUE

Here is a script to install OSCAR and R server in your laptop.

Bell Eapen
Follow Me