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
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 69 70 71 72 73 74 75 |
# File 'app/models/renalware/transplants/registrations/wait_list_query.rb', line 42 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','suspended') and ( transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' not ilike '%' || transplant_registration_status_descriptions.code || '%' or transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' = '' or transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' IS NULL ) ) or ( transplant_registration_status_descriptions.code not in ('active','suspended') and ( transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' ilike '%active%' or transplant_registrations.document -> 'uk_transplant_centre' ->> 'status' ilike '%suspended%' ) ) SQL ) else all end end |