Sha256: 15df0b9683316e0666c21dcec66f637d92efcce2f3eefb7d11fbbb5f15257895

Contents?: true

Size: 825 Bytes

Versions: 28

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Renalware
  module HD
    class MDMPatientsQuery
      include ModalityScopes
      include PatientPathologyScopes
      MODALITY_NAMES = "HD"
      DEFAULT_SEARCH_PREDICATE = "hgb_date desc"
      attr_reader :q, :relation

      def initialize(relation: HD::Patient.all, q:)
        @q = q || {}
        @q[:s] = DEFAULT_SEARCH_PREDICATE if @q[:s].blank?
        @relation = relation
      end

      def call
        search.result
      end

      def search
        @search ||= begin
          relation
            .includes(:hd_profile)
            .extending(ModalityScopes)
            .extending(PatientPathologyScopes)
            .with_current_pathology
            .with_current_modality_matching(MODALITY_NAMES)
            .search(q)
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
renalware-core-2.0.39 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.38 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.37 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.36 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.35 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.34 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.33 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.32 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.31 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.30 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.28 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.27 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.26 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.25 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.24 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.23 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.22 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.21 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.20 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.18 app/models/renalware/hd/mdm_patients_query.rb