Class: Lab::TestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lab/tests_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#permit_parameters

Instance Method Details

#createObject

Add a specimen to an existing order



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/lab/tests_controller.rb', line 14

def create
  test_params = params.slice(:order_id, :date, tests: [:concept_id])
  order_id, test_concepts = test_params.require(%i[order_id tests])
  date = test_params[:date] || Date.today

  tests = service.create_tests(Lab::LabOrder.find(order_id), date, test_concepts)
  Lab::PushOrderJob.perform_later(order_id)

  render json: tests, status: :created
end

#indexObject



5
6
7
8
9
10
11
# File 'app/controllers/lab/tests_controller.rb', line 5

def index
  filters = params.slice(:order_date, :accession_number, :patient_id, :test_type_id, :specimen_type_id,
                         :pending_results)

  tests = service.find_tests(filters)
  render json: tests
end

#serviceObject



25
26
27
# File 'app/controllers/lab/tests_controller.rb', line 25

def service
  Lab::TestsService
end