Sha256: 1858f627d14b9994f2a7442c6a4b255d99e8afa6e96acfec58df6bea908d2772

Contents?: true

Size: 879 Bytes

Versions: 7

Compression:

Stored size: 879 Bytes

Contents

module Renalware
  module HD
    class MDMPatientsQuery
      include ModalityScopes
      MODALITY_NAMES = "HD".freeze
      attr_reader :q, :relation

      def initialize(relation: HD::Patient.all, q:)
        @q = q
        @relation = relation
      end

      def call
        search.result
      end

      def search
        @search ||= begin
          relation
            .includes(:hd_profile)
            .extending(ModalityScopes)
            .extending(Scopes)
            .with_current_key_pathology
            .with_current_modality_matching(MODALITY_NAMES)
            .search(q)
          # .order("pathology_current_key_observations.hgb_result asc")
        end
      end

      module Scopes

        def with_current_key_pathology
          eager_load(:current_key_observation_set) # .joins(:current_key_observation)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/hd/mdm_patients_query.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/hd/mdm_patients_query.rb