Sha256: fa83d0976f8ab406ec13e53cb5c6a719f07980c06c4249f3ffe1a8348964f1a3

Contents?: true

Size: 1.17 KB

Versions: 149

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/reporting"

module Renalware
  module Reporting
    class FetchAuditJson
      class << self
        def call(view_name)
          convert_rows_from_audit_view_into_datatables_compatible_json(view_name)
        end

        def convert_rows_from_audit_view_into_datatables_compatible_json(view_name)
          conn = ActiveRecord::Base.connection
          result = conn.execute("select audit_view_as_json(#{conn.quote(view_name)});")
          result.values[0][0]
        end
      end

      # A WIP to translate audit column names into human friendly ones.
      # May need to establish guidelines for instance apply text case in the view itself so
      # eg pct_HGB = % HGB without having to know to upcase certain bits of the name but
      # capitalise others etc.
      # def self.humanize_column_name(column)
      #   column
      #     .gsub("pct_", "% ")
      #     .gsub("count_", "No.")
      #     .gsub("avg_", "Avg ")
      #     .gsub("max", "Max ")
      #     .gsub("gt_eq_", "≥ ")
      #     .gsub("lt_eq_", "≤ ")
      #     .gsub("gt_", "> ")
      #     .gsub("lt_", "< ")
      # end
    end
  end
end

Version data entries

149 entries across 149 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.1.0 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.167 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.166 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.165 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.164 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.163 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.162 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.161 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.160 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.159 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.158 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.157 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.156 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.155 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.153 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.152 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.151 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.149 app/models/renalware/reporting/fetch_audit_json.rb
renalware-core-2.0.148 app/models/renalware/reporting/fetch_audit_json.rb