Class: Renalware::PD::MDMPatientsQuery

Inherits:
Object
  • Object
show all
Includes:
ModalityScopes, Renalware::PatientPathologyScopes
Defined in:
app/models/renalware/pd/mdm_patients_query.rb

Constant Summary collapse

MODALITY_NAMES =
"PD"
DEFAULT_SEARCH_PREDICATE =
"hgb_date desc"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Renalware::PatientPathologyScopes

extended, pathology_date_sort_predicate, pathology_result_sort_predicate, #with_current_pathology

Methods included from ModalityScopes

#with_current_modality_matching, #with_current_modality_of_class

Constructor Details

#initialize(relation: PD::Patient.all, q:) ⇒ MDMPatientsQuery

Returns a new instance of MDMPatientsQuery.



12
13
14
15
16
# File 'app/models/renalware/pd/mdm_patients_query.rb', line 12

def initialize(relation: PD::Patient.all, q:)
  @q = q || {}
  @q[:s] = DEFAULT_SEARCH_PREDICATE if @q[:s].blank?
  @relation = relation
end

Instance Attribute Details

#qObject (readonly)

Returns the value of attribute q.



10
11
12
# File 'app/models/renalware/pd/mdm_patients_query.rb', line 10

def q
  @q
end

#relationObject (readonly)

Returns the value of attribute relation.



10
11
12
# File 'app/models/renalware/pd/mdm_patients_query.rb', line 10

def relation
  @relation
end

Instance Method Details

#callObject



18
19
20
# File 'app/models/renalware/pd/mdm_patients_query.rb', line 18

def call
  search.result
end

#searchObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/renalware/pd/mdm_patients_query.rb', line 22

def search
  @search ||= begin
    relation
      .extending(PatientTransplantScopes)
      .extending(ModalityScopes)
      .extending(PatientPathologyScopes)
      .with_current_modality_matching(MODALITY_NAMES)
      .with_current_pathology
      .with_registration_statuses
      .left_outer_joins(:current_observation_set)
      .search(q)
  end
end