top of page
  • Writer's pictureBryan Eckard

A Healthcare Analysis with SQL


A Look into what Factors may Affect Hospital Stays


Overview

Having been in and around the healthcare industry for 10+ years, I understand the need for hospitals to be able to reduce patient stays as much as possible. If patients take up beds with long stays, it makes it less likely that the hospital can take in new patients. This creates backups in emergency rooms where patients receive less individualized care a lot of the time, or results in patients needing to be transferred to other hospitals.


This analysis focused mainly on lab procedures and amount of medication and how they affect length of stay and or readmittance. Some of the insights I was able to gain were:

  • The majority of patients stay less than 5 days.

  • When lab procedures exceed 55, the avg length of stay is greater than 5 days.

  • In a list of top 50 patients with the most medications the majority had over 55 lab procedures.


The Data

The original dataset can be found on kaggle at the following link: Prediction on Hospital Readmission | Kaggle .


This data was originally used for a research article analyzing A1c measurements and readmission rates. The article can be found by following the link to kaggle and locating it under the data sources. The dataset was modified into two tables for educational purposes during this analysis: a demographics table and a table with specific measurements.


The Analysis

To begin, I created a crude histogram in SQL using the RPAD() function in order to get an idea of the distribution of the length of time spent in the hospital.


This showed that the vast majority of patients are discharged under 5 days, but the most patients stayed for 3 days.



To understand what may be causing longer stays, I looked at the number of lab procedures ordered. I used a CASE WHEN statement to create 3 ranges for the number of lab procedures: less than 25, "few"; 25 to 54, "average"; and greater than 55 "many." I then compared these ranges to the average time patients spent in the hospital.



As you can see above, the average time spent in the hospital for the "many" category is about 5.7 days. The dataset did not specify what types of lab procedures were performed. Certain lab procedures may take longer to get results which may cause a delay in a patient getting discharged sooner.


Finally, I looked at the number of medications a patient has and the number of lab procedures, and whether it led to them being readmitted. This was done using the CONCAT statement and creating a written summary for each patient.



In the above summaries you can see that, for patients in the top 50 for medications, all their lab procedure numbers would put them at least in the "average" category and most in the "many" category. This means that the majority of these patients would have had stays of at least 5 days. One reason for patients with a lot of medication needing more lab procedures may be so their levels of medication can be monitored. Another could be to see if the medication is effective at treating what it should be.


The other part of this section was to see if these numbers affected readmittance. In the top 50, the patient readmittance was almost even. So, this sample is likely not enough to determine correlation with medications and/or lab procedures.


Final Thoughts

Despite what some people may think, hospitals do not want to keep patients longer than necessary. This would affect their ability to take in new patients that may need more critical care. While most patients stay around 3 days, if their number of lab procedures increases above 55, they stay an average of at least 5 days. Also, if they have numerous medications, they appear likely to need more lab procedures. This could be for various reasons and this dataset did not provide the types of lab procedures conducted. To conclude, unnecessary lab procedures should be limited as one way to help reduce length of patient stays in the hospital.


Thank you for reading! If you have any questions, feel free to comment below, reach out at my email (ch13f_48@zoho.com), or connect with me on LinkedIn Bryan Eckard.

30 views0 comments

Recent Posts

See All
bottom of page