Rapu Ture - Exploring the Rules

Is a potential earner

Acc Boolean ETERNITY Person Formula Included used 1 time

Value type Boolean . Default value false Entity person


How is this calculated?

To calculate this variable, the following input is used


Where is this used?

This variable is referred to by these other variables in their own calculations


Formulas

This is the formula used to calculate the value of acc__potential_earner

0001-01-01

This formula is used for scenarios from the date 0001-01-01 onwards. More info on formulas

def formula(persons, period, parameters):
    birth = persons('date_of_birth', period)
    eighteenth_year = birth.astype('datetime64[Y]').astype(int) + 1970 + 18
    eighteenth_month = birth.astype('datetime64[M]').astype(int) % 12 + 1
    eighteenth_day = (birth - birth.astype('datetime64[M]') + 1).astype(int)\

    date_of_injury = persons('date_of_injury', period)
    injury_year = date_of_injury.astype('datetime64[Y]').astype(int) + 1970
    injury_month = date_of_injury.astype('datetime64[M]').astype(int) % 12 + 1
    injury_day = (date_of_injury - date_of_injury.astype('datetime64[M]') + 1).astype(int)\

    injured_under_18 = ((injury_year < eighteenth_year)
                        + ((injury_year == eighteenth_year) * (injury_month < eighteenth_month))
                        + ((injury_year == eighteenth_year) * (injury_month == eighteenth_month) * (injury_day < eighteenth_day))
                        ) > 0

    finish_date = persons('finish_date_of_full_time_study_training_bridging_18th_birthday', period)
    finish_year = finish_date.astype('datetime64[Y]').astype(int) + 1970
    finish_month = finish_date.astype('datetime64[M]').astype(int) % 12 + 1
    finish_day = (finish_date - finish_date.astype('datetime64[M]') + 1).astype(int)\

    injured_while_studying = ((injury_year < finish_year)
                              + ((injury_year == finish_year) * (injury_month < finish_month))
                              + ((injury_year == finish_year) * (injury_month == finish_month) * (injury_day <= finish_day))
                              ) > 0

    injured_over_18_in_study = logical_not(injured_under_18) * injured_while_studying

    return (injured_under_18 + injured_over_18_in_study) > 0