Skip to content

eds_scikit.icu.icu_visit

tag_icu_visit

tag_icu_visit(visit_detail: DataFrame, care_site: DataFrame, algo: str = 'from_authorisation_type') -> DataFrame

Tag care_sites that correspond to ICU units.

The tagging is done by adding a "IS_ICU" column to the provided DataFrame.

It works by tagging each visit detail's care site.

PARAMETER DESCRIPTION
visit_detail

TYPE: DataFrame

care_site

TYPE: DataFrame

algo

Possible values are:

TYPE: str DEFAULT: 'from_authorisation_type'

RETURNS DESCRIPTION
visit_detail

Dataframe with 1 added column corresponding to the following concept:

  • "IS_ICU"

TYPE: DataFrame

Source code in eds_scikit/icu/icu_visit.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@algo_checker(algos=ALGOS)
def tag_icu_visit(
    visit_detail: DataFrame,
    care_site: DataFrame,
    algo: str = "from_authorisation_type",
) -> DataFrame:
    """Tag care_sites that correspond to **ICU units**.

    The tagging is done by adding a `"IS_ICU"` column to the provided DataFrame.

    It works by [tagging each visit detail's care site][eds_scikit.icu.icu_care_site.tag_icu_care_site].

    Parameters
    ----------
    visit_detail: DataFrame
    care_site: DataFrame
    algo: str
        Possible values are:

        - [`"from_authorisation_type"`][eds_scikit.icu.icu_care_site.from_authorisation_type]
        - [`"from_regex_on_care_site_description"`][eds_scikit.icu.icu_care_site.from_regex_on_care_site_description]

    Returns
    -------
    visit_detail: DataFrame
        Dataframe with 1 added column corresponding to the following concept:

        - `"IS_ICU"`

    """
    tagged_care_site = tag_icu_care_site(care_site, algo=algo)

    return visit_detail.merge(
        tagged_care_site[["care_site_id", "IS_ICU"]], on="care_site_id", how="left"
    )
Back to top