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.147 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.146 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.145 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.144 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.143 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.142 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.141 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.140 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.139 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.138 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.137 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.136 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.135 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.134 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.133 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.132 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.131 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.130 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.129 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.128 app/models/renalware/patients/practice_search_query.rb