Sha256: 2c2a94bb9610bc684f9edb5137827d01406b1e4dc3148dbd5c2789020fef2127

Contents?: true

Size: 995 Bytes

Versions: 52

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/patients"

module Renalware
  module Patients
    class AbridgementsController < BaseController
      def index
        authorize Abridgement, :index?
        render locals: {
          form: AbridgementSearchForm.new,
          results: abridgements_matching_search_criteria,
          results_matching_dob: abridgements_matching_dobs
        }
      end

      private

      def abridgements_matching_search_criteria
        return [] if search_params.blank?

        Abridgement.where(hospital_number: search_params)
      end

      def abridgements_matching_dobs
        return [] if abridgements_matching_search_criteria.empty?

        dobs = abridgements_matching_search_criteria.map(&:born_on).uniq.compact
        return [] if dobs.empty?

        Abridgement.where(born_on: dobs) - abridgements_matching_search_criteria
      end

      def search_params
        params.dig(:search, :criteria)
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.1.0 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.167 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.166 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.165 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.164 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.163 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.162 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.161 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.160 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.159 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.158 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.157 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.156 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.155 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.153 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.152 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.151 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.149 app/controllers/renalware/patients/abridgements_controller.rb
renalware-core-2.0.148 app/controllers/renalware/patients/abridgements_controller.rb