Sha256: 357c10b393e38e43a9bdd0934c049d9121327502d367cdd8b431a606ac898950

Contents?: true

Size: 993 Bytes

Versions: 54

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

module Renalware
  class DeathsController < BaseController
    include PresenterHelper
    include Renalware::Concerns::Pageable

    def index
      patients = Patient.dead.page(page).per(per_page)
      authorize patients
      render locals: { patients: present(patients, PatientPresenter) }
    end

    def edit
      authorize patient
      render_edit
    end

    def update
      authorize patient
      if patient.update(death_params)
        redirect_to patient_clinical_profile_path(patient),
                    notice: t(".success", model_name: "patient")
      else
        flash.now[:error] = t(".failed", model_name: "patient")
        render_edit
      end
    end

    private

    def render_edit
      render :edit, locals: { patient: patient }
    end

    def death_params
      params
        .require(:patient)
        .permit(:died_on, :first_cause_id, :second_cause_id, :death_notes)
        .merge(by: current_user)
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
renalware-core-2.0.134 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.133 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.132 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.131 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.130 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.129 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.128 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.127 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.126 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.125 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.124 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.123 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.121 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.120 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.119 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.118 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.117 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.116 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.115 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.113 app/controllers/renalware/deaths_controller.rb