Class: Renalware::Medications::PrescriptionsController
Instance Method Summary
collapse
#present
#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
#patient
Instance Method Details
#create ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/renalware/medications/prescriptions_controller.rb', line 28
def create
@treatable = treatable_class.find(treatable_id)
prescription = patient.prescriptions.new(
prescription_params.merge(treatable: @treatable)
)
if prescription.save
render_index
else
render_form(prescription, url: patient_prescriptions_path(patient, @treatable))
end
end
|
#edit ⇒ Object
42
43
44
45
46
47
|
# File 'app/controllers/renalware/medications/prescriptions_controller.rb', line 42
def edit
prescription = patient.prescriptions.find(params[:id])
@treatable = prescription.treatable
render_form(prescription, url: patient_prescription_path(patient, prescription))
end
|
#index ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'app/controllers/renalware/medications/prescriptions_controller.rb', line 13
def index
@treatable = treatable_class.find(treatable_id)
respond_to do |format|
format.html { render_index }
format.js { render_index }
format.pdf { render_prescriptions_list_to_hand_to_patient }
end
end
|
#new ⇒ Object
22
23
24
25
26
|
# File 'app/controllers/renalware/medications/prescriptions_controller.rb', line 22
def new
@treatable = treatable_class.find(treatable_id)
prescription = build_new_prescription_for(@treatable)
render_form(prescription, url: patient_prescriptions_path(patient, @treatable))
end
|
#update ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/renalware/medications/prescriptions_controller.rb', line 49
def update
prescription = patient.prescriptions.find(params[:id])
@treatable = prescription.treatable
updated = RevisePrescription.new(prescription).call(prescription_params)
if updated
render_index
else
render_form(prescription, url: patient_prescription_path(patient, prescription))
end
end
|