Sha256: 2a1951d1820a77eb07b759bd07038a2ac80c949309bbcc176d06feb44037a598

Contents?: true

Size: 1.4 KB

Versions: 78

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    class Patient < ActiveType::Record[Renalware::Patient]
      has_many :observation_requests, dependent: :restrict_with_exception
      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

78 entries across 78 versions & 1 rubygems

Version Path
renalware-core-2.0.124 app/models/renalware/pathology/patient.rb
renalware-core-2.0.123 app/models/renalware/pathology/patient.rb
renalware-core-2.0.121 app/models/renalware/pathology/patient.rb
renalware-core-2.0.120 app/models/renalware/pathology/patient.rb
renalware-core-2.0.119 app/models/renalware/pathology/patient.rb
renalware-core-2.0.118 app/models/renalware/pathology/patient.rb
renalware-core-2.0.117 app/models/renalware/pathology/patient.rb
renalware-core-2.0.116 app/models/renalware/pathology/patient.rb
renalware-core-2.0.115 app/models/renalware/pathology/patient.rb
renalware-core-2.0.113 app/models/renalware/pathology/patient.rb
renalware-core-2.0.112 app/models/renalware/pathology/patient.rb
renalware-core-2.0.111 app/models/renalware/pathology/patient.rb
renalware-core-2.0.110 app/models/renalware/pathology/patient.rb
renalware-core-2.0.109 app/models/renalware/pathology/patient.rb
renalware-core-2.0.108 app/models/renalware/pathology/patient.rb
renalware-core-2.0.106 app/models/renalware/pathology/patient.rb
renalware-core-2.0.105 app/models/renalware/pathology/patient.rb
renalware-core-2.0.104 app/models/renalware/pathology/patient.rb
renalware-core-2.0.103 app/models/renalware/pathology/patient.rb
renalware-core-2.0.102 app/models/renalware/pathology/patient.rb