Sha256: 2f88cdd5a68ca7dfe724c139e6708d9446a7355555afec38fbcfe6f44c46419c

Contents?: true

Size: 1.21 KB

Versions: 85

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/transplants/base_controller"

module Renalware
  module Transplants
    class DonorWorkupsController < BaseController
      before_action :load_patient

      def show
        workup = DonorWorkup.for_patient(patient).first_or_initialize
        if workup.new_record?
          redirect_to edit_patient_transplants_donor_workup_path(patient)
        else
          render locals: { patient: patient, workup: workup }
        end
      end

      def edit
        workup = DonorWorkup.for_patient(patient).first_or_initialize
        render locals: { patient: patient, workup: workup }
      end

      def update
        workup = DonorWorkup.for_patient(patient).first_or_initialize

        if workup.update(workup_params)
          redirect_to patient_transplants_donor_workup_path(patient),
                      notice: t(".success", model_name: "donor work up")
        else
          flash.now[:error] = t(".failed", model_name: "donor work up")
          render :edit, locals: { patient: patient, workup: workup }
        end
      end

      private

      def workup_params
        params.require(:transplants_donor_workup).permit(document: {})
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
renalware-core-2.0.102 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.101 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.100 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.99 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.98 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.97 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.96 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.95 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.94 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.93 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.92 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.91 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.90 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.89 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.88 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.87 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.86 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.85 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.84 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.83 app/controllers/renalware/transplants/donor_workups_controller.rb