Class: Renalware::HD::MDMPatientsQuery
- Inherits:
-
Object
- Object
- Renalware::HD::MDMPatientsQuery
- Includes:
- ModalityScopes, PatientPathologyScopes
- Defined in:
- app/models/renalware/hd/mdm_patients_query.rb
Defined Under Namespace
Modules: QueryablePatient
Constant Summary collapse
- MODALITY_NAMES =
"HD"
- DEFAULT_SEARCH_PREDICATE =
"hgb_date desc"
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(params:) ⇒ MDMPatientsQuery
constructor
A new instance of MDMPatientsQuery.
-
#search ⇒ Object
rubocop:disable Metrics/MethodLength.
Methods included from PatientPathologyScopes
extended, pathology_date_sort_predicate, pathology_result_sort_predicate, sanitize, #with_current_pathology
Methods included from ModalityScopes
#with_current_modality_matching, #with_current_modality_of_class
Constructor Details
#initialize(params:) ⇒ MDMPatientsQuery
Returns a new instance of MDMPatientsQuery.
14 15 16 17 |
# File 'app/models/renalware/hd/mdm_patients_query.rb', line 14 def initialize(params:) @params = params || {} @params[:s] = DEFAULT_SEARCH_PREDICATE if @params[:s].blank? end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
12 13 14 |
# File 'app/models/renalware/hd/mdm_patients_query.rb', line 12 def params @params end |
Instance Method Details
#call ⇒ Object
19 20 21 |
# File 'app/models/renalware/hd/mdm_patients_query.rb', line 19 def call search.result end |
#search ⇒ Object
rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/models/renalware/hd/mdm_patients_query.rb', line 24 def search @search ||= begin HD::Patient .include(QueryablePatient) .extending(PatientTransplantScopes) .merge(Accesses::Patient.with_current_plan) .merge(Accesses::Patient.with_profile) .eager_load(hd_profile: [:hospital_unit]) .extending(ModalityScopes) .extending(PatientPathologyScopes) .with_current_pathology .with_registration_statuses .with_current_modality_matching(MODALITY_NAMES) .search(params) end end |