Class: Renalware::Pathology::ObservationsForCodesPresenter
- Inherits:
-
Object
- Object
- Renalware::Pathology::ObservationsForCodesPresenter
- Defined in:
- app/presenters/renalware/pathology/observations_for_codes_presenter.rb
Instance Method Summary collapse
-
#initialize(patient:, codes:) ⇒ ObservationsForCodesPresenter
constructor
Example usage ObservationsForCodesPresenter.new(patient: patient, codes: %w(HBA FER PHT)).
-
#observations ⇒ Object
Returns an array of observations reformatted to be easy to consume.
Constructor Details
#initialize(patient:, codes:) ⇒ ObservationsForCodesPresenter
Example usage
ObservationsForCodesPresenter.new(patient: patient, codes: %w(HBA FER PHT))
10 11 12 13 |
# File 'app/presenters/renalware/pathology/observations_for_codes_presenter.rb', line 10 def initialize(patient:, codes:) @patient = Pathology.cast_patient(patient) @codes = Array(codes).map(&:upcase) end |
Instance Method Details
#observations ⇒ Object
Returns an array of observations reformatted to be easy to consume.
16 17 18 19 20 21 22 23 24 |
# File 'app/presenters/renalware/pathology/observations_for_codes_presenter.rb', line 16 def observations codes.map do |code| observation = observation_for(code) || NullObject.instance OpenStruct.new(code: code, description: description_for(code).name, result: observation.result, observed_at: observation.observed_at) end end |