Class: Lab::OrdersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Lab::OrdersController
- Defined in:
- app/controllers/lab/orders_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #order_result ⇒ Object
- #order_status ⇒ Object
- #update ⇒ Object
- #verify_tracking_number ⇒ Object
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/lab/orders_controller.rb', line 7 def create order_params_list = params.require(:orders) orders = order_params_list.map do |order_params| OrdersService.order_test(order_params) end orders.each { |order| Lab::PushOrderJob.perform_later(order.fetch(:order_id)) } render json: orders, status: :created end |
#destroy ⇒ Object
47 48 49 50 51 52 |
# File 'app/controllers/lab/orders_controller.rb', line 47 def destroy OrdersService.void_order(params[:id], params[:reason]) Lab::VoidOrderJob.perform_later(params[:id]) render status: :no_content end |
#index ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/lab/orders_controller.rb', line 26 def index filters = params.permit(%i[patient_id patient accession_number date status]) id = filters[:patient_id] || filters[:patient] patient = Patient.find(id) if filters[:patient_id] || filters[:patient] Lab::UpdatePatientOrdersJob.perform_later(patient.id) if filters[:patient_id] || filters[:patient] orders = OrdersSearchService.find_orders(filters) begin render json: orders.reload, status: :ok rescue StandardError render json: orders end end |
#order_result ⇒ Object
60 61 62 63 64 65 |
# File 'app/controllers/lab/orders_controller.rb', line 60 def order_result params.permit! order_params = params[:data].to_h OrdersService.update_order_result(order_params) render json: { message: 'Results processed successfully' }, status: :ok end |
#order_status ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/lab/orders_controller.rb', line 54 def order_status order_params = params.permit(:tracking_number, :status, :status_time, :comments) OrdersService.update_order_status(order_params) render json: { message: "Status for order #{order_params['tracking_number']} successfully updated" }, status: :ok end |
#update ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/controllers/lab/orders_controller.rb', line 18 def update specimen = params.require(:specimen).permit(:concept_id) order = OrdersService.update_order(params[:id], specimen: specimen, force_update: params[:force_update]) Lab::PushOrderJob.perform_later(order.fetch(:order_id)) render json: order end |
#verify_tracking_number ⇒ Object
42 43 44 45 |
# File 'app/controllers/lab/orders_controller.rb', line 42 def verify_tracking_number tracking_number = params.require(:accession_number) render json: { exists: OrdersService.check_tracking_number(tracking_number) }, status: :ok end |