Class: Renalware::HD::GenerateMonthlyStatisticsForPatient::FilteredObservationSet
- Inherits:
-
Object
- Object
- Renalware::HD::GenerateMonthlyStatisticsForPatient::FilteredObservationSet
- Defined in:
- app/models/renalware/hd/generate_monthly_statistics_for_patient.rb
Overview
Filters a set of observations using a specific set of OBX codes. The snapshot is stored on the hd_patient_statistics table - i.e. it represents the state of the patient’s pathology *at the time the hd_stats row is created*. So for an hd_stats row for say Patient X in the month of April 2018, the pathology_snapshot is a frozen snapshot of their pathology at 30/4/2018 23:59 TODO: de-dupe this with the other FilteredObservationSet in Letters::?
Constant Summary collapse
- CODES =
These are the codes for the results we want to store in hd_patient_statics.pathology_snapshot - we are only interested in these results. They will be used for instance in reporting_hd_overall_audit
%w(HGB PTHI PHOS CRE URE URR).freeze
Instance Method Summary collapse
-
#initialize(patient:) ⇒ FilteredObservationSet
constructor
A new instance of FilteredObservationSet.
-
#to_h ⇒ Object
Returns a hash of the filtered observations e.g.
Constructor Details
#initialize(patient:) ⇒ FilteredObservationSet
Returns a new instance of FilteredObservationSet.
65 66 67 |
# File 'app/models/renalware/hd/generate_monthly_statistics_for_patient.rb', line 65 def initialize(patient:) @observation_set = Pathology.cast_patient(patient).fetch_current_observation_set end |
Instance Method Details
#to_h ⇒ Object
Returns a hash of the filtered observations e.g.
"HGB"=>{"result"=>"139", "observed_at"=>"2016-03-15T03:28:00",
"URR"=>"observed_at"=>"2016-03-15T03:28:00",
...
}
75 76 77 78 79 |
# File 'app/models/renalware/hd/generate_monthly_statistics_for_patient.rb', line 75 def to_h return {} if observation_set.blank? observation_set.values.select { |code, _| CODES.include?(code.to_s) } end |