Sha256: 192e0ce163411e3ce741c4043e7068b5c9bbb36942ae60f265c0d42213f9840f

Contents?: true

Size: 943 Bytes

Versions: 139

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/pathology"

module Renalware
  module Pathology
    class Observation < ApplicationRecord
      belongs_to :request,
                 class_name: "ObservationRequest",
                 touch: true,
                 inverse_of: :observations
      belongs_to :description,
                 class_name: "ObservationDescription",
                 inverse_of: :observations

      validates :description, presence: true
      validates :result, presence: true, unless: ->(obs) { obs.cancelled? }
      validates :observed_at, presence: true

      scope :ordered, -> { order(observed_at: :desc) }
      scope :for_description, ->(description) { where(description: description) }
      scope :having_a_loinc_code, -> { joins(:description).where("loinc_code is not null") }

      def observed_on
        observed_at.to_date
      end

      delegate :to_s, to: :result
    end
  end
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/models/renalware/pathology/observation.rb
renalware-core-2.0.158 app/models/renalware/pathology/observation.rb
renalware-core-2.0.157 app/models/renalware/pathology/observation.rb
renalware-core-2.0.156 app/models/renalware/pathology/observation.rb
renalware-core-2.0.155 app/models/renalware/pathology/observation.rb
renalware-core-2.0.153 app/models/renalware/pathology/observation.rb
renalware-core-2.0.152 app/models/renalware/pathology/observation.rb
renalware-core-2.0.151 app/models/renalware/pathology/observation.rb
renalware-core-2.0.149 app/models/renalware/pathology/observation.rb
renalware-core-2.0.148 app/models/renalware/pathology/observation.rb
renalware-core-2.0.147 app/models/renalware/pathology/observation.rb
renalware-core-2.0.146 app/models/renalware/pathology/observation.rb
renalware-core-2.0.145 app/models/renalware/pathology/observation.rb
renalware-core-2.0.144 app/models/renalware/pathology/observation.rb
renalware-core-2.0.143 app/models/renalware/pathology/observation.rb
renalware-core-2.0.142 app/models/renalware/pathology/observation.rb
renalware-core-2.0.141 app/models/renalware/pathology/observation.rb
renalware-core-2.0.140 app/models/renalware/pathology/observation.rb
renalware-core-2.0.139 app/models/renalware/pathology/observation.rb
renalware-core-2.0.138 app/models/renalware/pathology/observation.rb