<commit_before>def has_condition(c, conditions):
    for condition in conditions:
        if condition == c:
            return True

    return False


def assess_waist_hip_ratio(waist, hip, gender):
    raise NotImplementedError('"assess_waist_hip_ratio" method removed')


def assess_smoking_status(smoking):
    is_smoker = False
    smoking_calc = False

    if smoking['current'] == 1:
        is_smoker = True
        smoking_calc = True
        result_code = 'SM-1'
    elif (smoking['ex_smoker']) & (smoking['quit_within_year']):
        # quit within 1 year, considered smoker for calc
        is_smoker = False
        smoking_calc = True
        result_code = 'SM-2'
    elif smoking['ex_smoker']:
        is_smoker = False
        result_code = 'SM-3'
    else:
        is_smoker = False
        result_code = 'SM-4'

    smoking_status = {
        'code': result_code,
        'status': is_smoker,
        'smoking_calc': smoking_calc,
    }

    return smoking_status


def assess_blood_pressure(bp, conditions):
    result_code = ""

    _sbp = bp['sbp'][0]
    _dbp = bp['dbp'][0]

    if _sbp > 160:
        result_code = "BP-2"

    elif has_condition('diabetes', conditions):
        if _sbp > 130:
            result_code = "BP-3B"
            target = "130/80"
        else:
            result_code = "BP-3A"
    elif (_sbp <= 140) and (_sbp >= 120):
        result_code = "BP-1A"
        target = "140/90"
    elif _sbp > 140:
        result_code = "BP-1B"
        target = "140/90"
    elif _sbp <= 120:
        result_code = "BP-0"
        target = "140/90"

    bp_output = {
        'bp': str(_sbp) + "/" + str(_dbp),
        'code': result_code,
        'target': target
    }
    return bp_output


def assess_bmi(bmi):
    target = "18.5 - 24.9"

    if bmi < 18.5:
        result_code = "BMI-1"
    elif bmi < 25:
        result_code = "BMI-0"
    elif bmi < 30:
        result_code = "BMI-2"
    else:
        result_code = "BMI-3"

    bmi_output = {
        'value': bmi,
        'code': result_code,
        'target': target
    }

    return bmi_output


def assess_diet(diet_history, conditions, targets):
    """
    General Rules:
    - Aim for 50% fruit & vegetables (with specific targets for F&V), 25% lean protein, 25% carbohydrates
    - Minimise amount of fast foods, processed foods
    - Replace soda with non-sugary alternatives
    - Limit amount of added salt & sugar - for diabetics and hypertensives, target is 0
    - If trying to lose weight, avoid hotel or fast food (not sure what is in them)
    - For diabetes:
        - no added sugar
        - If BMI > 25, aim for weight loss of 600-700 calories per day
    - For Hypertensive:
        - no added salt
    Step 1: Assess general diet, fruits & vegetables based on targets (2 fruits & 5 vegetables per day)
    Step 2: Proportion of carbohydrates - should be 25% (other 25% lean protein, 50% vegetables, salads)<commit_msg>remove assess_bmi method<commit_after>def has_condition(c, conditions):
    for condition in conditions:
        if condition == c:
            return True

    return False


def assess_waist_hip_ratio(waist, hip, gender):
    raise NotImplementedError('"assess_waist_hip_ratio" method removed')


def assess_smoking_status(smoking):
    is_smoker = False
    smoking_calc = False

    if smoking['current'] == 1:
        is_smoker = True
        smoking_calc = True
        result_code = 'SM-1'
    elif (smoking['ex_smoker']) & (smoking['quit_within_year']):
        # quit within 1 year, considered smoker for calc
        is_smoker = False
        smoking_calc = True
        result_code = 'SM-2'
    elif smoking['ex_smoker']:
        is_smoker = False
        result_code = 'SM-3'
    else:
        is_smoker = False
        result_code = 'SM-4'

    smoking_status = {
        'code': result_code,
        'status': is_smoker,
        'smoking_calc': smoking_calc,
    }

    return smoking_status


def assess_blood_pressure(bp, conditions):
    result_code = ""

    _sbp = bp['sbp'][0]
    _dbp = bp['dbp'][0]

    if _sbp > 160:
        result_code = "BP-2"

    elif has_condition('diabetes', conditions):
        if _sbp > 130:
            result_code = "BP-3B"
            target = "130/80"
        else:
            result_code = "BP-3A"
    elif (_sbp <= 140) and (_sbp >= 120):
        result_code = "BP-1A"
        target = "140/90"
    elif _sbp > 140:
        result_code = "BP-1B"
        target = "140/90"
    elif _sbp <= 120:
        result_code = "BP-0"
        target = "140/90"

    bp_output = {
        'bp': str(_sbp) + "/" + str(_dbp),
        'code': result_code,
        'target': target
    }
    return bp_output


def assess_bmi(bmi):
    raise NotImplementedError('"assess_bmi" method removed')


def assess_diet(diet_history, conditions, targets):
    """
    General Rules:
    - Aim for 50% fruit & vegetables (with specific targets for F&V), 25% lean protein, 25% carbohydrates
    - Minimise amount of fast foods, processed foods
    - Replace soda with non-sugary alternatives
    - Limit amount of added salt & sugar - for diabetics and hypertensives, target is 0
    - If trying to lose weight, avoid hotel or fast food (not sure what is in them)
    - For diabetes:
        - no added sugar
        - If BMI > 25, aim for weight loss of 600-700 calories per day
    - For Hypertensive:
        - no added salt
    Step 1: Assess general diet, fruits & vegetables based on targets (2 fruits & 5 vegetables per day)
    Step 2: Proportion of carbohydrates - should be 25% (other 25% lean protein, 50% vegetables, salads)
{'fraction_non_alphanumeric': 0.10217934976777421, 'fraction_numerical': 0.03054662379421222, 'mean_word_length': 2.255232558139535, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1735871', 'n_tokens_mistral': 1966, 'n_tokens_neox': 1778, 'n_words': 537}