Sha256: 6b045d88fea7225a389ae4bf298ff582046a373622c52a25b356e4396db1e923
Contents?: true
Size: 1.36 KB
Versions: 18
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true require_dependency "renalware/renal" module Renalware module Renal module Registry module PreflightChecks # Finds patients with a current modality of HD, PD or Transplant, who have no ESRF date class MissingESRFQuery include ModalityScopes MODALITY_NAMES = %w(HD PD Transplant).freeze attr_reader :relation, :query_params def initialize(relation: nil, query_params: {}) @relation = relation || default_relation @query_params = query_params @query_params[:s] = "modality_descriptions_name ASC" if @query_params[:s].blank? end def default_relation Renalware::Renal::Patient.left_outer_joins(:profile) end def call search .result .extending(ModalityScopes) .preload(current_modality: [:description]) .merge(HD::Patient.with_profile) .eager_load(:profile) .with_current_modality_matching(MODALITY_NAMES) .where("renal_profiles.esrf_on IS NULL") end def search @search ||= relation.ransack(query_params) end def self.missing_data_for(_patient) [ :esrf ] end end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems