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.91 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.90 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.89 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.88 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.87 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.86 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.85 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.84 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.83 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.82 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.81 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.80 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.79 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.78 app/controllers/renalware/deaths_controller.rb