Thursday, March 31, 2016

taskscheduleR: Scheduling R script via R and Rstudio

Scheduling R script via R / Rstudio

Scheduling R script via R.?

taskscheduleR - It allow users to automate R script on specific timepoints from R / Rstudio itself. No need of windows Task scheduling or Linux Cron to automate R script.

Installation of taskscheduleR

devtools::install_github("jwijffels/taskscheduleR")

If you want the RStudio add-in to work, also install miniUI and shiny

install.packages('miniUI') install.packages('shiny')
Open Rscheduler window

Click the Addins menu added in Rstudio

You can also open Rscheuler window in Browser by

hit below command in R terminal,
taskscheduleR:::taskschedulerAddin()

you will notify with "Listening on http://127.0.0.1:5499 " and the same can be viewed in browser


Friday, March 25, 2016

Analyze Data to Identify type of Readmissions using PostgreSQL

Analyze Data to Identify Causes of Readmissions using PostgreSQL

What is patient readmission

Normally Readmission is - if a patient returns within 30 days of previous discharge.

reason for readmission

Multiple factors contribute to avoidable hospital readmission: they may result from poor quality care or from poor transitions between different providers and care settings.

The problem of readmission to the hospital is receiving increased attention as a potential way to address problems in quality of care, cost of care, and care transition

readmission table structure

After cleansed and identified the required attribute to get the readmission details, my entity model look like this

patient_id disease adm_date dis_date
1069 Oncology 6/17/2013 6:51 6/21/2013 7:15
1078 Neuro 7/18/2013 12:10 7/20/2013 08:12
1082 Ortho 7/19/2013 12:10 7/22/2013 08:12
1085 Cardiothor 8/25/2013 12:10 8/27/2013 08:12
1085 Cardiothor 9/13/2013 12:10 9/16/2013 08:12

Now, we have to write a query to get the list of readmission details. Condition is, current admit date is between the last discharge date and 30 days from then.

readmission query in postgresql

Select count(*) "Readmission Count", disease
From readmission_view v
Where Exists
(
Select * From readmission_view
Where patient_id = v.patient_id and
v.adm_date between dis_date and dis_date + 30
)
group by disease
order by count(*)

readmission result

disease Readmission Count
Ortho 878
Neuro 567
Oncology 155
Using the result optioned from the query to find the percentage of patient readmission. based on the result need extra care on the disease.