<commit_before>module SmartAnswer
  class CheckUkVisaFlow < Flow
    def define
      content_id "dc1a1744-4089-43b3-b2e3-4e397b6b15b1"
      name 'check-uk-visa'
      status :published
      satisfies_need "100982"

      additional_countries = UkbaCountry.all

      # Q1
      country_select :what_passport_do_you_have?, additional_countries: additional_countries, exclude_countries: Calculators::UkVisaCalculator::EXCLUDE_COUNTRIES do
        next_node_calculation :calculator do
          Calculators::UkVisaCalculator.new
        end

        calculate :purpose_of_visit_answer do
          nil
        end

        permitted_next_nodes = [
          :israeli_document_type?,
          :outcome_no_visa_needed,
          :purpose_of_visit?
        ]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.passport_country = response
          if calculator.passport_country_is_israel?
            :israeli_document_type?
          elsif calculator.passport_country_in_eea?
            :outcome_no_visa_needed
          else
            :purpose_of_visit?
          end
        end
      end

      # Q1b
      multiple_choice :israeli_document_type? do
        option :"full-passport"
        option :"provisional-passport"

        permitted_next_nodes = [:purpose_of_visit?]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.passport_country = 'israel-provisional-passport' if response == 'provisional-passport'
          :purpose_of_visit?
        end
      end

      # Q2
      multiple_choice :purpose_of_visit? do
        option :tourism
        option :work
        option :study
        option :transit
        option :family
        option :marriage
        option :school
        option :medical
        option :diplomatic

        permitted_next_nodes = [
          :outcome_diplomatic_business,
          :outcome_joining_family_m,
          :outcome_joining_family_nvn,
          :outcome_joining_family_y,
          :outcome_marriage,
          :outcome_medical_n,
          :outcome_medical_y,
          :outcome_no_visa_needed,
          :outcome_school_n,
          :outcome_school_waiver,
          :outcome_school_y,
          :outcome_standard_visit,
          :outcome_taiwan_exception,
          :outcome_visit_waiver,
          :passing_through_uk_border_control?,
          :staying_for_how_long?
        ]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.purpose_of_visit_answer = response

          if calculator.study_visit? || calculator.work_visit?
            next :staying_for_how_long?
          elsif calculator.diplomatic_visit?
            next :outcome_diplomatic_business
          elsif calculator.school_visit?
            if calculator.passport_country_in_electronic_visa_waiver_list?
              next :outcome_school_waiver
            elsif calculator.passport_country_is_taiwan?
              next :outcome_taiwan_exception
            elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
              next :outcome_school_n
            else
              next :outcome_school_y
            end
          elsif calculator.medical_visit? || calculator.tourism_visit?
            if calculator.passport_country_in_electronic_visa_waiver_list?
              next :outcome_visit_waiver
            elsif calculator.passport_country_is_taiwan?
              next :outcome_taiwan_exception
            end
          end

          if calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
            if calculator.tourism_visit?
              next :outcome_school_n
            elsif calculator.medical_visit?
              next :outcome_medical_n
            end
          end

          if calculator.tourism_visit?
            :outcome_standard_visit
          elsif calculator.marriage_visit?
            :outcome_marriage
          elsif calculator.medical_visit?
            :outcome_medical_y
          elsif calculator.transit_visit?
            if calculator.passport_country_in_datv_list? ||
                calculator.passport_country_in_visa_national_list? || calculator.passport_country_is_taiwan? || calculator.passport_country_is_venezuela?
              :passing_through_uk_border_control?
            else
              :outcome_no_visa_needed
            end
          elsif calculator.family_visit?
            if calculator.passport_country_in_ukot_list?
              :outcome_joining_family_m
            elsif calculator.passport_country_in_non_visa_national_list?
              :outcome_joining_family_nvn
            else
              :outcome_joining_family_y
            end
          end
        end
      end<commit_msg>Update next_node block in check-uk-visa<commit_after>module SmartAnswer
  class CheckUkVisaFlow < Flow
    def define
      content_id "dc1a1744-4089-43b3-b2e3-4e397b6b15b1"
      name 'check-uk-visa'
      status :published
      satisfies_need "100982"

      additional_countries = UkbaCountry.all

      # Q1
      country_select :what_passport_do_you_have?, additional_countries: additional_countries, exclude_countries: Calculators::UkVisaCalculator::EXCLUDE_COUNTRIES do
        next_node_calculation :calculator do
          Calculators::UkVisaCalculator.new
        end

        calculate :purpose_of_visit_answer do
          nil
        end

        permitted_next_nodes = [
          :israeli_document_type?,
          :outcome_no_visa_needed,
          :purpose_of_visit?
        ]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.passport_country = response
          if calculator.passport_country_is_israel?
            :israeli_document_type?
          elsif calculator.passport_country_in_eea?
            :outcome_no_visa_needed
          else
            :purpose_of_visit?
          end
        end
      end

      # Q1b
      multiple_choice :israeli_document_type? do
        option :"full-passport"
        option :"provisional-passport"

        permitted_next_nodes = [:purpose_of_visit?]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.passport_country = 'israel-provisional-passport' if response == 'provisional-passport'
          :purpose_of_visit?
        end
      end

      # Q2
      multiple_choice :purpose_of_visit? do
        option :tourism
        option :work
        option :study
        option :transit
        option :family
        option :marriage
        option :school
        option :medical
        option :diplomatic

        permitted_next_nodes = [
          :outcome_diplomatic_business,
          :outcome_joining_family_m,
          :outcome_joining_family_nvn,
          :outcome_joining_family_y,
          :outcome_marriage,
          :outcome_medical_n,
          :outcome_medical_y,
          :outcome_no_visa_needed,
          :outcome_school_n,
          :outcome_school_waiver,
          :outcome_school_y,
          :outcome_standard_visit,
          :outcome_taiwan_exception,
          :outcome_visit_waiver,
          :passing_through_uk_border_control?,
          :staying_for_how_long?
        ]
        next_node(permitted: permitted_next_nodes) do |response|
          calculator.purpose_of_visit_answer = response

          if calculator.study_visit? || calculator.work_visit?
            next :staying_for_how_long?
          end

          if calculator.diplomatic_visit?
            next :outcome_diplomatic_business
          end

          if calculator.school_visit?
            if calculator.passport_country_in_electronic_visa_waiver_list?
              next :outcome_school_waiver
            elsif calculator.passport_country_is_taiwan?
              next :outcome_taiwan_exception
            elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
              next :outcome_school_n
            else
              next :outcome_school_y
            end
          end

          if calculator.medical_visit?
            if calculator.passport_country_in_electronic_visa_waiver_list?
              next :outcome_visit_waiver
            elsif calculator.passport_country_is_taiwan?
              next :outcome_taiwan_exception
            elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
              next :outcome_medical_n
            else
              next :outcome_medical_y
            end
          end

          if calculator.tourism_visit?
            if calculator.passport_country_in_electronic_visa_waiver_list?
              next :outcome_visit_waiver
            elsif calculator.passport_country_is_taiwan?
              next :outcome_taiwan_exception
            elsif calculator.passport_country_in_non_visa_national_list? || calculator.passport_country_in_ukot_list?
              next :outcome_school_n # outcome does not contain school specific content
            else
              next :outcome_standard_visit
            end
          end

          if calculator.marriage_visit?
            next :outcome_marriage
          end

          if calculator.transit_visit?
            if calculator.passport_country_in_datv_list? ||
                calculator.passport_country_in_visa_national_list? || calculator.passport_country_is_taiwan? || calculator.passport_country_is_venezuela?
              next :passing_through_uk_border_control?
            else
              next :outcome_no_visa_needed
            end
          end

          if calculator.family_visit?
            if calculator.passport_country_in_ukot_list?
              next :outcome_joining_family_m
            elsif calculator.passport_country_in_non_visa_national_list?
              next :outcome_joining_family_nvn
            else
              next :outcome_joining_family_y
            end
          end
        end
      end
{'fraction_non_alphanumeric': 0.048095190480951906, 'fraction_numerical': 0.006199380061993801, 'mean_word_length': 2.1423185673892555, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6187731', 'n_tokens_mistral': 3096, 'n_tokens_neox': 2904, 'n_words': 451}