Sha256: 2d96ab2c18acf5eb3b232ebd5844be49508b021fcd7eda75c30043f31e0c5391

Contents?: true

Size: 924 Bytes

Versions: 8

Compression:

Stored size: 924 Bytes

Contents

module Renalware
  module Patients
    class MDMPatientsQuery
      include ModalityScopes
      attr_reader :modality_names, :q, :relation

      # modality_names: eg "HD" or "PD"
      def initialize(relation: Patient.all, q:, modality_names:)
        @modality_names = modality_names
        @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
          includes(:current_key_observation_set) # .joins(:current_key_observation)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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