Class: Renalware::Medications::TerminationsController

Inherits:
BaseController show all
Includes:
PresenterHelper, PrescriptionsHelper
Defined in:
app/controllers/renalware/medications/terminations_controller.rb

Instance Method Summary collapse

Methods included from PresenterHelper

#present

Methods included from PrescriptionsHelper

#default_provider, #highlight_validation_fail, #medication_and_route, #new_patient_medications_prescription_termination_path, #new_patient_prescription_path, #patient_medications_prescription_termination_path, #patient_prescriptions_path, #validation_fail

Methods inherited from BaseController

#patient

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/renalware/medications/terminations_controller.rb', line 24

def create
  prescription = patient.prescriptions.find(params[:prescription_id])
  @treatable = treatable_class.find(treatable_id)

  termination = prescription.build_termination(termination_params)

  if termination.save
    render_index
  else
    render_form(
      prescription, termination,
      url: patient_medications_prescription_termination_path(patient,
                                                             prescription,
                                                             @treatable)
    )
  end
end

#newObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/renalware/medications/terminations_controller.rb', line 13

def new
  prescription = patient.prescriptions.find(params[:prescription_id])
  termination = prescription.build_termination(terminated_on: Date.current)
  @treatable = treatable_class.find(treatable_id)

  render_form(
    prescription, termination,
    url: patient_medications_prescription_termination_path(patient, prescription, @treatable)
  )
end