def fix_ghdx_injuries(df):
    """Remove injury endorsement which occured more than 30 days before death.

    The original survey instrument asked the question about injuries in a very
    open ended manner which was interpreted as any injuries ever, as opposed
    to the injuries leading to death. The subsequent analysis dropped injuries
    which occured more than 30 days before death.

    Args:
        df (dataframe): GHDx data.

    Returns:
        (dataframe): the same dataframe is returned with inplace modifications.
    """
    if 'a5_04' in df:
        mask = df.a5_04 > 30
        for col in df.filter(like='a5_').columns:
            df.loc[mask & df[col].notnull(), col] = 0
    if 'c4_49' in df:
        mask = df.c4_49 > 30
        for col in df.filter(regex='c4_47_|c4_48|c4_49').columns:
            df.loc[mask & df[col].notnull(), col] = 0
    return df