Sha256: 43c29929101b9dfc761fba446b3a63386f5c170a02ce41d0e43516f7cb4041d1

Contents?: true

Size: 840 Bytes

Versions: 7

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

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

7 entries across 7 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.15 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.14 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.13 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.12 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.11 app/models/renalware/pd/mdm_patients_query.rb
renalware-core-2.0.9 app/models/renalware/pd/mdm_patients_query.rb