Sha256: 5039e996990682be0dbf1c62dd565f82a870443d0967833e82f0d624d19cb957

Contents?: true

Size: 823 Bytes

Versions: 10

Compression:

Stored size: 823 Bytes

Contents

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

      def initialize(relation: PD::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
            .extending(ModalityScopes)
            .extending(PatientPathologyScopes)
            .with_current_modality_matching(MODALITY_NAMES)
            .with_current_pathology
            .left_joins(:current_observation_set)
            .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/pd/mdm_patients_query.rb
renalware-core-2.0.7 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.5 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.4 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.3 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.2 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.1 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.0 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/pd/mdm_patients_query.rb