Class: Renalware::Transplants::MDMPatientsQuery
- Inherits:
-
Object
- Object
- Renalware::Transplants::MDMPatientsQuery
- Includes:
- ModalityScopes, PatientPathologyScopes
- Defined in:
- app/models/renalware/transplants/mdm_patients_query.rb
Overview
a list of everyone whose Modality is Transplant and the sort should
be based on date of latest creatinine result descending (most recent
at the top) - the default sort order should be same for all of the
different filter groups
Defined Under Namespace
Modules: NamedFilterScopes
Constant Summary collapse
- MODALITY_NAMES =
["Transplant"].freeze
- DEFAULT_SEARCH_PREDICATE =
"hgb_date DESC"
Instance Attribute Summary collapse
-
#named_filter ⇒ Object
readonly
Returns the value of attribute named_filter.
-
#q ⇒ Object
readonly
Returns the value of attribute q.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(relation: Transplants::Patient.all, named_filter: nil, q: nil) ⇒ MDMPatientsQuery
constructor
A new instance of MDMPatientsQuery.
- #search ⇒ Object
Methods included from 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: Transplants::Patient.all, named_filter: nil, q: nil) ⇒ MDMPatientsQuery
Returns a new instance of MDMPatientsQuery.
16 17 18 19 20 21 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 16 def initialize(relation: Transplants::Patient.all, named_filter: nil, q: nil) @q = q || {} @q[:s] = DEFAULT_SEARCH_PREDICATE if @q[:s].blank? @relation = relation @named_filter = named_filter || :none end |
Instance Attribute Details
#named_filter ⇒ Object (readonly)
Returns the value of attribute named_filter.
14 15 16 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 14 def named_filter @named_filter end |
#q ⇒ Object (readonly)
Returns the value of attribute q.
14 15 16 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 14 def q @q end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
14 15 16 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 14 def relation @relation end |
Instance Method Details
#call ⇒ Object
23 24 25 26 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 23 def call search.sorts = %w(given_name) search.result end |
#search ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/renalware/transplants/mdm_patients_query.rb', line 28 def search @search ||= begin relation .extending(ModalityScopes) .extending(PatientPathologyScopes) .extending(NamedFilterScopes) .with_current_modality_matching(MODALITY_NAMES) .with_current_pathology .left_outer_joins(:current_observation_set) .public_send(named_filter.to_s) .search(q) end end |