Skip to content

eds_scikit.icu.icu_care_site

tag_icu_care_site

tag_icu_care_site(care_site: DataFrame, algo: str = 'from_mapping') -> DataFrame

Tag care sites that correspond to ICU units.

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

PARAMETER DESCRIPTION
care_site

TYPE: DataFrame

algo

Possible values are:

TYPE: str DEFAULT: 'from_mapping'

RETURNS DESCRIPTION
care_site

Dataframe with 1 added column corresponding to the following concept:

  • "IS_ICU"

TYPE: DataFrame

Source code in eds_scikit/icu/icu_care_site.py
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
@algo_checker(algos=ALGOS)
def tag_icu_care_site(
    care_site: DataFrame,
    algo: str = "from_mapping",
) -> DataFrame:
    """Tag care sites that correspond to **ICU units**.

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

    Parameters
    ----------
    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
    -------
    care_site: DataFrame
        Dataframe with 1 added column corresponding to the following concept:

        - `"IS_ICU"`
    """
    if algo == "from_authorisation_type":
        return from_authorisation_type(care_site)
    elif algo == "from_regex_on_care_site_description":
        return from_regex_on_care_site_description(care_site)

from_authorisation_type

from_authorisation_type(care_site: DataFrame) -> DataFrame

This algo uses the care_site.place_of_service_source_value columns to retrieve Intensive Care Units.

The following values are used to tag a care site as ICU:

  • "REA PED"
  • "REA"
  • "REA ADULTE"
  • "REA NEONAT"
  • "USI"
  • "USI ADULTE"
  • "USI NEONAT"
  • "SC PED"
  • "SC"
  • "SC ADULTE"
PARAMETER DESCRIPTION
care_site

Should at least contains the place_of_service_source_value column

TYPE: DataFrame

RETURNS DESCRIPTION
care_site

Dataframe with 1 added column corresponding to the following concepts:

  • "IS_ICU"

TYPE: DataFrame

Source code in eds_scikit/icu/icu_care_site.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
@concept_checker(concepts=["IS_ICU"])
def from_authorisation_type(care_site: DataFrame) -> DataFrame:
    """This algo uses the `care_site.place_of_service_source_value` columns
    to retrieve Intensive Care Units.

    The following values are used to tag a care site as ICU:

    - `"REA PED"`
    - `"REA"`
    - `"REA ADULTE"`
    - `"REA NEONAT"`
    - `"USI"`
    - `"USI ADULTE"`
    - `"USI NEONAT"`
    - `"SC PED"`
    - `"SC"`
    - `"SC ADULTE"`

    Parameters
    ----------
    care_site: DataFrame
        Should at least contains the `place_of_service_source_value` column

    Returns
    -------
    care_site: DataFrame
        Dataframe with 1 added column corresponding to the following concepts:

        - `"IS_ICU"`

    """

    icu_units = set(
        [
            "REA PED",
            "USI",
            "SC PED",
            "SC",
            "REA",
            "SC ADULTE",
            "USI ADULTE",
            "REA ADULTE",
            "USI NEONAT",
            "REA NEONAT",
        ]
    )

    care_site["IS_ICU"] = care_site["place_of_service_source_value"].isin(icu_units)

    return care_site

from_regex_on_care_site_description

from_regex_on_care_site_description(care_site: DataFrame, subset_care_site_type_source_value: Union[list, set] = {'UDS'}) -> DataFrame

Use regular expressions on care_site_name to decide if it an ICU care site.

This relies on this function. The regular expression used to detect ICU is r"USI|REA[N\s]|REA|USC|SOINS.*INTENSIF|SURV.{0,15}CONT|SI|SC".

Keeping only 'UDS'

At AP-HP, all ICU are UDS (Unité De Soins). Therefore, this function filters care sites by default to only keep UDS.

PARAMETER DESCRIPTION
care_site

Should at least contains the care_site_name and care_site_type_source_value columns

TYPE: DataFrame

subset_care_site_type_source_value

Acceptable values for care_site_type_source_value

TYPE: Union[list, set] DEFAULT: {'UDS'}

RETURNS DESCRIPTION
care_site

Dataframe with 1 added column corresponding to the following concept:

  • "IS_ICU"

TYPE: DataFrame

Source code in eds_scikit/icu/icu_care_site.py
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def from_regex_on_care_site_description(
    care_site: DataFrame, subset_care_site_type_source_value: Union[list, set] = {"UDS"}
) -> DataFrame:
    """Use regular expressions on `care_site_name` to decide if it an ICU care site.

    This relies on [this function][eds_scikit.structures.attributes.add_care_site_attributes].
    The regular expression used to detect ICU is
    `r"\bUSI|\bREA[N\s]|\bREA\b|\bUSC\b|SOINS.*INTENSIF|SURV.{0,15}CONT|\bSI\b|\bSC\b"`.

    !!! aphp "Keeping only 'UDS'"
         At AP-HP, all ICU are **UDS** (*Unité De Soins*).
         Therefore, this function filters care sites by default to only keep UDS.

    Parameters
    ----------
    care_site: DataFrame
        Should at least contains the `care_site_name` and `care_site_type_source_value` columns
    subset_care_site_type_source_value: Union[list, set]
        Acceptable values for `care_site_type_source_value`

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

        - `"IS_ICU"`

    """  # noqa

    care_site = attributes.add_care_site_attributes(
        care_site, only_attributes=["IS_ICU"]
    )

    # Filtering matches

    if subset_care_site_type_source_value:
        care_site["IS_ICU"] = care_site["IS_ICU"] & (
            care_site.care_site_type_source_value.isin(
                subset_care_site_type_source_value
            )
        )

    return care_site
Back to top