Class: Lab::TestsController
- Inherits:
-
ApplicationController
- Object
- 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
Instance Method Details
#create ⇒ Object
Add a specimen to an existing order
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/lab/tests_controller.rb', line 11 def create test_params = params.permit(: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
4 5 6 7 8 |
# File 'app/controllers/lab/tests_controller.rb', line 4 def index filters = params.permit(%i[order_date accession_number patient patient_id test_type_id specimen_type_id pending_results]) tests = service.find_tests(filters) render json: tests end |
#service ⇒ Object
22 23 24 |
# File 'app/controllers/lab/tests_controller.rb', line 22 def service Lab::TestsService end |