Class: Renalware::Pathology::ObservationsGroupedByDateTable
- Inherits:
-
Object
- Object
- Renalware::Pathology::ObservationsGroupedByDateTable
- Defined in:
- app/models/renalware/pathology/observations_grouped_by_date_table.rb
Overview
A helper class wrapping a custom relation object which has aggregated a patient’s pathology results by date of observation using raw SQL + PGResult. Note we implement the required interface for kaminari pagination (we delegate to the underlying relation to achieve this).
This class exists to make the underlying PGResult set (wrapped in a custom relation-like object) easier to consume.
Example usage: (ruby) codes = %i(HGB PLT WBC) rows = ObservationsGroupedByDateQuery.new(patient_id: 1, codes: codes) table = ObservationsGroupedByDateTable.new(rows: rows, codes: %i(HGB PLT WBC)) (html) table
tr
td Date
- table.codes do |code|
td= code
tbody
tr
- table.each_row do |row|
td= l(row.observed_on)
- table.codes.each do |code|
td= row.result_for(code)
paginate(table)
Defined Under Namespace
Classes: Row
Instance Method Summary collapse
Instance Method Details
#rows ⇒ Object
40 41 42 |
# File 'app/models/renalware/pathology/observations_grouped_by_date_table.rb', line 40 def rows @rows ||= relation.all.map(&:with_indifferent_access).map { |row| Row.new(row) } end |