ICU - Admissions

This section shows how to use the admissions functionality of Episuite. The class ICUAdmissions holds a admission series that is indexed by day and number of admissions on that dat.


In the example below, we will use a sample dataset that comes embedded in Episuite with real data from the SARS-CoV-2 outbreak in south of Brazil. This dataset can be accessed using the admissions_sample() function from the data module.

See also


Documentation of the module.


Documentation of the module.

from matplotlib import pyplot as plt
from import ICUAdmissions
from episuite import data

Load the sample data and aggregate by day

First we need to load a sample dataset.

sample_data = data.admissions_sample()
0 2020-06-17 2020-08-03 RECOVERY
1 2020-06-11 2020-06-21 DEATH
2 2020-07-12 2020-08-02 DEATH
3 2020-06-25 2020-07-31 DEATH
4 2020-07-24 2020-08-16 DEATH
(4538, 3)
# Filter for only RECOVERY or DEATH outcomes
sample_data = sample_data[sample_data["OUTCOME"].isin(["RECOVERY", "DEATH"])]
# Build an aggregation by day
sample_data_admissions = sample_data.groupby("DATE_START").size().sort_index()
# Resample the DataFrame per day and fill dates without admissions with zeros
sample_data_admissions = sample_data_admissions.resample("D").sum().fillna(0)
2020-03-18    2
2020-03-19    1
2020-03-20    2
2020-03-21    1
2020-03-22    2
Freq: D, dtype: int64

As you can see, we now have a series of admissions per day indexed by DATE_START.

Build the admissions object

Here we are going to build the admissions object. This class accepts any series, therefore it can be reused for other admissions such as regular hospitalizations and not only ICU.

admissions = ICUAdmissions(sample_data_admissions)
ICUAdmissions[Entries=352, Total Admissions=4431]>

Check for data consistency

One of the major difficulties when dealing with real data is that it often comes with some issues such as duplicated dates, admissions with gaps, non-monotonicity, etc. This method below called sanity_check() will check for these issues and raise an exception in case of failure.



fig = plt.figure(figsize=(10, 4))

Now that we have the admissions, we can proceed by using it for simulation or modelling purposes.