Class: Lab::LabOrder

Inherits:
Order
  • Object
show all
Defined in:
app/models/lab/lab_order.rb

Class Method Summary collapse

Class Method Details

.make_obs_concept_filter(concept_name) ⇒ Object



6
7
8
9
10
# File 'app/models/lab/lab_order.rb', line 6

def make_obs_concept_filter(concept_name)
  concept = ConceptName.where(name: concept_name).select(:concept_id)

  -> { where(concept:) }
end

.order_status_concept_idObject

Cache the concept ID to avoid lookups in association scopes



13
14
15
# File 'app/models/lab/lab_order.rb', line 13

def order_status_concept_id
  @order_status_concept_id ||= ConceptName.find_by(name: 'Lab Order Status')&.concept_id
end

.prefetch_relationshipsObject



72
73
74
75
76
77
78
79
80
# File 'app/models/lab/lab_order.rb', line 72

def self.prefetch_relationships
  # NOTE: status_trail_observations and test results are not preloaded due to
  # Rails limitations with eager loading unscoped associations. They load on-demand instead.
  preload(:reason_for_test,
          :requesting_clinician,
          :target_lab,
          :comment_to_fulfiller,
          :tests)
end