Sha256: 9673f86ac56da0d0ac4fb7587e89278e8f3070cc9c8a845cbaa98dbd07487b3a

Contents?: true

Size: 808 Bytes

Versions: 10

Compression:

Stored size: 808 Bytes

Contents

module Renalware
  module HD
    class MDMPatientsQuery
      include ModalityScopes
      include PatientPathologyScopes
      MODALITY_NAMES = "HD".freeze
      DEFAULT_SEARCH_PREDICATE = "hgb_date desc".freeze
      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

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.7 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.5 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.4 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.3 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.2 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.1 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/hd/mdm_patients_query.rb