eds_scikit.structures.attributes
ATTRIBUTE_REGEX_PATTERNS
module-attribute
ATTRIBUTE_REGEX_PATTERNS = [{'attribute': 'IS_EMERGENCY', 'pattern': '\\bURG|\\bSAU\\b|\\bUHCD\\b|\\bZHTCD\\b', 'true_examples': ['URG', 'URGENCES', 'SAU'], 'false_examples': ['CHIRURGIE']}, {'attribute': 'IS_ICU', 'pattern': '\\bUSI|\\bREA[N\\s]|\\bREA\\b|\\bUSC\\b|SOINS.*INTENSIF|SURV.{0,15}CONT|\\bSI\\b|\\bSC\\b', 'true_examples': ['REA', 'REA NEURO', 'REANIMATION'], 'false_examples': ['CARREAU']}]
Default argument of func:~eds_scikit.structures.attributes.add_care_site_attributes
.
:meta private:
Examples:
::
ATTRIBUTE_REGEX_PATTERNS = [
{
# required elements: name of attribute and pattern of regular expression
"attribute": "IS_EMERGENCY",
"pattern": r"URG|SAU|UHCD|ZHTCD",
# optional elements: list of test strings to validate the regular expression
"true_examples": ["URG", "URGENCES", "SAU"],
"false_examples": ["CHIRURGIE"],
},
...
]
add_care_site_attributes
add_care_site_attributes(care_site: DataFrame, only_attributes: Optional[List[str]] = None, attribute_regex_patterns: Optional[List[str]] = None) -> DataFrame
Add boolean attributes as columns to care_site dataframe.
This algo applies simple regular expressions to the care_site_name
in order to compute boolean attributes of the care site.
Implemented attributes are:
IS_EMERGENCY
IS_ICU
In order to make the detection of attributes more robust, the
column care_site_name
is first transformed to a DESCRIPTION
.
This is done by func:~eds_scikit.structures.description.add_care_site_description
.
PARAMETER | DESCRIPTION |
---|---|
care_site |
TYPE:
|
only_attributes |
if only a subset of all possible attributes should be computed
TYPE:
|
attribute_regex_patterns |
If
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
care_site
|
same as input with additional columns corresponding to boolean attributes.
the column
TYPE:
|
Examples:
>>> care_site.head(2)
care_site_id, care_site_name
21, HOSP ACCUEIL URG PED (UF)
22, HOSP CHIRURGIE DIGESTIVE
23, HOSP PEDIATRIE GEN ET SAU
>>> care_site = add_care_site_attributes(care_site, only_attributes=["IS_EMERGENCY"])
>>> care_site.head(2)
care_site_id, care_site_name, DESCRIPTION, IS_EMERGENCY
21, HOSP ACCUEIL URG PED (UF),ACCUEIL URG PED,True
22, HOSP CHIRURGIE DIGESTIVE,CHIRURGIE DIGESTIVE,False
23, HOSP PEDIATRIE GEN ET SAU,PEDIATRIE GEN ET SAU,True
Specifying custom regular expressions. It is a good idea to provide true and false examples for each attribute. These examples will be tested against the provided regular expressions.
>>> my_attributes = [
{
"attribute": "IS_EMERGENCY",
"pattern": r"URG|SAU|UHCD|ZHTCD",
"true_examples": ["URG", "URGENCES", "SAU"],
"false_examples": ["CHIRURGIE"],
},
{
"attribute": "IS_ICU",
"pattern": r"REA|REANI",
"true_examples": ["REA", "REA NEURO", "REANIMATION"],
"false_examples": ["CARREAU"],
},
]
>>> care_site = add_care_site_attributes(care_site, attribute_regex_patterns=my_attributes)
Source code in eds_scikit/structures/attributes.py
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 95 96 97 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 141 142 143 144 145 146 147 148 149 |
|
get_parent_attributes
get_parent_attributes(care_site: DataFrame, only_attributes: Optional[List[str]] = None, version: Optional[str] = None, parent_type: str = 'Unité Fonctionnelle (UF)') -> DataFrame
Get all known attributes from parent care sites and propagates them to each child care site
PARAMETER | DESCRIPTION |
---|---|
care_site |
required columns:
TYPE:
|
only_attributes |
same as func:
TYPE:
|
version |
Optional version string for the care site hierarchy
TYPE:
|
parent_type |
Type of care site to consider as parent, by default "Unité Fonctionnelle (UF)".
Corresponds to the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
care_site_attributes
|
same index as input care_site. columns: care_site, is_emergency
TYPE:
|
Warnings
This algo requires that the care_site
dataframe contains
the parent care sites as well as the care sites
that you want to tag.
Examples:
>>> attributes = get_parent_attributes(care_site,
only_attributes=["IS_EMERGENCY"],
parent_type="Unité Fonctionnelle (UF)")
>>> attributes.head()
care_site_id, care_site_name, care_site_type_source_value, IS_EMERGENCY
92829 , ... , False
29820 , ... , True
Source code in eds_scikit/structures/attributes.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|