Sha256: b021f8ea211dd314bf258d23ca73852607d09ab5176de47fefe4388f4d34d192

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 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

7 entries across 7 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/letters/part/recent_pathology_results.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/letters/part/recent_pathology_results.rb