API Reference

class dea.encounter.Encounter(id: int, dynamic: pandas.DataFrame, static: pandas.DataFrame, processed: pandas.DataFrame, root: Path)

Bases: object

Encounter data class.

This basically stores all relevant information for a single visit of a patient to the hospital. You can add more fields if you need them, but make sure to update the save and load methods.

delete_extra()

This method is deletes all but dynamic, static and id.

dynamic: pandas.DataFrame
static from_path(path: Path, static: pandas.DataFrame) Encounter

Loads the encounter from disk. Reads every csv file in the passed folder and adds it to the encounter.

static from_path_single(payload: tuple[pathlib.Path, pandas.DataFrame]) Encounter

Wrapper for the from_path method to be used with multiprocessing.

id: int
pickle(path: Path | None = None)

Saves the encounter to disk as pickle file. Used for HPC interaction mostly.

preprocess()

Preprocessing is executed at loadtime and should be used to get the data in workable format. This includes mostly resampling, filtering and datatype fixing that can not or should not be saved in the source data.

process()

This method is called after the cohort is loaded and can be used to calculate additional information. This is the place to add your own code.

processed: pandas.DataFrame
root: Path
save(path: Path | None = None)

Saves the encounter to disk. Extend this methods for every information you want store at the encounter level. Usually this method is called through the dea.cohort.Cohort.save() method.

static: pandas.DataFrame
class dea.cohort.Cohort(root: Path | None = None, hpc_bridge=None)

Bases: object

Cohort class encompasses multiple encounters..

delete_extra()

This method deletes all extra information from the encounters.

static from_path(path: str, hpc_bridge=None) Cohort

Loads the data from the source and stores all information found.

get_processed() pandas.DataFrame

Returns all encounters that have already been processed.

preprocess()

Executes preprocessing on all Encounters in the cohort. Extend this method for preprocessing that requires cohort-level information, or use dea.encounter.Encounter.preprocess(). This method additionally calls dea.encounter.Encounter.preprocess() on every encounter in the cohort.

process(safe: bool = True)

This methods executes dea.encounter.Encounter.process() on all encounters in the cohort. If a hpc_bridge is defined, it will be used to query the jobs for HPC. Returns a message for the DEA Interface to be displayed.

property processed
save(path: str | None = None)

Saves the cohort to csv folder structure. Extend this method for every information you want store at the encounter level. This method additionally calls dea.encounter.Encounter.save() on every encounter in the cohort.

to_pandas() pandas.DataFrame

Returns a concatenated dataframe of the dynamic data of all encounters.

dea.app.delete_encounter(id)

Flask Route for “/delete/<id>”.

Redirects to the index page for cohort selection if no cohort is currently selected.

Deletes all extra data for an individual encounter.

Returns:

Redirects to /encounter_list

dea.app.delete_processed()
dea.app.encounter_list()

Flask Route for “/encounter_list”.

Redirects to the index page for cohort selection if no cohort is currently selected.

Otherwise shows a list of encounters in the current cohort.

Custom filters can be added here, as well as additional information that should be shown, such as length of stay or age

Returns:

Renders the encounter_list.html template

dea.app.filter_many_measurements(e)

Filter encounters with more than 100 measurements

dea.app.filter_severe_ards(e)

Filter encounters with a Horovitz of less than 100

dea.app.filter_short_stay(e)

Filter encounters with a length of stay of less than 3 days

dea.app.handle_shutdown(signum, frame)
dea.app.index()

Flask Route for “/”.

Entrypoint for the webserver. Lists all available Cohorts as defined in app.py. Renders a cohort-selection screen.

Returns:

Renders the index.html template

dea.app.overview()

Flask Route for “/overview”.

Redirects to the index page for cohort selection if no cohort is currently selected.

Otherwise renders the cohort overview.

You can add custom plots for the cohort.

Returns:

Renders the overview.html template

dea.app.plot_cohort_hist()

Plot a histogram of the cohort’s length of stay

dea.app.process()
dea.app.process_encounter(id)

Flask Route for “/process/<id>”.

Redirects to the index page for cohort selection if no cohort is currently selected.

Processes an individual encounter.

Returns:

Redirects to /encounter/<id>

dea.app.reload()

Reloads the cohort. Useful for fetching updates from the HPC calculations.

dea.app.route_encounter(id)

Flask Route for “/encounter/<id>”.

Redirects to the index page for cohort selection if no cohort is currently selected.

Custom plots for individual encounters can be added here. Custom computations can be executed on encounter level here as well.

Returns:

Renders the encounter.html template

dea.app.search()

Flask Route for “/search”.

Used to quickly navigate to individual encounters.

Returns:

Redirects to the searched encounter if available, or to the /overview page if an error occurs.

dea.app.set_cohort()

Flask Route for “/set_cohort”.

Run when a cohort is selected either on the starting page, or later on through the menu.

Internally changes the COHORT and loads the relevant data into COHORT.

Returns:

Redirects to /overview

dea.app.set_filters()

Currently not used.