Sha256: 90f2d3a0c4bdd55460e000dec1d8c36f462891161ce2fd1c8c91f85a7bf700f0

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 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
            .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

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta4 app/models/renalware/hd/mdm_patients_query.rb