Sha256: 5869b3e8db215642019d31f07911c7979d340e502d28ae2487656be5bd16f68f

Contents?: true

Size: 795 Bytes

Versions: 8

Compression:

Stored size: 795 Bytes

Contents

require_dependency "renalware/pathology/requests"

module Renalware
  module Pathology
    module Requests
      class GlobalRule
        class TransplantDateWithinWeeks < GlobalRule
          validates :param_comparison_value, presence: true

          def observation_required_for_patient?(patient, date)
            most_recent_operation =
              Transplants::RecipientOperation.for_patient(patient).most_recent
            return false unless most_recent_operation.present?

            latest_date_possible = date - param_comparison_value.to_i.weeks

            most_recent_operation.performed_on > latest_date_possible
          end

          def to_s
            "transplant date within #{@param_comparison_value} weeks ago"
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.beta11 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta10 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta9 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta8 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta7 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta6 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta5 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb
renalware-core-2.0.0.pre.beta4 app/models/renalware/pathology/requests/global_rule/transplant_date_within_weeks.rb