Sha256: 90ecbbedc17e0b7744aa3c2161b708b6a4480c2ca36ff31147435a099e416d7f

Contents?: true

Size: 1.7 KB

Versions: 35

Compression:

Stored size: 1.7 KB

Contents

require_dependency "renalware/transplants/base_controller"

module Renalware
  module Transplants
    class DonorFollowupsController < BaseController
      before_action :load_patient

      def show
        render locals: { patient: patient, donor_followup: operation.followup }
      end

      def new
        donor_followup = operation.build_followup
        render locals: { patient: patient, donor_followup: donor_followup }
      end

      def create
        donor_followup = operation.build_followup
        donor_followup.attributes = followup_attributes

        if donor_followup.save
          redirect_to patient_transplants_donor_dashboard_path(patient)
        else
          render :new, locals: { patient: patient, donor_followup: donor_followup }
        end
      end

      def edit
        render locals: { patient: patient, donor_followup: operation.followup }
      end

      def update
        donor_followup = operation.followup
        donor_followup.attributes = followup_attributes

        if donor_followup.save
          redirect_to patient_transplants_donor_dashboard_path(patient)
        else
          render :edit, locals: { patient: patient, donor_followup: donor_followup }
        end
      end

      protected

      def operation
        @operation ||= DonorOperation.find(params[:donor_operation_id])
      end

      def followup_attributes
        params
          .require(:transplants_donor_followup)
          .permit(attributes)
      end

      def attributes
        [
          :notes,
          :last_seen_on,
          :followed_up,
          :ukt_center_code,
          :lost_to_followup,
          :transferred_for_followup,
          :dead_on
        ]
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.16 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.15 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.14 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.13 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.12 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.11 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.9 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.8 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.7 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.5 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.4 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.3 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.2 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.1 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0.pre.rc13 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/transplants/donor_followups_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/transplants/donor_followups_controller.rb