Sha256: 7e729f001cbe4dc5517f2f2e570d518200c83ef72aba7a461a679a9604c72dc7

Contents?: true

Size: 1.05 KB

Versions: 12

Compression:

Stored size: 1.05 KB

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)
      search = patients.ransack(params[:q])
      authorize patients
      render locals: {
        patients: present(search.result, PatientPresenter),
        q: search
      }
    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

12 entries across 12 versions & 1 rubygems

Version Path
renalware-core-2.0.146 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.145 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.144 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.143 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.142 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.141 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.140 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.139 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.138 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.137 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.136 app/controllers/renalware/deaths_controller.rb
renalware-core-2.0.135 app/controllers/renalware/deaths_controller.rb