Sha256: 2f0d1eaf67b514f9b9f2c1987dae007b1bf150044a54fe950d143db5f64d8a16
Contents?: true
Size: 1.59 KB
Versions: 21
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true require_dependency "renalware/low_clearance" module Renalware module LowClearance class MDMPatientsQuery include ModalityScopes DEFAULT_SEARCH_PREDICATE = "hgb_date DESC" attr_reader :query, :relation, :named_filter def initialize(relation: Patient.all, query: nil, named_filter: nil) @query = query || {} @named_filter = named_filter || :none @query[:s] = DEFAULT_SEARCH_PREDICATE if @query[:s].blank? @relation = relation end def call search.result end def search @search ||= begin relation .extending(PatientPathologyScopes) .extending(ModalityScopes) .extending(NamedFilterScopes) .with_current_pathology .left_outer_joins(:current_observation_set) .with_current_modality_of_class(LowClearance::ModalityDescription) .public_send(named_filter.to_s) .search(query) end end module NamedFilterScopes def none self # NOOP end def on_worryboard joins("RIGHT OUTER JOIN patient_worries ON patient_worries.patient_id = patients.id") end def tx_candidates self end def urea where("cast(values->'URE'->>'result' as float) >= 30.0") end def hgb_low where("cast(values->'HGB'->>'result' as float) < 100.0") end def hgb_high where("cast(values->'HGB'->>'result' as float) > 130.0") end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems