Sha256: 1c47aa99dfd26ca37d1f187e8d5fc1c792977b602558b5aa079c7b479344db0e

Contents?: true

Size: 532 Bytes

Versions: 6

Compression:

Stored size: 532 Bytes

Contents

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)
                .joins(:address)
                .where("patient_practices.name ILIKE ? OR addresses.postcode ILIKE ?", term, term)
        # .select("patient_practices.id", "patient_practices.name")
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc6 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.0.pre.rc1 app/models/renalware/patients/practice_search_query.rb
renalware-core-2.0.0.pre.beta12 app/models/renalware/patients/practice_search_query.rb