Sha256: e02f909a945b64a9173f61f5b67706a78b0cbd717a280138cce3ec41c7c99334

Contents?: true

Size: 1.09 KB

Versions: 52

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology/requests"

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

          # Returns true if the patient has a transplant registration with a latest CRF date
          # older than <param_comparison_value> weeks ago.
          def observation_required_for_patient?(patient, date)
            registration = registration_for(patient)
            return false unless registration

            latest_crf_date = registration.document.crf.latest.recorded_on
            return false if latest_crf_date.blank?

            max_crf_date = date - param_comparison_value.to_i.weeks
            latest_crf_date < max_crf_date
          end

          def to_s
            "latest CRF older than #{param_comparison_value} weeks"
          end

          private

          def registration_for(patient)
            Transplants::Registration.for_patient(patient).first
          end
        end
      end
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.1.0 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.167 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.166 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.165 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.164 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.163 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.162 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.161 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.160 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.159 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.158 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.157 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.156 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.155 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.153 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.152 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.151 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.149 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb
renalware-core-2.0.148 app/models/renalware/pathology/requests/global_rule/latest_crf_older_than_weeks.rb