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.137 app/models/renalware/pathology/observation.rb
renalware-core-2.0.136 app/models/renalware/pathology/observation.rb
renalware-core-2.0.135 app/models/renalware/pathology/observation.rb
renalware-core-2.0.134 app/models/renalware/pathology/observation.rb
renalware-core-2.0.133 app/models/renalware/pathology/observation.rb
renalware-core-2.0.132 app/models/renalware/pathology/observation.rb
renalware-core-2.0.131 app/models/renalware/pathology/observation.rb
renalware-core-2.0.130 app/models/renalware/pathology/observation.rb
renalware-core-2.0.129 app/models/renalware/pathology/observation.rb
renalware-core-2.0.128 app/models/renalware/pathology/observation.rb
renalware-core-2.0.127 app/models/renalware/pathology/observation.rb
renalware-core-2.0.126 app/models/renalware/pathology/observation.rb
renalware-core-2.0.125 app/models/renalware/pathology/observation.rb
renalware-core-2.0.124 app/models/renalware/pathology/observation.rb
renalware-core-2.0.123 app/models/renalware/pathology/observation.rb
renalware-core-2.0.121 app/models/renalware/pathology/observation.rb
renalware-core-2.0.120 app/models/renalware/pathology/observation.rb
renalware-core-2.0.119 app/models/renalware/pathology/observation.rb
renalware-core-2.0.118 app/models/renalware/pathology/observation.rb
renalware-core-2.0.117 app/models/renalware/pathology/observation.rb