<commit_before>function(doc) {
    // !code util/mvp.js
    if( isChildVisitForm(doc) ||
        isPregnancyVisitForm(doc) ||
        isHomeVisitForm(doc)) {

        function get_pregnancy_start_from_edd_date(edd_date) {
            var preg_start = new Date(),
                gestation_ms = 266*MS_IN_DAY;
            var start_ms = edd_date.getTime() - gestation_ms;
            preg_start.setTime(start_ms);
            return preg_start;
        }

        function get_danger_signs(danger_sign_value) {
            var signs = danger_sign_value.trim().toLowerCase();
            if (signs) {
                signs = signs.split(' ');
                return signs;
            }
            return [];
        }

        var indicators = get_indicators(doc),
            meta = doc.form.meta,
            case_id = get_case_id(doc),
            emergency_signs = [];

        var visit_date = new Date(meta.timeEnd);

        var indicator_entries = {};

        try {
            emergency_signs = get_danger_signs(indicators.emergency_danger_sign.value);
        } catch (err) {
            // pass
        }

        if (isChildWelfareForm(doc) && indicators.vaccination_status && indicators.vaccination_status.value === 'yes') {
            // special case for Bonsaaso
            indicator_entries['child under1 not_immunized'] = case_id;
        }

        if (isChildVisitForm(doc) && indicators.child_dob && indicators.child_dob.value) {
            // birthdate found, is child under 5?
            var age = get_age_from_dob(indicators.child_dob.value, visit_date);
            if (age < 1825*MS_IN_DAY) {
                indicator_entries['child under5'] = case_id;
                if (age < 365*MS_IN_DAY) {
                    indicator_entries['child under1'] = case_id;

                    if (indicators.vaccination_status && indicators.vaccination_status.value) {
                        var is_immunized = (indicators.vaccination_status.value === 'yes');
                        if (is_immunized && indicators.vaccination_status_6weeks) {
                            // start looking at timelines for vaccinations too.
                            if (age > 75 * MS_IN_DAY) {
                                // at least 6 weeks old
                                is_immunized = is_immunized && (indicators.vaccination_status_6weeks.value === 'yes');
                            }
                            if (age > 105 * MS_IN_DAY && indicators.vaccination_status_10weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_10weeks.value === 'yes');
                            }
                            if (age > 135 * MS_IN_DAY && indicators.vaccination_status_14weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_14weeks.value === 'yes');
                            }
                            if (age > 300 * MS_IN_DAY && indicators.vaccination_status_36weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_36weeks.value === 'yes');
                            }
                        }

                        if (!is_immunized) {
                            indicator_entries['child under1 not_immunized'] = case_id;
                        }
                    }

                    if (emergency_signs.length < 1) {
                        var not_immunized = false;
                        if (age > 45 * MS_IN_DAY){
                            if (indicators.prev_vaccination_birth.value === 'no' || indicators.vaccination_birth.value === 'no') {
                                not_immunized = true;
                            }
                            if (indicators.prev_vaccination_birth_2.value === 'no' || indicators.vaccination_birth_2.value === 'no') {
                                not_immunized = true;
                            }
                        }
                        if (age > 75 * MS_IN_DAY && (indicators.prev_vaccination_6week.value === 'no' || indicators.vaccination_6week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 105 * MS_IN_DAY && (indicators.prev_vaccination_10week.value === 'no' || indicators.vaccination_10week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 135 * MS_IN_DAY && (indicators.prev_vaccination_14week.value === 'no' || indicators.vaccination_14week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 300 * MS_IN_DAY && (indicators.prev_vaccination_36week.value === 'no' || indicators.vaccination_36week.value === 'no')) {
                            not_immunized = true;
                        }

                        if (not_immunized) {
                            indicator_entries['child under1 not_immunized'] = case_id;
                        }<commit_msg>check if indicator exists before looking at its value to prevent type error<commit_after>function(doc) {
    // !code util/mvp.js
    if( isChildVisitForm(doc) ||
        isPregnancyVisitForm(doc) ||
        isHomeVisitForm(doc)) {

        function get_pregnancy_start_from_edd_date(edd_date) {
            var preg_start = new Date(),
                gestation_ms = 266*MS_IN_DAY;
            var start_ms = edd_date.getTime() - gestation_ms;
            preg_start.setTime(start_ms);
            return preg_start;
        }

        function get_danger_signs(danger_sign_value) {
            var signs = danger_sign_value.trim().toLowerCase();
            if (signs) {
                signs = signs.split(' ');
                return signs;
            }
            return [];
        }

        var indicators = get_indicators(doc),
            meta = doc.form.meta,
            case_id = get_case_id(doc),
            emergency_signs = [];

        var visit_date = new Date(meta.timeEnd);

        var indicator_entries = {};

        try {
            emergency_signs = get_danger_signs(indicators.emergency_danger_sign.value);
        } catch (err) {
            // pass
        }

        if (isChildWelfareForm(doc) && indicators.vaccination_status && indicators.vaccination_status.value === 'yes') {
            // special case for Bonsaaso
            indicator_entries['child under1 not_immunized'] = case_id;
        }

        if (isChildVisitForm(doc) && indicators.child_dob && indicators.child_dob.value) {
            // birthdate found, is child under 5?
            var age = get_age_from_dob(indicators.child_dob.value, visit_date);
            if (age < 1825*MS_IN_DAY) {
                indicator_entries['child under5'] = case_id;
                if (age < 365*MS_IN_DAY) {
                    indicator_entries['child under1'] = case_id;

                    if (indicators.vaccination_status && indicators.vaccination_status.value) {
                        var is_immunized = (indicators.vaccination_status.value === 'yes');
                        if (is_immunized && indicators.vaccination_status_6weeks) {
                            // start looking at timelines for vaccinations too.
                            if (age > 75 * MS_IN_DAY) {
                                // at least 6 weeks old
                                is_immunized = is_immunized && (indicators.vaccination_status_6weeks.value === 'yes');
                            }
                            if (age > 105 * MS_IN_DAY && indicators.vaccination_status_10weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_10weeks.value === 'yes');
                            }
                            if (age > 135 * MS_IN_DAY && indicators.vaccination_status_14weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_14weeks.value === 'yes');
                            }
                            if (age > 300 * MS_IN_DAY && indicators.vaccination_status_36weeks) {
                                is_immunized = is_immunized && (indicators.vaccination_status_36weeks.value === 'yes');
                            }
                        }

                        if (!is_immunized) {
                            indicator_entries['child under1 not_immunized'] = case_id;
                        }
                    }

                    if (emergency_signs.length < 1) {
                        var not_immunized = false;
                        if (age > 45 * MS_IN_DAY){
                            if (indicators.prev_vaccination_birth
                                && (indicators.prev_vaccination_birth.value === 'no' || indicators.vaccination_birth.value === 'no')) {
                                not_immunized = true;
                            }
                            if (indicators.prev_vaccination_birth_2
                                && (indicators.prev_vaccination_birth_2.value === 'no' || indicators.vaccination_birth_2.value === 'no')) {
                                not_immunized = true;
                            }
                        }
                        if (age > 75 * MS_IN_DAY
                            && indicators.prev_vaccination_6week
                            && (indicators.prev_vaccination_6week.value === 'no' || indicators.vaccination_6week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 105 * MS_IN_DAY
                            && indicators.prev_vaccination_10week
                            && (indicators.prev_vaccination_10week.value === 'no' || indicators.vaccination_10week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 135 * MS_IN_DAY
                            && indicators.prev_vaccination_14week
                            && (indicators.prev_vaccination_14week.value === 'no' || indicators.vaccination_14week.value === 'no')) {
                            not_immunized = true;
                        }
                        if (age > 300 * MS_IN_DAY
                            && indicators.prev_vaccination_36week
                            && (indicators.prev_vaccination_36week.value === 'no' || indicators.vaccination_36week.value === 'no')) {
                            not_immunized = true;
                        }

                        if (not_immunized) {
                            indicator_entries['child under1 not_immunized'] = case_id;
                        }
{'fraction_non_alphanumeric': 0.09347886929750909, 'fraction_numerical': 0.014180427278664054, 'mean_word_length': 1.3138355277358083, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6272550', 'n_tokens_mistral': 3100, 'n_tokens_neox': 2735, 'n_words': 470}