Sha256: 009e4ea86ba857494f2203046e490ccf46bb92541a14b4dd0e7e74df955eeeb6

Contents?: true

Size: 775 Bytes

Versions: 86

Compression:

Stored size: 775 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, :code)
                .left_outer_joins(:address)
                .includes(:address)
                .where("patient_practices.name ILIKE ? "\
                       "OR patient_practices.code = ? " \
                       "OR addresses.street_1 ILIKE ? " \
                       "OR addresses.postcode ILIKE ?", term, search_term, term, term)
                .where(active: true)
                .limit(50)
      end
    end
  end
end

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
renalware-core-2.0.127 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.126 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.125 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.124 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.123 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.121 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.120 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.119 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.118 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.117 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.116 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.115 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.113 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.112 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.111 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.110 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.109 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.108 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.106 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.105 app/models/renalware/patients/practice_search_query.rb