<commit_before>module World
  module Pathology
    module RequestForm
      module Domain
        # @section helpers
        #
        def extract_request_form_params(form_params)
          clinic = find_requested_clinic(form_params[:clinic])
          consultant = find_requested_consultant(form_params[:consultant])
          patients = find_requested_patients(form_params[:patients])
          telephone = form_params[:telephone]

          [patients, clinic, consultant, telephone]
        end

        # @section commands
        #
        def generate_request_forms_for_single_patient(_clinician, params)
          patients, clinic, consultant, telephone = extract_request_form_params(params)

          options = { patients: patients }
          options[:clinic] = clinic if clinic.present?
          options[:consultant] = consultant if consultant.present?
          options[:telephone] = telephone if telephone.present?

          request_form_options =
            Renalware::Pathology::RequestAlgorithm::RequestFormOptions.new(options)

          Renalware::Pathology::RequestAlgorithm::FormsBuilder
            .new(patients, request_form_options).build
        end

        def generate_request_forms_for_appointments(clinician, appointments, params)
          patients = appointments.map { |patient| Renalware::Pathology.cast_patient(patient) }
          _patients, clinic, consultant, telephone = extract_request_form_params(params)

          options = { patients: patients }
          options[:clinic] = clinic if clinic.present?
          options[:consultant] = consultant if consultant.present?
          options[:telephone] = telephone if telephone.present?

          request_form_options =
            Renalware::Pathology::RequestAlgorithm::RequestFormOptions.new(options)

          Renalware::Pathology::RequestAlgorithm::FormsBuilder
            .new(patients, request_form_options).build
        end

        # @section expectations
        #
        def expect_patient_summary_to_match_table(request_forms, patient, expected_table)
          request_form = find_request_form_for_patient(request_forms, patient)

          expected_table.rows_hash.each do |key, expected_value|
            expected_value = nil if expected_value.blank?<commit_msg>fix acceptance tests<commit_after>module World
  module Pathology
    module RequestForm
      module Domain
        # @section helpers
        #
        def extract_request_form_params(form_params)
          clinic = find_requested_clinic(form_params[:clinic])
          consultant = find_requested_consultant(form_params[:consultant])
          patients = find_requested_patients(form_params[:patients])
          telephone = form_params[:telephone]

          [patients, clinic, consultant, telephone]
        end

        def build_request_forms(patients, options)
          request_form_options =
            Renalware::Pathology::RequestAlgorithm::RequestFormOptions.new(options)

          Renalware::Pathology::RequestAlgorithm::FormsBuilder
            .new(patients, request_form_options).build
        end

        # @section commands
        #
        def generate_request_forms_for_single_patient(_clinician, params)
          patients, clinic, consultant, telephone = extract_request_form_params(params)

          options = { patients: patients }
          options[:clinic] = clinic if clinic.present?
          options[:consultant] = consultant if consultant.present?
          options[:telephone] = telephone if telephone.present?

          build_request_forms(patients, options)
        end

        def generate_request_forms_for_appointments(clinician, appointments, params)
          patients = appointments.map do |appointment|
            Renalware::Pathology.cast_patient(appointment.patient)
          end
          _patients, clinic, consultant, telephone = extract_request_form_params(params)

          options = { patients: patients }
          options[:clinic] = clinic if clinic.present?
          options[:consultant] = consultant if consultant.present?
          options[:telephone] = telephone if telephone.present?

          build_request_forms(patients, options)
        end

        # @section expectations
        #
        def expect_patient_summary_to_match_table(request_forms, patient, expected_table)
          request_form = find_request_form_for_patient(request_forms, patient)

          expected_table.rows_hash.each do |key, expected_value|
            expected_value = nil if expected_value.blank?
{'fraction_non_alphanumeric': 0.07363998230871296, 'fraction_numerical': 0.0, 'mean_word_length': 2.971027216856892, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1209570', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1118, 'n_words': 220}