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.51 app/models/renalware/pathology/observation.rb
renalware-core-2.0.50 app/models/renalware/pathology/observation.rb
renalware-core-2.0.48 app/models/renalware/pathology/observation.rb
renalware-core-2.0.47 app/models/renalware/pathology/observation.rb
renalware-core-2.0.46 app/models/renalware/pathology/observation.rb
renalware-core-2.0.45 app/models/renalware/pathology/observation.rb
renalware-core-2.0.44 app/models/renalware/pathology/observation.rb
renalware-core-2.0.43 app/models/renalware/pathology/observation.rb
renalware-core-2.0.42 app/models/renalware/pathology/observation.rb
renalware-core-2.0.41 app/models/renalware/pathology/observation.rb
renalware-core-2.0.40 app/models/renalware/pathology/observation.rb
renalware-core-2.0.39 app/models/renalware/pathology/observation.rb
renalware-core-2.0.38 app/models/renalware/pathology/observation.rb
renalware-core-2.0.37 app/models/renalware/pathology/observation.rb
renalware-core-2.0.36 app/models/renalware/pathology/observation.rb
renalware-core-2.0.35 app/models/renalware/pathology/observation.rb
renalware-core-2.0.34 app/models/renalware/pathology/observation.rb
renalware-core-2.0.33 app/models/renalware/pathology/observation.rb
renalware-core-2.0.32 app/models/renalware/pathology/observation.rb
renalware-core-2.0.31 app/models/renalware/pathology/observation.rb