@concept_checker(concepts=["IS_EMERGENCY", "EMERGENCY_TYPE"])
def from_mapping(
care_site: DataFrame,
version: Optional[str] = None,
) -> DataFrame:
"""This algo uses a labelled list of 201 emergency care sites.
Those care sites were extracted and verified by Ariel COHEN,
Judith LEBLANC, and an ER doctor validated them.
Those emergency care sites are further divised into different categories,
as defined in the concept 'EMERGENCY_TYPE'.
The different categories are:
- Urgences spécialisées
- UHCD + Post-urgences
- Urgences pédiatriques
- Urgences générales adulte
- Consultation urgences
- SAMU / SMUR
See the dataset [here](/datasets/care-site-emergency)
Parameters
----------
care_site: DataFrame
Should at least contains the `care_site_source_value` column
version: Optional[str]
Optional version string for the mapping
Returns
-------
care_site: DataFrame
Dataframe with 2 added columns corresponding to the following concepts:
- `"IS_EMERGENCY"`
- `"EMERGENCY_TYPE"`
"""
function_name = "get_care_site_emergency_mapping"
if version is not None:
function_name += f".{version}"
mapping = registry.get("data", function_name=function_name)()
# Getting the right framework
fw = framework.get_framework(care_site)
mapping = framework.to(fw, mapping)
care_site = care_site.merge(
mapping,
how="left",
on="care_site_source_value",
)
care_site["IS_EMERGENCY"] = care_site["EMERGENCY_TYPE"].notna()
return care_site