Module: Renalware::Transplants::Registrations::WaitListQuery::Scopes
- Defined in:
- app/models/renalware/transplants/registrations/wait_list_query.rb
Overview
The status_mismatch filter finds patients with a UKT status that does not match their tx wait list status. We filter out UKT statuses of null or ”. At some point we will have turn this into a mapping object or hash because there will probably not be a 1 to 1 mapping from wait list to UKT status.
Instance Method Summary collapse
-
#apply_filter(filter) ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#apply_filter(filter) ⇒ Object
rubocop:disable Metrics/MethodLength
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/models/renalware/transplants/registrations/wait_list_query.rb', line 41 def apply_filter(filter) case filter when :status_mismatch joins(statuses: :description) .where(transplant_registration_statuses: { terminated_on: nil }) .where( <<-SQL.squish ( transplant_registration_status_descriptions.code in ('active') and ( transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' not ilike 'A' ) ) or ( transplant_registration_status_descriptions.code not in ('active') and ( transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' ilike 'A' ) ) SQL ) else all end end |