Class: Lab::TestsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Lab::TestsController
- Defined in:
- app/controllers/lab/tests_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
Add a specimen to an existing order.
- #index ⇒ Object
- #service ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
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 |
#index ⇒ Object
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 |
#service ⇒ Object
25 26 27 |
# File 'app/controllers/lab/tests_controller.rb', line 25 def service Lab::TestsService end |