Class: Renalware::DeathsController

Inherits:
BaseController show all
Includes:
Pagy::Backend, PresenterHelper
Defined in:
app/controllers/renalware/deaths_controller.rb

Instance Method Summary collapse

Methods included from PresenterHelper

#present

Methods inherited from BaseController

#patient

Instance Method Details

#editObject



19
20
21
22
# File 'app/controllers/renalware/deaths_controller.rb', line 19

def edit
  authorize patient
  render_edit
end

#indexObject



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/renalware/deaths_controller.rb', line 8

def index
  query = Patients::DeceasedPatientsQuery.new(params[:q])
  pagy, patients = pagy(query.call.includes(previous_modality: :description))
  authorize patients
  render locals: {
    patients: present(patients, PatientPresenter),
    q: query.search,
    pagy: pagy
  }
end

#updateObject



24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/renalware/deaths_controller.rb', line 24

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