Sha256: 01dfb7cbea9fd149ff2083896af534d1bf8a0e0651de0eec979bb265b0e2c133
Contents?: true
Size: 1.01 KB
Versions: 9
Compression:
Stored size: 1.01 KB
Contents
require_dependency "renalware/patients" module Renalware module Patients class PracticesController < BaseController # Search for GP Practices matching part of a name def search authorize Practice, :search? respond_to do |format| format.json do render json: practices_matching_search_term end end end private def practices_matching_search_term PracticeSearchQuery.new(search_term: params[:q]) .call .map { |practice| format_practice_into_hash_for_json(practice) } end def null_address Address.new end def format_practice_into_hash_for_json(practice) address = practice.address || null_address { id: practice.id, name: practice.name, address: [ address.street_1, address.town, address.county, address.postcode ].reject(&:blank?).join(", ") } end end end end
Version data entries
9 entries across 9 versions & 1 rubygems