Sha256: 8f74b04869fa0791604bbfa44953b9155515c1c9ee37e3d9adb27b1b03bf1976

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require "renalware/letters/part"

module Renalware
  module Letters
    class Part::RecentPathologyResults < Part
      delegate :each, :any?, :present?, to: :recent_pathology_results

      def to_partial_path
        "renalware/letters/parts/recent_pathology_results"
      end

      private

      def recent_pathology_results
        @recent_pathology_results ||= find_recent_pathology_results
      end

      def find_recent_pathology_results
        presenter = Pathology::CurrentObservationResults::Presenter.new
        descriptions = Letters::RelevantObservationDescription.all
        query = Pathology::CurrentObservationsForDescriptionsQuery.new(
          patient: @patient,
          descriptions: descriptions
        )

        # Only select display result with a value
        results = query.call.reject{ |result| result.result.blank? }

        # Removes the header from the results, this will be unnecessary when
        # a custom Presenter is implemented
        presenter.present(results)[1..-1]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta12 app/models/renalware/letters/part/recent_pathology_results.rb