Sha256: 28664d12cf35008af38eb5daa59308d1921f7c0db97c57cbfdc12ade57645c08

Contents?: true

Size: 803 Bytes

Versions: 8

Compression:

Stored size: 803 Bytes

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc10 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/hd/mdm_patients_query.rb