Sha256: e94f1783fc65da69142b0d264f21405dd0fddb3f59520069d3f93ff8194a3977
Contents?: true
Size: 1.56 KB
Versions: 8
Compression:
Stored size: 1.56 KB
Contents
require_dependency "renalware/low_clearance" module Renalware module LowClearance class MDMPatientsQuery include ModalityScopes DEFAULT_SEARCH_PREDICATE = "ure_date ASC".freeze 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_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
8 entries across 8 versions & 1 rubygems