Sha256: b1cafbf74869cf533e5a6e1f4d8befe87ff0e7bd41c4fcfc0d1a5f824265653b

Contents?: true

Size: 1.2 KB

Versions: 23

Compression:

Stored size: 1.2 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

23 entries across 23 versions & 1 rubygems

Version Path
renalware-core-2.0.77 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.76 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.75 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.74 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.73 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.72 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.71 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.70 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.69 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.68 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.67 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.64 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.63 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.62 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.61 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.60 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.58 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.57 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.56 app/controllers/renalware/transplants/donor_workups_controller.rb
renalware-core-2.0.55 app/controllers/renalware/transplants/donor_workups_controller.rb