Sha256: 701a7cf89f72bcd67da5fd0ecca40e48136ee019cdea1a81ace982c53682a4f8
Contents?: true
Size: 1.06 KB
Versions: 52
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true # A generic patient search that returns an AR relation that can used directly or merged into other # queries if required in order to use the extensive patient search criteria added by the # `identity_match` ransacker. See also a corresponding Patients::SearchForm form object and its # partial. # # Example usage to find letters relating to any patient with rabbit in their surname: # Letter # .joins(:patients) # .merge( # Patients::SearchQuery.new(term: "rabbit").call # ) # module Renalware module Patients class SearchQuery # FIELDS = %i(id family_name given_name nhs_number).freeze attr_reader :term, :scope def initialize(scope: Patient.all, term:) @term = term @scope = scope end def call search.result end # .select(FIELDS) def search @search ||= begin scope .search(identity_match: term).tap do |search| search.sorts = %w(family_name given_name) end end end end end end
Version data entries
52 entries across 52 versions & 1 rubygems