Sha256: e72aaa30b0cdf497cc828877369710aa1c0f7c014b1786660b40c418d12d425b
Contents?: true
Size: 1.35 KB
Versions: 17
Compression:
Stored size: 1.35 KB
Contents
require_dependency "renalware/pathology" module Renalware module Pathology class ViewCurrentObservationResults def initialize(patient, presenter, descriptions: default_descriptions) @patient = patient @descriptions = descriptions @presenter = presenter end def call(_params = {}) # Get an array of observations for the requested descriptions results = find_current_observations_for_descriptions # Although we now have all the observations, they are not in the right order. # Hence this sort by description code. sorted_results = sort_results(results) present(sorted_results) end private def find_current_observations_for_descriptions CurrentObservationsForDescriptionsQuery .new(patient: @patient, descriptions: @descriptions) .call end def sort_results(results) @descriptions.map { |description| find_result_for_description(results, description) } .compact end def find_result_for_description(results, description) results.detect { |result| result.description_code == description.code } end def present(results) @presenter.present(results) end def default_descriptions RelevantObservationDescription.all end end end end
Version data entries
17 entries across 17 versions & 1 rubygems