Class: Renalware::Pathology::ObservationsGroupedByDateTable::Row
- Inherits:
-
Object
- Object
- Renalware::Pathology::ObservationsGroupedByDateTable::Row
- Defined in:
- app/models/renalware/pathology/observations_grouped_by_date_table.rb
Overview
Each row wraps a PGResult (database row). Each row is all the pathology results for this patient on a particular day. Hence there is one observed_on date but multiple results which are the columns going across the table.
Instance Method Summary collapse
- #comment_for(code) ⇒ Object
- #observed_on ⇒ Object
- #result_for(code) ⇒ Object
-
#row_hash ⇒ Object
A hash keyed by OBX code, containing an array of [result, comment] arrays, e.g.
Instance Method Details
#comment_for(code) ⇒ Object
59 60 61 |
# File 'app/models/renalware/pathology/observations_grouped_by_date_table.rb', line 59 def comment_for(code) row_hash[code&.to_sym]&.last end |
#observed_on ⇒ Object
51 52 53 |
# File 'app/models/renalware/pathology/observations_grouped_by_date_table.rb', line 51 def observed_on Date.parse(row[:observed_on]) end |
#result_for(code) ⇒ Object
55 56 57 |
# File 'app/models/renalware/pathology/observations_grouped_by_date_table.rb', line 55 def result_for(code) row_hash[code&.to_sym]&.first end |
#row_hash ⇒ Object
A hash keyed by OBX code, containing an array of [result, comment] arrays, e.g.
{ "HGB": [[123,nil],[124,'Some comment about the result',[..]], "PLT": [..] }
This is a compressed format (as opposed to returning more verbose json) to improve performance. Just remember that for any result, its an array of [result, comment]
69 70 71 |
# File 'app/models/renalware/pathology/observations_grouped_by_date_table.rb', line 69 def row_hash @row_hash = JSON.parse(row[:results]).with_indifferent_access end |