Sha256: fbeba2e6750aa3163229d8c26eb5180e1c5af426dcc9045e7c56cabda209c311

Contents?: true

Size: 660 Bytes

Versions: 63

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module Patients
    class PracticeSearchQuery
      attr_reader :search_term

      def initialize(search_term:)
        @search_term = search_term
      end

      def call
        return [] if search_term.blank?

        term = "%#{search_term}%"
        Practice.select(:id, :name)
                .left_outer_joins(:address)
                .includes(:address)
                .where("patient_practices.name ILIKE ? "\
                       "OR addresses.street_1 ILIKE ? " \
                       "OR addresses.postcode ILIKE ?", term, term, term)
                .limit(50)
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
renalware-core-2.0.78 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.77 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.76 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.75 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.74 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.73 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.72 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.71 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.70 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.69 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.68 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.67 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.64 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.63 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.62 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.61 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.60 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.58 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.57 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.56 app/models/renalware/patients/practice_search_query.rb