Sha256: cceb7e9b571983d606c150ca74d5e4ea83bc428ed9280effbe10fa9768041952

Contents?: true

Size: 1.33 KB

Versions: 18

Compression:

Stored size: 1.33 KB

Contents

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    class Patient < ActiveType::Record[Renalware::Patient]
      has_many :observation_requests
      has_many :observations, through: :observation_requests
      has_many :current_observations, class_name: "Pathology::CurrentObservation"
      has_many :rules, class_name: "Requests::PatientRule"
      has_many :requests, class_name: "Requests::Request"

      def last_request_for_patient_rule(patient_rule)
        requests
          .includes(:patient_rules)
          .where(
            pathology_requests_patient_rules: { id: [patient_rule] }
          )
          .first
      end

      def required_observation_requests(clinic)
        Requests::GlobalAlgorithm.new(
          self, clinic, date: date_for_algorithms
        ).determine_required_request_descriptions
      end

      def required_patient_pathology
        Requests::PatientAlgorithm.new(
          self, date: date_for_algorithms
        ).determine_required_tests
      end

      def high_risk?
        Requests::HighRiskAlgorithm.new(self).patient_is_high_risk?
      end

      def fetch_current_observation_set
        current_observation_set || build_current_observation_set
      end

      private

      def date_for_algorithms
        @date_for_algorithms ||= Date.current
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.0.8 app/models/renalware/pathology/patient.rb
renalware-core-2.0.7 app/models/renalware/pathology/patient.rb
renalware-core-2.0.5 app/models/renalware/pathology/patient.rb
renalware-core-2.0.4 app/models/renalware/pathology/patient.rb
renalware-core-2.0.3 app/models/renalware/pathology/patient.rb
renalware-core-2.0.2 app/models/renalware/pathology/patient.rb
renalware-core-2.0.1 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc13 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc11 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc10 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc9 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc8 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc7 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc6 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc5 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc4 app/models/renalware/pathology/patient.rb
renalware-core-2.0.0.pre.rc3 app/models/renalware/pathology/patient.rb