Class: Renalware::Transplants::RecipientWorkupsController

Inherits:
BaseController show all
Defined in:
app/controllers/renalware/transplants/recipient_workups_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#patient

Methods inherited from BaseController

#patient

Instance Method Details

#editObject



20
21
22
23
24
25
26
27
# File 'app/controllers/renalware/transplants/recipient_workups_controller.rb', line 20

def edit
  workup = RecipientWorkup.for_patient(patient).first_or_initialize
  workup = RecipientWorkupBuilder.new(
    workup: workup,
    default_consenter_name: current_user.to_s
  ).build
  render locals: { patient: patient, workup: workup }
end

#showObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/renalware/transplants/recipient_workups_controller.rb', line 10

def show
  workup = RecipientWorkup.for_patient(patient).first_or_initialize

  if workup.new_record?
    redirect_to edit_patient_transplants_recipient_workup_path(patient)
  else
    render locals: { patient: patient, workup: workup }
  end
end

#updateObject



29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/renalware/transplants/recipient_workups_controller.rb', line 29

def update
  workup = RecipientWorkup.for_patient(patient).first_or_initialize

  if workup.update workup_params
    redirect_to patient_transplants_recipient_workup_path(patient),
                notice: t(".success", model_name: "recipient work up")
  else
    flash.now[:error] = t(".failed", model_name: "recipient work up")
    render :edit, locals: { patient: patient, workup: workup }
  end
end