Skip to content

eds_scikit.phenotype.suicide_attempt.suicide_attempt

SuicideAttemptFromICD10

SuicideAttemptFromICD10(data: BaseData, algo: str = 'Haguenoer2008')

Bases: Phenotype

Phenotyping visits related to a suicide attempt. Two algorithms are available:

  • "X60-X84": The visit needs to have at least one ICD10 code in the range X60 to X84
  • "Haguenoer2008": The visit needs to have at least one ICD10 DAS code in the range X60 to X84, and a ICD10 DP code in the range S to T
PARAMETER DESCRIPTION
data

A BaseData object

TYPE: BaseData

algo

The name of the algorithm. Should be either "Haguenoer2008" or "X60-X84"

TYPE: str, optional DEFAULT: 'Haguenoer2008'

Source code in eds_scikit/phenotype/suicide_attempt/suicide_attempt.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def __init__(
    self,
    data: BaseData,
    algo: str = "Haguenoer2008",
):
    """
    Parameters
    ----------
    data : BaseData
        A BaseData object
    algo : str, optional
        The name of the algorithm.
        Should be either "Haguenoer2008" or "X60-X84"
    """
    super().__init__(
        data,
        name=f"SuicideAttemptFromICD10_{algo}",
    )
    self.algo = algo

ICD10_CODES class-attribute

ICD10_CODES = {'X60-X84': dict(codes={'X60-X84': dict(regex=['X[67]', 'X8[0-4]'])}), 'Haguenoer2008': dict(codes={'Haguenoer2008': dict(regex=['S', 'T[0-9]'])}, additional_filtering=dict(condition_status_source_value='DP'))}

ICD10 codes used by both algorithms

compute

compute()

Fetch and aggregate features

Source code in eds_scikit/phenotype/suicide_attempt/suicide_attempt.py
 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
def compute(self):
    """
    Fetch and aggregate features
    """

    if self.algo == "X60-X84":

        self.add_code_feature(
            output_feature="X60-X84",
            source="icd10",
            codes=self.ICD10_CODES["X60-X84"]["codes"],
        )

        self.agg_single_feature(
            "X60-X84",
            level="visit",
            subphenotype=False,
            threshold=1,
        )

    elif self.algo == "Haguenoer2008":

        self.add_code_feature(
            output_feature="X60-X84",
            source="icd10",
            codes=self.ICD10_CODES["X60-X84"]["codes"],
            additional_filtering=dict(condition_status_source_value="DAS"),
        )

        self.add_code_feature(
            output_feature="DP",
            source="icd10",
            codes=self.ICD10_CODES["Haguenoer2008"]["codes"],
            additional_filtering=self.ICD10_CODES["Haguenoer2008"][
                "additional_filtering"
            ],
        )

        self.agg_two_features(
            "X60-X84",
            "DP",
            output_feature="Haguenoer2008",
            how="AND",
            level="visit",
            subphenotype=False,
            thresholds=(1, 1),
        )
Back to top