Sha256: c3e439a7edeb30119b5f9f9dbb2f849a1f98135060dcda780cc588a31749e693
Contents?: true
Size: 1.05 KB
Versions: 21
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true module Renalware module Patients # Finds patients with a death modality or who have a died_on date class DeceasedPatientsQuery attr_reader :query_params def initialize(query_params) @query_params = query_params || {} @query_params[:s] = "family_name ASC" if @query_params[:s].blank? end def call search.result.where(id: ids_of_deceased_patients) end def search Patient .includes(:first_cause, current_modality: :description) .ransack(query_params) end private def ids_of_deceased_patients (ids_of_patients_with_death_modality + ids_of_patients_with_died_on_date).uniq end def ids_of_patients_with_death_modality Patient .extending(ModalityScopes) .with_current_modality_of_class(Renalware::Deaths::ModalityDescription) .pluck(:id) end def ids_of_patients_with_died_on_date Patient.where.not(died_on: nil).pluck(:id) end end end end
Version data entries
21 entries across 21 versions & 1 rubygems