Contents

Volumes Data Analysis Using SQL

Contents

Knowing our population is important for further development and the improvement of care. Looking at volumes helps us understand the flow and activity of patients in our healthcare institutions.

Number of encounters occurred in 2019.

1
2
3
4
SELECT COUNT(*)
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'

/images/posts/sql_vol/sqlVol.png


Identify more specific patients.

Let’s use the DISTINCT function to extract from the encounters column.

1
2
3
4
SELECT DISTINCT PATIENT
FROM encounters
WHERE START >= '2019-01-01'
AND START < '2020-01-01'

/images/posts/sql_vol/sqlVol2.png
Shows a list of distinct patients, 910 rows returned.

If we wanted the total number returned, use the COUNT function:

1
2
3
4
SELECT COUNT(DISTINCT patient)
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'

/images/posts/sql_vol/sqlVol3.png


Identify the different encounters.

1
2
3
4
SELECT DISTINCT encounterclass
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'

/images/posts/sql_vol/sqlVol4.png


Return the total number of encounters, use the COUNT funtion:
1
2
3
4
SELECT COUNT(DISTINCT encounterclass)
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'

/images/posts/sql_vol/sqlVol5.png


Let's specify an ecounter that we want to extract:
1
2
3
4
SELECT * FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'
and encounterclass = 'ambulatory'

/images/posts/sql_vol/sqlVol6.png


Return the total number of encounters, use the COUNT funtion:
1
2
3
4
5
SELECT COUNT(*)
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'
and encounterclass = 'ambulatory'

/images/posts/sql_vol/sqlVol7.png


Extract the inpatient class only:
1
2
3
4
SELECT * FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'
and encounterclass = 'inpatient'

/images/posts/sql_vol/sqlVol8.png


If you want to get the total number of encounters in sepcific departments:
1
2
3
4
5
SELECT COUNT(*)
FROM ENCOUNTERS
WHERE START >= '2019-01-01'
AND START < '2020-01-01'
and encounterclass IN ('ambulatory', 'wellness', 'outpatient', 'urgentcare')

/images/posts/sql_vol/sqlVol9.png



Dataset source: https://synthetichealth.github.io/synthea/

Github repository: https://github.com/ib99