Class: Renalware::PD::PETResultsController

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

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/renalware/pd/pet_results_controller.rb', line 17

def create
  pet = PETResult.new(pet_result_params)
  authorize pet

  if pet.save_by(current_user)
    redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("PET result")
  else
    render_new(pet)
  end
end

#destroyObject



55
56
57
58
# File 'app/controllers/renalware/pd/pet_results_controller.rb', line 55

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

#editObject



42
43
44
# File 'app/controllers/renalware/pd/pet_results_controller.rb', line 42

def edit
  render locals: { pet: find_authorize_pet_result }
end

#indexObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/renalware/pd/pet_results_controller.rb', line 28

def index
  respond_to do |format|
    format.json do # Graphing data
      authorize PETResult, :index?
      render json: pet_graph_data
    end
    format.js do
      results = patient.pet_results.ordered
      authorize results
      render locals: { results: results }
    end
  end
end

#newObject



8
9
10
11
12
13
14
15
# File 'app/controllers/renalware/pd/pet_results_controller.rb', line 8

def new
  pet = PETResult.new(
    patient: patient,
    performed_on: Date.current
  )
  authorize pet
  render_new(pet)
end

#updateObject



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

def update
  pet = find_authorize_pet_result
  if pet.update_by(current_user, pet_result_params)
    redirect_to patient_pd_dashboard_path(patient), notice: success_msg_for("PET result")
  else
    render_edit(pet)
  end
end