Class: Renalware::PD::AdequacyResultsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/pd/adequacy_results_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 14

def create
  adequacy = AdequacyResult.new(result_params)
  authorize adequacy

  if adequacy.save_by(current_user)
    redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("Adequacy result")
  else
    render :new, locals: { adequacy: adequacy }
  end
end

#destroyObject



40
41
42
43
44
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 40

def destroy
  result = find_and_authorize_result
  result.destroy!
  redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("Result")
end

#editObject



25
26
27
28
29
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 25

def edit
  adequacy = find_and_authorize_result
  # adequacy.derive_calculated_attributes
  render locals: { adequacy: adequacy }
end

#indexObject



46
47
48
49
50
51
52
53
54
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 46

def index
  respond_to do |format|
    format.js do
      results = patient.adequacy_results.ordered
      authorize results
      render locals: { results: results }
    end
  end
end

#newObject



8
9
10
11
12
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 8

def new
  adequacy = AdequacyResult.new(patient: patient, performed_on: Date.current)
  authorize adequacy
  render locals: { adequacy: adequacy }
end

#updateObject



31
32
33
34
35
36
37
38
# File 'app/controllers/renalware/pd/adequacy_results_controller.rb', line 31

def update
  result = find_and_authorize_result
  if result.update_by(current_user, result_params)
    redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("Result")
  else
    render_edit(result)
  end
end