Skip to content

edsnlp.pipes.ner.frailty.mobility_status.factory

create_component = registry.factory.register('eds.mobility_status', assigns=['doc.ents', 'doc.spans'])(MobilityMatcher) module-attribute [source]

The eds.mobility_status pipeline component extracts mentions of the mobility status.

Details of the used patterns
# fmt: off
from ..utils import make_assign_regex, make_status_assign, normalize_space_characters

healthy = dict(
    source="healthy",
    regex=[
        "autonomie motrice",
        "sort dans le jardin",
        "sort tous les jours",
        "sort regulierement",
        "se verticalise",
        "activite physique quotidienne",
    ],
    regex_attr="NORM",
)
severe = dict(
    source="severe",
    regex=[
        "lit medicalise",
        "grabataire",
        "alitement",
        "leve malade",
        r"\balitee?\b",
        r"pose de ridelles",
        "chaise roulante",
        "fauteuil roulant",
    ],
    regex_attr="NORM",
)
altered = dict(
    source="altered",
    regex=[
        r"troubles? de l'equilibre",
        r"syndromes? extra(?:[\s-])?pyramida(?:l|ux)",
        r"signes? extra(?:[\s-])?pyramida(?:l|ux)",
        r"syndromes? parkinsonn?iens?",
        "fonte musculaire",
        "sarcopenie",
    ],
    regex_attr="NORM",
)

sarcopenia = dict(
    source="altered_sarcopenia",
    regex=["sarcopenie"],
    regex_attr="NORM",
    assign=dict(
        name="severe",
        regex=make_assign_regex(["severe"]),
        window=2,
    ),
)

altered_equilibrium = dict(
    source="altered_equilibrium",
    regex=[
        "desequilibre",
    ],
    regex_attr="NORM",
    exclude=dict(
        regex=["profondeur", "diabete"],
        window=5,
    ),
)

reeducation = dict(
    source="other_reeducation",
    regex=["reeducation"],
    regex_attr="NORM",
    exclude=[
        dict(regex=["traitement", "vesicale?", "orthophonique"], window=5),
        dict(regex=["service", "unite", "medecine"], window=-10),
    ],
)

other = dict(
    source="other",
    regex=[
        "mobilite",
        r"appui (mono|uni)?podal",
        "locomotion",
        "test(?:ing)? moteur",
        "force motrice",
        "station debout",
        "station tandem",
        r"station (mono|uni)?podal",
        r"(?:sur le )plan (?:loco[\s-]?)?moteur",
        "travail sur l'equilibre",
        r"lutter contre l'enraidissement",
        "renforcement musculaire",
        "genee? dans son activite physique",
        "force de prehension",
        "vitesse de marche",
    ],
    regex_attr="NORM",
    assign=make_status_assign(-4, 4),
)

mild = dict(
    source="mild",
    regex=[
        r"\bcanne\b",
        r"syndrome post[\s-]chute",
        "deambulateur",
        r"rollator",
        r"\bchutes?( a repetitions?)?",
        "petit perimetre",
        "se mobilisant difficilement",
    ],
    regex_attr="NORM",
)

ralentissement = dict(
    source="mild_ralentissement",
    regex=["ralentissement"],
    assign=dict(
        name="complement",
        regex=make_assign_regex(["moteur", "marche"]),
        window=5,
        required=True,
    ),
)

WALKING_ALTERED_COMPLEMENTS = [
    r"(?<!un )\bpeu\b",
    "a petits? pas",
    "troubles?",
    "renforcer",
    "pertes? des capacites?",
    "incapable",
    "precaire",
    "instable",
    "instabilite",
    "limite",
    "difficile",
    "(?<!sans )difficultes?",
    "(?<!sans )aides?",
]

WALKING_HEALTHY_COMPLEMENTS = [
    "sans aides?(?: techniques?)?",
    "sans difficultes?",
    "sans canne",
    r"\bcapable",
    "amelioree?s?",
    r"amelior(?:er|ation)",
    "normale?",
    "normalement",
    "correcte?s?",
    "bon(?:ne)?",
    "reprise",
    r"\bstable",
    "seule?",
]

walking = dict(
    source="walking",
    regex=[r"\bmarche", "deplacement", r"equilibre\b", "se deplace"],
    regex_attr="NORM",
    assign=[
        dict(
            name="altered_complement",
            regex=make_assign_regex(WALKING_ALTERED_COMPLEMENTS),
            window=(-4, 6),
        ),
        dict(
            name="healthy_complement",
            regex=make_assign_regex(WALKING_HEALTHY_COMPLEMENTS),
            window=(-4, 6),
        ),
    ],
    include=[
        dict(
            name="walking_complement",
            regex=make_assign_regex(
                WALKING_ALTERED_COMPLEMENTS + WALKING_HEALTHY_COMPLEMENTS
            ),
            window=(-4, 6),
        )
    ],
    exclude=dict(regex=["diabete", "profondeur"], window=3),
)

walking_perimeter = dict(
    source="other_perimeter",
    regex=["perimetre de marche"],
    regex_attr="NORM",
    assign=[
        dict(
            name="altered_complement",
            regex=make_assign_regex(
                ["reduit", "retreci", "limite", "inferieur a (?:5|cinq) ?m"]
            ),
        ),
        dict(name="healthy_complement", regex=make_assign_regex(["normal"])),
    ],
)

sustentation = dict(
    source="other_sustentation",
    regex=["polygone de sustentation"],
    regex_attr="NORM",
    assign=dict(name="altered_retreci", regex="(retreci)", window=3),
)

default_patterns = normalize_space_characters(
    [
        healthy,
        altered,
        severe,
        other,
        mild,
        sarcopenia,
        ralentissement,
        walking,
        reeducation,
        sustentation,
        walking_perimeter,
        altered_equilibrium,
    ]
)

# fmt: on

Extensions

On each span span that match, the following attribute is available:

  • span._.mobility_status: set to None.

It will specify the severity of the mention regarding the mobility status of the patient.

Possible values are:

  • healthy : this span suggests the patient is well regarding that domain.
  • altered_nondescript : this span suggests the patient is not well, but it is not yet possible to ascertain the degree of alteration.
  • altered_mild : this span suggests a light alteration regarding this domain.
  • altered_severe : this span suggests a severe alteration regarding this domain.
  • other : this span is not indicative of the level of alteration regarding this domain. Still, it hints that this domain has been evaluated.

Examples

import edsnlp, edsnlp.pipes as eds

nlp = edsnlp.blank("eds")
nlp.add_pipe(eds.sentences())
nlp.add_pipe(eds.normalizer())
nlp.add_pipe(f"eds.mobility_status")

Below are a few examples:

Parameters

PARAMETER DESCRIPTION
nlp

The pipeline

TYPE: Optional[PipelineProtocol]

name

The name of the component

TYPE: Optional[str] DEFAULT: mobility_status

patterns

The patterns to use for matching

TYPE: FullConfig DEFAULT: [{'source': 'healthy', 'regex': ['autonomie\\s{...

label

The label to use for the Span object and the extension

TYPE: str DEFAULT: mobility_status

span_setter

How to set matches on the doc

TYPE: SpanSetterArg DEFAULT: {'ents': True, 'mobility_status': True}